Skip to content

Commit

Permalink
#12 Update Report by TestFolder with servlet response
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony-Jhoiro committed Aug 6, 2019
1 parent 5f094de commit 04842d8
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 23 deletions.
42 changes: 40 additions & 2 deletions src/app/core/services/crud/reporting.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export class ReportingService {
private reportTestFolder = {};
private reportLabel = {};
status: Array<any> = [

{
label: "FA",
color: "#F0AD4E",
Expand Down Expand Up @@ -66,6 +65,7 @@ export class ReportingService {

observableTagDetail = new BehaviorSubject<any>(this.tagDetail);
observableReportStatus = new BehaviorSubject<any>(this.reportStatus);
observableReportTestFolder = new BehaviorSubject<any>(this.reportTestFolder);

// variables
private tagsList: Array<ITag>;
Expand All @@ -84,7 +84,7 @@ export class ReportingService {
}
ReadTestCaseExecutionByTag(tag: string, callback: (any) => any) {
//TODO : Specified type
this.http.get<any>(environment.cerberus_api_url + '/ReadTestCaseExecutionByTag?Tag=' + tag)
this.http.get<any>(environment.cerberus_api_url + '/ReadTestCaseExecutionByTag?Tag=' + tag + '&OK=on&KO=on&FA=on&NA=on&NE=on&WE=on&PE=on&QU=on&QE=on&CA=on&BE=on&CH=on&ES=on&FR=on&IT=on&LU=on&NL=on&PT=on&RU=on&UK=on&VI=on&PL=on&DE=on&RX=on&UF=on&env=on&country=on&robotDecli=on&app=on&')
.subscribe(response => {
callback(response);
})
Expand All @@ -95,6 +95,7 @@ export class ReportingService {
console.log("response :", response);
this.parseTagDetail(response);
this.parseReportStatus(response);
this.parseReportTestFolder(response);
});
}

Expand Down Expand Up @@ -135,5 +136,42 @@ export class ReportingService {
this.reportStatus.total = response.tagObject.nbExeUsefull;
this.observableReportStatus.next(this.reportStatus)
}
parseReportTestFolder(response) {
let labelList = [];
let datasets = [];
let colors = [];

for (let axis of response.functionChart.axis) {
labelList.push(axis.name);
}

for (let status of this.status){
let temp = {data: [], label: status.label, backgroundColor: status.color, hoverBackgroundColor: status.color};
for (let axis of response.functionChart.axis) {
if (axis[status.label]) temp.data.push(axis[status.label].value);
else temp.data.push(0);
}
if (temp.data.some(number => number!=0)) datasets.push(temp);
}


this.reportTestFolder = {
datasets: datasets,
label: labelList,
options : {
responsive: true,
// We use these empty structures as placeholders for dynamic theming.
scales: { xAxes: [{stacked: true}], yAxes: [{stacked: true}] },
plugins: {
datalabels: {
anchor: 'end',
align: 'end',
}
}
},
legend: true
}
this.observableReportTestFolder.next(this.reportTestFolder);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ <h3 class="block-title">Report <small>by Test Folder</small></h3>
</button>
</div>

<div class="block-content row" *ngIf="expand">
<div class="block-content row" *ngIf="expand && chart.datasets">
<canvas baseChart [datasets]="chart.datasets" [labels]="chart.label" [options]="chart.options"
[plugins]="chart.plugin" [legend]="chart.legend" [chartType]="'bar'">
</canvas>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { ChartOptions, ChartType, ChartDataSets } from 'chart.js';
import { Label } from 'ng2-charts';
import { ReportingService } from 'src/app/core/services/crud/reporting.service';

@Component({
selector: 'app-reportby-testfolder',
Expand All @@ -17,29 +18,30 @@ export class ReportbyTestfolderComponent implements OnInit {
}
expand: boolean = true;

constructor() { }
constructor(private reportingService: ReportingService) { }

ngOnInit() {
this.chart = {
datasets: [
{ data: [65, 59, 80, 81, 56, 55, 40], label: 'Series A' },
{ data: [10, 48, 40, 19, 86, 27, 90], label: 'Series B' }
],
label: ['2006', '2007', '2008', '2009', '2010', '2011', '2012'],
options : {
responsive: true,
// We use these empty structures as placeholders for dynamic theming.
scales: { xAxes: [{stacked: true}], yAxes: [{stacked: true}] },
plugins: {
datalabels: {
anchor: 'end',
align: 'end',
}
}
},
legend: true
this.reportingService.observableReportTestFolder.subscribe(data => this.chart = data);
// this.chart = {
// datasets: [
// { data: [65, 59, 80, 81, 56, 55, 40], label: 'Series A' },
// { data: [10, 48, 40, 19, 86, 27, 90], label: 'Series B' }
// ],
// label: ['2006', '2007', '2008', '2009', '2010', '2011', '2012'],
// options : {
// responsive: true,
// // We use these empty structures as placeholders for dynamic theming.
// scales: { xAxes: [{stacked: true}], yAxes: [{stacked: true}] },
// plugins: {
// datalabels: {
// anchor: 'end',
// align: 'end',
// }
// }
// },
// legend: true

}
// }
}

}

0 comments on commit 04842d8

Please sign in to comment.