diff --git a/demo-shell-ng2/app/components/activiti/activiti-demo.component.html b/demo-shell-ng2/app/components/activiti/activiti-demo.component.html
index 943a2cacdc..f0d51fef29 100644
--- a/demo-shell-ng2/app/components/activiti/activiti-demo.component.html
+++ b/demo-shell-ng2/app/components/activiti/activiti-demo.component.html
@@ -167,9 +167,12 @@
[reportId]="report.id"
[hideParameters]="false"
(editReport)="onEditReport($event)"
- (reportSaved)="onReportSaved()"
+ (reportSaved)="onReportSaved($event)"
(reportDeleted)="onReportDeleted()">
+
+ {{'ANALYTICS_REPORT.NO_REPORT_MESSAGE' | translate}}
+
diff --git a/demo-shell-ng2/app/components/activiti/activiti-demo.component.ts b/demo-shell-ng2/app/components/activiti/activiti-demo.component.ts
index 982905e7e3..cdf820b5f4 100644
--- a/demo-shell-ng2/app/components/activiti/activiti-demo.component.ts
+++ b/demo-shell-ng2/app/components/activiti/activiti-demo.component.ts
@@ -115,8 +115,8 @@ export class ActivitiDemoComponent implements AfterViewInit {
this.dataProcesses = new ObjectDataTableAdapter(
[],
[
- {type: 'text', key: 'name', title: 'Name', cssClass: 'full-width name-column', sortable: true},
- {type: 'text', key: 'started', title: 'Started', cssClass: 'hidden', sortable: true}
+ { type: 'text', key: 'name', title: 'Name', cssClass: 'full-width name-column', sortable: true },
+ { type: 'text', key: 'started', title: 'Started', cssClass: 'hidden', sortable: true }
]
);
this.dataProcesses.setSorting(new DataSorting('started', 'desc'));
@@ -209,13 +209,13 @@ export class ActivitiDemoComponent implements AfterViewInit {
this.analyticsreportlist.reload();
}
- onReportSaved() {
- this.analyticsreportlist.reload();
+ onReportSaved(reportId) {
+ this.analyticsreportlist.reload(reportId);
}
onReportDeleted() {
- this.selectFirstReport = true;
this.analyticsreportlist.reload();
+ this.analyticsreportlist.selectReport(null);
}
navigateStartProcess() {
diff --git a/demo-shell-ng2/resources/i18n/en.json b/demo-shell-ng2/resources/i18n/en.json
index 9a2c5c5f89..e6e64b9745 100644
--- a/demo-shell-ng2/resources/i18n/en.json
+++ b/demo-shell-ng2/resources/i18n/en.json
@@ -21,5 +21,8 @@
"CUSTOM": "Custom action"
}
}
+ },
+ "ANALYTICS_REPORT":{
+ "NO_REPORT_MESSAGE":"No report selected. Choose a report from the list"
}
}
diff --git a/ng2-components/ng2-activiti-analytics/src/components/analytics-report-list.component.spec.ts b/ng2-components/ng2-activiti-analytics/src/components/analytics-report-list.component.spec.ts
index 7e31bd19b9..eef9c2e558 100644
--- a/ng2-components/ng2-activiti-analytics/src/components/analytics-report-list.component.spec.ts
+++ b/ng2-components/ng2-activiti-analytics/src/components/analytics-report-list.component.spec.ts
@@ -28,14 +28,14 @@ declare let jasmine: any;
describe('AnalyticsReportListComponent', () => {
let 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'},
- {'id': 2005, 'name': 'Fake Test Task overview'},
- {'id': 2006, 'name': 'Fake Test Task service level agreement'}
+ { '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' },
+ { 'id': 2005, 'name': 'Fake Test Task overview' },
+ { 'id': 2006, 'name': 'Fake Test Task service level agreement' }
];
- let reportSelected = {'id': 2003, 'name': 'Fake Test Process definition overview'};
+ let reportSelected = { 'id': 2003, 'name': 'Fake Test Process definition overview' };
let component: AnalyticsReportListComponent;
let fixture: ComponentFixture;
@@ -57,7 +57,9 @@ describe('AnalyticsReportListComponent', () => {
let translateService = TestBed.get(AlfrescoTranslationService);
spyOn(translateService, 'addTranslationFolder').and.stub();
- spyOn(translateService, 'get').and.callFake((key) => { return Observable.of(key); });
+ spyOn(translateService, 'get').and.callFake((key) => {
+ return Observable.of(key);
+ });
}));
beforeEach(() => {
@@ -174,13 +176,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'};
+ let 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'});
+ let report = new ReportParametersModel({ 'id': 2002, 'name': 'Fake Test Process definition heat map' });
component.reports = [report];
expect(component.reports.length).toEqual(1);
component.reload();
@@ -197,6 +199,27 @@ describe('AnalyticsReportListComponent', () => {
});
});
+ it('Should reload the report list and select the report with the given id', (done) => {
+ component.initObserver();
+ expect(component.reports.length).toEqual(0);
+
+ component.reload(2002);
+
+ component.onSuccess.subscribe(() => {
+ expect(component.reports.length).toEqual(5);
+ expect(component.currentReport).toBeDefined();
+ expect(component.currentReport).not.toBeNull();
+ expect(component.currentReport.id).toEqual(2002);
+ done();
+ });
+
+ jasmine.Ajax.requests.mostRecent().respondWith({
+ status: 200,
+ contentType: 'json',
+ responseText: reportList
+ });
+ });
+
});
describe('layout', () => {
diff --git a/ng2-components/ng2-activiti-analytics/src/components/analytics-report-list.component.ts b/ng2-components/ng2-activiti-analytics/src/components/analytics-report-list.component.ts
index 7b726035ec..41ca9c87ef 100644
--- a/ng2-components/ng2-activiti-analytics/src/components/analytics-report-list.component.ts
+++ b/ng2-components/ng2-activiti-analytics/src/components/analytics-report-list.component.ts
@@ -26,7 +26,7 @@ import { ReportParametersModel } from '../models/report.model';
templateUrl: './analytics-report-list.component.html',
styleUrls: ['./analytics-report-list.component.css']
})
-export class AnalyticsReportListComponent implements OnInit {
+export class AnalyticsReportListComponent implements OnInit {
public static LAYOUT_LIST: string = 'LIST';
public static LAYOUT_GRID: string = 'GRID';
@@ -76,15 +76,15 @@ export class AnalyticsReportListComponent implements OnInit {
/**
* Reload the component
*/
- reload() {
+ reload(reportId?) {
this.reset();
- this.getReportList(this.appId);
+ this.getReportList(this.appId, reportId);
}
/**
* Get the report list
*/
- getReportList(appId: string) {
+ getReportList(appId: string, reportId?: string) {
this.analyticsService.getReportList(appId).subscribe(
(res: ReportParametersModel[]) => {
if (res && res.length === 0) {
@@ -93,6 +93,10 @@ export class AnalyticsReportListComponent implements OnInit {
res.forEach((report) => {
this.reportObserver.next(report);
});
+ if (reportId) {
+ console.log('SELEZIONO IL REPORT!');
+ this.selectReportByReportId(reportId);
+ }
if (this.selectFirst) {
this.selectFirstReport();
}
@@ -149,6 +153,14 @@ export class AnalyticsReportListComponent implements OnInit {
this.reportClick.emit(report);
}
+ public selectReportByReportId(reportId) {
+ let reportFound = this.reports.find(report => report.id === reportId);
+ if (reportFound) {
+ this.currentReport = reportFound;
+ this.reportClick.emit(reportFound);
+ }
+ }
+
selectFirstReport() {
this.selectReport(this.reports[0]);
this.selectFirst = false;
diff --git a/ng2-components/ng2-activiti-analytics/src/components/analytics-report-parameters.component.spec.ts b/ng2-components/ng2-activiti-analytics/src/components/analytics-report-parameters.component.spec.ts
index 7fc8734875..bcc4e270ed 100644
--- a/ng2-components/ng2-activiti-analytics/src/components/analytics-report-parameters.component.spec.ts
+++ b/ng2-components/ng2-activiti-analytics/src/components/analytics-report-parameters.component.spec.ts
@@ -483,7 +483,7 @@ describe('AnalyticsReportParametersComponent', () => {
validForm = true;
});
- xit('Should be able to change the report title', (done) => {
+ it('Should be able to change the report title', (done) => {
let title: HTMLElement = element.querySelector('h4');
title.click();
@@ -514,9 +514,10 @@ describe('AnalyticsReportParametersComponent', () => {
});
it('Should show a dialog to allowing report save', async(() => {
- component.saveReportSuccess.subscribe(() => {
+ component.saveReportSuccess.subscribe((repId) => {
let reportDialogTitle: HTMLElement = element.querySelector('#report-dialog');
expect(reportDialogTitle.getAttribute('open')).toBeNull();
+ expect(repId).toBe('1');
});
component.submit(values);
diff --git a/ng2-components/ng2-activiti-analytics/src/components/analytics-report-parameters.component.ts b/ng2-components/ng2-activiti-analytics/src/components/analytics-report-parameters.component.ts
index 6c4212569e..51609586e2 100644
--- a/ng2-components/ng2-activiti-analytics/src/components/analytics-report-parameters.component.ts
+++ b/ng2-components/ng2-activiti-analytics/src/components/analytics-report-parameters.component.ts
@@ -372,7 +372,7 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On
doSave(paramQuery: ReportQuery) {
this.analyticsService.saveReport(this.reportId, paramQuery).subscribe(() => {
- this.saveReportSuccess.emit();
+ this.saveReportSuccess.emit(this.reportId);
});
}
diff --git a/ng2-components/ng2-activiti-analytics/src/components/analytics.component.html b/ng2-components/ng2-activiti-analytics/src/components/analytics.component.html
index 9245d6cc62..134e460d86 100644
--- a/ng2-components/ng2-activiti-analytics/src/components/analytics.component.html
+++ b/ng2-components/ng2-activiti-analytics/src/components/analytics.component.html
@@ -3,7 +3,7 @@
[hideComponent]="hideParameters"
(onFormValueChanged)="reset()"
(onSuccess)="showReport($event)"
- (saveReportSuccess)="onSaveReportSuccess()"
+ (saveReportSuccess)="onSaveReportSuccess($event)"
(deleteReportSuccess)="onDeleteReportSuccess()"
(onEdit)="onEditReport($event)">
diff --git a/ng2-components/ng2-activiti-analytics/src/components/analytics.component.ts b/ng2-components/ng2-activiti-analytics/src/components/analytics.component.ts
index bf0ac9a338..b32136e2d4 100644
--- a/ng2-components/ng2-activiti-analytics/src/components/analytics.component.ts
+++ b/ng2-components/ng2-activiti-analytics/src/components/analytics.component.ts
@@ -79,8 +79,8 @@ export class AnalyticsComponent implements OnChanges {
this.editReport.emit(name);
}
- public onSaveReportSuccess() {
- this.reportSaved.emit();
+ public onSaveReportSuccess(reportId) {
+ this.reportSaved.emit(reportId);
}
public onDeleteReportSuccess() {