diff --git a/src/app/components/logs-dashboard/report/logs-data/logs-data.component.html b/src/app/components/logs-dashboard/report/logs-data/logs-data.component.html index 81f05555e1d273b9ca689d04eb8f7b54a042bbc2..aa1a22323c3357a2263029d6bba67e998ea0732c 100644 --- a/src/app/components/logs-dashboard/report/logs-data/logs-data.component.html +++ b/src/app/components/logs-dashboard/report/logs-data/logs-data.component.html @@ -1,77 +1,8 @@ <div class="section"> <div class="columns is-centered is-marginless"> - <div class="input-field"> - <form> - <label> Slug/Uuid: </label> - <input type="text" size="40" name="uuid" [(ngModel)]="uuid"> - <!-- <br> --> - <label> SessionId: </label> - <input type="text" size="40" name="sessionId" [(ngModel)]="sessionId"> - <!-- <label> Slug: </label> - <input type="text" size="20" name="slug" [(ngModel)]="slug"> --> - <a class="button button-gl is-centered" (click)="onSubmit()"> - <i class="fas fa-search"></i> - </a> - </form> - <br> - - - <a class="button button-gl is-centered" (click)="tabsToggler(true)"> - Slugs - </a> - <a class="button button-gl is-centered" (click)="tabsToggler(false)"> - Sessions - </a> - - </div> - </div> - <!-- <div class="columns is-centered is-marginless"> - <div class="column has-text-centered"> - <h2>{{ nbSessionId }} sessionId trouvées</h2> - <div *ngFor="let s of allFields.session_id_list"> - <p>{{s}} </p> - </div> - - <h2>{{ nbSlug }} slugs trouvées</h2> - <div *ngFor="let slg of allFields.slug_list"> - <p>{{slg}} </p> - </div> - <h2>{{ nbUuid }} uuid trouvées</h2> - <div *ngFor="let ul of allFields.uuid_list"> - <p>{{ul}} </p> - </div> - - </div> - </div> --> - <div class="columns is-centered is-marginless"> - <div class="column has-text-centered is-marginless"> - <app-logs-sessions [hidden]="isToggled" [childSessionId]="sessionId" [childNbSessions]="nbSessionId"> - </app-logs-sessions> - <app-logs-slugs [hidden]="!isToggled" [childSlugsList]="allFields.slug_list" [childNbSlugs]="nbSlug" - [childNbUuids]="nbUuid"></app-logs-slugs> - </div> - </div> - <div class="columns is-centered is-marginless" [ngClass]="{'hidden': !isDashboardDisplayed}"> - <div class="column has-text-centered" > - <div *ngFor="let a of [data]"> - <hr> - <span> - <h3> - uuid: {{a.uuid}} - </h3> - <p>|</p> - <p>V</p> - session_id list: - <div *ngFor="let s of a.sessionIdList"> - {{s}} - </div> - </span> - </div> - </div> - <div class="column has-text-left"> <div *ngFor="let oneStepData of allStepsData"> - <div class="mini-log-card"> + <div class="mini-log-card" *ngIf="oneStepData"> <span> <p>slug: {{oneStepData._id.slug}} </p> <p>uuid: {{oneStepData._id.uuid}} </p> @@ -81,13 +12,9 @@ <p>total-time: {{oneStepData.totalHoursSpent}}h : {{oneStepData.totalMinutesSpent}}m : {{oneStepData.totalSecondsSpent}}s </p> </h3> - </span> </div> </div> - </div> - </div> - <app-logs-graph [childUuid]="uuid" [childSessionId]="sessionId" [childSlug]="slug"></app-logs-graph> \ No newline at end of file diff --git a/src/app/components/logs-dashboard/report/logs-data/logs-data.component.ts b/src/app/components/logs-dashboard/report/logs-data/logs-data.component.ts index d230e4b5466d9efeea4b2ccae888594482ae1601..2effd05c2177e03ba77dfacb4844103336c0aafa 100644 --- a/src/app/components/logs-dashboard/report/logs-data/logs-data.component.ts +++ b/src/app/components/logs-dashboard/report/logs-data/logs-data.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnChanges, SimpleChanges, Input } from '@angular/core'; import { DataLogsService } from 'src/app/services/data-logs.service'; import { ActivatedRoute, ParamMap } from '@angular/router'; import { switchMap } from 'rxjs/operators'; @@ -10,10 +10,12 @@ import { FormsModule } from '@angular/forms'; templateUrl: './logs-data.component.html', styleUrls: ['./logs-data.component.scss'], }) -export class LogsDataComponent implements OnInit { +export class LogsDataComponent implements OnChanges { + @Input() childUuid: string = ''; + @Input() childSessionId: string = ''; + @Input() childSlug: string; isDashboardDisplayed: boolean = false; uuid: string; - allFields: any; sessionId: string; slug: string; data: any; @@ -22,7 +24,6 @@ export class LogsDataComponent implements OnInit { nbSessionId: number; nbUuid: number; nbSlug: number; - isToggled: boolean; sessionIdList: [string]; constructor( @@ -30,50 +31,27 @@ export class LogsDataComponent implements OnInit { private route: ActivatedRoute, ) { } - ngOnInit() { - this.isToggled = true; + ngOnChanges(changes: SimpleChanges): void { this.data = []; - this.uuid = 'c1b069ca-181d-4265-9838-8d182f207bd3'; - this.sessionId = '372b59a4-72b0-4a3a-b518-843e516da0cd'; - this.slug = 'not implemented yet'; + this.slug = this.childSlug; this.allStepsData = []; - this.allFields = []; - this.getAllUniqueFields(); - + this.getLogsSteps(); } - onSubmit() { - this.isDashboardDisplayed = true; - this.isToggled = false; - this.dataLogsService.uuidToSessionId(this.uuid) - .subscribe((result) => { - this.data.uuid = result[0]._id.uuid; - this.data.sessionIdList = result[0].session_id_list; - }, - ); - this.dataLogsService.getAllStepsDuration( - this.uuid, - this.sessionId, - ).subscribe((results) => { - console.log('results', results); - this.allStepsData = results; - }, - ); - } + getLogsSteps() { + if ((this.childUuid != null) && (this.childSessionId != null)) { + console.log('parameters', this.childUuid, this.childSessionId); - getAllUniqueFields() { - this.dataLogsService.getAllUniqueFields().subscribe((result) => { - this.allFields = result[0]; - this.nbSessionId = result[0]['session_id_list'].length; - this.nbUuid = result[0]['uuid_list'].length; - this.nbSlug = result[0]['slug_list'].length; + this.dataLogsService.getAllStepsDuration( + this.childUuid, + this.childSessionId, + ).subscribe((results) => { + console.log('results', results); + this.allStepsData = results; + }, + ); + } - }, - ); - } - tabsToggler(oneBoolean) { - this.isToggled = oneBoolean; - this.isDashboardDisplayed = false; } } diff --git a/src/app/components/logs-dashboard/report/logs-graph/logs-graph.component.ts b/src/app/components/logs-dashboard/report/logs-graph/logs-graph.component.ts index 1415e940f7221bdaae360624c0d409c693203da7..4bec41da2a8732b8b6baf6f24abd112aee393304 100644 --- a/src/app/components/logs-dashboard/report/logs-graph/logs-graph.component.ts +++ b/src/app/components/logs-dashboard/report/logs-graph/logs-graph.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, Input } from '@angular/core'; +import { Component, OnChanges, SimpleChanges, Input } from '@angular/core'; import { Chart } from 'chart.js'; import { DataLogsService } from 'src/app/services/data-logs.service'; import { ActivatedRoute, ParamMap } from '@angular/router'; @@ -11,7 +11,7 @@ import { FormsModule } from '@angular/forms'; templateUrl: './logs-graph.component.html', styleUrls: ['./logs-graph.component.scss'], }) -export class LogsGraphComponent implements OnInit { +export class LogsGraphComponent implements OnChanges { @Input() childUuid: string; @Input() childSessionId: string; @Input() childSlug: string; @@ -27,15 +27,14 @@ export class LogsGraphComponent implements OnInit { constructor( private dataLogsService: DataLogsService, ) { } - - ngOnInit() { + ngOnChanges(changes: SimpleChanges): void { this.graphData = [0.2, 0.3]; this.xValues = []; this.yValues = []; this.dataset = []; - this.getData(); - // this.myChart.update(); - + if ((this.childUuid != null) && (this.childSessionId != null)) { + this.getData(); + } } plotGraph() { @@ -112,7 +111,6 @@ export class LogsGraphComponent implements OnInit { } } replotGraph() { - // this.myChart.destroy(); this.getData(); this.myChart.update(); } diff --git a/src/app/components/logs-dashboard/report/logs-pre-report/logs-pre-report.component.html b/src/app/components/logs-dashboard/report/logs-pre-report/logs-pre-report.component.html index 7afe83a47bafc24c9397ff932111e8e59513de69..9b5e557de4614bc8f67f6fa7e76ab4c3e08d3b78 100644 --- a/src/app/components/logs-dashboard/report/logs-pre-report/logs-pre-report.component.html +++ b/src/app/components/logs-dashboard/report/logs-pre-report/logs-pre-report.component.html @@ -38,7 +38,7 @@ </div> <div class="data-list"> <div class="data columns is-multiline is-vcentered is-marginless" - *ngFor="let session of responseArray.session_id_list; let i=index;"> + *ngFor="let session of responseArray.session_id_list; let i=index; let odd=odd; let even=even;" [ngClass]="{ odd: odd, even: even }"> <div class="column is-4 has-text-left"> {{ session }} </div> @@ -116,7 +116,7 @@ <span class="column-title"></span> </div> </div> - <div class="data-list" *ngFor="let slug of responseArray.slug_list; let i=index;"> + <div class="data-list" *ngFor="let slug of responseArray.slug_list; let i=index;let odd=odd; let even=even;" [ngClass]="{ odd: odd, even: even }"> <div class="data columns is-multiline is-vcentered is-marginless" *ngIf="slug"> <div class="column is-4 has-text-centered"> {{ slug }} diff --git a/src/app/components/logs-dashboard/report/logs-report/logs-report.component.html b/src/app/components/logs-dashboard/report/logs-report/logs-report.component.html index c0a0136f01e5656d30f62688e130ba663ec9e51c..87db07de688349cf66880686032a3a4c0f8981ce 100644 --- a/src/app/components/logs-dashboard/report/logs-report/logs-report.component.html +++ b/src/app/components/logs-dashboard/report/logs-report/logs-report.component.html @@ -7,5 +7,6 @@ <app-logs-graph [childUuid]="uuid" [childSessionId]="sessionId" [childSlug]="slug"></app-logs-graph> + <app-logs-data [childUuid]="uuid" [childSessionId]="sessionId" [childSlug]="slug"></app-logs-data> </div> </ng-container> \ No newline at end of file diff --git a/src/app/components/logs-dashboard/report/logs-report/logs-report.component.ts b/src/app/components/logs-dashboard/report/logs-report/logs-report.component.ts index 4253a25db94b114fd3d54f6d9ff0cb1fbc35f788..7579d9892a7e9bfb81130c997aca31db228fecd6 100644 --- a/src/app/components/logs-dashboard/report/logs-report/logs-report.component.ts +++ b/src/app/components/logs-dashboard/report/logs-report/logs-report.component.ts @@ -38,33 +38,14 @@ export class LogsReportComponent implements OnInit { this.slug = this._route.snapshot.paramMap.get('slug'); this.urlCode = this._route.snapshot.paramMap.get('urlCode'); if (this.urlCode === 'session') { - this.previousUrl = '/datalogs/preReport/session/' + this.sessionId; + this.previousUrl = `/datalogs/preReport/session/${this.sessionId}`; } else if (this.urlCode === 'slug') { - this.previousUrl = '/datalogs/preReport/slug/' + this.slug; + this.previousUrl = `/datalogs/preReport/slug/${this.slug}`; } else { this.previousUrl = '/datalogs'; } this.getUuidFromSlug(this.slug); - - // this._route.paramMap.pipe( - // filter((paramMap: ParamMap) => (paramMap.get('id') !== null)), - // filter((paramMap: ParamMap) => (paramMap.get('type') !== null)), - // switchMap((paramMap: ParamMap) => this._dataLogsService.getComplementaryFromSlugOrSession( - // paramMap.get('type'), - // paramMap.get('id')))) - // .subscribe((response) => { - - // this.responseArray = response[0]; - // if (this.type === 'session') { - // this.nbObjects = response[0].slug_list.length; - // } else { - // this.nbObjects = response[0].session_id_list.length; - // } - // console.log('responseArray: ', this.responseArray); - // console.log('nbObjects: ', this.nbObjects); - - // }); } getUuidFromSlug(slug) {