diff --git a/ng2-components/ng2-activiti-analytics/index.ts b/ng2-components/ng2-activiti-analytics/index.ts
index 279de053d7..c06595d22a 100644
--- a/ng2-components/ng2-activiti-analytics/index.ts
+++ b/ng2-components/ng2-activiti-analytics/index.ts
@@ -17,13 +17,27 @@
import { NgModule, ModuleWithProviders } from '@angular/core';
import { CoreModule } from 'ng2-alfresco-core';
-import { AnalyticsComponent } from './src/components/analytics.component';
+
+import { AnalyticsReportListComponent } from './src/components/analytics-report-list.component';
+import { AnalyticsComponent } from './src/components/analytics.component';
+import { AnalyticsService } from './src/services/analytics.service';
import { CHART_DIRECTIVES } from 'ng2-charts/ng2-charts';
+import { WIDGET_DIRECTIVES } from './src/components/widgets/index';
+
export * from './src/components/analytics.component';
+export * from './src/components/analytics-report-list.component';
+export * from './src/services/analytics.service';
+export * from './src/components/widgets/index';
export const ANALYTICS_DIRECTIVES: any[] = [
- AnalyticsComponent
+ AnalyticsComponent,
+ AnalyticsReportListComponent,
+ WIDGET_DIRECTIVES
+];
+
+export const ANALYTICS_PROVIDERS: any[] = [
+ AnalyticsService
];
@NgModule({
@@ -32,7 +46,10 @@ export const ANALYTICS_DIRECTIVES: any[] = [
],
declarations: [
...ANALYTICS_DIRECTIVES,
- CHART_DIRECTIVES
+ ...CHART_DIRECTIVES
+ ],
+ providers: [
+ ...ANALYTICS_PROVIDERS
],
exports: [
...ANALYTICS_DIRECTIVES
@@ -43,7 +60,7 @@ export class AnalyticsModule {
return {
ngModule: AnalyticsModule,
providers: [
- ...ANALYTICS_DIRECTIVES
+ ...ANALYTICS_PROVIDERS
]
};
}
diff --git a/ng2-components/ng2-activiti-analytics/karma-test-shim.js b/ng2-components/ng2-activiti-analytics/karma-test-shim.js
index 688f465ff2..4702804ae0 100644
--- a/ng2-components/ng2-activiti-analytics/karma-test-shim.js
+++ b/ng2-components/ng2-activiti-analytics/karma-test-shim.js
@@ -52,7 +52,6 @@ var map = {
// other libraries
'rxjs': 'npm:rxjs',
'ng2-translate': 'npm:ng2-translate',
-
'ng2-charts' : 'npm:ng2-charts',
'alfresco-js-api': 'npm:alfresco-js-api/dist',
diff --git a/ng2-components/ng2-activiti-analytics/karma.conf.js b/ng2-components/ng2-activiti-analytics/karma.conf.js
index 2e7c9d4430..1f5f12c324 100644
--- a/ng2-components/ng2-activiti-analytics/karma.conf.js
+++ b/ng2-components/ng2-activiti-analytics/karma.conf.js
@@ -39,9 +39,12 @@ module.exports = function (config) {
'karma-test-shim.js',
// paths loaded via module imports
- {pattern: 'dist/**/*.js', included: false, watched: true},
- {pattern: 'dist/**/*.html', included: true, served: true, watched: true},
- {pattern: 'dist/**/*.css', included: true, served: true, watched: true},
+ {pattern: 'dist/**/*.*', included: false, watched: true},
+
+ // ng2-components
+
+ { pattern: 'node_modules/ng2-alfresco-core/dist/**/*.js', included: false, served: true, watched: false },
+ { pattern: 'node_modules/ng2-charts/**/*.js', included: false, served: true, watched: false },
// ng2-components
{pattern: 'node_modules/ng2-alfresco-core/dist/**/*.*', included: false, served: true, watched: false},
diff --git a/ng2-components/ng2-activiti-analytics/package.json b/ng2-components/ng2-activiti-analytics/package.json
index 76ae3079e9..8a77a7d52e 100644
--- a/ng2-components/ng2-activiti-analytics/package.json
+++ b/ng2-components/ng2-activiti-analytics/package.json
@@ -3,6 +3,8 @@
"description": "Activiti Angular2 Analytics Component",
"version": "0.3.3",
"author": "Alfresco Software, Ltd.",
+ "main": "./dist/index.js",
+ "typings": "./dist/index.d.ts",
"scripts": {
"clean": "npm install rimraf && rimraf dist node_modules typings",
"build": "npm run tslint && rimraf dist && tsc && npm run copy-dist && license-check",
@@ -21,8 +23,16 @@
"prepublish": "npm run build",
"travis": "echo 'placeholder'"
},
- "main": "./dist/index.js",
- "typings": "./dist/index.d.ts",
+ "contributors": [
+ {
+ "name": "Mario Romano",
+ "email": "mario.romnao@alfresco.com"
+ },
+ {
+ "name": "Maurizio Vitale",
+ "email": "maurizio.vitale84@gmail.com"
+ }
+ ],
"repository": {
"type": "git",
"url": "https://github.com/Alfresco/alfresco-ng2-components.git"
@@ -30,21 +40,6 @@
"bugs": {
"url": "https://github.com/Alfresco/alfresco-ng2-components/issues"
},
- "license": "Apache-2.0",
- "contributors": [
- {
- "name": "Mario Romano",
- "email": "mario.romnao@alfresco.com"
- }
- ],
- "keywords": [
- "ng2",
- "angular",
- "angular2",
- "analytics",
- "alfresco-component",
- "alfresco"
- ],
"dependencies": {
"@angular/common": "2.0.0",
"@angular/compiler": "2.0.0",
@@ -56,38 +51,43 @@
"@angular/router": "3.0.0",
"@angular/upgrade": "2.0.0",
"@types/node": "^6.0.42",
+ "alfresco-js-api": "^0.3.0",
+ "chart.js": "^2.1.4",
"core-js": "^2.4.1",
+ "ng2-alfresco-core": "0.3.2",
+ "ng2-charts": "1.1.0",
+ "ng2-translate": "2.5.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.12",
"systemjs": "0.19.27",
- "zone.js": "^0.6.23",
- "ng2-translate": "2.5.0",
- "alfresco-js-api": "^0.3.0",
- "ng2-alfresco-core": "0.3.2",
- "ng2-charts": "1.1.0",
- "chart.js": "^2.1.4"
+ "zone.js": "^0.6.23"
},
"devDependencies": {
"@types/core-js": "^0.9.32",
"@types/jasmine": "^2.2.33",
"concurrently": "^2.2.0",
- "cpx": "1.3.1",
+ "cpx": "^1.3.1",
+ "jasmine-ajax": "^3.2.0",
"jasmine-core": "2.4.1",
- "karma": "0.13.22",
- "karma-chrome-launcher": "1.0.1",
- "karma-coverage": "1.0.0",
- "karma-jasmine": "1.0.2",
- "karma-jasmine-ajax": "0.1.13",
- "karma-mocha-reporter": "2.0.3",
- "karma-jasmine-html-reporter": "0.2.0",
- "license-check": "1.1.5",
+ "karma": "~0.13.22",
+ "karma-chrome-launcher": "~1.0.1",
+ "karma-coverage": "^1.0.0",
+ "karma-jasmine": "~1.0.2",
+ "karma-jasmine-ajax": "^0.1.13",
+ "karma-jasmine-html-reporter": "^0.2.0",
+ "karma-mocha-reporter": "^2.0.3",
+ "license-check": "^1.0.4",
+ "remap-istanbul": "^0.6.3",
"rimraf": "2.5.2",
- "remap-istanbul": "0.6.3",
- "traceur": "0.0.91",
- "tslint": "3.8.1",
+ "traceur": "^0.0.91",
+ "tslint": "^3.8.1",
"typescript": "^2.0.3",
"wsrv": "^0.1.5"
},
+ "keywords": [
+ "tag",
+ "alfresco-component"
+ ],
"license-check-config": {
"src": [
"./dist/**/*.js"
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 5bb81bc756..01b14984b7 100644
--- a/ng2-components/ng2-activiti-analytics/src/components/analytics.component.html
+++ b/ng2-components/ng2-activiti-analytics/src/components/analytics.component.html
@@ -1,21 +1,104 @@
+
-
-
-
-
-
-
+
+
{{report.title}}
+
+
+
+
+
+ {{label | translate}} |
+
+
+ {{row | translate }} |
+
+
+
+
+
+
+ {{label | translate}} |
+
+
+ {{row | translate }} |
+
+
+
+
+
+ UNKNOWN WIDGET TYPE: {{report.type}}
+
+
+
+
+
\ No newline at end of file
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 92f4aa7c40..1fe4d00070 100644
--- a/ng2-components/ng2-activiti-analytics/src/components/analytics.component.ts
+++ b/ng2-components/ng2-activiti-analytics/src/components/analytics.component.ts
@@ -15,35 +15,158 @@
* limitations under the License.
*/
-import { Component } from '@angular/core';
+import { Component, EventEmitter, OnInit, OnChanges, Input, Output, SimpleChanges, ViewChild } from '@angular/core';
+import { AlfrescoTranslationService } from 'ng2-alfresco-core';
+import { AnalyticsService } from '../services/analytics.service';
+import { ReportModel, ReportQuery, ParameterValueModel, ReportParameterModel } from '../models/report.model';
+import { Chart } from '../models/chart.model';
+
@Component({
moduleId: module.id,
selector: 'activiti-analytics',
- templateUrl: './analytics.component.html'
+ templateUrl: './analytics.component.html',
+ styleUrls: ['./analytics.component.css']
})
-export class AnalyticsComponent {
+export class AnalyticsComponent implements OnInit, OnChanges {
- constructor() {
+ @ViewChild('processDefinition')
+ processDefinition: any;
+
+ @Input()
+ reportId: string;
+
+ @Output()
+ onSuccess = new EventEmitter();
+
+ @Output()
+ onError = new EventEmitter();
+
+ reportDetails: ReportModel;
+
+ reportParamQuery = new ReportQuery();
+
+ reports: any[];
+
+ constructor(private translate: AlfrescoTranslationService,
+ private analyticsService: AnalyticsService) {
console.log('AnalyticsComponent');
+ if (translate) {
+ translate.addTranslationFolder('node_modules/ng2-activiti-analytics/src');
+ }
}
- // lineChart
- public lineChartData: Array = [
- [65, 59, 80, 81, 56, 55, 40],
- [28, 48, 40, 19, 86, 27, 90]
- ];
- public lineChartLabels: Array = ['January', 'February', 'March', 'April', 'May', 'June', 'July'];
- public lineChartType: string = 'line';
- public pieChartType: string = 'pie';
+ ngOnInit() {
- // Pie
- public pieChartLabels: string[] = ['Download Sales', 'In-Store Sales', 'Mail Sales'];
- public pieChartData: number[] = [300, 500, 100];
+ }
- public randomizeType(): void {
- this.lineChartType = this.lineChartType === 'line' ? 'bar' : 'line';
- this.pieChartType = this.pieChartType === 'doughnut' ? 'pie' : 'doughnut';
+ ngOnChanges(changes: SimpleChanges) {
+ let reportId = changes['reportId'];
+ if (reportId && reportId.currentValue) {
+ this.getParamsReports(reportId.currentValue);
+ return;
+ }
+ }
+
+ public getParamsReports(reportId: string) {
+ this.reset();
+ this.analyticsService.getParamsReports(reportId).subscribe(
+ (res: ReportModel) => {
+ this.reportDetails = res;
+ this.retriveParameterOptions();
+ this.onSuccess.emit(res);
+ },
+ (err: any) => {
+ this.onError.emit(err);
+ console.log(err);
+ },
+ () => console.log('Login done')
+ );
+ }
+
+ private retriveParameterOptions() {
+ this.reportDetails.definition.parameters.forEach((param) => {
+ this.analyticsService.getParamValuesByType(param.type).subscribe(
+ (opts: ParameterValueModel[]) => {
+ param.options = opts;
+ },
+ (err: any) => {
+ console.log(err);
+ },
+ () => console.log(`${param.type} options loaded`)
+ );
+ });
+ }
+
+ public createReport() {
+ this.analyticsService.getReportsByParams(this.reportDetails.id, this.reportParamQuery).subscribe(
+ (res: Chart[]) => {
+ this.reports = res;
+ this.onSuccess.emit(res);
+ },
+ (err: any) => {
+ this.onError.emit(err);
+ console.log(err);
+ },
+ () => console.log('Login done')
+ );
+ }
+
+ onNumberChanges(field: any) {
+ this.reset();
+ this.reportParamQuery.slowProcessInstanceInteger = parseInt(field.value, 10);
+ }
+
+ onDurationChanges(field: any) {
+ this.reset();
+ if (field && field.value) {
+ this.reportParamQuery.duration = parseInt(field.value, 10);
+ }
+ }
+
+ onTypeFilteringChanges(field: any) {
+ this.reset();
+ this.reportParamQuery.typeFiltering = field.value;
+ }
+
+ onStatusChanges(field: any) {
+ this.reset();
+ this.reportParamQuery.status = field.value;
+ }
+
+ onProcessDefinitionChanges(field: any) {
+ this.reset();
+ if (field.value) {
+ this.reportParamQuery.processDefinitionId = field.value;
+ this.analyticsService.getTasksByProcessDefinitionId(this.reportId, this.reportParamQuery.processDefinitionId).subscribe(
+ (res: any) => {
+ let paramTask: ReportParameterModel = this.reportDetails.definition.parameters.find(p => p.type === 'task');
+ if (paramTask) {
+ paramTask.options = res;
+ }
+ });
+ }
+ }
+
+ onTaskChanges(field: any) {
+ this.reset();
+ this.reportParamQuery.taskName = field.value;
+ }
+
+ onDateRangeChange(dateRange: any) {
+ this.reset();
+ this.reportParamQuery.dateRange.startDate = dateRange.startDate;
+ this.reportParamQuery.dateRange.endDate = dateRange.endDate;
+ }
+
+
+ onDateRangeIntervalChange(field: any) {
+ this.reset();
+ this.reportParamQuery.dateRangeInterval = field.value;
+ }
+
+ public reset() {
+ this.reports = null;
}
public chartClicked(e: any): void {
@@ -53,4 +176,8 @@ export class AnalyticsComponent {
public chartHovered(e: any): void {
console.log(e);
}
+
+ public convertNumber(value: string): number {
+ return parseInt(value, 10);
+ }
}