-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #356 from Sunbird-cQube/dev
merge dev to staging
- Loading branch information
Showing
12 changed files
with
730 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...eports/telemetry-active-users-big-number/telemetry-active-users-big-number.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<app-big-number [bigNumberReportData]="bigNumberReportData"></app-big-number> |
Empty file.
23 changes: 23 additions & 0 deletions
23
...rts/telemetry-active-users-big-number/telemetry-active-users-big-number.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { TelemetryActiveUsersBigNumberComponent } from './telemetry-active-users-big-number.component'; | ||
|
||
describe('TelemetryActiveUsersBigNumberComponent', () => { | ||
let component: TelemetryActiveUsersBigNumberComponent; | ||
let fixture: ComponentFixture<TelemetryActiveUsersBigNumberComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ TelemetryActiveUsersBigNumberComponent ] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(TelemetryActiveUsersBigNumberComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
158 changes: 158 additions & 0 deletions
158
.../reports/telemetry-active-users-big-number/telemetry-active-users-big-number.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
import { Component, Input, OnDestroy, OnInit } from '@angular/core'; | ||
import { CommonService } from 'src/app/core/services/common/common.service'; | ||
import { RbacService } from 'src/app/core/services/rbac-service.service'; | ||
import { WrapperService } from 'src/app/core/services/wrapper.service'; | ||
import { buildQuery, parseRbacFilter, parseTimeSeriesQuery } from 'src/app/utilities/QueryBuilder'; | ||
import { config } from '../../../../config/telemetry_config'; | ||
import { DataService } from 'src/app/core/services/data.service'; | ||
|
||
@Component({ | ||
selector: 'app-telemetry-active-users-big-number', | ||
templateUrl: './telemetry-active-users-big-number.component.html', | ||
styleUrls: ['./telemetry-active-users-big-number.component.scss'] | ||
}) | ||
export class TelemetryActiveUsersBigNumberComponent implements OnInit, OnDestroy { | ||
|
||
reportName: string = 'active_users_bignumber'; | ||
filters: any = []; | ||
levels: any; | ||
tableReportData: any; | ||
bigNumberReportData: any = { | ||
reportName: "Total Active Users" | ||
}; | ||
currentReportName: string = "Telemetry"; | ||
minDate: any; | ||
maxDate: any; | ||
compareDateRange: any = 30; | ||
filterIndex: any; | ||
rbacDetails: any; | ||
title = 'Total Active Users'; | ||
@Input() startDate: any; | ||
@Input() endDate: any; | ||
drillDownSubscription: any; | ||
drillDownLevel: any; | ||
|
||
|
||
constructor(private readonly _commonService: CommonService, | ||
private _dataService: DataService, | ||
private _rbacService: RbacService, | ||
) { | ||
|
||
} | ||
ngOnInit(): void { | ||
this.drillDownSubscription = this._rbacService.getRbacDetails().subscribe((rbacDetails: any) => { | ||
this.rbacDetails = rbacDetails; | ||
}) | ||
// this.getReportData(); | ||
} | ||
|
||
getReportData(values): void { | ||
console.log(values) | ||
let { filterValues, timeSeriesValues } = values ?? {}; | ||
|
||
this.startDate = timeSeriesValues?.startDate; | ||
this.endDate = timeSeriesValues?.endDate; | ||
let reportConfig = config | ||
let { timeSeriesQueries, queries, levels, label, defaultLevel, filters, options } = reportConfig[this.reportName]; | ||
let onLoadQuery; | ||
if (this.rbacDetails?.role !== undefined && this.rbacDetails?.role !== null) { | ||
filters.every((filter: any) => { | ||
if (Number(this.rbacDetails?.role) === Number(filter.hierarchyLevel)) { | ||
timeSeriesQueries = { ...filter?.timeSeriesQueries } | ||
Object.keys(timeSeriesQueries).forEach((key) => { | ||
timeSeriesQueries[key] = this.parseRbacFilter(timeSeriesQueries[key]) | ||
}); | ||
return false | ||
} | ||
return true | ||
}) | ||
} | ||
|
||
Object.keys(timeSeriesQueries).forEach(async (key: any) => { | ||
if (key.toLowerCase().includes('comparison')) { | ||
let endDate = new Date(); | ||
let days = endDate.getDate() - this.compareDateRange; | ||
let startDate = new Date(); | ||
startDate.setDate(days) | ||
onLoadQuery = parseTimeSeriesQuery(timeSeriesQueries[key], startDate.toISOString().split('T')[0], endDate.toISOString().split('T')[0]) | ||
} | ||
else if (this.startDate !== undefined && this.endDate !== undefined && Object.keys(timeSeriesQueries).length > 0) { | ||
onLoadQuery = parseTimeSeriesQuery(timeSeriesQueries[key], this.startDate, this.endDate) | ||
} | ||
else { | ||
onLoadQuery = queries[key] | ||
} | ||
let query = buildQuery(onLoadQuery, defaultLevel, this.levels, this.filters, this.startDate, this.endDate, key, this.compareDateRange); | ||
|
||
// if (query && key === 'bigNumber') { | ||
// this.getBigNumberReportData(query, options, 'averagePercentage'); | ||
// } | ||
if (query && key === 'bigNumber') { | ||
this.bigNumberReportData = await this._dataService.getBigNumberReportData(query, options, 'averagePercentage', this.bigNumberReportData); | ||
} | ||
}) | ||
} | ||
|
||
parseRbacFilter(query: string) { | ||
let newQuery = query; | ||
|
||
let startIndex = newQuery?.indexOf('{'); | ||
let endIndex = newQuery?.indexOf('}'); | ||
|
||
while (startIndex > -1 && endIndex > -1) { | ||
if (newQuery && startIndex > -1) { | ||
let propertyName = newQuery.substring(startIndex + 1, endIndex); | ||
let re = new RegExp(`{${propertyName}}`, "g"); | ||
|
||
Object.keys(this.rbacDetails).forEach((key: any) => { | ||
if (propertyName === key + '_id') { | ||
newQuery = newQuery.replace(re, '\'' + this.rbacDetails[key] + '\''); | ||
} | ||
}); | ||
} | ||
startIndex = newQuery?.indexOf('{'); | ||
endIndex = newQuery?.indexOf('}'); | ||
} | ||
return newQuery | ||
} | ||
|
||
// async getBigNumberReportData(query: string, options: any, indicator: string): Promise<void> { | ||
// let { bigNumber } = options ?? {}; | ||
// let { valueSuffix, property } = bigNumber ?? {}; | ||
|
||
// if (indicator === 'averagePercentage') { | ||
// this.bigNumberReportData = { | ||
// ...this.bigNumberReportData, | ||
// valueSuffix: valueSuffix, | ||
|
||
// } | ||
// await this._commonService.getReportDataNew(query).subscribe((res: any) => { | ||
|
||
// if (res) { | ||
// let rows = res; | ||
// this.bigNumberReportData = { | ||
// ...this.bigNumberReportData, | ||
// averagePercentage: rows[0]?.[property] | ||
// } | ||
// } | ||
// }) | ||
// } | ||
// else if (indicator === 'differencePercentage') { | ||
// await this._commonService.getReportDataNew(query).subscribe((res: any) => { | ||
// if (res) { | ||
// let rows = res; | ||
// this.bigNumberReportData = { | ||
// ...this.bigNumberReportData, | ||
// differencePercentage: rows[0]?.[property] | ||
// } | ||
// } | ||
// }) | ||
// } | ||
|
||
// } | ||
|
||
ngOnDestroy(): void { | ||
this.drillDownSubscription.unsubscribe() | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
.../reports/telemetry-active-users-trendline/telemetry-active-users-trendline.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<canvas id="trendlineChart"></canvas> |
Empty file.
23 changes: 23 additions & 0 deletions
23
...ports/telemetry-active-users-trendline/telemetry-active-users-trendline.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { TelemetryActiveUsersTrendlineComponent } from './telemetry-active-users-trendline.component'; | ||
|
||
describe('TelemetryActiveUsersTrendlineComponent', () => { | ||
let component: TelemetryActiveUsersTrendlineComponent; | ||
let fixture: ComponentFixture<TelemetryActiveUsersTrendlineComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ TelemetryActiveUsersTrendlineComponent ] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(TelemetryActiveUsersTrendlineComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
Oops, something went wrong.