mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-3299] and [ADF-3300] upgrade to Angular and Material 6 (#3579)
* upgrade to HttpClient * upgrade to Renderer2 * upgrade Document reference * remove useless test with deprecated ReflectiveInjector * upgrade to latest typescript * upgrade libs * upgrade package scripts * remove rxjs blacklists and duplicate rules * add rxjs compat to help with migration * fix breaking changes * fix breaking changes in material * fix breaking changes (material 6) * upgrade rxjs, ngx-translate and flex layout * update unit tests * restore providers * upgrade deprecated Observable.error * rebase fix first configuration problems * fix style issues commented * fix core build * fix lib template errors * move lib test execution in angular.json * ignore * karma conf files * fix import statement test * single run option * update packages reporter * restore report * increase timeout * improve karma conf test configuration * fix test issues about lint * fix test analytics * fix process service test * content service fix test * fix logout directive test * fix core test * fix build * update node-sass to latest * update angular cli dependencies * improve build script create directorites and move files only if previous command succeded * upgrade individual libs to 6.0 * remove old webpack files * revert sass change * fix type issues fix style issues * fix tslint demo shell issue * fix peerdependencies * fix test e2e BC * package upate * fix style import issue * extract-text-webpack-plugin beta * fix test dist build command * remove alpha js-api * fix tslint issue add banner tslint rule * upload service fix * change BC script * fix test dist script * increase demo shell timeout test * verbose copy * path absolute * fix script bc * fix copy part * fix path warning fix monaco editor * remove duplicate header * remove unused import * fix align and check ago tests * add missing import * fix notification button selector * [ANGULAR6] fixed core tests * fix CS test * fix cs test step 2 * increase travis_wait for dist * fix attachment PS * fix checklist test * use pdf min
This commit is contained in:
committed by
Eugenio Romano
parent
c510ec864d
commit
6b24bfb1d4
@@ -16,10 +16,10 @@
|
||||
*/
|
||||
|
||||
import { Component, EventEmitter, Input, OnInit, Output, ViewEncapsulation } from '@angular/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observer } from 'rxjs/Observer';
|
||||
import { Observable, Observer } from 'rxjs';
|
||||
import { ReportParametersModel } from '../../diagram/models/report/reportParameters.model';
|
||||
import { AnalyticsService } from '../services/analytics.service';
|
||||
import { share } from 'rxjs/operators';
|
||||
|
||||
// @deprecated 2.3.0 analytics-report-list tag removed
|
||||
@Component({
|
||||
@@ -59,7 +59,8 @@ export class AnalyticsReportListComponent implements OnInit {
|
||||
reports: ReportParametersModel[] = [];
|
||||
|
||||
constructor(private analyticsService: AnalyticsService) {
|
||||
this.report$ = new Observable<ReportParametersModel>(observer => this.reportObserver = observer).share();
|
||||
this.report$ = new Observable<ReportParametersModel>(observer => this.reportObserver = observer)
|
||||
.pipe(share());
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
@@ -15,8 +15,8 @@
|
||||
data-automation-id="reportName"
|
||||
[value]="reportParameters.name"
|
||||
(input)="reportParameters.name=$event.target.value"
|
||||
(blur)="editTitle($event)"
|
||||
(keyup.enter)="editTitle($event)"
|
||||
(blur)="editTitle()"
|
||||
(keyup.enter)="editTitle()"
|
||||
/>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
@@ -24,7 +24,7 @@
|
||||
<mat-icon class="adf-report-icon" >mode_edit</mat-icon>
|
||||
<h4>{{reportParameters.name}}</h4>
|
||||
</div>
|
||||
</adf-toolbar-title>
|
||||
</adf-toolbar-title>
|
||||
<adf-buttons-action-menu *ngIf="!isEditable">
|
||||
<button mat-menu-item (click)="toggleParameters()" id="">
|
||||
<mat-icon>settings</mat-icon><span>{{ 'ANALYTICS.MESSAGES.ICON-SETTING' | translate }}</span>
|
||||
@@ -40,7 +40,7 @@
|
||||
<mat-icon>save</mat-icon><span>{{ 'ANALYTICS.MESSAGES.ICON-SAVE' | translate }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</adf-buttons-action-menu>
|
||||
</adf-buttons-action-menu>
|
||||
</adf-toolbar>
|
||||
<div *ngFor="let field of reportParameters.definition.parameters"
|
||||
[class.is-hide]="isParametersHide()">
|
||||
@@ -132,4 +132,4 @@
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -23,7 +23,7 @@ import { AnalyticsReportParametersComponent } from '../components/analytics-repo
|
||||
import { setupTestBed } from '@alfresco/adf-core';
|
||||
import { InsightsTestingModule } from '../../testing/insights.testing.module';
|
||||
import { AnalyticsService } from '../services/analytics.service';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@@ -448,7 +448,7 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
}));
|
||||
|
||||
it('Should be able to change the report title', (done) => {
|
||||
spyOn(service, 'updateReport').and.returnValue(Observable.of(analyticParamsMock.reportDefParamStatus));
|
||||
spyOn(service, 'updateReport').and.returnValue(of(analyticParamsMock.reportDefParamStatus));
|
||||
|
||||
let title: HTMLElement = element.querySelector('h4');
|
||||
title.click();
|
||||
|
@@ -98,7 +98,7 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On
|
||||
private dropDownSub;
|
||||
private reportParamsSub;
|
||||
private paramOpts;
|
||||
private reportParamQuery: ReportQuery;
|
||||
reportParamQuery: ReportQuery;
|
||||
private hideParameters: boolean = true;
|
||||
formValidState: boolean = false;
|
||||
|
||||
|
@@ -18,7 +18,7 @@
|
||||
import { AlfrescoApiService, LogService } from '@alfresco/adf-core';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Response } from '@angular/http';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observable, from, throwError } 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';
|
||||
@@ -28,8 +28,7 @@ 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';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
export class AnalyticsService {
|
||||
@@ -39,31 +38,37 @@ export class AnalyticsService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrive all the Deployed app
|
||||
* Retrieve all the Deployed app
|
||||
*/
|
||||
getReportList(appId: number): Observable<any> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().activiti.reportApi.getReportList())
|
||||
.map((res: any) => {
|
||||
let reports: ReportParametersModel[] = [];
|
||||
res.forEach((report: ReportParametersModel) => {
|
||||
let reportModel = new ReportParametersModel(report);
|
||||
if (this.isReportValid(appId, report)) {
|
||||
reports.push(reportModel);
|
||||
}
|
||||
});
|
||||
return reports;
|
||||
}).catch(err => this.handleError(err));
|
||||
return from(this.apiService.getInstance().activiti.reportApi.getReportList())
|
||||
.pipe(
|
||||
map((res: any) => {
|
||||
let reports: ReportParametersModel[] = [];
|
||||
res.forEach((report: ReportParametersModel) => {
|
||||
let reportModel = new ReportParametersModel(report);
|
||||
if (this.isReportValid(appId, report)) {
|
||||
reports.push(reportModel);
|
||||
}
|
||||
});
|
||||
return reports;
|
||||
}),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrive Report by name
|
||||
* Retrieve Report by name
|
||||
* @param reportName - string - The name of report
|
||||
*/
|
||||
getReportByName(reportName: string): Observable<any> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().activiti.reportApi.getReportList())
|
||||
.map((response: any) => {
|
||||
return response.find(report => report.name === reportName);
|
||||
}).catch(err => this.handleError(err));
|
||||
return from(this.apiService.getInstance().activiti.reportApi.getReportList())
|
||||
.pipe(
|
||||
map((response: any) => {
|
||||
return response.find(report => report.name === reportName);
|
||||
}),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
private isReportValid(appId: number, report: ReportParametersModel) {
|
||||
@@ -75,10 +80,13 @@ export class AnalyticsService {
|
||||
}
|
||||
|
||||
getReportParams(reportId: string): Observable<any> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().activiti.reportApi.getReportParams(reportId))
|
||||
.map((res: any) => {
|
||||
return new ReportParametersModel(res);
|
||||
}).catch(err => this.handleError(err));
|
||||
return from(this.apiService.getInstance().activiti.reportApi.getReportParams(reportId))
|
||||
.pipe(
|
||||
map((res: any) => {
|
||||
return new ReportParametersModel(res);
|
||||
}),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
getParamValuesByType(type: string, appId: number, reportId?: string, processDefinitionId?: string) {
|
||||
@@ -144,101 +152,125 @@ export class AnalyticsService {
|
||||
}
|
||||
|
||||
getProcessDefinitionsValuesNoApp(): Observable<any> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().activiti.reportApi.getProcessDefinitions())
|
||||
.map((res: any) => {
|
||||
let paramOptions: ParameterValueModel[] = [];
|
||||
res.forEach((opt) => {
|
||||
paramOptions.push(new ParameterValueModel(opt));
|
||||
});
|
||||
return paramOptions;
|
||||
}).catch(err => this.handleError(err));
|
||||
return from(this.apiService.getInstance().activiti.reportApi.getProcessDefinitions())
|
||||
.pipe(
|
||||
map((res: any) => {
|
||||
let paramOptions: ParameterValueModel[] = [];
|
||||
res.forEach((opt) => {
|
||||
paramOptions.push(new ParameterValueModel(opt));
|
||||
});
|
||||
return paramOptions;
|
||||
}),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
getProcessDefinitionsValues(appId: number): Observable<any> {
|
||||
let options = { 'appDefinitionId': appId };
|
||||
return Observable.fromPromise(this.apiService.getInstance().activiti.processDefinitionsApi.getProcessDefinitions(options))
|
||||
.map((res: any) => {
|
||||
let paramOptions: ParameterValueModel[] = [];
|
||||
res.data.forEach((opt) => {
|
||||
paramOptions.push(new ParameterValueModel(opt));
|
||||
});
|
||||
return paramOptions;
|
||||
}).catch(err => this.handleError(err));
|
||||
return from(this.apiService.getInstance().activiti.processDefinitionsApi.getProcessDefinitions(options))
|
||||
.pipe(
|
||||
map((res: any) => {
|
||||
let paramOptions: ParameterValueModel[] = [];
|
||||
res.data.forEach((opt) => {
|
||||
paramOptions.push(new ParameterValueModel(opt));
|
||||
});
|
||||
return paramOptions;
|
||||
}),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
getTasksByProcessDefinitionId(reportId: string, processDefinitionId: string): Observable<any> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().activiti.reportApi.getTasksByProcessDefinitionId(reportId, processDefinitionId))
|
||||
.map((res: any) => {
|
||||
let paramOptions: ParameterValueModel[] = [];
|
||||
res.forEach((opt) => {
|
||||
paramOptions.push(new ParameterValueModel({ id: opt, name: opt }));
|
||||
});
|
||||
return paramOptions;
|
||||
}).catch(err => this.handleError(err));
|
||||
return from(this.apiService.getInstance().activiti.reportApi.getTasksByProcessDefinitionId(reportId, processDefinitionId))
|
||||
.pipe(
|
||||
map((res: any) => {
|
||||
let paramOptions: ParameterValueModel[] = [];
|
||||
res.forEach((opt) => {
|
||||
paramOptions.push(new ParameterValueModel({ id: opt, name: opt }));
|
||||
});
|
||||
return paramOptions;
|
||||
}),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
getReportsByParams(reportId: number, paramsQuery: any): Observable<any> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().activiti.reportApi.getReportsByParams(reportId, paramsQuery))
|
||||
.map((res: any) => {
|
||||
let elements: Chart[] = [];
|
||||
res.elements.forEach((chartData) => {
|
||||
if (chartData.type === 'pieChart') {
|
||||
elements.push(new PieChart(chartData));
|
||||
} else if (chartData.type === 'table') {
|
||||
elements.push(new TableChart(chartData));
|
||||
} else if (chartData.type === 'processDefinitionHeatMap') {
|
||||
elements.push(new HeatMapChart(chartData));
|
||||
} else if (chartData.type === 'masterDetailTable') {
|
||||
elements.push(new DetailsTableChart(chartData));
|
||||
} else if (chartData.type === 'barChart') {
|
||||
elements.push(new BarChart(chartData));
|
||||
} else if (chartData.type === 'multiBarChart') {
|
||||
elements.push(new MultiBarChart(chartData));
|
||||
}
|
||||
});
|
||||
return from(this.apiService.getInstance().activiti.reportApi.getReportsByParams(reportId, paramsQuery))
|
||||
.pipe(
|
||||
map((res: any) => {
|
||||
let elements: Chart[] = [];
|
||||
res.elements.forEach((chartData) => {
|
||||
if (chartData.type === 'pieChart') {
|
||||
elements.push(new PieChart(chartData));
|
||||
} else if (chartData.type === 'table') {
|
||||
elements.push(new TableChart(chartData));
|
||||
} else if (chartData.type === 'processDefinitionHeatMap') {
|
||||
elements.push(new HeatMapChart(chartData));
|
||||
} else if (chartData.type === 'masterDetailTable') {
|
||||
elements.push(new DetailsTableChart(chartData));
|
||||
} else if (chartData.type === 'barChart') {
|
||||
elements.push(new BarChart(chartData));
|
||||
} else if (chartData.type === 'multiBarChart') {
|
||||
elements.push(new MultiBarChart(chartData));
|
||||
}
|
||||
});
|
||||
|
||||
return elements;
|
||||
}).catch(err => this.handleError(err));
|
||||
return elements;
|
||||
}),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
createDefaultReports(): Observable<any> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().activiti.reportApi.createDefaultReports())
|
||||
.map(this.toJson)
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.apiService.getInstance().activiti.reportApi.createDefaultReports())
|
||||
.pipe(
|
||||
map(this.toJson),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
updateReport(reportId: number, name: string): Observable<any> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().activiti.reportApi.updateReport(reportId, name))
|
||||
.map((res: any) => {
|
||||
this.logService.info('upload');
|
||||
}).catch(err => this.handleError(err));
|
||||
return from(this.apiService.getInstance().activiti.reportApi.updateReport(reportId, name))
|
||||
.pipe(
|
||||
map(() => this.logService.info('upload')),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
exportReportToCsv(reportId: string, paramsQuery: any): Observable<any> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().activiti.reportApi.exportToCsv(reportId, paramsQuery))
|
||||
.map((res: any) => {
|
||||
this.logService.info('export');
|
||||
return res;
|
||||
}).catch(err => this.handleError(err));
|
||||
return from(this.apiService.getInstance().activiti.reportApi.exportToCsv(reportId, paramsQuery))
|
||||
.pipe(
|
||||
map((res: any) => {
|
||||
this.logService.info('export');
|
||||
return res;
|
||||
}),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
saveReport(reportId: string, paramsQuery: any): Observable<any> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().activiti.reportApi.saveReport(reportId, paramsQuery))
|
||||
.map(() => {
|
||||
this.logService.info('save');
|
||||
}).catch(err => this.handleError(err));
|
||||
return from(this.apiService.getInstance().activiti.reportApi.saveReport(reportId, paramsQuery))
|
||||
.pipe(
|
||||
map(() => {
|
||||
this.logService.info('save');
|
||||
}),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
deleteReport(reportId: string): Observable<any> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().activiti.reportApi.deleteReport(reportId))
|
||||
.map(() => {
|
||||
this.logService.info('delete');
|
||||
}).catch(err => this.handleError(err));
|
||||
return from(this.apiService.getInstance().activiti.reportApi.deleteReport(reportId))
|
||||
.pipe(
|
||||
map(() => {
|
||||
this.logService.info('delete');
|
||||
}),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
private handleError(error: Response) {
|
||||
this.logService.error(error);
|
||||
return Observable.throw(error || 'Server error');
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
|
||||
toJson(res: any) {
|
||||
|
Reference in New Issue
Block a user