Merge pull request #1267 from Alfresco/dev-mvitale-1174

Report rename
This commit is contained in:
Mario Romano 2016-12-14 17:06:35 +00:00 committed by GitHub
commit b4b008416c
9 changed files with 97 additions and 8 deletions

View File

@ -92,10 +92,17 @@
<div class="page-content"> <div class="page-content">
<div class="mdl-grid"> <div class="mdl-grid">
<div class="mdl-cell mdl-cell--4-col task-column mdl-shadow--2dp"> <div class="mdl-cell mdl-cell--4-col task-column mdl-shadow--2dp">
<analytics-report-list (reportClick)="onReportClick($event)"></analytics-report-list> <analytics-report-list
(reportClick)="onReportClick($event)"
#analyticsreportlist >
</analytics-report-list>
</div> </div>
<div class="mdl-cell mdl-cell--8-col task-column mdl-shadow--2dp"> <div class="mdl-cell mdl-cell--8-col task-column mdl-shadow--2dp">
<activiti-analytics [appId]="appId" *ngIf="report" [reportId]="report.id"></activiti-analytics> <activiti-analytics *ngIf="report"
[appId]="appId"
[reportId]="report.id"
(editReport)="onEditReport($event)">
</activiti-analytics>
</div> </div>
</div> </div>
</div> </div>

View File

