diff --git a/demo-shell/package.json b/demo-shell/package.json index 6e2166d4754..02abfb46cfd 100644 --- a/demo-shell/package.json +++ b/demo-shell/package.json @@ -77,7 +77,7 @@ "@alfresco/adf-content-services": "2.0.0", "@alfresco/adf-process-services": "2.0.0", "@alfresco/adf-core": "2.0.0", - "@alfresco/adf-insights": "2.0.0", + "@alfresco/adf-insights": "2.0.1", "chart.js": "2.5.0", "classlist.js": "1.1.20150312", "core-js": "2.4.1", @@ -102,7 +102,7 @@ "@types/jasmine": "~2.5.53", "@types/jasminewd2": "~2.0.2", "@types/node": "~6.0.60", - "codelyzer": "~3.2.0", + "codelyzer": "4.0.0", "jasmine-core": "~2.6.2", "jasmine-spec-reporter": "~4.1.0", "karma": "~1.7.0", diff --git a/lib/insights/analytics-process/components/analytics-generator.component.spec.ts b/lib/insights/analytics-process/components/analytics-generator.component.spec.ts index f9db2871faa..92899ee3548 100644 --- a/lib/insights/analytics-process/components/analytics-generator.component.spec.ts +++ b/lib/insights/analytics-process/components/analytics-generator.component.spec.ts @@ -21,8 +21,8 @@ import { ChartsModule } from 'ng2-charts'; import { MaterialModule } from '../../material.module'; import { DiagramsModule } from '../../diagram/diagram.module'; -import { Chart } from '../../diagram'; -import { ReportQuery } from '../../diagram'; +import { Chart } from '../../diagram/models/chart/chart.model'; +import { ReportQuery } from '../../diagram/models/report/reportQuery.model'; import * as analyticMock from '../../mock'; import { AnalyticsGeneratorComponent } from '../components/analytics-generator.component'; import { AnalyticsProcessModule } from '../analytics-process.module'; diff --git a/lib/insights/analytics-process/components/analytics-generator.component.ts b/lib/insights/analytics-process/components/analytics-generator.component.ts index 59abcc887ee..30a2c920871 100644 --- a/lib/insights/analytics-process/components/analytics-generator.component.ts +++ b/lib/insights/analytics-process/components/analytics-generator.component.ts @@ -16,8 +16,8 @@ */ import { Component, EventEmitter, Input, OnChanges, Output, ViewEncapsulation } from '@angular/core'; -import { ReportQuery } from '../../diagram'; -import { Chart } from '../../diagram'; +import { ReportQuery } from '../../diagram/models/report/reportQuery.model'; +import { Chart } from '../../diagram/models/chart/chart.model'; import { AnalyticsService } from '../services/analytics.service'; @Component({ diff --git a/lib/insights/analytics-process/components/analytics-report-list.component.spec.ts b/lib/insights/analytics-process/components/analytics-report-list.component.spec.ts index 0e8001cc5b6..9d2b89baa45 100644 --- a/lib/insights/analytics-process/components/analytics-report-list.component.spec.ts +++ b/lib/insights/analytics-process/components/analytics-report-list.component.spec.ts @@ -20,7 +20,7 @@ import { DiagramsModule } from '../../diagram/diagram.module'; import { AnalyticsProcessModule } from '../analytics-process.module'; import { AnalyticsReportListComponent } from '../components/analytics-report-list.component'; import { MaterialModule } from '../../material.module'; -import { ReportParametersModel } from '../../diagram/models/report.model'; +import { ReportParametersModel } from '../../diagram/models/report/reportParameters.model'; declare let jasmine: any; diff --git a/lib/insights/analytics-process/components/analytics-report-list.component.ts b/lib/insights/analytics-process/components/analytics-report-list.component.ts index 43e0d283a66..a0525b7fdce 100644 --- a/lib/insights/analytics-process/components/analytics-report-list.component.ts +++ b/lib/insights/analytics-process/components/analytics-report-list.component.ts @@ -18,7 +18,7 @@ import { Component, EventEmitter, Input, OnInit, Output, ViewEncapsulation } from '@angular/core'; import { Observable } from 'rxjs/Observable'; import { Observer } from 'rxjs/Observer'; -import { ReportParametersModel } from '../../diagram'; +import { ReportParametersModel } from '../../diagram/models/report/reportParameters.model'; import { AnalyticsService } from '../services/analytics.service'; @Component({ diff --git a/lib/insights/analytics-process/components/analytics-report-parameters.component.spec.ts b/lib/insights/analytics-process/components/analytics-report-parameters.component.spec.ts index 1c3c5934cd3..9984f57b232 100644 --- a/lib/insights/analytics-process/components/analytics-report-parameters.component.spec.ts +++ b/lib/insights/analytics-process/components/analytics-report-parameters.component.spec.ts @@ -17,7 +17,7 @@ import { SimpleChange } from '@angular/core'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { ReportParametersModel } from '../../diagram'; +import { ReportParametersModel } from '../../diagram/models/report/reportParameters.model'; import * as analyticParamsMock from '../../mock'; import { AnalyticsReportParametersComponent } from '../components/analytics-report-parameters.component'; import { AnalyticsProcessModule } from '../analytics-process.module'; diff --git a/lib/insights/analytics-process/components/analytics-report-parameters.component.ts b/lib/insights/analytics-process/components/analytics-report-parameters.component.ts index 93755a24ded..4866d53c604 100644 --- a/lib/insights/analytics-process/components/analytics-report-parameters.component.ts +++ b/lib/insights/analytics-process/components/analytics-report-parameters.component.ts @@ -32,7 +32,10 @@ import { import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; import { MatDialog } from '@angular/material'; import moment from 'moment-es6'; -import { ParameterValueModel, ReportParameterDetailsModel, ReportParametersModel, ReportQuery } from '../../diagram'; +import { ParameterValueModel } from '../../diagram/models/report/parameterValue.model'; +import { ReportParameterDetailsModel } from '../../diagram/models/report/reportParameterDetails.model'; +import { ReportParametersModel } from '../../diagram/models/report/reportParameters.model'; +import { ReportQuery } from '../../diagram/models/report/reportQuery.model'; import { AnalyticsService } from '../services/analytics.service'; @Component({ @@ -147,37 +150,37 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On case 'processDefinition': formBuilderGroup.processDefGroup = new FormGroup({ processDefinitionId: new FormControl(null, Validators.required, null) - }, Validators.required); + }, Validators.required); break; case 'duration': formBuilderGroup.durationGroup = new FormGroup({ duration: new FormControl(null, Validators.required, null) - }, Validators.required); + }, Validators.required); break; case 'dateInterval': formBuilderGroup.dateIntervalGroup = new FormGroup({ dateRangeInterval: new FormControl(null, Validators.required, null) - }, Validators.required); + }, Validators.required); break; case 'boolean': formBuilderGroup.typeFilteringGroup = new FormGroup({ typeFiltering: new FormControl(null, Validators.required, null) - }, Validators.required); + }, Validators.required); break; case 'task': formBuilderGroup.taskGroup = new FormGroup({ taskName: new FormControl(null, Validators.required, null) - }, Validators.required); + }, Validators.required); break; case 'integer': formBuilderGroup.processInstanceGroup = new FormGroup({ slowProcessInstanceInteger: new FormControl(null, Validators.required, null) - }, Validators.required); + }, Validators.required); break; case 'status': formBuilderGroup.statusGroup = new FormGroup({ status: new FormControl(null, Validators.required, null) - }, Validators.required); + }, Validators.required); break; default: return; @@ -245,7 +248,7 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On public convertMomentDate(date: string) { return moment(date, AnalyticsReportParametersComponent.FORMAT_DATE_ACTIVITI, true) - .format(AnalyticsReportParametersComponent.FORMAT_DATE_ACTIVITI) + 'T00:00:00.000Z'; + .format(AnalyticsReportParametersComponent.FORMAT_DATE_ACTIVITI) + 'T00:00:00.000Z'; } public getTodayDate() { @@ -351,7 +354,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'}); + let blob: Blob = new Blob([data], { type: 'text/csv' }); this.contentService.downloadBlob(blob, paramQuery.reportName + '.csv'); }); } @@ -365,7 +368,7 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On deleteReport(reportId: string) { this.analyticsService.deleteReport(reportId).subscribe(() => { this.deleteReportSuccess.emit(reportId); - }, error => this.logService.error(error)); + }, error => this.logService.error(error)); } ngAfterContentChecked() { diff --git a/lib/insights/analytics-process/components/analytics.component.ts b/lib/insights/analytics-process/components/analytics.component.ts index 01b3ebff2e3..c05aaeae282 100644 --- a/lib/insights/analytics-process/components/analytics.component.ts +++ b/lib/insights/analytics-process/components/analytics.component.ts @@ -16,7 +16,7 @@ */ import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges, ViewChild, ViewEncapsulation } from '@angular/core'; -import { ReportQuery } from '../../diagram'; +import { ReportQuery } from '../../diagram/models/report/reportQuery.model'; import { AnalyticsGeneratorComponent } from './analytics-generator.component'; @Component({ diff --git a/lib/insights/analytics-process/components/widgets/duration/duration.widget.ts b/lib/insights/analytics-process/components/widgets/duration/duration.widget.ts index 676f734ed11..d6cc715e913 100644 --- a/lib/insights/analytics-process/components/widgets/duration/duration.widget.ts +++ b/lib/insights/analytics-process/components/widgets/duration/duration.widget.ts @@ -20,8 +20,8 @@ /* tslint:disable::no-access-missing-member */ import { Component, ElementRef, Input, OnInit, ViewEncapsulation } from '@angular/core'; import { FormControl, FormGroup, Validators } from '@angular/forms'; -import { ParameterValueModel } from '../../../../diagram/models/report.model'; -import { ReportParameterDetailsModel } from '../../../../diagram/models/report.model'; +import { ParameterValueModel } from '../../../../diagram/models/report/parameterValue.model'; +import { ReportParameterDetailsModel } from '../../../../diagram/models/report/reportParameterDetails.model'; import { NumberWidgetAanlyticsComponent } from './../number/number.widget'; @Component({ diff --git a/lib/insights/analytics-process/public-api.ts b/lib/insights/analytics-process/public-api.ts index c2135291e91..f79e7355840 100644 --- a/lib/insights/analytics-process/public-api.ts +++ b/lib/insights/analytics-process/public-api.ts @@ -20,10 +20,4 @@ export * from './components/analytics-generator.component'; export * from './components/analytics-report-list.component'; export * from './components/analytics-report-parameters.component'; -export * from './components/widgets/checkbox/checkbox.widget'; -export * from './components/widgets/date-range/date-range.widget'; -export * from './components/widgets/dropdown/dropdown.widget'; -export * from './components/widgets/duration/duration.widget'; -export * from './components/widgets/number/number.widget'; - export * from './services/analytics.service'; diff --git a/lib/insights/analytics-process/services/analytics.service.ts b/lib/insights/analytics-process/services/analytics.service.ts index 400b8d4b3c6..1760d36142b 100644 --- a/lib/insights/analytics-process/services/analytics.service.ts +++ b/lib/insights/analytics-process/services/analytics.service.ts @@ -19,16 +19,16 @@ import { AlfrescoApiService, LogService } from '@alfresco/adf-core'; import { Injectable } from '@angular/core'; import { Response } from '@angular/http'; import { Observable } from 'rxjs/Observable'; -import { ParameterValueModel, ReportParametersModel } from '../../diagram'; -import { - BarChart, - Chart, - DetailsTableChart, - HeatMapChart, - MultiBarChart, - PieChart, - TableChart -} from '../../diagram'; +import { ParameterValueModel } from '../../diagram/models/report/parameterValue.model'; +import { ReportParametersModel } from '../../diagram/models/report/reportParameters.model'; +import { BarChart } from '../../diagram/models/chart/barChart.model'; +import { Chart } from '../../diagram/models/chart/chart.model'; +import { DetailsTableChart } from '../../diagram/models/chart/detailsTableChart.model'; +import { HeatMapChart } from '../../diagram/models/chart/heatMapChart.model'; +import { MultiBarChart } from '../../diagram/models/chart/multiBarChart.model'; +import { PieChart } from '../../diagram/models/chart/pieChart.model'; +import { TableChart } from '../../diagram/models/chart/tableChart.model'; + import 'rxjs/add/observable/throw'; @Injectable() @@ -107,9 +107,9 @@ export class AnalyticsService { getProcessStatusValues(): Observable { let paramOptions: ParameterValueModel[] = []; - paramOptions.push(new ParameterValueModel({id: 'All', name: 'All'})); - paramOptions.push(new ParameterValueModel({id: 'Active', name: 'Active'})); - paramOptions.push(new ParameterValueModel({id: 'Complete', name: 'Complete'})); + paramOptions.push(new ParameterValueModel({ id: 'All', name: 'All' })); + paramOptions.push(new ParameterValueModel({ id: 'Active', name: 'Active' })); + paramOptions.push(new ParameterValueModel({ id: 'Complete', name: 'Complete' })); return Observable.create(observer => { observer.next(paramOptions); @@ -120,11 +120,11 @@ export class AnalyticsService { getDateIntervalValues(): Observable { let paramOptions: ParameterValueModel[] = []; - paramOptions.push(new ParameterValueModel({id: 'byHour', name: 'By hour'})); - paramOptions.push(new ParameterValueModel({id: 'byDay', name: 'By day'})); - paramOptions.push(new ParameterValueModel({id: 'byWeek', name: 'By week'})); - paramOptions.push(new ParameterValueModel({id: 'byMonth', name: 'By month'})); - paramOptions.push(new ParameterValueModel({id: 'byYear', name: 'By year'})); + paramOptions.push(new ParameterValueModel({ id: 'byHour', name: 'By hour' })); + paramOptions.push(new ParameterValueModel({ id: 'byDay', name: 'By day' })); + paramOptions.push(new ParameterValueModel({ id: 'byWeek', name: 'By week' })); + paramOptions.push(new ParameterValueModel({ id: 'byMonth', name: 'By month' })); + paramOptions.push(new ParameterValueModel({ id: 'byYear', name: 'By year' })); return Observable.create(observer => { observer.next(paramOptions); @@ -135,9 +135,9 @@ export class AnalyticsService { getMetricValues(): Observable { let 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'})); - paramOptions.push(new ParameterValueModel({id: 'avgTime', name: 'Average time spent in a process step'})); + 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' })); + paramOptions.push(new ParameterValueModel({ id: 'avgTime', name: 'Average time spent in a process step' })); return Observable.create(observer => { observer.next(paramOptions); @@ -157,7 +157,7 @@ export class AnalyticsService { } getProcessDefinitionsValues(appId: number): Observable { - let options = {'appDefinitionId': appId}; + let options = { 'appDefinitionId': appId }; return Observable.fromPromise(this.apiService.getInstance().activiti.processDefinitionsApi.getProcessDefinitions(options)) .map((res: any) => { let paramOptions: ParameterValueModel[] = []; @@ -173,7 +173,7 @@ export class AnalyticsService { .map((res: any) => { let paramOptions: ParameterValueModel[] = []; res.forEach((opt) => { - paramOptions.push(new ParameterValueModel({id: opt, name: opt})); + paramOptions.push(new ParameterValueModel({ id: opt, name: opt })); }); return paramOptions; }).catch(err => this.handleError(err)); diff --git a/lib/insights/diagram/components/diagram.component.ts b/lib/insights/diagram/components/diagram.component.ts index 611e3c56186..8b173ddb711 100644 --- a/lib/insights/diagram/components/diagram.component.ts +++ b/lib/insights/diagram/components/diagram.component.ts @@ -16,7 +16,8 @@ */ import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core'; -import { DiagramElementModel, DiagramModel } from '../models/diagram.model'; +import { DiagramElementModel } from '../models/diagram/diagramElement.model'; +import { DiagramModel } from '../models/diagram/diagram.model'; import { DiagramColorService } from '../services/diagram-color.service'; import { DiagramsService } from '../services/diagrams.service'; import { RaphaelService } from './raphael/raphael.service'; diff --git a/lib/insights/diagram/models/chart.model.ts b/lib/insights/diagram/models/chart.model.ts deleted file mode 100644 index 32803335710..00000000000 --- a/lib/insights/diagram/models/chart.model.ts +++ /dev/null @@ -1,307 +0,0 @@ -/*! - * @license - * Copyright 2016 Alfresco Software, Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import moment from 'moment-es6'; - -export class Chart { - id: string; - type: string; - icon: string; - - constructor(obj?: any) { - this.id = obj && obj.id || null; - if (obj && obj.type) { - this.type = this.convertType(obj.type); - this.icon = this.getIconType(this.type); - } - } - - private convertType(type: string) { - let chartType = ''; - switch (type) { - case 'pieChart': - chartType = 'pie'; - break; - case 'table': - chartType = 'table'; - break; - case 'line': - chartType = 'line'; - break; - case 'barChart': - chartType = 'bar'; - break; - case 'multiBarChart': - chartType = 'multiBar'; - break; - case 'processDefinitionHeatMap': - chartType = 'HeatMap'; - break; - case 'masterDetailTable': - chartType = 'masterDetailTable'; - break; - default: - chartType = 'table'; - break; - } - return chartType; - } - - private getIconType(type: string): string { - let typeIcon: string = ''; - switch (type) { - case 'pie': - typeIcon = 'pie_chart'; - break; - case 'table': - typeIcon = 'web'; - break; - case 'line': - typeIcon = 'show_chart'; - break; - case 'bar': - typeIcon = 'equalizer'; - break; - case 'multiBar': - typeIcon = 'poll'; - break; - case 'HeatMap': - typeIcon = 'share'; - break; - case 'masterDetailTable': - typeIcon = 'subtitles'; - break; - default: - typeIcon = 'web'; - break; - } - return typeIcon; - } -} - -export class LineChart extends Chart { - title: string; - titleKey: string; - labels: string[] = []; - datasets: any[] = []; - - constructor(obj?: any) { - super(obj); - this.title = obj && obj.title || null; - this.titleKey = obj && obj.titleKey || null; - this.labels = obj && obj.columnNames.slice(1, obj.columnNames.length); - - obj.rows.forEach((value: any) => { - this.datasets.push({data: value.slice(1, value.length), label: value[0]}); - }); - } -} - -export class BarChart extends Chart { - title: string; - titleKey: string; - labels: any = []; - datasets: any[] = []; - data: any[] = []; - xAxisType: string; - yAxisType: string; - options: any = { - responsive: true, - scales: { - yAxes: [{ - ticks: { - beginAtZero: true, - stepSize: 1 - } - }], - xAxes: [{ - ticks: { - }, - stacked: false - }] - } - }; - - constructor(obj?: any) { - super(obj); - this.title = obj && obj.title || null; - this.titleKey = obj && obj.titleKey || null; - this.xAxisType = obj && obj.xAxisType || null; - this.yAxisType = obj && obj.yAxisType || null; - this.options.scales.xAxes[0].ticks.callback = this.xAxisTickFormatFunction(this.xAxisType); - this.options.scales.yAxes[0].ticks.callback = this.yAxisTickFormatFunction(this.yAxisType); - if (obj.values) { - obj.values.forEach((params: any) => { - let dataValue = []; - params.values.forEach((info: any) => { - info.forEach((value: any, index: any) => { - if (index % 2 === 0) { - if (!this.labels.includes(value)) { - this.labels.push(value); - } - } else { - dataValue.push(value); - } - }); - }); - if (dataValue && dataValue.length > 0) { - this.datasets.push({data: dataValue, label: params.key}); - } - }); - } - } - - xAxisTickFormatFunction = function (xAxisType) { - return function (value) { - if (xAxisType !== null && xAxisType !== undefined) { - if ('date_day' === xAxisType) { - return moment(new Date(value)).format('DD'); - } else if ('date_month' === xAxisType) { - return moment(new Date(value)).format('MMMM'); - } else if ('date_year' === xAxisType) { - return moment(new Date(value)).format('YYYY'); - } - } - return value; - }; - }; - - yAxisTickFormatFunction = function (yAxisType) { - return function (value) { - if (yAxisType !== null && yAxisType !== undefined) { - if ('count' === yAxisType) { - let label = '' + value; - if (label.indexOf('.') !== -1) { - return ''; - } - } - } - return value; - }; - }; - - hasDatasets() { - return this.datasets && this.datasets.length > 0 ? true : false; - } -} - -export class MultiBarChart extends BarChart { - - constructor(obj?: any) { - super(obj); - } -} - -export class TableChart extends Chart { - title: string; - titleKey: string; - labels: string[] = []; - datasets: any[] = []; - - constructor(obj?: any) { - super(obj); - this.title = obj && obj.title || null; - this.titleKey = obj && obj.titleKey || null; - this.labels = obj && obj.columnNames; - if (obj.rows) { - this.datasets = obj && obj.rows; - } - } - - hasDatasets() { - return this.datasets && this.datasets.length > 0 ? true : false; - } -} - -export class DetailsTableChart extends TableChart { - detailsTable: any; - showDetails: boolean = false; - - constructor(obj?: any) { - super(obj); - if (obj.detailTables) { - this.detailsTable = new TableChart(obj.detailTables[0]); - } - } - - hasDetailsTable() { - return this.detailsTable ? true : false; - } -} - -export class HeatMapChart extends Chart { - avgTimePercentages: string; - avgTimeValues: string; - processDefinitionId: string; - titleKey: string; - totalCountValues: string; - totalCountsPercentages: string; - totalTimePercentages: string; - totalTimeValues: string; - - constructor(obj?: any) { - super(obj); - this.avgTimePercentages = obj && obj.avgTimePercentages || null; - this.avgTimeValues = obj && obj.avgTimeValues || null; - this.processDefinitionId = obj && obj.processDefinitionId || null; - this.totalCountValues = obj && obj.totalCountValues || null; - this.titleKey = obj && obj.titleKey || null; - this.totalCountsPercentages = obj && obj.totalCountsPercentages || null; - this.totalTimePercentages = obj && obj.totalTimePercentages || null; - this.totalTimeValues = obj && obj.totalTimeValues || null; - } -} - -export class PieChart extends Chart { - title: string; - titleKey: string; - labels: string[] = []; - data: string[] = []; - - constructor(obj?: any) { - super(obj); - this.title = obj && obj.title || null; - this.titleKey = obj && obj.titleKey || null; - if (obj.values) { - obj.values.forEach((value: any) => { - this.add(value.key, value.y); - }); - } - } - - add(label: string, data: string) { - this.labels.push(label); - this.data.push(data); - } - - hasData(): boolean { - return this.data && this.data.length > 0 ? true : false; - } - - hasZeroValues(): boolean { - let isZeroValues: boolean = false; - if (this.hasData()) { - isZeroValues = true; - this.data.forEach((value) => { - if (value.toString() !== '0') { - isZeroValues = false; - } - }); - } - return isZeroValues; - } -} diff --git a/lib/insights/diagram/models/chart/barChart.model.ts b/lib/insights/diagram/models/chart/barChart.model.ts new file mode 100644 index 00000000000..633ff779897 --- /dev/null +++ b/lib/insights/diagram/models/chart/barChart.model.ts @@ -0,0 +1,107 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import moment from 'moment-es6'; +import { Chart } from './chart.model'; + +export class BarChart extends Chart { + title: string; + titleKey: string; + labels: any = []; + datasets: any[] = []; + data: any[] = []; + xAxisType: string; + yAxisType: string; + options: any = { + responsive: true, + scales: { + yAxes: [{ + ticks: { + beginAtZero: true, + stepSize: 1 + } + }], + xAxes: [{ + ticks: { + }, + stacked: false + }] + } + }; + + constructor(obj?: any) { + super(obj); + this.title = obj && obj.title || null; + this.titleKey = obj && obj.titleKey || null; + this.xAxisType = obj && obj.xAxisType || null; + this.yAxisType = obj && obj.yAxisType || null; + this.options.scales.xAxes[0].ticks.callback = this.xAxisTickFormatFunction(this.xAxisType); + this.options.scales.yAxes[0].ticks.callback = this.yAxisTickFormatFunction(this.yAxisType); + if (obj.values) { + obj.values.forEach((params: any) => { + let dataValue = []; + params.values.forEach((info: any) => { + info.forEach((value: any, index: any) => { + if (index % 2 === 0) { + if (!this.labels.includes(value)) { + this.labels.push(value); + } + } else { + dataValue.push(value); + } + }); + }); + if (dataValue && dataValue.length > 0) { + this.datasets.push({data: dataValue, label: params.key}); + } + }); + } + } + + xAxisTickFormatFunction = function (xAxisType) { + return function (value) { + if (xAxisType !== null && xAxisType !== undefined) { + if ('date_day' === xAxisType) { + return moment(new Date(value)).format('DD'); + } else if ('date_month' === xAxisType) { + return moment(new Date(value)).format('MMMM'); + } else if ('date_year' === xAxisType) { + return moment(new Date(value)).format('YYYY'); + } + } + return value; + }; + }; + + yAxisTickFormatFunction = function (yAxisType) { + return function (value) { + if (yAxisType !== null && yAxisType !== undefined) { + if ('count' === yAxisType) { + let label = '' + value; + if (label.indexOf('.') !== -1) { + return ''; + } + } + } + return value; + }; + }; + + hasDatasets() { + return this.datasets && this.datasets.length > 0 ? true : false; + } +} diff --git a/lib/insights/diagram/models/chart/chart.model.ts b/lib/insights/diagram/models/chart/chart.model.ts new file mode 100644 index 00000000000..394a372178f --- /dev/null +++ b/lib/insights/diagram/models/chart/chart.model.ts @@ -0,0 +1,92 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class Chart { + id: string; + type: string; + icon: string; + + constructor(obj?: any) { + this.id = obj && obj.id || null; + if (obj && obj.type) { + this.type = this.convertType(obj.type); + this.icon = this.getIconType(this.type); + } + } + + private convertType(type: string) { + let chartType = ''; + switch (type) { + case 'pieChart': + chartType = 'pie'; + break; + case 'table': + chartType = 'table'; + break; + case 'line': + chartType = 'line'; + break; + case 'barChart': + chartType = 'bar'; + break; + case 'multiBarChart': + chartType = 'multiBar'; + break; + case 'processDefinitionHeatMap': + chartType = 'HeatMap'; + break; + case 'masterDetailTable': + chartType = 'masterDetailTable'; + break; + default: + chartType = 'table'; + break; + } + return chartType; + } + + private getIconType(type: string): string { + let typeIcon: string = ''; + switch (type) { + case 'pie': + typeIcon = 'pie_chart'; + break; + case 'table': + typeIcon = 'web'; + break; + case 'line': + typeIcon = 'show_chart'; + break; + case 'bar': + typeIcon = 'equalizer'; + break; + case 'multiBar': + typeIcon = 'poll'; + break; + case 'HeatMap': + typeIcon = 'share'; + break; + case 'masterDetailTable': + typeIcon = 'subtitles'; + break; + default: + typeIcon = 'web'; + break; + } + return typeIcon; + } +} diff --git a/lib/insights/diagram/models/chart/detailsTableChart.model.ts b/lib/insights/diagram/models/chart/detailsTableChart.model.ts new file mode 100644 index 00000000000..b3806270183 --- /dev/null +++ b/lib/insights/diagram/models/chart/detailsTableChart.model.ts @@ -0,0 +1,34 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { TableChart } from './tableChart.model'; + +export class DetailsTableChart extends TableChart { + detailsTable: any; + showDetails: boolean = false; + + constructor(obj?: any) { + super(obj); + if (obj.detailTables) { + this.detailsTable = new TableChart(obj.detailTables[0]); + } + } + + hasDetailsTable() { + return this.detailsTable ? true : false; + } +} diff --git a/lib/insights/diagram/models/chart/heatMapChart.model.ts b/lib/insights/diagram/models/chart/heatMapChart.model.ts new file mode 100644 index 00000000000..b351e9eb886 --- /dev/null +++ b/lib/insights/diagram/models/chart/heatMapChart.model.ts @@ -0,0 +1,41 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Chart } from './chart.model'; + +export class HeatMapChart extends Chart { + avgTimePercentages: string; + avgTimeValues: string; + processDefinitionId: string; + titleKey: string; + totalCountValues: string; + totalCountsPercentages: string; + totalTimePercentages: string; + totalTimeValues: string; + + constructor(obj?: any) { + super(obj); + this.avgTimePercentages = obj && obj.avgTimePercentages || null; + this.avgTimeValues = obj && obj.avgTimeValues || null; + this.processDefinitionId = obj && obj.processDefinitionId || null; + this.totalCountValues = obj && obj.totalCountValues || null; + this.titleKey = obj && obj.titleKey || null; + this.totalCountsPercentages = obj && obj.totalCountsPercentages || null; + this.totalTimePercentages = obj && obj.totalTimePercentages || null; + this.totalTimeValues = obj && obj.totalTimeValues || null; + } +} diff --git a/lib/insights/diagram/models/chart/lineChart.model.ts b/lib/insights/diagram/models/chart/lineChart.model.ts new file mode 100644 index 00000000000..9bf96d33f3d --- /dev/null +++ b/lib/insights/diagram/models/chart/lineChart.model.ts @@ -0,0 +1,36 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Chart } from './chart.model'; + +export class LineChart extends Chart { + title: string; + titleKey: string; + labels: string[] = []; + datasets: any[] = []; + + constructor(obj?: any) { + super(obj); + this.title = obj && obj.title || null; + this.titleKey = obj && obj.titleKey || null; + this.labels = obj && obj.columnNames.slice(1, obj.columnNames.length); + + obj.rows.forEach((value: any) => { + this.datasets.push({data: value.slice(1, value.length), label: value[0]}); + }); + } +} diff --git a/lib/insights/diagram/models/chart/multiBarChart.model.ts b/lib/insights/diagram/models/chart/multiBarChart.model.ts new file mode 100644 index 00000000000..ff8479cdca4 --- /dev/null +++ b/lib/insights/diagram/models/chart/multiBarChart.model.ts @@ -0,0 +1,25 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { BarChart } from './barChart.model'; + +export class MultiBarChart extends BarChart { + + constructor(obj?: any) { + super(obj); + } +} diff --git a/lib/insights/diagram/models/chart/pieChart.model.ts b/lib/insights/diagram/models/chart/pieChart.model.ts new file mode 100644 index 00000000000..d2cf7efd42a --- /dev/null +++ b/lib/insights/diagram/models/chart/pieChart.model.ts @@ -0,0 +1,58 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Chart } from './chart.model'; + +export class PieChart extends Chart { + title: string; + titleKey: string; + labels: string[] = []; + data: string[] = []; + + constructor(obj?: any) { + super(obj); + this.title = obj && obj.title || null; + this.titleKey = obj && obj.titleKey || null; + if (obj.values) { + obj.values.forEach((value: any) => { + this.add(value.key, value.y); + }); + } + } + + add(label: string, data: string) { + this.labels.push(label); + this.data.push(data); + } + + hasData(): boolean { + return this.data && this.data.length > 0 ? true : false; + } + + hasZeroValues(): boolean { + let isZeroValues: boolean = false; + if (this.hasData()) { + isZeroValues = true; + this.data.forEach((value) => { + if (value.toString() !== '0') { + isZeroValues = false; + } + }); + } + return isZeroValues; + } +} diff --git a/lib/insights/diagram/models/chart/tableChart.model.ts b/lib/insights/diagram/models/chart/tableChart.model.ts new file mode 100644 index 00000000000..d9fad1f0d1d --- /dev/null +++ b/lib/insights/diagram/models/chart/tableChart.model.ts @@ -0,0 +1,39 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Chart } from './chart.model'; + +export class TableChart extends Chart { + title: string; + titleKey: string; + labels: string[] = []; + datasets: any[] = []; + + constructor(obj?: any) { + super(obj); + this.title = obj && obj.title || null; + this.titleKey = obj && obj.titleKey || null; + this.labels = obj && obj.columnNames; + if (obj.rows) { + this.datasets = obj && obj.rows; + } + } + + hasDatasets() { + return this.datasets && this.datasets.length > 0 ? true : false; + } +} diff --git a/lib/insights/diagram/models/diagram.model.ts b/lib/insights/diagram/models/diagram.model.ts deleted file mode 100644 index 2b92024cfde..00000000000 --- a/lib/insights/diagram/models/diagram.model.ts +++ /dev/null @@ -1,206 +0,0 @@ -/*! - * @license - * Copyright 2016 Alfresco Software, Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export class DiagramModel { - diagramBeginX: number; - diagramBeginY: number; - diagramHeight: number; - diagramWidth: number; - elements: DiagramElementModel[] = []; - flows: DiagramFlowElementModel[] = []; - pools: DiagramPoolElementModel[] = []; - - constructor(obj?: any) { - if (obj) { - this.diagramBeginX = obj.diagramBeginX; - this.diagramBeginY = obj.diagramBeginY; - this.diagramHeight = obj.diagramHeight; - this.diagramWidth = obj.diagramWidth; - if (obj.elements) { - obj.elements.forEach((element: DiagramElementModel) => { - this.elements.push(new DiagramElementModel(element)); - }); - } - if (obj.flows) { - obj.flows.forEach((flow: DiagramFlowElementModel) => { - this.flows.push(new DiagramFlowElementModel(flow)); - }); - } - if (obj.pools) { - obj.pools.forEach((pool: DiagramPoolElementModel) => { - this.pools.push(new DiagramPoolElementModel(pool)); - }); - } - } - } -} - -export class DiagramElementModel { - completed: boolean; - current: boolean; - height: string; - id: string; - name: string; - type: string; - width: string; - value: string; - x: string; - y: string; - properties: DiagramElementPropertyModel[] = []; - dataType: string = ''; - eventDefinition: DiagramEventDefinitionModel; - taskType: string = ''; - - constructor(obj?: any) { - if (obj) { - this.completed = !!obj.completed; - this.current = !!obj.current; - this.height = obj.height || ''; - this.id = obj.id || ''; - this.name = obj.name || ''; - this.type = obj.type || ''; - this.width = obj.width || ''; - this.value = obj.value || ''; - this.x = obj.x || ''; - this.y = obj.y || ''; - this.taskType = obj.taskType || ''; - if (obj.properties) { - obj.properties.forEach((property: DiagramElementPropertyModel) => { - this.properties.push(new DiagramElementPropertyModel(property)); - }); - } - this.dataType = obj.dataType || ''; - if (obj.eventDefinition) { - this.eventDefinition = new DiagramEventDefinitionModel(obj.eventDefinition); - } - } - } -} - -export class DiagramElementPropertyModel { - name: string; - type: string; - value: any; - - constructor(obj?: any) { - if (obj) { - this.name = obj.name; - this.type = obj.type; - this.value = obj.value; - } - } -} - -export class DiagramFlowElementModel { - completed: boolean; - current: boolean; - id: string; - properties: any[] = []; - sourceRef: string; - targetRef: string; - type: string; - waypoints: DiagramWayPointModel[] = []; - - constructor(obj?: any) { - if (obj) { - this.completed = !!obj.completed; - this.current = !!obj.current; - this.id = obj.id; - this.properties = obj.properties; - this.sourceRef = obj.sourceRef; - this.targetRef = obj.targetRef; - this.type = obj.type; - if (obj.waypoints) { - obj.waypoints.forEach((waypoint: DiagramWayPointModel) => { - this.waypoints.push(new DiagramWayPointModel(waypoint)); - }); - } - } - } -} - -export class DiagramWayPointModel { - x: number; - y: number; - - constructor(obj?: any) { - if (obj) { - this.x = obj.x; - this.y = obj.y; - } - } -} - -export class DiagramEventDefinitionModel { - timeCycle: string; - type: string; - - constructor(obj?: any) { - if (obj) { - this.timeCycle = obj.timeCycle; - this.type = obj.type; - } - } -} - -export class DiagramPoolElementModel { - height: string; - id: string; - name: string; - properties: any; - lanes: DiagramLaneElementModel[] = []; - width: string; - x: number; - y: number; - - constructor(obj?: any) { - if (obj) { - this.height = obj.height; - this.id = obj.id; - this.name = obj.name; - this.properties = obj.properties; - this.width = obj.width; - this.x = obj.x; - this.y = obj.y; - if (obj.lanes) { - obj.lanes.forEach((lane: DiagramLaneElementModel) => { - this.lanes.push(new DiagramLaneElementModel(lane)); - }); - } - } - } -} - -export class DiagramLaneElementModel { - height: number; - id: string; - name: string; - width: number; - x: number; - y: number; - - constructor(obj?: any) { - if (obj) { - this.height = obj.height; - this.id = obj.id; - this.name = obj.name; - this.width = obj.width; - this.x = obj.x; - this.y = obj.y; - } - } -} diff --git a/lib/insights/diagram/models/diagram/diagram.model.ts b/lib/insights/diagram/models/diagram/diagram.model.ts new file mode 100644 index 00000000000..c22a59e97d8 --- /dev/null +++ b/lib/insights/diagram/models/diagram/diagram.model.ts @@ -0,0 +1,54 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { DiagramElementModel } from './diagramElement.model'; +import { DiagramFlowElementModel } from './diagramFlowElement.model'; +import { DiagramPoolElementModel } from './diagramPoolElement.model'; + +export class DiagramModel { + diagramBeginX: number; + diagramBeginY: number; + diagramHeight: number; + diagramWidth: number; + elements: DiagramElementModel[] = []; + flows: DiagramFlowElementModel[] = []; + pools: DiagramPoolElementModel[] = []; + + constructor(obj?: any) { + if (obj) { + this.diagramBeginX = obj.diagramBeginX; + this.diagramBeginY = obj.diagramBeginY; + this.diagramHeight = obj.diagramHeight; + this.diagramWidth = obj.diagramWidth; + if (obj.elements) { + obj.elements.forEach((element: DiagramElementModel) => { + this.elements.push(new DiagramElementModel(element)); + }); + } + if (obj.flows) { + obj.flows.forEach((flow: DiagramFlowElementModel) => { + this.flows.push(new DiagramFlowElementModel(flow)); + }); + } + if (obj.pools) { + obj.pools.forEach((pool: DiagramPoolElementModel) => { + this.pools.push(new DiagramPoolElementModel(pool)); + }); + } + } + } +} diff --git a/lib/insights/diagram/models/diagram/diagramElement.model.ts b/lib/insights/diagram/models/diagram/diagramElement.model.ts new file mode 100644 index 00000000000..695ecd5938a --- /dev/null +++ b/lib/insights/diagram/models/diagram/diagramElement.model.ts @@ -0,0 +1,61 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { DiagramElementPropertyModel } from './diagramElementProperty.model'; +import { DiagramEventDefinitionModel } from './diagramEventDefinition.model'; + +export class DiagramElementModel { + completed: boolean; + current: boolean; + height: string; + id: string; + name: string; + type: string; + width: string; + value: string; + x: string; + y: string; + properties: DiagramElementPropertyModel[] = []; + dataType: string = ''; + eventDefinition: DiagramEventDefinitionModel; + taskType: string = ''; + + constructor(obj?: any) { + if (obj) { + this.completed = !!obj.completed; + this.current = !!obj.current; + this.height = obj.height || ''; + this.id = obj.id || ''; + this.name = obj.name || ''; + this.type = obj.type || ''; + this.width = obj.width || ''; + this.value = obj.value || ''; + this.x = obj.x || ''; + this.y = obj.y || ''; + this.taskType = obj.taskType || ''; + if (obj.properties) { + obj.properties.forEach((property: DiagramElementPropertyModel) => { + this.properties.push(new DiagramElementPropertyModel(property)); + }); + } + this.dataType = obj.dataType || ''; + if (obj.eventDefinition) { + this.eventDefinition = new DiagramEventDefinitionModel(obj.eventDefinition); + } + } + } +} diff --git a/lib/insights/diagram/models/diagram/diagramElementProperty.model.ts b/lib/insights/diagram/models/diagram/diagramElementProperty.model.ts new file mode 100644 index 00000000000..cea5bb081fa --- /dev/null +++ b/lib/insights/diagram/models/diagram/diagramElementProperty.model.ts @@ -0,0 +1,30 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class DiagramElementPropertyModel { + name: string; + type: string; + value: any; + + constructor(obj?: any) { + if (obj) { + this.name = obj.name; + this.type = obj.type; + this.value = obj.value; + } + } +} diff --git a/lib/insights/diagram/models/diagram/diagramEventDefinition.model.ts b/lib/insights/diagram/models/diagram/diagramEventDefinition.model.ts new file mode 100644 index 00000000000..c2a7947c8c3 --- /dev/null +++ b/lib/insights/diagram/models/diagram/diagramEventDefinition.model.ts @@ -0,0 +1,28 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class DiagramEventDefinitionModel { + timeCycle: string; + type: string; + + constructor(obj?: any) { + if (obj) { + this.timeCycle = obj.timeCycle; + this.type = obj.type; + } + } +} diff --git a/lib/insights/diagram/models/diagram/diagramFlowElement.model.ts b/lib/insights/diagram/models/diagram/diagramFlowElement.model.ts new file mode 100644 index 00000000000..8d2b5fb3635 --- /dev/null +++ b/lib/insights/diagram/models/diagram/diagramFlowElement.model.ts @@ -0,0 +1,46 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { DiagramWayPointModel } from './diagramWayPoint.model'; + +export class DiagramFlowElementModel { + completed: boolean; + current: boolean; + id: string; + properties: any[] = []; + sourceRef: string; + targetRef: string; + type: string; + waypoints: DiagramWayPointModel[] = []; + + constructor(obj?: any) { + if (obj) { + this.completed = !!obj.completed; + this.current = !!obj.current; + this.id = obj.id; + this.properties = obj.properties; + this.sourceRef = obj.sourceRef; + this.targetRef = obj.targetRef; + this.type = obj.type; + if (obj.waypoints) { + obj.waypoints.forEach((waypoint: DiagramWayPointModel) => { + this.waypoints.push(new DiagramWayPointModel(waypoint)); + }); + } + } + } +} diff --git a/lib/insights/diagram/models/diagram/diagramLaneElement.model.ts b/lib/insights/diagram/models/diagram/diagramLaneElement.model.ts new file mode 100644 index 00000000000..018e1481e0c --- /dev/null +++ b/lib/insights/diagram/models/diagram/diagramLaneElement.model.ts @@ -0,0 +1,36 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class DiagramLaneElementModel { + height: number; + id: string; + name: string; + width: number; + x: number; + y: number; + + constructor(obj?: any) { + if (obj) { + this.height = obj.height; + this.id = obj.id; + this.name = obj.name; + this.width = obj.width; + this.x = obj.x; + this.y = obj.y; + } + } +} diff --git a/lib/insights/diagram/models/diagram/diagramPoolElement.model.ts b/lib/insights/diagram/models/diagram/diagramPoolElement.model.ts new file mode 100644 index 00000000000..d2036eeee6b --- /dev/null +++ b/lib/insights/diagram/models/diagram/diagramPoolElement.model.ts @@ -0,0 +1,46 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { DiagramLaneElementModel } from './diagramLaneElement.model'; + +export class DiagramPoolElementModel { + height: string; + id: string; + name: string; + properties: any; + lanes: DiagramLaneElementModel[] = []; + width: string; + x: number; + y: number; + + constructor(obj?: any) { + if (obj) { + this.height = obj.height; + this.id = obj.id; + this.name = obj.name; + this.properties = obj.properties; + this.width = obj.width; + this.x = obj.x; + this.y = obj.y; + if (obj.lanes) { + obj.lanes.forEach((lane: DiagramLaneElementModel) => { + this.lanes.push(new DiagramLaneElementModel(lane)); + }); + } + } + } +} diff --git a/lib/insights/diagram/models/diagram/diagramWayPoint.model.ts b/lib/insights/diagram/models/diagram/diagramWayPoint.model.ts new file mode 100644 index 00000000000..f5699c440e3 --- /dev/null +++ b/lib/insights/diagram/models/diagram/diagramWayPoint.model.ts @@ -0,0 +1,28 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class DiagramWayPointModel { + x: number; + y: number; + + constructor(obj?: any) { + if (obj) { + this.x = obj.x; + this.y = obj.y; + } + } +} diff --git a/lib/insights/diagram/models/report.model.ts b/lib/insights/diagram/models/report.model.ts deleted file mode 100644 index e8cd9f25842..00000000000 --- a/lib/insights/diagram/models/report.model.ts +++ /dev/null @@ -1,144 +0,0 @@ -/*! - * @license - * Copyright 2016 Alfresco Software, Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * - * This object represent the report definition. - * - * - * @returns {ReportParametersModel} . - */ -export class ReportParametersModel { - id: number; - name: string; - definition: ReportDefinitionModel; - created: string; - - constructor(obj?: any) { - this.id = obj && obj.id; - this.name = obj && obj.name || null; - if (obj && obj.definition) { - this.definition = new ReportDefinitionModel(JSON.parse(obj.definition)); - } - this.created = obj && obj.created || null; - } - - hasParameters() { - return (this.definition && this.definition.parameters && this.definition.parameters.length > 0) ? true : false; - } -} - -export class ReportDefinitionModel { - parameters: ReportParameterDetailsModel[] = []; - - constructor(obj?: any) { - obj.parameters.forEach((params: any) => { - let reportParamsModel = new ReportParameterDetailsModel(params); - this.parameters.push(reportParamsModel); - }); - } - - findParam(name: string): ReportParameterDetailsModel { - this.parameters.forEach((param) => { - return param.type === name ? param : null; - }); - return null; - } -} - -/** - * - * This object represent the report parameter definition. - * - * - * @returns {ReportParameterDetailsModel} . - */ -export class ReportParameterDetailsModel { - id: string; - name: string; - nameKey: string; - type: string; - value: any; - options: ParameterValueModel[]; - dependsOn: string; - - constructor(obj?: any) { - this.id = obj && obj.id; - this.name = obj && obj.name || null; - this.nameKey = obj && obj.nameKey || null; - this.type = obj && obj.type || null; - this.value = obj && obj.value || null; - this.options = obj && obj.options || null; - this.dependsOn = obj && obj.dependsOn || null; - } -} - -export class ParameterValueModel { - id: string; - name: string; - version: string; - value: string; - - constructor(obj?: any) { - this.id = obj && obj.id; - this.name = obj && obj.name || null; - this.value = obj && obj.value || null; - this.version = obj && obj.version || null; - } - - get label () { - return this.version ? `${this.name} (v ${this.version}) ` : this.name; - } -} - -export class ReportQuery { - reportName: string; - processDefinitionId: string; - status: string; - taskName: string; - typeFiltering: boolean; - dateRange: ReportDateRange; - dateRangeInterval: string; - slowProcessInstanceInteger: number; - duration: number; - - constructor(obj?: any) { - this.reportName = obj && obj.reportName || null; - this.processDefinitionId = obj && obj.processDefinitionId || null; - this.status = obj && obj.status || null; - this.taskName = obj && obj.taskName || null; - this.dateRangeInterval = obj && obj.dateRangeInterval || null; - this.typeFiltering = obj && (typeof obj.typeFiltering !== 'undefined') ? obj.typeFiltering : true; - this.slowProcessInstanceInteger = obj && obj.slowProcessInstanceInteger || 0; - this.duration = obj && obj.duration || 0; - this.dateRange = new ReportDateRange(obj); - } - -} - -export class ReportDateRange { - startDate: string; - endDate: string; - rangeId: string; - - constructor(obj?: any) { - this.startDate = obj && obj.startDate || null; - this.endDate = obj && obj.endDate || null; - this.rangeId = obj && obj.rangeId || null; - } - -} diff --git a/lib/insights/diagram/models/report/parameterValue.model.ts b/lib/insights/diagram/models/report/parameterValue.model.ts new file mode 100644 index 00000000000..d96c1ed8fb5 --- /dev/null +++ b/lib/insights/diagram/models/report/parameterValue.model.ts @@ -0,0 +1,34 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class ParameterValueModel { + id: string; + name: string; + version: string; + value: string; + + constructor(obj?: any) { + this.id = obj && obj.id; + this.name = obj && obj.name || null; + this.value = obj && obj.value || null; + this.version = obj && obj.version || null; + } + + get label () { + return this.version ? `${this.name} (v ${this.version}) ` : this.name; + } +} diff --git a/lib/insights/diagram/models/report/reportDateRange.model.ts b/lib/insights/diagram/models/report/reportDateRange.model.ts new file mode 100644 index 00000000000..9ed3f020764 --- /dev/null +++ b/lib/insights/diagram/models/report/reportDateRange.model.ts @@ -0,0 +1,29 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class ReportDateRange { + startDate: string; + endDate: string; + rangeId: string; + + constructor(obj?: any) { + this.startDate = obj && obj.startDate || null; + this.endDate = obj && obj.endDate || null; + this.rangeId = obj && obj.rangeId || null; + } + +} diff --git a/lib/insights/diagram/models/report/reportDefinition.model.ts b/lib/insights/diagram/models/report/reportDefinition.model.ts new file mode 100644 index 00000000000..22ea6ecba75 --- /dev/null +++ b/lib/insights/diagram/models/report/reportDefinition.model.ts @@ -0,0 +1,36 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ReportParameterDetailsModel } from './reportParameterDetails.model'; + +export class ReportDefinitionModel { + parameters: ReportParameterDetailsModel[] = []; + + constructor(obj?: any) { + obj.parameters.forEach((params: any) => { + let reportParamsModel = new ReportParameterDetailsModel(params); + this.parameters.push(reportParamsModel); + }); + } + + findParam(name: string): ReportParameterDetailsModel { + this.parameters.forEach((param) => { + return param.type === name ? param : null; + }); + return null; + } +} diff --git a/lib/insights/diagram/models/report/reportParameterDetails.model.ts b/lib/insights/diagram/models/report/reportParameterDetails.model.ts new file mode 100644 index 00000000000..f4de8736a42 --- /dev/null +++ b/lib/insights/diagram/models/report/reportParameterDetails.model.ts @@ -0,0 +1,38 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ParameterValueModel } from './parameterValue.model'; + +export class ReportParameterDetailsModel { + id: string; + name: string; + nameKey: string; + type: string; + value: any; + options: ParameterValueModel[]; + dependsOn: string; + + constructor(obj?: any) { + this.id = obj && obj.id; + this.name = obj && obj.name || null; + this.nameKey = obj && obj.nameKey || null; + this.type = obj && obj.type || null; + this.value = obj && obj.value || null; + this.options = obj && obj.options || null; + this.dependsOn = obj && obj.dependsOn || null; + } +} diff --git a/lib/insights/diagram/models/report/reportParameters.model.ts b/lib/insights/diagram/models/report/reportParameters.model.ts new file mode 100644 index 00000000000..c7c30382e32 --- /dev/null +++ b/lib/insights/diagram/models/report/reportParameters.model.ts @@ -0,0 +1,38 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ReportDefinitionModel } from './reportDefinition.model'; + +export class ReportParametersModel { + id: number; + name: string; + definition: ReportDefinitionModel; + created: string; + + constructor(obj?: any) { + this.id = obj && obj.id; + this.name = obj && obj.name || null; + if (obj && obj.definition) { + this.definition = new ReportDefinitionModel(JSON.parse(obj.definition)); + } + this.created = obj && obj.created || null; + } + + hasParameters() { + return (this.definition && this.definition.parameters && this.definition.parameters.length > 0) ? true : false; + } +} diff --git a/lib/insights/diagram/models/report/reportQuery.model.ts b/lib/insights/diagram/models/report/reportQuery.model.ts new file mode 100644 index 00000000000..6bab1776688 --- /dev/null +++ b/lib/insights/diagram/models/report/reportQuery.model.ts @@ -0,0 +1,43 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ReportDateRange } from './reportDateRange.model'; + +export class ReportQuery { + reportName: string; + processDefinitionId: string; + status: string; + taskName: string; + typeFiltering: boolean; + dateRange: ReportDateRange; + dateRangeInterval: string; + slowProcessInstanceInteger: number; + duration: number; + + constructor(obj?: any) { + this.reportName = obj && obj.reportName || null; + this.processDefinitionId = obj && obj.processDefinitionId || null; + this.status = obj && obj.status || null; + this.taskName = obj && obj.taskName || null; + this.dateRangeInterval = obj && obj.dateRangeInterval || null; + this.typeFiltering = obj && (typeof obj.typeFiltering !== 'undefined') ? obj.typeFiltering : true; + this.slowProcessInstanceInteger = obj && obj.slowProcessInstanceInteger || 0; + this.duration = obj && obj.duration || 0; + this.dateRange = new ReportDateRange(obj); + } + +} diff --git a/lib/insights/diagram/public-api.ts b/lib/insights/diagram/public-api.ts index 161c35c6387..7d1b08c069a 100644 --- a/lib/insights/diagram/public-api.ts +++ b/lib/insights/diagram/public-api.ts @@ -21,6 +21,27 @@ export * from './components/diagram.component'; export * from './services/diagram-color.service'; export * from './services/diagrams.service'; -export * from './models/diagram.model'; -export * from './models/chart.model'; -export * from './models/report.model'; +export * from './models/diagram/diagram.model'; +export * from './models/diagram/diagramElement.model'; +export * from './models/diagram/diagramElementProperty.model'; +export * from './models/diagram/diagramEventDefinition.model'; +export * from './models/diagram/diagramFlowElement.model'; +export * from './models/diagram/diagramLaneElement.model'; +export * from './models/diagram/diagramPoolElement.model'; +export * from './models/diagram/diagramWayPoint.model'; + +export * from './models/chart/barChart.model'; +export * from './models/chart/chart.model'; +export * from './models/chart/detailsTableChart.model'; +export * from './models/chart/heatMapChart.model'; +export * from './models/chart/lineChart.model'; +export * from './models/chart/multiBarChart.model'; +export * from './models/chart/pieChart.model'; +export * from './models/chart/tableChart.model'; + +export * from './models/report/parameterValue.model'; +export * from './models/report/reportDateRange.model'; +export * from './models/report/reportDefinition.model'; +export * from './models/report/reportParameterDetails.model'; +export * from './models/report/reportParameters.model'; +export * from './models/report/reportQuery.model'; diff --git a/lib/insights/index.ts b/lib/insights/index.ts index 01fd7c4de0a..42a4a5bc7b5 100644 --- a/lib/insights/index.ts +++ b/lib/insights/index.ts @@ -16,9 +16,7 @@ */ export * from './insights.module'; - -export * from './diagram/diagram.module'; +// export * from './analytics-process/analytics-process.module'; - -export * from './diagram'; +// export * from './analytics-process'; diff --git a/lib/insights/package.json b/lib/insights/package.json index 3a025044653..e4e2bf535f2 100644 --- a/lib/insights/package.json +++ b/lib/insights/package.json @@ -1,7 +1,7 @@ { "name": "@alfresco/adf-insights", "description": "Alfresco ADF insights", - "version": "2.0.0", + "version": "2.0.1", "author": "Alfresco Software, Ltd.", "main": "bundles/adf-insights.js", "repository": { diff --git a/scripts/npm-publish.sh b/scripts/npm-publish.sh index 4996178966d..1fab5cee86e 100755 --- a/scripts/npm-publish.sh +++ b/scripts/npm-publish.sh @@ -14,8 +14,10 @@ eval EXEC_SLEEP=false eval SLEEP_TIME="0" eval EXEC_VERSION_JSAPI=false eval JSAPI_VERSION="" +eval EXEC_BUILD=true -eval projects=( "core" +eval projects=( + "core" "insights" "content-services" "process-services" ) @@ -29,6 +31,7 @@ show_help() { echo "-r or --registry to publish in an alternative npm registry -registry 'http://npm.local.me:8080/' " echo "-token auth token for publish in the npm registry" echo "-t or --tag to add a tag when publish a package" + echo "-sb skip build" echo "--sleep add a sleep before any publish" echo "-gitjsapi to build all the components against a commit-ish version of the JS-API" echo "-vjsapi Install different version from npm of JS-API defined in the package.json" @@ -48,6 +51,10 @@ set_sleep(){ EXEC_SLEEP=true } +skip_build(){ + EXEC_BUILD=false +} + get_token_registry(){ TOKEN_REGISTRY=$1 @@ -109,6 +116,7 @@ while [[ $1 == -* ]]; do -f|--force) enable_force; shift;; -token) get_token_registry $2; shift 2;; --sleep) set_sleep $2; shift 2;; + -sb) skip_build; shift;; -r|--registry) enable_change_registry $2; shift 2;; -gitjsapi) enable_js_api_git_link $2; shift 2;; -vjsapi) version_js_api $2; shift 2;; @@ -116,10 +124,12 @@ while [[ $1 == -* ]]; do esac done +if $EXEC_BUILD == true; then echo "====== INSTALL AND CLEAN ${PACKAGE} ===== " -npm install rimraf -npm run clean -npm install + npm install rimraf + npm run clean + npm install +fi if $EXEC_GIT_NPM_INSTALL_JSAPI == true; then echo "====== Use the alfresco JS-API '$GIT_ISH'=====" @@ -134,8 +144,10 @@ if $EXEC_VERSION_JSAPI == true; then npm install alfresco-js-api@${JSAPI_VERSION} --no-save fi -echo "====== Build ADF ===== " -npm run new-build +if $EXEC_BUILD == true; then + echo "====== Build ADF ===== " + npm run new-build +fi for PACKAGE in ${projects[@]} do