mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
upgrade js api (#5152)
* upgrade to latest js api
* add missing types
* remove useless function
* fix types
* enable strict mode
* Revert "enable strict mode"
This reverts commit 8e3f9c4563
.
This commit is contained in:
committed by
Eugenio Romano
parent
47ec01555a
commit
b3ca2166f0
@@ -67,13 +67,13 @@ export class AnalyticsGeneratorComponent implements OnChanges {
|
||||
|
||||
ngOnChanges() {
|
||||
if (this.reportId && this.reportParamQuery) {
|
||||
this.generateReport(this.reportId, this.reportParamQuery);
|
||||
this.generateReport(`${this.reportId}`, this.reportParamQuery);
|
||||
} else {
|
||||
this.reset();
|
||||
}
|
||||
}
|
||||
|
||||
public generateReport(reportId, reportParamQuery) {
|
||||
public generateReport(reportId: string, reportParamQuery: any) {
|
||||
if (reportParamQuery === undefined || reportParamQuery === null) {
|
||||
reportParamQuery = {};
|
||||
}
|
||||
|
@@ -315,7 +315,7 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On
|
||||
|
||||
public editTitle() {
|
||||
this.analyticsService
|
||||
.updateReport(this.reportParameters.id, this.reportParameters.name)
|
||||
.updateReport(`${this.reportParameters.id}`, this.reportParameters.name)
|
||||
.subscribe(
|
||||
() => {
|
||||
this.editDisable();
|
||||
|
@@ -54,8 +54,8 @@ export class AnalyticsComponent implements OnChanges {
|
||||
this.analyticsGenerator.reset();
|
||||
}
|
||||
|
||||
public showReport($event) {
|
||||
this.analyticsGenerator.generateReport(this.reportId, $event);
|
||||
public showReport($event: any) {
|
||||
this.analyticsGenerator.generateReport(`${this.reportId}`, $event);
|
||||
}
|
||||
|
||||
public reset() {
|
||||
|
@@ -18,7 +18,7 @@
|
||||
import { AlfrescoApiService, LogService } from '@alfresco/adf-core';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Response } from '@angular/http';
|
||||
import { Observable, from, throwError } from 'rxjs';
|
||||
import { Observable, from, throwError, of } from 'rxjs';
|
||||
import { ParameterValueModel } from '../../diagram/models/report/parameterValue.model';
|
||||
import { ReportParametersModel } from '../../diagram/models/report/reportParameters.model';
|
||||
import { BarChart } from '../../diagram/models/chart/barChart.model';
|
||||
@@ -40,7 +40,7 @@ export class AnalyticsService {
|
||||
/**
|
||||
* Retrieve all the Deployed app
|
||||
*/
|
||||
getReportList(appId: number): Observable<any> {
|
||||
getReportList(appId: number): Observable<ReportParametersModel[]> {
|
||||
return from(this.apiService.getInstance().activiti.reportApi.getReportList())
|
||||
.pipe(
|
||||
map((res: any) => {
|
||||
@@ -79,7 +79,7 @@ export class AnalyticsService {
|
||||
return isValid;
|
||||
}
|
||||
|
||||
getReportParams(reportId: string): Observable<any> {
|
||||
getReportParams(reportId: string): Observable<ReportParametersModel> {
|
||||
return from(this.apiService.getInstance().activiti.reportApi.getReportParams(reportId))
|
||||
.pipe(
|
||||
map((res: any) => {
|
||||
@@ -89,7 +89,7 @@ export class AnalyticsService {
|
||||
);
|
||||
}
|
||||
|
||||
getParamValuesByType(type: string, appId: number, reportId?: string, processDefinitionId?: string) {
|
||||
getParamValuesByType(type: string, appId: number, reportId?: string, processDefinitionId?: string): Observable<ParameterValueModel[]> {
|
||||
if (type === 'status') {
|
||||
return this.getProcessStatusValues();
|
||||
} else if (type === 'processDefinition') {
|
||||
@@ -103,27 +103,21 @@ export class AnalyticsService {
|
||||
} else if (type === 'task' && reportId && processDefinitionId) {
|
||||
return this.getTasksByProcessDefinitionId(reportId, processDefinitionId);
|
||||
} else {
|
||||
return new Observable((observer) => {
|
||||
observer.next(null);
|
||||
observer.complete();
|
||||
});
|
||||
return of(null);
|
||||
}
|
||||
}
|
||||
|
||||
getProcessStatusValues(): Observable<any> {
|
||||
getProcessStatusValues(): Observable<ParameterValueModel[]> {
|
||||
const 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' }));
|
||||
|
||||
return new Observable((observer) => {
|
||||
observer.next(paramOptions);
|
||||
observer.complete();
|
||||
});
|
||||
return of(paramOptions);
|
||||
}
|
||||
|
||||
getDateIntervalValues(): Observable<any> {
|
||||
getDateIntervalValues(): Observable<ParameterValueModel[]> {
|
||||
const paramOptions: ParameterValueModel[] = [];
|
||||
|
||||
paramOptions.push(new ParameterValueModel({ id: 'byHour', name: 'By hour' }));
|
||||
@@ -132,26 +126,20 @@ export class AnalyticsService {
|
||||
paramOptions.push(new ParameterValueModel({ id: 'byMonth', name: 'By month' }));
|
||||
paramOptions.push(new ParameterValueModel({ id: 'byYear', name: 'By year' }));
|
||||
|
||||
return new Observable((observer) => {
|
||||
observer.next(paramOptions);
|
||||
observer.complete();
|
||||
});
|
||||
return of(paramOptions);
|
||||
}
|
||||
|
||||
getMetricValues(): Observable<any> {
|
||||
getMetricValues(): Observable<ParameterValueModel[]> {
|
||||
const paramOptions: ParameterValueModel[] = [];
|
||||
|
||||
paramOptions.push(new ParameterValueModel({ id: 'totalCount', name: 'Number of times a step is executed' }));
|
||||
paramOptions.push(new ParameterValueModel({ id: 'totalTime', name: 'Total time spent in a process step' }));
|
||||
paramOptions.push(new ParameterValueModel({ id: 'avgTime', name: 'Average time spent in a process step' }));
|
||||
|
||||
return new Observable((observer) => {
|
||||
observer.next(paramOptions);
|
||||
observer.complete();
|
||||
});
|
||||
return of(paramOptions);
|
||||
}
|
||||
|
||||
getProcessDefinitionsValuesNoApp(): Observable<any> {
|
||||
getProcessDefinitionsValuesNoApp(): Observable<ParameterValueModel[]> {
|
||||
return from(this.apiService.getInstance().activiti.reportApi.getProcessDefinitions())
|
||||
.pipe(
|
||||
map((res: any) => {
|
||||
@@ -165,7 +153,7 @@ export class AnalyticsService {
|
||||
);
|
||||
}
|
||||
|
||||
getProcessDefinitionsValues(appId: number): Observable<any> {
|
||||
getProcessDefinitionsValues(appId: number): Observable<ParameterValueModel[]> {
|
||||
const options = { 'appDefinitionId': appId };
|
||||
return from(this.apiService.getInstance().activiti.processDefinitionsApi.getProcessDefinitions(options))
|
||||
.pipe(
|
||||
@@ -180,7 +168,7 @@ export class AnalyticsService {
|
||||
);
|
||||
}
|
||||
|
||||
getTasksByProcessDefinitionId(reportId: string, processDefinitionId: string): Observable<any> {
|
||||
getTasksByProcessDefinitionId(reportId: string, processDefinitionId: string): Observable<ParameterValueModel[]> {
|
||||
return from(this.apiService.getInstance().activiti.reportApi.getTasksByProcessDefinitionId(reportId, processDefinitionId))
|
||||
.pipe(
|
||||
map((res: any) => {
|
||||
@@ -194,7 +182,7 @@ export class AnalyticsService {
|
||||
);
|
||||
}
|
||||
|
||||
getReportsByParams(reportId: number, paramsQuery: any): Observable<any> {
|
||||
getReportsByParams(reportId: string, paramsQuery: any): Observable<any> {
|
||||
return from(this.apiService.getInstance().activiti.reportApi.getReportsByParams(reportId, paramsQuery))
|
||||
.pipe(
|
||||
map((res: any) => {
|
||||
@@ -224,12 +212,12 @@ export class AnalyticsService {
|
||||
createDefaultReports(): Observable<any> {
|
||||
return from(this.apiService.getInstance().activiti.reportApi.createDefaultReports())
|
||||
.pipe(
|
||||
map(this.toJson),
|
||||
map(res => res || {}),
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
updateReport(reportId: number, name: string): Observable<any> {
|
||||
updateReport(reportId: string, name: string): Observable<any> {
|
||||
return from(this.apiService.getInstance().activiti.reportApi.updateReport(reportId, name))
|
||||
.pipe(
|
||||
map(() => this.logService.info('upload')),
|
||||
@@ -272,8 +260,4 @@ export class AnalyticsService {
|
||||
this.logService.error(error);
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
|
||||
toJson(res: any) {
|
||||
return res || {};
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user