mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
enable prefer-const rule for tslint, fix issues (#4409)
* enable prefer-const rule for tslint, fix issues * Update content-node-selector.component.spec.ts * Update content-node-selector.component.spec.ts * fix const * fix lint issues * update tests * update tests * update tests * fix code * fix page class
This commit is contained in:
committed by
Eugenio Romano
parent
26c5982a1a
commit
a7a48e8b2b
@@ -104,7 +104,7 @@ export class AnalyticsGeneratorComponent implements OnChanges {
|
||||
* so one way around it, is to clone the data, change it and then
|
||||
* assign it;
|
||||
*/
|
||||
let clone = JSON.parse(JSON.stringify(report));
|
||||
const clone = JSON.parse(JSON.stringify(report));
|
||||
report.datasets = clone.datasets;
|
||||
}
|
||||
|
||||
|
@@ -28,13 +28,13 @@ describe('AnalyticsReportHeatMapComponent', () => {
|
||||
let fixture: ComponentFixture<AnalyticsReportHeatMapComponent>;
|
||||
let element: HTMLElement;
|
||||
|
||||
let totalCountPercent: any = { 'sid-fake-id': 0, 'fake-start-event': 100 };
|
||||
let totalTimePercent: any = { 'sid-fake-id': 10, 'fake-start-event': 30 };
|
||||
let avgTimePercentages: any = { 'sid-fake-id': 5, 'fake-start-event': 50 };
|
||||
const totalCountPercent: any = { 'sid-fake-id': 0, 'fake-start-event': 100 };
|
||||
const totalTimePercent: any = { 'sid-fake-id': 10, 'fake-start-event': 30 };
|
||||
const avgTimePercentages: any = { 'sid-fake-id': 5, 'fake-start-event': 50 };
|
||||
|
||||
let totalCountValues: any = { 'sid-fake-id': 2, 'fake-start-event': 3 };
|
||||
let totalTimeValues: any = { 'sid-fake-id': 1, 'fake-start-event': 4 };
|
||||
let avgTimeValues: any = { 'sid-fake-id': 4, 'fake-start-event': 5 };
|
||||
const totalCountValues: any = { 'sid-fake-id': 2, 'fake-start-event': 3 };
|
||||
const totalTimeValues: any = { 'sid-fake-id': 1, 'fake-start-event': 4 };
|
||||
const avgTimeValues: any = { 'sid-fake-id': 4, 'fake-start-event': 5 };
|
||||
|
||||
setupTestBed({
|
||||
imports: [InsightsTestingModule]
|
||||
@@ -70,7 +70,7 @@ describe('AnalyticsReportHeatMapComponent', () => {
|
||||
|
||||
component.success.subscribe(() => {
|
||||
fixture.whenStable().then(() => {
|
||||
let dropDown: any = element.querySelector('#select-metrics');
|
||||
const dropDown: any = element.querySelector('#select-metrics');
|
||||
expect(dropDown).toBeDefined();
|
||||
expect(dropDown.length).toEqual(3);
|
||||
expect(dropDown[0].innerHTML).toEqual('Number of times a step is executed');
|
||||
@@ -91,21 +91,21 @@ describe('AnalyticsReportHeatMapComponent', () => {
|
||||
}));
|
||||
|
||||
it('should change the currentMetric width totalCount', async(() => {
|
||||
let field = { value: 'totalCount' };
|
||||
const field = { value: 'totalCount' };
|
||||
component.onMetricChanges(field);
|
||||
expect(component.currentMetric).toEqual(totalCountValues);
|
||||
expect(component.currentMetricColors).toEqual(totalCountPercent);
|
||||
}));
|
||||
|
||||
it('should change the currentMetric width totalTime', async(() => {
|
||||
let field = { value: 'totalTime' };
|
||||
const field = { value: 'totalTime' };
|
||||
component.onMetricChanges(field);
|
||||
expect(component.currentMetric).toEqual(totalTimeValues);
|
||||
expect(component.currentMetricColors).toEqual(totalTimePercent);
|
||||
}));
|
||||
|
||||
it('should change the currentMetric width avgTime', async(() => {
|
||||
let field = { value: 'avgTime' };
|
||||
const field = { value: 'avgTime' };
|
||||
component.onMetricChanges(field);
|
||||
expect(component.currentMetric).toEqual(avgTimeValues);
|
||||
expect(component.currentMetricColors).toEqual(avgTimePercentages);
|
||||
|
@@ -25,7 +25,7 @@ declare let jasmine: any;
|
||||
|
||||
describe('AnalyticsReportListComponent', () => {
|
||||
|
||||
let reportList = [
|
||||
const reportList = [
|
||||
{ 'id': 2002, 'name': 'Fake Test Process definition heat map' },
|
||||
{ 'id': 2003, 'name': 'Fake Test Process definition overview' },
|
||||
{ 'id': 2004, 'name': 'Fake Test Process instances overview' },
|
||||
@@ -33,7 +33,7 @@ describe('AnalyticsReportListComponent', () => {
|
||||
{ 'id': 2006, 'name': 'Fake Test Task service level agreement' }
|
||||
];
|
||||
|
||||
let reportSelected = { 'id': 2003, 'name': 'Fake Test Process definition overview' };
|
||||
const reportSelected = { 'id': 2003, 'name': 'Fake Test Process definition overview' };
|
||||
|
||||
let component: AnalyticsReportListComponent;
|
||||
let fixture: ComponentFixture<AnalyticsReportListComponent>;
|
||||
@@ -155,13 +155,13 @@ describe('AnalyticsReportListComponent', () => {
|
||||
|
||||
it('Should return false if the current report is different', () => {
|
||||
component.selectReport(reportSelected);
|
||||
let anotherReport = { 'id': 111, 'name': 'Another Fake Test Process definition overview' };
|
||||
const anotherReport = { 'id': 111, 'name': 'Another Fake Test Process definition overview' };
|
||||
expect(component.isSelected(anotherReport)).toBe(false);
|
||||
});
|
||||
|
||||
it('Should reload the report list', (done) => {
|
||||
component.initObserver();
|
||||
let report = new ReportParametersModel({ 'id': 2002, 'name': 'Fake Test Process definition heat map' });
|
||||
const report = new ReportParametersModel({ 'id': 2002, 'name': 'Fake Test Process definition heat map' });
|
||||
component.reports = [report];
|
||||
expect(component.reports.length).toEqual(1);
|
||||
component.reload();
|
||||
|
@@ -153,7 +153,7 @@ export class AnalyticsReportListComponent implements OnInit {
|
||||
}
|
||||
|
||||
public selectReportByReportId(reportId) {
|
||||
let reportFound = this.reports.find((report) => report.id === reportId);
|
||||
const reportFound = this.reports.find((report) => report.id === reportId);
|
||||
if (reportFound) {
|
||||
this.currentReport = reportFound;
|
||||
this.reportClick.emit(reportFound);
|
||||
|
@@ -60,7 +60,7 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
});
|
||||
|
||||
it('Should initialize the Report form with a Form Group ', (done) => {
|
||||
let fakeReportParam = new ReportParametersModel(analyticParamsMock.reportDefParamTask);
|
||||
const fakeReportParam = new ReportParametersModel(analyticParamsMock.reportDefParamTask);
|
||||
component.successReportParams.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
expect(component.reportForm.get('taskGroup')).toBeDefined();
|
||||
@@ -73,7 +73,7 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
it('Should render a dropdown with all the status when the definition parameter type is \'status\' ', (done) => {
|
||||
component.successReportParams.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
let dropDown: any = element.querySelector('#select-status');
|
||||
const dropDown: any = element.querySelector('#select-status');
|
||||
expect(element.querySelector('h4').textContent.trim()).toEqual('Fake Task overview status');
|
||||
expect(dropDown).toBeDefined();
|
||||
expect(dropDown.length).toEqual(4);
|
||||
@@ -84,8 +84,8 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
let reportId = 1;
|
||||
let change = new SimpleChange(null, reportId, true);
|
||||
const reportId = 1;
|
||||
const change = new SimpleChange(null, reportId, true);
|
||||
component.ngOnChanges({'reportId': change});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
@@ -98,14 +98,14 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
it('Should render a number with the default value when the definition parameter type is \'integer\' ', (done) => {
|
||||
component.successReportParams.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
let numberElement: any = element.querySelector('#slowProcessInstanceInteger');
|
||||
const numberElement: any = element.querySelector('#slowProcessInstanceInteger');
|
||||
expect(numberElement.value).toEqual('10');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
let reportId = 1;
|
||||
let change = new SimpleChange(null, reportId, true);
|
||||
const reportId = 1;
|
||||
const change = new SimpleChange(null, reportId, true);
|
||||
component.ngOnChanges({'reportId': change});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
@@ -118,10 +118,10 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
it('Should render a duration component when the definition parameter type is \'duration\' ', (done) => {
|
||||
component.successReportParams.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
let numberElement: any = element.querySelector('#duration');
|
||||
const numberElement: any = element.querySelector('#duration');
|
||||
expect(numberElement.value).toEqual('0');
|
||||
|
||||
let dropDown: any = element.querySelector('#select-duration');
|
||||
const dropDown: any = element.querySelector('#select-duration');
|
||||
expect(dropDown).toBeDefined();
|
||||
expect(dropDown.length).toEqual(4);
|
||||
expect(dropDown[0].innerHTML).toEqual('Seconds');
|
||||
@@ -131,8 +131,8 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
let reportId = 1;
|
||||
let change = new SimpleChange(null, reportId, true);
|
||||
const reportId = 1;
|
||||
const change = new SimpleChange(null, reportId, true);
|
||||
component.ngOnChanges({'reportId': change});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
@@ -155,7 +155,7 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
expect(res.typeFiltering).toEqual(true);
|
||||
});
|
||||
|
||||
let values: any = {
|
||||
const values: any = {
|
||||
dateRange: {
|
||||
startDate: '2016-09-01', endDate: '2016-10-05'
|
||||
},
|
||||
@@ -188,13 +188,13 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
it('Should render a checkbox with the value true when the definition parameter type is \'boolean\' ', (done) => {
|
||||
component.successReportParams.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
let checkElement: any = element.querySelector('#typeFiltering-input');
|
||||
const checkElement: any = element.querySelector('#typeFiltering-input');
|
||||
expect(checkElement.checked).toBeTruthy();
|
||||
done();
|
||||
});
|
||||
|
||||
let reportId = 1;
|
||||
let change = new SimpleChange(null, reportId, true);
|
||||
const reportId = 1;
|
||||
const change = new SimpleChange(null, reportId, true);
|
||||
component.ngOnChanges({'reportId': change});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
@@ -206,13 +206,13 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
|
||||
it('Should render a date range components when the definition parameter type is \'dateRange\' ', (done) => {
|
||||
component.successReportParams.subscribe(() => {
|
||||
let dateElement: any = element.querySelector('adf-date-range-widget');
|
||||
const dateElement: any = element.querySelector('adf-date-range-widget');
|
||||
expect(dateElement).toBeDefined();
|
||||
done();
|
||||
});
|
||||
|
||||
let reportId = 1;
|
||||
let change = new SimpleChange(null, reportId, true);
|
||||
const reportId = 1;
|
||||
const change = new SimpleChange(null, reportId, true);
|
||||
component.toggleParameters();
|
||||
component.ngOnChanges({'reportId': change});
|
||||
|
||||
@@ -226,7 +226,7 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
it('Should render a dropdown with all the RangeInterval when the definition parameter type is \'dateRangeInterval\' ', (done) => {
|
||||
component.successReportParams.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
let dropDown: any = element.querySelector('#select-dateRangeInterval');
|
||||
const dropDown: any = element.querySelector('#select-dateRangeInterval');
|
||||
expect(dropDown).toBeDefined();
|
||||
expect(dropDown.length).toEqual(5);
|
||||
expect(dropDown[0].innerHTML).toEqual('By hour');
|
||||
@@ -237,8 +237,8 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
let reportId = 1;
|
||||
let change = new SimpleChange(null, reportId, true);
|
||||
const reportId = 1;
|
||||
const change = new SimpleChange(null, reportId, true);
|
||||
component.ngOnChanges({'reportId': change});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
@@ -252,7 +252,7 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
' reportId change', (done) => {
|
||||
component.successParamOpt.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
let dropDown: any = element.querySelector('#select-processDefinitionId');
|
||||
const dropDown: any = element.querySelector('#select-processDefinitionId');
|
||||
expect(dropDown).toBeDefined();
|
||||
expect(dropDown.length).toEqual(5);
|
||||
expect(dropDown[0].innerHTML).toEqual('Choose One');
|
||||
@@ -275,8 +275,8 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
responseText: analyticParamsMock.reportDefParamProcessDefOptionsNoApp
|
||||
});
|
||||
|
||||
let reportId = 1;
|
||||
let change = new SimpleChange(null, reportId, true);
|
||||
const reportId = 1;
|
||||
const change = new SimpleChange(null, reportId, true);
|
||||
component.ngOnChanges({'reportId': change});
|
||||
|
||||
});
|
||||
@@ -285,7 +285,7 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
' appId change', (done) => {
|
||||
component.successParamOpt.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
let dropDown: any = element.querySelector('#select-processDefinitionId');
|
||||
const dropDown: any = element.querySelector('#select-processDefinitionId');
|
||||
expect(dropDown).toBeDefined();
|
||||
expect(dropDown.length).toEqual(3);
|
||||
expect(dropDown[0].innerHTML).toEqual('Choose One');
|
||||
@@ -300,7 +300,7 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
responseText: analyticParamsMock.reportDefParamProcessDef
|
||||
});
|
||||
|
||||
let appId = 1;
|
||||
const appId = 1;
|
||||
|
||||
jasmine.Ajax.stubRequest('http://localhost:9876/bpm/activiti-app/api/enterprise/process-definitions?appDefinitionId=' + appId).andReturn({
|
||||
status: 200,
|
||||
@@ -310,7 +310,7 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
|
||||
component.appId = appId;
|
||||
component.reportId = '1';
|
||||
let change = new SimpleChange(null, appId, true);
|
||||
const change = new SimpleChange(null, appId, true);
|
||||
component.ngOnChanges({'appId': change});
|
||||
|
||||
});
|
||||
@@ -322,8 +322,8 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
expect(component.reportForm.controls).toEqual({});
|
||||
});
|
||||
|
||||
let reportId = 1;
|
||||
let change = new SimpleChange(null, reportId, true);
|
||||
const reportId = 1;
|
||||
const change = new SimpleChange(null, reportId, true);
|
||||
component.ngOnChanges({'reportId': change});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
@@ -372,8 +372,8 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
responseText: []
|
||||
});
|
||||
|
||||
let reportId = 1;
|
||||
let change = new SimpleChange(null, reportId, true);
|
||||
const reportId = 1;
|
||||
const change = new SimpleChange(null, reportId, true);
|
||||
component.ngOnChanges({'reportId': change});
|
||||
|
||||
});
|
||||
@@ -384,8 +384,8 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
let reportId = 1;
|
||||
let change = new SimpleChange(null, reportId, true);
|
||||
const reportId = 1;
|
||||
const change = new SimpleChange(null, reportId, true);
|
||||
component.ngOnChanges({'reportId': change});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
@@ -396,13 +396,13 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
});
|
||||
|
||||
it('Should convert a string in number', () => {
|
||||
let numberConvert = component.convertNumber('2');
|
||||
const numberConvert = component.convertNumber('2');
|
||||
expect(numberConvert).toEqual(2);
|
||||
});
|
||||
|
||||
describe('When the form is rendered correctly', () => {
|
||||
|
||||
let values: any = {
|
||||
const values: any = {
|
||||
dateRange: {
|
||||
startDate: '2016-09-01', endDate: '2016-10-05'
|
||||
},
|
||||
@@ -430,8 +430,8 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
};
|
||||
|
||||
beforeEach(async(() => {
|
||||
let reportId = 1;
|
||||
let change = new SimpleChange(null, reportId, true);
|
||||
const reportId = 1;
|
||||
const change = new SimpleChange(null, reportId, true);
|
||||
component.ngOnChanges({'reportId': change});
|
||||
fixture.detectChanges();
|
||||
|
||||
@@ -450,11 +450,11 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
it('Should be able to change the report title', (done) => {
|
||||
spyOn(service, 'updateReport').and.returnValue(of(analyticParamsMock.reportDefParamStatus));
|
||||
|
||||
let title: HTMLElement = element.querySelector('h4');
|
||||
const title: HTMLElement = element.querySelector('h4');
|
||||
title.click();
|
||||
fixture.detectChanges();
|
||||
|
||||
let reportName: HTMLInputElement = <HTMLInputElement> element.querySelector('#reportName');
|
||||
const reportName: HTMLInputElement = <HTMLInputElement> element.querySelector('#reportName');
|
||||
expect(reportName).not.toBeNull();
|
||||
|
||||
reportName.focus();
|
||||
@@ -465,7 +465,7 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let titleChanged: HTMLElement = element.querySelector('h4');
|
||||
const titleChanged: HTMLElement = element.querySelector('h4');
|
||||
expect(titleChanged.textContent.trim()).toEqual('FAKE_TEST_NAME');
|
||||
done();
|
||||
});
|
||||
@@ -481,7 +481,7 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
|
||||
component.submit(values);
|
||||
fixture.detectChanges();
|
||||
let saveButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#save-button');
|
||||
const saveButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#save-button');
|
||||
expect(saveButton).toBeDefined();
|
||||
expect(saveButton).not.toBeNull();
|
||||
saveButton.click();
|
||||
@@ -490,11 +490,11 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let reportDialogTitle: HTMLElement = <HTMLElement> window.document.querySelector('#report-dialog-title');
|
||||
let saveTitleSubMessage: HTMLElement = <HTMLElement> window.document.querySelector('#save-title-submessage');
|
||||
let inputSaveName: HTMLInputElement = <HTMLInputElement> window.document.querySelector('#repName');
|
||||
let performActionButton: HTMLButtonElement = <HTMLButtonElement> window.document.querySelector('#action-dialog-button');
|
||||
let todayDate = component.getTodayDate();
|
||||
const reportDialogTitle: HTMLElement = <HTMLElement> window.document.querySelector('#report-dialog-title');
|
||||
const saveTitleSubMessage: HTMLElement = <HTMLElement> window.document.querySelector('#save-title-submessage');
|
||||
const inputSaveName: HTMLInputElement = <HTMLInputElement> window.document.querySelector('#repName');
|
||||
const performActionButton: HTMLButtonElement = <HTMLButtonElement> window.document.querySelector('#action-dialog-button');
|
||||
const todayDate = component.getTodayDate();
|
||||
|
||||
expect(reportDialogTitle).not.toBeNull('Dialog title should not be null');
|
||||
expect(saveTitleSubMessage).not.toBeNull('Dialog save title submessage should not be null');
|
||||
@@ -513,7 +513,7 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
xit('Should show a dialog to allowing report export', async(() => {
|
||||
component.submit(values);
|
||||
fixture.detectChanges();
|
||||
let exportButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#export-button');
|
||||
const exportButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#export-button');
|
||||
|
||||
expect(exportButton).toBeDefined();
|
||||
expect(exportButton).not.toBeNull();
|
||||
@@ -523,10 +523,10 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let reportDialogTitle: HTMLElement = <HTMLElement> window.document.querySelector('#report-dialog-title');
|
||||
let inputSaveName: HTMLInputElement = <HTMLInputElement> window.document.querySelector('#repName');
|
||||
let performActionButton: HTMLButtonElement = <HTMLButtonElement> window.document.querySelector('#action-dialog-button');
|
||||
let todayDate = component.getTodayDate();
|
||||
const reportDialogTitle: HTMLElement = <HTMLElement> window.document.querySelector('#report-dialog-title');
|
||||
const inputSaveName: HTMLInputElement = <HTMLInputElement> window.document.querySelector('#repName');
|
||||
const performActionButton: HTMLButtonElement = <HTMLButtonElement> window.document.querySelector('#action-dialog-button');
|
||||
const todayDate = component.getTodayDate();
|
||||
|
||||
expect(reportDialogTitle).not.toBeNull();
|
||||
expect(inputSaveName.value.trim()).toEqual(analyticParamsMock.reportDefParamStatus.name + ' ( ' + todayDate + ' )');
|
||||
@@ -562,7 +562,7 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
it('Should raise an event for report deleted', async(() => {
|
||||
fixture.detectChanges();
|
||||
spyOn(component, 'deleteReport');
|
||||
let deleteButton = fixture.debugElement.nativeElement.querySelector('#delete-button');
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('#delete-button');
|
||||
expect(deleteButton).toBeDefined();
|
||||
expect(deleteButton).not.toBeNull();
|
||||
component.deleteReportSuccess.subscribe((reportId) => {
|
||||
|
@@ -111,7 +111,7 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On
|
||||
|
||||
ngOnInit() {
|
||||
this.dropDownSub = this.onDropdownChanged.subscribe((field) => {
|
||||
let paramDependOn: ReportParameterDetailsModel = this.reportParameters.definition.parameters.find((p) => p.dependsOn === field.id);
|
||||
const paramDependOn: ReportParameterDetailsModel = this.reportParameters.definition.parameters.find((p) => p.dependsOn === field.id);
|
||||
if (paramDependOn) {
|
||||
this.retrieveParameterOptions(this.reportParameters.definition.parameters, this.appId, this.reportId, field.value);
|
||||
}
|
||||
@@ -131,20 +131,20 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On
|
||||
this.reportForm.reset();
|
||||
}
|
||||
|
||||
let reportId = changes['reportId'];
|
||||
const reportId = changes['reportId'];
|
||||
if (reportId && reportId.currentValue) {
|
||||
this.reportId = reportId.currentValue;
|
||||
this.getReportParams(reportId.currentValue);
|
||||
}
|
||||
|
||||
let appId = changes['appId'];
|
||||
const appId = changes['appId'];
|
||||
if (appId && (appId.currentValue || appId.currentValue === null)) {
|
||||
this.getReportParams(this.reportId);
|
||||
}
|
||||
}
|
||||
|
||||
private generateFormGroupFromParameter(parameters: ReportParameterDetailsModel[]) {
|
||||
let formBuilderGroup: any = {};
|
||||
const formBuilderGroup: any = {};
|
||||
parameters.forEach((param: ReportParameterDetailsModel) => {
|
||||
switch (param.type) {
|
||||
case 'dateRange':
|
||||
@@ -263,7 +263,7 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On
|
||||
}
|
||||
|
||||
convertFormValuesToReportParamQuery(values: any): ReportQuery {
|
||||
let reportParamQuery: ReportQuery = new ReportQuery();
|
||||
const reportParamQuery: ReportQuery = new ReportQuery();
|
||||
if (values.dateRange) {
|
||||
reportParamQuery.dateRange.startDate = this.convertMomentDate(values.dateRange.startDate);
|
||||
reportParamQuery.dateRange.endDate = this.convertMomentDate(values.dateRange.endDate);
|
||||
@@ -353,7 +353,7 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On
|
||||
doExport(paramQuery: ReportQuery) {
|
||||
this.analyticsService.exportReportToCsv(this.reportId, paramQuery).subscribe(
|
||||
(data: any) => {
|
||||
let blob: Blob = new Blob([data], { type: 'text/csv' });
|
||||
const blob: Blob = new Blob([data], { type: 'text/csv' });
|
||||
this.contentService.downloadBlob(blob, paramQuery.reportName + '.csv');
|
||||
});
|
||||
}
|
||||
|
@@ -62,7 +62,7 @@ export class DateRangeWidgetComponent implements OnInit {
|
||||
this.dateAdapter.setLocale(locale);
|
||||
});
|
||||
|
||||
let momentDateAdapter = <MomentDateAdapter> this.dateAdapter;
|
||||
const momentDateAdapter = <MomentDateAdapter> this.dateAdapter;
|
||||
momentDateAdapter.overrideDisplayFormat = this.SHOW_FORMAT;
|
||||
|
||||
if (this.field) {
|
||||
@@ -75,11 +75,11 @@ export class DateRangeWidgetComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
let startDateControl = new FormControl(this.startDatePicker);
|
||||
const startDateControl = new FormControl(this.startDatePicker);
|
||||
startDateControl.setValidators(Validators.required);
|
||||
this.dateRange.addControl('startDate', startDateControl);
|
||||
|
||||
let endDateControl = new FormControl(this.endDatePicker);
|
||||
const endDateControl = new FormControl(this.endDatePicker);
|
||||
endDateControl.setValidators(Validators.required);
|
||||
this.dateRange.addControl('endDate', endDateControl);
|
||||
|
||||
@@ -89,8 +89,8 @@ export class DateRangeWidgetComponent implements OnInit {
|
||||
|
||||
onGroupValueChanged() {
|
||||
if (this.dateRange.valid) {
|
||||
let dateStart = this.convertToMomentDateWithTime(this.dateRange.controls.startDate.value);
|
||||
let endStart = this.convertToMomentDateWithTime(this.dateRange.controls.endDate.value);
|
||||
const dateStart = this.convertToMomentDateWithTime(this.dateRange.controls.startDate.value);
|
||||
const endStart = this.convertToMomentDateWithTime(this.dateRange.controls.endDate.value);
|
||||
this.dateRangeChanged.emit({startDate: dateStart, endDate: endStart});
|
||||
}
|
||||
}
|
||||
@@ -100,9 +100,9 @@ export class DateRangeWidgetComponent implements OnInit {
|
||||
}
|
||||
|
||||
dateCheck(formControl: AbstractControl) {
|
||||
let startDate = moment(formControl.get('startDate').value);
|
||||
let endDate = moment(formControl.get('endDate').value);
|
||||
let isAfterCheck = startDate.isAfter(endDate);
|
||||
const startDate = moment(formControl.get('startDate').value);
|
||||
const endDate = moment(formControl.get('endDate').value);
|
||||
const isAfterCheck = startDate.isAfter(endDate);
|
||||
return isAfterCheck ? {'greaterThan': true} : null;
|
||||
}
|
||||
|
||||
|
@@ -65,7 +65,7 @@ export class DropdownWidgetAnalyticsComponent extends WidgetComponent implements
|
||||
}
|
||||
|
||||
buildValidatorList() {
|
||||
let validatorList = [];
|
||||
const validatorList = [];
|
||||
validatorList.push(Validators.required);
|
||||
if (this.showDefaultOption) {
|
||||
validatorList.push(this.validateDropDown);
|
||||
|
@@ -53,7 +53,7 @@ export class DurationWidgetComponent extends NumberWidgetAnalyticsComponent impl
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
let timeType = new FormControl();
|
||||
const timeType = new FormControl();
|
||||
this.formGroup.addControl('timeType', timeType);
|
||||
|
||||
if (this.required) {
|
||||
@@ -63,7 +63,7 @@ export class DurationWidgetComponent extends NumberWidgetAnalyticsComponent impl
|
||||
this.field.value = 0;
|
||||
}
|
||||
|
||||
let paramOptions: ParameterValueModel[] = [];
|
||||
const paramOptions: ParameterValueModel[] = [];
|
||||
paramOptions.push(new ParameterValueModel({id: '1', name: 'Seconds'}));
|
||||
paramOptions.push(new ParameterValueModel({id: '60', name: 'Minutes'}));
|
||||
paramOptions.push(new ParameterValueModel({id: '3600', name: 'Hours'}));
|
||||
|
@@ -26,7 +26,7 @@ export class WidgetComponent implements OnChanges {
|
||||
fieldChanged: EventEmitter<any> = new EventEmitter<any>();
|
||||
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
let field = changes['field'];
|
||||
const field = changes['field'];
|
||||
if (field && field.currentValue) {
|
||||
this.fieldChanged.emit(field.currentValue.value);
|
||||
return;
|
||||
|
@@ -44,9 +44,9 @@ export class AnalyticsService {
|
||||
return from(this.apiService.getInstance().activiti.reportApi.getReportList())
|
||||
.pipe(
|
||||
map((res: any) => {
|
||||
let reports: ReportParametersModel[] = [];
|
||||
const reports: ReportParametersModel[] = [];
|
||||
res.forEach((report: ReportParametersModel) => {
|
||||
let reportModel = new ReportParametersModel(report);
|
||||
const reportModel = new ReportParametersModel(report);
|
||||
if (this.isReportValid(appId, report)) {
|
||||
reports.push(reportModel);
|
||||
}
|
||||
@@ -111,7 +111,7 @@ export class AnalyticsService {
|
||||
}
|
||||
|
||||
getProcessStatusValues(): Observable<any> {
|
||||
let paramOptions: ParameterValueModel[] = [];
|
||||
const paramOptions: ParameterValueModel[] = [];
|
||||
|
||||
paramOptions.push(new ParameterValueModel({ id: 'All', name: 'All' }));
|
||||
paramOptions.push(new ParameterValueModel({ id: 'Active', name: 'Active' }));
|
||||
@@ -124,7 +124,7 @@ export class AnalyticsService {
|
||||
}
|
||||
|
||||
getDateIntervalValues(): Observable<any> {
|
||||
let paramOptions: ParameterValueModel[] = [];
|
||||
const paramOptions: ParameterValueModel[] = [];
|
||||
|
||||
paramOptions.push(new ParameterValueModel({ id: 'byHour', name: 'By hour' }));
|
||||
paramOptions.push(new ParameterValueModel({ id: 'byDay', name: 'By day' }));
|
||||
@@ -139,7 +139,7 @@ export class AnalyticsService {
|
||||
}
|
||||
|
||||
getMetricValues(): Observable<any> {
|
||||
let paramOptions: ParameterValueModel[] = [];
|
||||
const paramOptions: ParameterValueModel[] = [];
|
||||
|
||||
paramOptions.push(new ParameterValueModel({ id: 'totalCount', name: 'Number of times a step is executed' }));
|
||||
paramOptions.push(new ParameterValueModel({ id: 'totalTime', name: 'Total time spent in a process step' }));
|
||||
@@ -155,7 +155,7 @@ export class AnalyticsService {
|
||||
return from(this.apiService.getInstance().activiti.reportApi.getProcessDefinitions())
|
||||
.pipe(
|
||||
map((res: any) => {
|
||||
let paramOptions: ParameterValueModel[] = [];
|
||||
const paramOptions: ParameterValueModel[] = [];
|
||||
res.forEach((opt) => {
|
||||
paramOptions.push(new ParameterValueModel(opt));
|
||||
});
|
||||
@@ -166,11 +166,11 @@ export class AnalyticsService {
|
||||
}
|
||||
|
||||
getProcessDefinitionsValues(appId: number): Observable<any> {
|
||||
let options = { 'appDefinitionId': appId };
|
||||
const options = { 'appDefinitionId': appId };
|
||||
return from(this.apiService.getInstance().activiti.processDefinitionsApi.getProcessDefinitions(options))
|
||||
.pipe(
|
||||
map((res: any) => {
|
||||
let paramOptions: ParameterValueModel[] = [];
|
||||
const paramOptions: ParameterValueModel[] = [];
|
||||
res.data.forEach((opt) => {
|
||||
paramOptions.push(new ParameterValueModel(opt));
|
||||
});
|
||||
@@ -184,7 +184,7 @@ export class AnalyticsService {
|
||||
return from(this.apiService.getInstance().activiti.reportApi.getTasksByProcessDefinitionId(reportId, processDefinitionId))
|
||||
.pipe(
|
||||
map((res: any) => {
|
||||
let paramOptions: ParameterValueModel[] = [];
|
||||
const paramOptions: ParameterValueModel[] = [];
|
||||
res.forEach((opt) => {
|
||||
paramOptions.push(new ParameterValueModel({ id: opt, name: opt }));
|
||||
});
|
||||
@@ -198,7 +198,7 @@ export class AnalyticsService {
|
||||
return from(this.apiService.getInstance().activiti.reportApi.getReportsByParams(reportId, paramsQuery))
|
||||
.pipe(
|
||||
map((res: any) => {
|
||||
let elements: Chart[] = [];
|
||||
const elements: Chart[] = [];
|
||||
res.elements.forEach((chartData) => {
|
||||
if (chartData.type === 'pieChart') {
|
||||
elements.push(new PieChart(chartData));
|
||||
|
Reference in New Issue
Block a user