diff --git a/src/app/components/logs-dashboard/logs-home/logs-home.component.html b/src/app/components/logs-dashboard/logs-home/logs-home.component.html index 49a5233dbd209efc509c7ba4b850f72b8fd23d4f..e7e0702bd2d2f9bbffe89b2be292e19d41ab2ac2 100644 --- a/src/app/components/logs-dashboard/logs-home/logs-home.component.html +++ b/src/app/components/logs-dashboard/logs-home/logs-home.component.html @@ -18,7 +18,7 @@ <div class="column is-2 has-text-left"> <label class="label"> </label> - <a class="button button-gl" (click)="uuidDetector(slug)"> + <a class="button button-gl" (click)="trimAndNavigate(slug, sessionId)"> <i class="fas fa-search"></i> </a> </div> diff --git a/src/app/components/logs-dashboard/logs-home/logs-home.component.ts b/src/app/components/logs-dashboard/logs-home/logs-home.component.ts index 1010d6ae12eaf289b6dda60764ce6de02ecafe13..6a9eade6ed3a3795b3e0b785552869ab1e3bcd99 100644 --- a/src/app/components/logs-dashboard/logs-home/logs-home.component.ts +++ b/src/app/components/logs-dashboard/logs-home/logs-home.component.ts @@ -81,21 +81,68 @@ export class LogsHomeComponent implements OnInit { } } - uuidDetector(testInput) { - const trimmedTestInput = testInput.trim(); + trimAndNavigate(slugOrUuid, sessionId) { + const trimmedSlugOrUuid = slugOrUuid.trim(); + this.sessionId = sessionId.trim(); + this.uuidDetectorAndNavigate(trimmedSlugOrUuid); + } + + uuidDetectorAndNavigate(slugOrUuid) { const regexp = new RegExp('^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'); - this.isUuid = regexp.test(trimmedTestInput); + this.isUuid = regexp.test(slugOrUuid); if (this.isUuid) { - this.convertUuidToSlugAndNavigate(trimmedTestInput); + this.convertUuidToSlugAndNavigate(slugOrUuid); } else { - this._router.navigate([this._route, 'report', trimmedTestInput, this.sessionId, 'home']); + this.mightyGeneralRouter(slugOrUuid, this.sessionId); } } convertUuidToSlugAndNavigate(uuidInput) { this._dataLogsService.getSlugFromUuid(uuidInput).subscribe((result) => { - this._router.navigate([this._route, 'report', result, this.sessionId, 'home']); + this.slug = result; + this.mightyGeneralRouter(this.slug, this.sessionId); }, ); } + + mightyGeneralRouter(slug, sessionId) { + let slugUuidIsEmpty = true; + let sessionIdIsEmpty = true; + + if (slug !== '') { + slugUuidIsEmpty = false; + } + if (sessionId !== '') { + sessionIdIsEmpty = false; + } + + if (slugUuidIsEmpty && !sessionIdIsEmpty) { + this.goToSessionPage(sessionId); + } + if (!slugUuidIsEmpty && sessionIdIsEmpty) { + this.goToSlugPage(slug); + } + if (slugUuidIsEmpty && sessionIdIsEmpty) { + return; + } + if (!slugUuidIsEmpty && !sessionIdIsEmpty) { + this.goToFinalReportPage(slug, sessionId); + } + + } + + goToSessionPage(sessionId) { + this._router.navigate([this._route, 'preReport', 'session', sessionId]); + + } + + goToSlugPage(slug) { + this._router.navigate([this._route, 'preReport', 'slug', slug]); + + } + + goToFinalReportPage (slug, sessionId) { + this._router.navigate([this._route, 'report', slug, sessionId, 'home']); + } + } diff --git a/src/app/components/logs-dashboard/logs-sessions/logs-sessions.component.ts b/src/app/components/logs-dashboard/logs-sessions/logs-sessions.component.ts index 87442db8fa54d7babb37397841264d3b2685959d..6f1d99072f23157c68822011bfc477a1d949f4bb 100644 --- a/src/app/components/logs-dashboard/logs-sessions/logs-sessions.component.ts +++ b/src/app/components/logs-dashboard/logs-sessions/logs-sessions.component.ts @@ -68,16 +68,20 @@ export class LogsSessionsComponent implements OnChanges { getAllInfoForOneSession($event) { // const foundSlug = (<HTMLInputElement>document.getElementById('foundSlug')).value; - this._dataLogsService.getAllInfoForOneSession(this.foundSession).subscribe((result) => { - console.log('result for getAllInfoForOneSlug', result); - this.allSessionsInfoList = result; - this.nbSessions = result.length; - this.paginator.limit = this._dataLogsService.limit; - this.paginator.pageIndex = this._dataLogsService.pageNumber; - this.paginator.length = this.childNbSessions; - this.formatDate(); - }, - ); + if (this.foundSession === '') { + this.getAllSessionsInfo(this.childNbSessions, 1); + } else { + this._dataLogsService.getAllInfoForOneSession(this.foundSession).subscribe((result) => { + console.log('result for getAllInfoForOneSlug', result); + this.allSessionsInfoList = result; + this.nbSessions = result.length; + this.paginator.limit = this._dataLogsService.limit; + this.paginator.pageIndex = this._dataLogsService.pageNumber; + this.paginator.length = this.childNbSessions; + this.formatDate(); + }, + ); + } } formatDate() { diff --git a/src/app/components/logs-dashboard/logs-slugs/logs-slugs.component.ts b/src/app/components/logs-dashboard/logs-slugs/logs-slugs.component.ts index a723acf21605dcbd8aabbade84b415f5bfa886c5..1901bbb8bbf8c28495afded16cfbb91b30e14830 100644 --- a/src/app/components/logs-dashboard/logs-slugs/logs-slugs.component.ts +++ b/src/app/components/logs-dashboard/logs-slugs/logs-slugs.component.ts @@ -68,16 +68,20 @@ export class LogsSlugsComponent implements OnChanges { } getAllInfoForOneSlug($event) { + if (this.foundSlug === '') { + this.getAllInfoForAllSlugs(this.childNbSlugs, 1); + } else { // const foundSlug = (<HTMLInputElement>document.getElementById('foundSlug')).value; - this._dataLogsService.getAllInfoForOneSlug(this.foundSlug).subscribe((result) => { - this.allSlugsInfoList = result; - this.slugInOnePage = result.length; - this.paginator.limit = this._dataLogsService.limit; - this.paginator.pageIndex = this._dataLogsService.pageNumber; - this.paginator.length = this.childNbSlugs; - this.formatDate(); - }, + this._dataLogsService.getAllInfoForOneSlug(this.foundSlug).subscribe((result) => { + this.allSlugsInfoList = result; + this.slugInOnePage = result.length; + this.paginator.limit = this._dataLogsService.limit; + this.paginator.pageIndex = this._dataLogsService.pageNumber; + this.paginator.length = this.childNbSlugs; + this.formatDate(); + }, ); + } } formatDate() { 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 f38022746a768151c79904bfd309e4b62160b4c0..9d9aae0efc0254c520b0545c5d20d0adf0b1e518 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 @@ -5,8 +5,9 @@ <div class="section"> <div class="columns is-left is-marginless"> <div class="column has-text-left"> - <span>{{nbObjects}} sessions(s) found for the slug : </span> + <span>{{nbObjects}} sessions(s) found for the slug </span> <span class="bold-text">{{id}}</span> + <span class="italic-text"> : ( {{uuid}} ) </span> </div> </div> diff --git a/src/app/components/logs-dashboard/report/logs-pre-report/logs-pre-report.component.scss b/src/app/components/logs-dashboard/report/logs-pre-report/logs-pre-report.component.scss index 91a597bb399dbba7bb8dbcea2fa25645674cb756..aaa6c7250fd49a1fdb867a75fa5d537b47935d87 100644 --- a/src/app/components/logs-dashboard/report/logs-pre-report/logs-pre-report.component.scss +++ b/src/app/components/logs-dashboard/report/logs-pre-report/logs-pre-report.component.scss @@ -31,4 +31,8 @@ h1 { .bold-text { font-weight:bold; display:inline; +} +.italic-text { + font-weight:italic; + display:inline; } \ No newline at end of file diff --git a/src/app/components/logs-dashboard/report/logs-pre-report/logs-pre-report.component.ts b/src/app/components/logs-dashboard/report/logs-pre-report/logs-pre-report.component.ts index 71428fe69f033dc753ff3a723119e568666a1ad8..22dbfbbf1eebcefccda63f84353a8c7c67fdc893 100644 --- a/src/app/components/logs-dashboard/report/logs-pre-report/logs-pre-report.component.ts +++ b/src/app/components/logs-dashboard/report/logs-pre-report/logs-pre-report.component.ts @@ -20,6 +20,7 @@ export class LogsPreReportComponent implements OnInit { prereportChangeSub: Subscription; responseArray: any = []; form: FormGroup; + uuid: any = ''; title: string; type: string; id: string; @@ -123,6 +124,7 @@ export class LogsPreReportComponent implements OnInit { } else { this.nbObjects = response[0].session_id_list.length; this.paginator.length = response[0].session_id_list.length; + this.getUuidFromSlug(this.id); this.completeSessionsInfos(this.id, response[0].session_id_list.slice(0, this.paginator.limit)); } }); @@ -146,6 +148,13 @@ export class LogsPreReportComponent implements OnInit { } } + getUuidFromSlug(slug) { + this._dataLogsService.getUuidFromSlug(slug).subscribe((result) => { + console.log('uuid result:', result[0]['uuid_list'][0]); + this.uuid = result[0]['uuid_list'][0]; + }, + ); + } changePageSize(pageSize) { this.paginator.pageIndex = 1; this.paginator.limit = pageSize; 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 49dd0cadd7122de8d26cf71d4879715f3bd8e68e..f3cb8ae7272156aa89a59965b6652d935e7c6cbb 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 @@ -14,7 +14,7 @@ <h2>{{errorMessage}}</h2> </div> - <app-logs-graph [hidden]="!isToggled" [childUuid]="uuid" [childSessionId]="sessionId" [childSlug]="slug"> + <app-logs-graph [hidden]="!isToggled || errorMessage!='' " [childUuid]="uuid" [childSessionId]="sessionId" [childSlug]="slug"> </app-logs-graph> <app-logs-info [hidden]="isToggled||isToggled==undefined" [childUuid]="uuid" [childSessionId]="sessionId" [childSlug]="slug"></app-logs-info>