@ -30,6 +30,7 @@ import {
ActivitiStartProcessInstance, ActivitiStartProcessInstance,
ProcessInstance ProcessInstance
} from 'ng2-activiti-processlist'; } from 'ng2-activiti-processlist';
import { AnalyticsReportListComponent } from 'ng2-activiti-analytics';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { Subscription } from 'rxjs/Rx'; import { Subscription } from 'rxjs/Rx';
import { import {
@ -75,6 +76,9 @@ export class ActivitiDemoComponent implements AfterViewInit {
@ViewChild(ActivitiStartProcessInstance) @ViewChild(ActivitiStartProcessInstance)
activitiStartProcess: ActivitiStartProcessInstance; activitiStartProcess: ActivitiStartProcessInstance;
@ViewChild(AnalyticsReportListComponent)
analyticsreportlist: AnalyticsReportListComponent;
@Input() @Input()
appId: number; appId: number;
@ -183,6 +187,10 @@ export class ActivitiDemoComponent implements AfterViewInit {
this.currentProcessInstanceId = processInstanceId; this.currentProcessInstanceId = processInstanceId;
} }
onEditReport(name: string) {
this.analyticsreportlist.reload();
}
navigateStartProcess() { navigateStartProcess() {
this.currentProcessInstanceId = currentProcessIdNew; this.currentProcessInstanceId = currentProcessIdNew;
} }

View File

@ -57,13 +57,21 @@ export class AnalyticsReportListComponent implements OnInit {
this.reports.push(report); this.reports.push(report);
}); });
this.getReportListByAppId(); this.getReportList();
} }
/** /**
* Get the report list by app id * Reload the component
*/ */
getReportListByAppId() { reload() {
this.reset();
this.getReportList();
}
/**
* Get the report list
*/
getReportList() {
this.analyticsService.getReportList().subscribe( this.analyticsService.getReportList().subscribe(
(res: ReportParametersModel[]) => { (res: ReportParametersModel[]) => {
if (res && res.length === 0) { if (res && res.length === 0) {
@ -108,6 +116,15 @@ export class AnalyticsReportListComponent implements OnInit {
return this.reports === undefined || (this.reports && this.reports.length === 0); return this.reports === undefined || (this.reports && this.reports.length === 0);
} }
/**
* Reset the list
*/
private reset() {
if (!this.isReportsEmpty()) {
this.reports = [];
}
}
/** /**
* Select the current report * Select the current report
* @param report * @param report

View File

@ -21,3 +21,7 @@
.dropdown-widget__invalid .mdl-textfield__error { .dropdown-widget__invalid .mdl-textfield__error {
visibility: visible !important; visibility: visible !important;
} }
.large {
font-size: x-large;
}

View File

@ -1,7 +1,18 @@
<div class="col-md-6"> <div class="col-md-6">
<div *ngIf="reportParameters"> <div *ngIf="reportParameters">
<form [formGroup]="reportForm" novalidate> <form [formGroup]="reportForm" novalidate>
<h4>{{reportParameters.name}}</h4> <div *ngIf="isEditable">
<input
type="text"
class="mdl-textfield__input large"
id="reportName"
data-automation-id="reportName"
[value]="reportParameters.name"
(input)="reportParameters.name=$event.target.value"
(blur)="editTitle($event)"
/>
</div>
<h4 *ngIf="!isEditable" (click)="editEnable()">{{reportParameters.name}}</h4>
<div *ngFor="let field of reportParameters.definition.parameters"> <div *ngFor="let field of reportParameters.definition.parameters">
<div [ngSwitch]="field.type"> <div [ngSwitch]="field.type">
<div *ngSwitchCase="'integer'"> <div *ngSwitchCase="'integer'">

View File

@ -47,6 +47,9 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges {
@Output() @Output()
onError = new EventEmitter(); onError = new EventEmitter();
@Output()
onEdit = new EventEmitter();
@Output() @Output()
onFormValueChanged = new EventEmitter(); onFormValueChanged = new EventEmitter();
@ -63,6 +66,7 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges {
private dropDownSub; private dropDownSub;
private reportParamsSub; private reportParamsSub;
private paramOpts; private paramOpts;
private isEditable: boolean = false;
constructor(private translate: AlfrescoTranslationService, constructor(private translate: AlfrescoTranslationService,
private analyticsService: AnalyticsService, private analyticsService: AnalyticsService,
@ -210,4 +214,25 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges {
this.reportParamsSub.unsubscribe(); this.reportParamsSub.unsubscribe();
} }
} }
public editEnable() {
this.isEditable = true;
}
public editDisable() {
this.isEditable = false;
}
public editTitle() {
this.reportParamsSub = this.analyticsService.updateReport(this.reportParameters.id, this.reportParameters.name).subscribe(
(res: ReportParametersModel) => {
this.editDisable();
this.onEdit.emit(this.reportParameters.name);
},
(err: any) => {
console.log(err);
this.onError.emit(err);
}
);
}
} }

View File

@ -1,6 +1,9 @@
<div class="col-md-6"> <div class="col-md-6">
<analytics-report-parameters [appId]="appId" [reportId]="reportId" <analytics-report-parameters [appId]="appId" [reportId]="reportId"
(onFormValueChanged)="reset()" (onSuccess)="showReport($event)"></analytics-report-parameters> (onFormValueChanged)="reset()"
(onSuccess)="showReport($event)"
(onEdit)="onEditReport($event)">
</analytics-report-parameters>
<div *ngIf="reports"> <div *ngIf="reports">
<div *ngFor="let report of reports"> <div *ngFor="let report of reports">

View File

@ -41,12 +41,15 @@ export class AnalyticsComponent implements OnChanges {
@Output() @Output()
onSuccess = new EventEmitter(); onSuccess = new EventEmitter();
@Output()
editReport = new EventEmitter();
@Output() @Output()
onError = new EventEmitter(); onError = new EventEmitter();
reportParamQuery = new ReportQuery(); reportParamQuery = new ReportQuery();
reports: any[]; reports: Chart[];
public barChartOptions: any = { public barChartOptions: any = {
responsive: true, responsive: true,
@ -107,4 +110,8 @@ export class AnalyticsComponent implements OnChanges {
let clone = JSON.parse(JSON.stringify(report)); let clone = JSON.parse(JSON.stringify(report));
report.datasets = clone.datasets; report.datasets = clone.datasets;
} }
public onEditReport(name: string) {
this.editReport.emit(name);
}
} }

View File

@ -178,6 +178,13 @@ export class AnalyticsService {
.catch(this.handleError); .catch(this.handleError);
} }
public updateReport(reportId: number, name: string): Observable<any> {
return Observable.fromPromise(this.apiService.getInstance().activiti.reportApi.updateReport(reportId, name))
.map((res: any) => {
console.log('upload');
}).catch(this.handleError);
}
private handleError(error: Response) { private handleError(error: Response) {
console.error(error); console.error(error);
return Observable.throw(error.json().error || 'Server error'); return Observable.throw(error.json().error || 'Server error');