mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
Add reports filter by appId
This commit is contained in:
@@ -69,7 +69,7 @@
|
|||||||
<analytics-report-list (reportClick)="onReportClick($event)"></analytics-report-list>
|
<analytics-report-list (reportClick)="onReportClick($event)"></analytics-report-list>
|
||||||
</div>
|
</div>
|
||||||
<div class="mdl-cell mdl-cell--8-col task-column mdl-shadow--2dp">
|
<div class="mdl-cell mdl-cell--8-col task-column mdl-shadow--2dp">
|
||||||
<activiti-analytics *ngIf="report" [reportId]="report.id"></activiti-analytics>
|
<activiti-analytics [appId]="appId" *ngIf="report" [reportId]="report.id"></activiti-analytics>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -69,7 +69,8 @@ export var reportDefParamProcessDef = {
|
|||||||
'definition': '{ "parameters" :[{"id":"processDefinitionId","name":null,"nameKey":null,"type":"processDefinition","value":null,"dependsOn":null}]}'
|
'definition': '{ "parameters" :[{"id":"processDefinitionId","name":null,"nameKey":null,"type":"processDefinition","value":null,"dependsOn":null}]}'
|
||||||
};
|
};
|
||||||
|
|
||||||
export var reportDefParamProcessDefOptions = [
|
export var reportDefParamProcessDefOptions = {
|
||||||
|
'size': 4, 'total': 4, 'start': 0, 'data': [
|
||||||
{
|
{
|
||||||
'id': 'FakeProcessTest 1:1:1',
|
'id': 'FakeProcessTest 1:1:1',
|
||||||
'name': 'Fake Process Test 1 Name ',
|
'name': 'Fake Process Test 1 Name ',
|
||||||
@@ -90,7 +91,23 @@ export var reportDefParamProcessDefOptions = [
|
|||||||
'name': 'Fake Process Test 3 Name ',
|
'name': 'Fake Process Test 3 Name ',
|
||||||
'version': 1
|
'version': 1
|
||||||
}
|
}
|
||||||
];
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
export var reportDefParamProcessDefOptionsApp = {
|
||||||
|
'size': 2, 'total': 2, 'start': 2, 'data': [
|
||||||
|
{
|
||||||
|
'id': 'FakeProcessTest 1:1:1',
|
||||||
|
'name': 'Fake Process Test 1 Name ',
|
||||||
|
'version': 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'id': 'FakeProcessTest 1:2:1',
|
||||||
|
'name': 'Fake Process Test 1 Name ',
|
||||||
|
'version': 2
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
export var reportDefParamTask = {
|
export var reportDefParamTask = {
|
||||||
'id': 2006,
|
'id': 2006,
|
||||||
|
@@ -33,8 +33,8 @@ import { DebugElement, SimpleChange } from '@angular/core';
|
|||||||
import {
|
import {
|
||||||
reportDefParamCheck, reportDefParamDateRange, chartProcessDefOverview, chartTaskOverview, fieldDateRange,
|
reportDefParamCheck, reportDefParamDateRange, chartProcessDefOverview, chartTaskOverview, fieldDateRange,
|
||||||
fieldDateRangeInterval, fieldDuration, fieldNumber, fieldProcessDef, fieldStatus, fieldTask, fieldTypeFiltering,
|
fieldDateRangeInterval, fieldDuration, fieldNumber, fieldProcessDef, fieldStatus, fieldTask, fieldTypeFiltering,
|
||||||
reportDefParamDuration, reportDefParamNumber, reportDefParamTaskOptions, reportDefParamStatus,
|
reportDefParamDuration, reportDefParamNumber, reportDefParamTaskOptions, reportDefParamStatus, reportDefParamRangeInterval,
|
||||||
reportDefParamRangeInterval, reportDefParamProcessDef, reportDefParamProcessDefOptions, reportDefParamTask
|
reportDefParamProcessDef, reportDefParamProcessDefOptions, reportDefParamProcessDefOptionsApp, reportDefParamTask
|
||||||
} from '../assets/analyticsComponent.mock';
|
} from '../assets/analyticsComponent.mock';
|
||||||
|
|
||||||
export const ANALYTICS_DIRECTIVES: any[] = [
|
export const ANALYTICS_DIRECTIVES: any[] = [
|
||||||
@@ -255,7 +255,9 @@ describe('Test ng2-activiti-analytics Report ', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should render a dropdown with all the process definition when the definition parameter type is \'processDefinition\' ', (done) => {
|
it('Should render a dropdown with all the process definition when the definition parameter type is \'processDefinition\' and the' +
|
||||||
|
' reportId change' +
|
||||||
|
' ', (done) => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
component.onSuccessParamOpt.subscribe(() => {
|
component.onSuccessParamOpt.subscribe(() => {
|
||||||
@@ -289,6 +291,41 @@ describe('Test ng2-activiti-analytics Report ', () => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Should render a dropdown with all the process definition when the definition parameter type is \'processDefinition\' and the' +
|
||||||
|
' appId change' +
|
||||||
|
' ', (done) => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
component.onSuccessParamOpt.subscribe(() => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
let dropDown: any = element.querySelector('#select-processDefinitionId');
|
||||||
|
expect(dropDown).toBeDefined();
|
||||||
|
expect(dropDown.length).toEqual(3);
|
||||||
|
expect(dropDown[0].innerHTML).toEqual('Choose One');
|
||||||
|
expect(dropDown[1].innerHTML).toEqual('Fake Process Test 1 Name (v 1) ');
|
||||||
|
expect(dropDown[2].innerHTML).toEqual('Fake Process Test 1 Name (v 2) ');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
let appId = 1;
|
||||||
|
component.appId = appId;
|
||||||
|
let change = new SimpleChange(null, appId);
|
||||||
|
component.ngOnChanges({ 'appId': change });
|
||||||
|
|
||||||
|
jasmine.Ajax.requests.first().respondWith({
|
||||||
|
status: 200,
|
||||||
|
contentType: 'json',
|
||||||
|
responseText: reportDefParamProcessDef
|
||||||
|
});
|
||||||
|
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
|
status: 200,
|
||||||
|
contentType: 'json',
|
||||||
|
responseText: reportDefParamProcessDefOptionsApp
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
it('Should render the Process definition overview report ', (done) => {
|
it('Should render the Process definition overview report ', (done) => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
@@ -33,6 +33,9 @@ export class AnalyticsComponent implements OnInit, OnChanges {
|
|||||||
@ViewChild('processDefinition')
|
@ViewChild('processDefinition')
|
||||||
processDefinition: any;
|
processDefinition: any;
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
appId: string;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
reportId: string;
|
reportId: string;
|
||||||
|
|
||||||
@@ -85,13 +88,13 @@ export class AnalyticsComponent implements OnInit, OnChanges {
|
|||||||
this.dropDownSub = this.onDropdownChanged.subscribe((field) => {
|
this.dropDownSub = this.onDropdownChanged.subscribe((field) => {
|
||||||
let paramDependOn: ReportParameterModel = this.reportDetails.definition.parameters.find(p => p.dependsOn === field.id);
|
let paramDependOn: ReportParameterModel = this.reportDetails.definition.parameters.find(p => p.dependsOn === field.id);
|
||||||
if (paramDependOn) {
|
if (paramDependOn) {
|
||||||
this.retrieveParameterOptions(this.reportDetails.definition.parameters, this.reportId, field.value);
|
this.retrieveParameterOptions(this.reportDetails.definition.parameters, this.appId, this.reportId, field.value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.paramOpts = this.onSuccessParamsReport.subscribe((report: ReportModel) => {
|
this.paramOpts = this.onSuccessParamsReport.subscribe((report: ReportModel) => {
|
||||||
if (report.hasParameters()) {
|
if (report.hasParameters()) {
|
||||||
this.retrieveParameterOptions(report.definition.parameters);
|
this.retrieveParameterOptions(report.definition.parameters, this.appId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -102,6 +105,12 @@ export class AnalyticsComponent implements OnInit, OnChanges {
|
|||||||
this.getParamsReports(reportId.currentValue);
|
this.getParamsReports(reportId.currentValue);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let appId = changes['appId'];
|
||||||
|
if (appId && (appId.currentValue || appId.currentValue === null)) {
|
||||||
|
this.getParamsReports(this.reportId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public getParamsReports(reportId: string) {
|
public getParamsReports(reportId: string) {
|
||||||
@@ -119,9 +128,9 @@ export class AnalyticsComponent implements OnInit, OnChanges {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private retrieveParameterOptions(parameters: ReportParameterModel[], reportId?: string, processDefinitionId?: string) {
|
private retrieveParameterOptions(parameters: ReportParameterModel[], appId: string, reportId?: string, processDefinitionId?: string) {
|
||||||
parameters.forEach((param) => {
|
parameters.forEach((param) => {
|
||||||
this.analyticsService.getParamValuesByType(param.type, this.reportId, processDefinitionId).subscribe(
|
this.analyticsService.getParamValuesByType(param.type, appId, reportId, processDefinitionId).subscribe(
|
||||||
(opts: ParameterValueModel[]) => {
|
(opts: ParameterValueModel[]) => {
|
||||||
param.options = opts;
|
param.options = opts;
|
||||||
this.onSuccessParamOpt.emit(opts);
|
this.onSuccessParamOpt.emit(opts);
|
||||||
|
@@ -64,11 +64,11 @@ export class AnalyticsService {
|
|||||||
}).catch(this.handleError);
|
}).catch(this.handleError);
|
||||||
}
|
}
|
||||||
|
|
||||||
getParamValuesByType(type: string, reportId?: string, processDefinitionId?: string) {
|
getParamValuesByType(type: string, appId: string, reportId?: string, processDefinitionId?: string) {
|
||||||
if (type === 'status') {
|
if (type === 'status') {
|
||||||
return this.getProcessStatusValues();
|
return this.getProcessStatusValues();
|
||||||
} else if (type === 'processDefinition') {
|
} else if (type === 'processDefinition') {
|
||||||
return this.getProcessDefinitionsValues();
|
return this.getProcessDefinitionsValues(appId);
|
||||||
} else if (type === 'dateInterval') {
|
} else if (type === 'dateInterval') {
|
||||||
return this.getDateIntervalValues();
|
return this.getDateIntervalValues();
|
||||||
} else if (type === 'task') {
|
} else if (type === 'task') {
|
||||||
@@ -109,8 +109,8 @@ export class AnalyticsService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getProcessDefinitionsValues(appId?: string): Observable<any> {
|
getProcessDefinitionsValues(appId: string): Observable<any> {
|
||||||
let url = `${this.alfrescoSettingsService.getBPMApiBaseUrl()}/app/rest/reporting/process-definitions`;
|
let url = `${this.alfrescoSettingsService.getBPMApiBaseUrl()}/app/rest/process-definitions`;
|
||||||
let params: URLSearchParams;
|
let params: URLSearchParams;
|
||||||
if (appId) {
|
if (appId) {
|
||||||
params = new URLSearchParams();
|
params = new URLSearchParams();
|
||||||
@@ -122,7 +122,7 @@ export class AnalyticsService {
|
|||||||
.map((res: any) => {
|
.map((res: any) => {
|
||||||
let paramOptions: ParameterValueModel[] = [];
|
let paramOptions: ParameterValueModel[] = [];
|
||||||
let body = res.json();
|
let body = res.json();
|
||||||
body.forEach((opt) => {
|
body.data.forEach((opt) => {
|
||||||
paramOptions.push(new ParameterValueModel(opt));
|
paramOptions.push(new ParameterValueModel(opt));
|
||||||
});
|
});
|
||||||
return paramOptions;
|
return paramOptions;
|
||||||
|
Reference in New Issue
Block a user