Skip to content

Commit

Permalink
#12 Rework all pages and add label block
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony-Jhoiro committed Aug 27, 2019
1 parent 70e81c6 commit 182fdc7
Show file tree
Hide file tree
Showing 16 changed files with 343 additions and 214 deletions.
169 changes: 113 additions & 56 deletions src/app/core/services/crud/reporting.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class ReportingService {
private tagDetail = {};
private reportStatus = { status: [], total: 0 };
private reportTestFolder = {};
private reportLabel = {};
private reportLabel = [];
private reportOther = [];
private reportStatisticsReliability = {};
private reportStatisticsDurationExecution = {};
Expand Down Expand Up @@ -76,7 +76,7 @@ export class ReportingService {
// variables
private tagsList: Array<ITag>;
// observables
observableTagsList = new BehaviorSubject<ITag[]>(this.tagsList);
private observableTagsList = new BehaviorSubject<ITag[]>(this.tagsList);

private colors = [
'#0665d0',
Expand All @@ -91,6 +91,9 @@ export class ReportingService {

constructor(private http: HttpClient) { }

/** getTagList
* * call the api to get the tag list
*/
getTagList() {
this.http.get<ITag[]>(environment.cerberus_api_url + '/ReadTag?iSortCol_0=0&sSortDir_0=desc&sColumns=id,tag,campaign,description')
.subscribe(response => {
Expand All @@ -99,18 +102,31 @@ export class ReportingService {
this.observableTagsList.next(this.tagsList);
})
}
ReadTestCaseExecutionByTag(callback: (any) => any) {
//TODO : Specified type

/** ReadTestCaseExecutionByTag
* * call the api to get tag informations then get campaign informations.
* @param callback function to execute with the tag information as parameter
*/
ReadTestCaseExecutionByTag(callback: (any) => any) {
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(campaignResponse => {
this.campaignData = campaignResponse.contentTable.tag.slice(0, 10);
if(campaignResponse.contentTable) {
this.campaignData = campaignResponse.contentTable.tag.slice(0, 10);
} else {
this.campaignData = [];
}
callback(response);
})
})
}

/** getTestCaseExecutionByTag
* * call `ReadTestCaseExecutionByTag`
* * parse the result to the graphs
* @param tag
*/
getTestCaseExecutionByTag(tag: string) {
this.selectedTagName = tag;
this.ReadTestCaseExecutionByTag(response => {
Expand All @@ -119,20 +135,34 @@ export class ReportingService {
this.parseReportTestFolder(response);
this.parseReportLabel(response);
this.parseOther(response);
this.parseStatisticDuration(response);
this.parseStatisticReliability(response);
this.parseStatisticDuration();
this.parseStatisticReliability();
});
}

/** tagExists
* * test if the tag exist
* @param tag the tag to test
* @returns true if the tag exist
*/
tagExists(tag: string) {
if (tag != null) { return this.tagsList.filter(t => t.tag === tag).length > 0; }
else { return false; }
}

/** findTag
* find a tag by his name
* @param tag the name of the tag
* @returns the tag
*/
findTag(tag: string): ITag {
return this.tagsList.find(t => t.tag === tag);
}

/** parseTagDetail
* * parse the response for the tag detail block
* @param response the response to parse
*/
parseTagDetail(response) {
this.tagDetail = {
start: response.functionChart.globalStart.split(' CEST')[0],
Expand All @@ -145,6 +175,11 @@ export class ReportingService {
}
this.observableTagDetail.next(this.tagDetail);
}

/** parseReportStatus
* * parse the response for the report by status graph
* @param response the response to parse
*/
parseReportStatus(response) {
this.reportStatus = {
total: 0,
Expand All @@ -161,6 +196,11 @@ export class ReportingService {
this.reportStatus.total = response.tagObject.nbExeUsefull;
this.observableReportStatus.next(this.reportStatus)
}

/** parseReportTestFolder
* * parse the response for the Report by Test Folder graph
* @param response the response to parse
*/
parseReportTestFolder(response) {
let labelList = [];
let datasets = [];
Expand All @@ -179,7 +219,6 @@ export class ReportingService {
if (temp.data.some(number => number != 0)) datasets.push(temp);
}


this.reportTestFolder = {
datasets: datasets,
label: labelList,
Expand All @@ -198,9 +237,57 @@ export class ReportingService {
}
this.observableReportTestFolder.next(this.reportTestFolder);
}
parseReportLabel(response) {
// TODO

/** getValuesFromLabelStats
* @returns percentage for all stat
* @param stats the stats to return
*/
getValuesFromLabelStats(stats) {
return {
KO: Math.round((stats.nbKO/stats.nbElementWithChild)*100),
OK: Math.round((stats.nbOK/stats.nbElementWithChild)*100),
FA: Math.round((stats.nbFA/stats.nbElementWithChild)*100),
NA: Math.round((stats.nbNA/stats.nbElementWithChild)*100),
NE: Math.round((stats.nbNE/stats.nbElementWithChild)*100),
CA: Math.round((stats.nbCA/stats.nbElementWithChild)*100) }
}

/** getValuesFromLabelStats
* * parse the response for the Report by Label graph
* @param stats the response to parse
*/
parseReportLabel(response) {

this.reportLabel = [];

for (let node of response.labelStat.labelTreeREQUIREMENT.concat(response.labelStat.labelTreeSTICKER)) {
if(node.counter1WithChild!=0) this.reportLabel.push(this.parseLabelChildren(node));
}
this.observableReportLabel.next(this.reportLabel);

}

/** parseLabelChildren
* * parse children nodes
* * RECURSIVE
* @param label
*/
parseLabelChildren(label) {
if (label.nodes) {
let children = [];
for (let node of label.nodes) {
if(node.counter1WithChild!=0) children.push(this.parseLabelChildren(node))
}
return { label: { value: label.label.label, color: label.label.color }, values: this.getValuesFromLabelStats(label.stats), children: children };
} else {
return { label: { value: label.label.label, color: label.label.color }, values: this.getValuesFromLabelStats(label.stats) };
}
}

/** parseOther
* * parse the response for the polar graphs
* @param response the response to parse
*/
parseOther(response) {
this.reportOther = [];

Expand All @@ -222,9 +309,6 @@ export class ReportingService {
if (!graphs.Applications[table.application]) graphs.Applications[table.application] = [];
graphs.Applications[table.application].push(percentage);
}
console.log('graphs :', graphs);



for (let graph in graphs) {
let labels = [];
Expand All @@ -239,6 +323,7 @@ export class ReportingService {
if (sum>0) display = true;
data.push(Math.round((sum / graphs[graph][label].length) * 10) / 10)
}
if(data.length <=1) display = false
let chart = {
display: display,
name: graph,
Expand All @@ -261,53 +346,19 @@ 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);

}
parseStatisticReliability(response) {

/** parseStatisticReliability
* * parse campaign data for the statistic by duration and execution graph
*/
parseStatisticReliability() {
let datasets = [
{ data: [], label: "Reliability", type: 'line' },
{ data: [], label: "Results" },
]
let labels = [];
let display = (this.campaignData.length>0)? true:false;

for (let tag of this.campaignData) {
datasets[0].data.push((Math.round(tag.nbExeUsefull / tag.nbExe) * 100));
Expand All @@ -319,17 +370,22 @@ export class ReportingService {
responsive: true
},
datasets: datasets,
labels: labels
labels: labels,
display: display
};
this.observableReportStatisticsReliability.next(this.reportStatisticsReliability);
}

parseStatisticDuration(response) {
/** parseStatisticDuration
* * parse campaign data for the statistic by reliability
*/
parseStatisticDuration() {
let datasets = [
{ data: [], label: "Duration", type: 'line' },
{ data: [], label: "Executions" },
]
let labels = [];
let display = (this.campaignData.length>0)? true:false;

for (let tag of this.campaignData) {
let dateEnd = new Date(tag.DateEndQueue);
Expand All @@ -344,7 +400,8 @@ export class ReportingService {
responsive: true
},
datasets: datasets,
labels: labels
labels: labels,
display: display
};
this.observableReportStatisticsDurationExecution.next(this.reportStatisticsDurationExecution);
}
Expand Down
4 changes: 3 additions & 1 deletion src/app/feat-analyse/analyse.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { TagDetailComponent } from './reportbytag/tag-detail/tag-detail.componen
import { TagSelectionComponent } from './reportbytag/tag-selection/tag-selection.component';
import { StatisticDurationComponent } from './reportbytag/graph/statistic-duration/statistic-duration.component';
import { StatisticReliabilityComponent } from './reportbytag/graph/statistic-reliability/statistic-reliability.component';
import { LabelProgressComponent } from './reportbytag/graph/reportby-label/label-progress/label-progress.component';

@NgModule({
declarations: [
Expand All @@ -32,7 +33,8 @@ import { StatisticReliabilityComponent } from './reportbytag/graph/statistic-rel
TagDetailComponent,
TagSelectionComponent,
StatisticDurationComponent,
StatisticReliabilityComponent
StatisticReliabilityComponent,
LabelProgressComponent
],
imports: [
CommonModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<div class="dd-handle" (click)="toggleChildren(label)">
<i class="fa fa-folder text-warning mr-1"></i> <span class="badge badge-primary"
[style.backgroundColor]="label.label.color"> {{label.label.value}}</span> <i *ngIf="label.children" class="si"
[ngClass]="{'si-arrow-right': label.expand, 'si-arrow-down': !label.expand}"></i>
</div>
<div class="progress">
<div class="progress-bar bg-succes" role="progressbar" [style.width]="label.values.OK+'%'"
[attr.aria-valuenow]="label.values.OK" aria-valuemin="0" aria-valuemax="100"></div>
<div class="progress-bar bg-danger" role="progressbar" [style.width]="label.values.KO+'%'"
[attr.aria-valuenow]="label.values.KO" aria-valuemin="0" aria-valuemax="100"></div>
<div class="progress-bar bg-warning" role="progressbar" [style.width]="label.values.FA+'%'"
[attr.aria-valuenow]="label.values.FA" aria-valuemin="0" aria-valuemax="100"></div>
<div class="progress-bar bg-warning" role="progressbar" [style.width]="label.values.NA+'%'"
[attr.aria-valuenow]="label.values.NA" aria-valuemin="0" aria-valuemax="100"></div>
<div class="progress-bar bg-info" role="progressbar" [style.width]="label.values.NE+'%'"
[attr.aria-valuenow]="label.values.NE" aria-valuemin="0" aria-valuemax="100"></div>
<div class="progress-bar bg-secondary" role="progressbar" [style.width]="label.values.CA+'%'"
[attr.aria-valuenow]="label.values.CA" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<ol class="dd-list" *ngIf="label.children && label.expand">
<li class="dd-item" data-id="23" *ngFor="let childLabel of label.children">
<app-label-progress [label]="childLabel"></app-label-progress>
</li>
</ol>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { LabelProgressComponent } from './label-progress.component';

describe('LabelProgressComponent', () => {
let component: LabelProgressComponent;
let fixture: ComponentFixture<LabelProgressComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ LabelProgressComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(LabelProgressComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Component, OnInit, Input } from '@angular/core';

@Component({
selector: 'app-label-progress',
templateUrl: './label-progress.component.html',
styleUrls: ['./label-progress.component.scss']
})
export class LabelProgressComponent implements OnInit {
@Input() label: any;

constructor() { }

ngOnInit() {
}

/** toggleChildren
* * open are collapse selected parent label
* @param label label to toggle
*/
toggleChildren(label) {
label.expand = !((label.expand)? true : false);
}

}
Loading

0 comments on commit 182fdc7

Please sign in to comment.