Skip to content

Commit

Permalink
#12 Update graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony-Jhoiro committed Aug 7, 2019
1 parent 57d418a commit f1f7434
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 72 deletions.
99 changes: 75 additions & 24 deletions src/app/core/services/crud/reporting.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ export class ReportingService {
this.http.get<any>(environment.cerberus_api_url + '/ReadTestCaseExecutionByTag?Tag=' + this.selectedTagName + '&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 => {
this.http.get<any>(environment.cerberus_api_url + '/ReadCampaign?tag=true&&campaign=' + response.tagObject.campaign)
.subscribe(campaignResonse => {
this.campaignData = campaignResonse.contentTable.tag;
.subscribe(campaignResponse => {
this.campaignData = campaignResponse.contentTable.tag.slice(0, 10);
callback(response);
})
})
Expand Down Expand Up @@ -193,29 +193,48 @@ export class ReportingService {
parseOther(response) {
this.reportOther = [];


let graphs = {
country: {},
environment: {},
robotDecli: {},
application: {}
}

for (let table of response.statsChart.contentTable.split) {
let percentage = Math.round((table.OK/table.total)*1000)/10
if (!graphs.country[table.country]) graphs.country[table.country] = [];
graphs.country[table.country].push(percentage);
if (!graphs.environment[table.environment]) graphs.environment[table.environment] = [];
graphs.environment[table.environment].push(percentage);
if (!graphs.robotDecli[table.robotDecli]) graphs.robotDecli[table.robotDecli] = [];
graphs.robotDecli[table.robotDecli].push(percentage);
if (!graphs.application[table.application]) graphs.application[table.application] = [];
graphs.application[table.application].push(percentage);
}
console.log('graphs :', graphs);

let tmp = [];
for (let status of this.status) {
tmp.push({
label: status.label,
color: status.color,
data: table[status.label]
})
}
tmp = tmp.filter(a => a.data>0);


for (let graph in graphs) {
let labels = [];
let data = [];
for (let label in graphs[graph]) {
labels.push(label);
let sum = 0;
graphs[graph][label].forEach(element => {
sum+=element;
});
data.push(Math.round((sum/graphs[graph][label].length)*10)/10)
}
let chart = {
data: tmp.map(a => a.data),
data: data,
legend: false,
labels: tmp.map(a => a.label),
colors: [ { backgroundColor: tmp.map(a => a.color) } ],
labels: labels,
// colors: [ { backgroundColor: tmp.map(a => a.color) } ],
options: {
title: {
display: true,
text: table.environment + ' ' + table.country + ' ' + table.robotDecli + ' ' + table.application
text: graph,
},
scales :{
yAxes: [{
Expand All @@ -226,6 +245,44 @@ export class ReportingService {
}
this.reportOther.push(chart);
}






// for (let table of response.statsChart.contentTable.split) {

// let tmp = [];
// for (let status of this.status) {
// tmp.push({
// label: status.label,
// color: status.color,
// data: table[status.label]
// })
// }
// tmp = tmp.filter(a => a.data>0);

// let chart = {
// data: tmp.map(a => a.data),
// legend: false,
// labels: tmp.map(a => a.label),
// colors: [ { backgroundColor: tmp.map(a => a.color) } ],
// options: {
// title: {
// display: true,
// text: table.environment + ' ' + table.country + ' ' + table.robotDecli + ' ' + table.application
// },
// scales :{
// yAxes: [{
// ticks: {display: false}
// }]
// }
// }
// }
// this.reportOther.push(chart);
// }
console.log(this.reportOther);
this.observableReportOther.next(this.reportOther);

}
Expand All @@ -235,22 +292,19 @@ export class ReportingService {
{data: [], label: "Results"},
]
let labels = [];
console.log(this.campaignData);

for (let tag of this.campaignData) {
datasets[0].data.push((tag.nbExeUsefull/tag.nbExe)*100);
datasets[1].data.push((tag.nbOK/tag.nbExe)*100);
datasets[0].data.push((Math.round(tag.nbExeUsefull/tag.nbExe)*100));
datasets[1].data.push(Math.round((tag.nbOK/tag.nbExe)*100));
labels.push(tag.tag);
}
this.reportStatisticsReliability = {
options : {
responsive: true
},
legend: false,
datasets: datasets,
labels: labels
};
console.log("report :", this.reportStatisticsDurationExecution);
this.observableReportStatisticsReliability.next(this.reportStatisticsReliability);
}

Expand All @@ -260,7 +314,6 @@ export class ReportingService {
{data: [], label: "Executions"},
]
let labels = [];
console.log(this.campaignData);

for (let tag of this.campaignData) {
let dateEnd = new Date(tag.DateEndQueue);
Expand All @@ -274,11 +327,9 @@ export class ReportingService {
options : {
responsive: true
},
legend: false,
datasets: datasets,
labels: labels
};
console.log("report :", this.reportStatisticsDurationExecution);
this.observableReportStatisticsDurationExecution.next(this.reportStatisticsDurationExecution);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,48 +33,6 @@ <h3 class="block-title">Report <small>by status</small></h3>
</div>
</div>
</div>
<!-- <div class="form-group">
<div class="input-group push">
<div class="input-group-prepend" ngbPopover="Successful execution"
triggers="mouseenter:mouseleave">
<span class="input-group-text input-group-text-alt ok-bg">OK</span>
</div>
<span class="form-control form-control-alt text-center ok-color" id="numberOK">65<i
class="fa fa-check ok-color ml-2"></i></span>
<div class="input-group-append">
<span class="input-group-text input-group-text-alt text-center ok-color"
id="percentageOK">65%</span>
</div>
</div>
</div>
<div class="form-group">
<div class="input-group push">
<div class="input-group-prepend" ngbPopover="Error in at least one control"
triggers="mouseenter:mouseleave">
<span class="input-group-text input-group-text-alt ko-bg">KO</span>
</div>
<span class="form-control form-control-alt text-center ko-color" id="numberOK">20<i
class="fa fa-times ko-color ml-2"></i></span>
<div class="input-group-append">
<span class="input-group-text input-group-text-alt text-center ko-color"
id="percentageOK">20%</span>
</div>
</div>
</div>
<div class="form-group">
<div class="input-group push">
<div class="input-group-prepend" ngbPopover="Execution couldn't be performed"
triggers="mouseenter:mouseleave">
<span class="input-group-text input-group-text-alt fa-bg">FA</span>
</div>
<span class="form-control form-control-alt text-center fa-color" id="numberOK">12<i
class="fa fa-robot fa-color ml-2"></i></span>
<div class="input-group-append">
<span class="input-group-text input-group-text-alt text-center fa-color"
id="percentageOK">15%</span>
</div>
</div>
</div> -->
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h3 class="block-title">Test Statistics <small>by Duration and Execution</small>
<i class="si" [ngClass]="{'si-arrow-down': !expand, 'si-arrow-up': expand}"></i>
</button>
</div>
<div class="block-content row" *ngIf="expand">
<div class="block-content row" *ngIf="expand && chart.datasets">
<div class="block-content row">
<canvas baseChart
[datasets]="chart.datasets"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h3 class="block-title">Test Statistics <small>by Reliability</small></h3>
<i class="si" [ngClass]="{'si-arrow-down': !expand, 'si-arrow-up': expand}"></i>
</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.labels"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,5 @@ export class StatisticReliabilityComponent implements OnInit {
this.chart = response;
});
}
chartClicked(event) {
console.log("click :", event);

}

}

0 comments on commit f1f7434

Please sign in to comment.