--- /dev/null
+/* Copyright (c) 2019 AT&T Intellectual Property. #\r
+# #\r
+# Licensed under the Apache License, Version 2.0 (the "License"); #\r
+# you may not use this file except in compliance with the License. #\r
+# You may obtain a copy of the License at #\r
+# #\r
+# http://www.apache.org/licenses/LICENSE-2.0 #\r
+# #\r
+# Unless required by applicable law or agreed to in writing, software #\r
+# distributed under the License is distributed on an "AS IS" BASIS, #\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #\r
+# See the License for the specific language governing permissions and #\r
+# limitations under the License. #\r
+##############################################################################*/\r
+\r
+\r
+import { Component, OnInit, ViewChild, HostListener, EventEmitter, OnDestroy } from '@angular/core';\r
+import { routerTransition } from '../../router.animations';\r
+import { MatPaginator, MatDialog } from '@angular/material';\r
+import { ListService } from 'app/shared/services/list.service';\r
+import { TestExecutionService } from 'app/shared/services/test-execution.service';\r
+import { TestDefinitionService } from 'app/shared/services/test-definition.service';\r
+import { SchedulingService } from 'app/shared/services/scheduling.service';\r
+import { Subject, Observable, Subscription } from 'rxjs';\r
+import { UserService } from 'app/shared/services/user.service';\r
+import { FeathersService } from 'app/shared/services/feathers.service';\r
+import { GroupService } from 'app/shared/services/group.service';\r
+import { FilterModalComponent } from '../components/stats/filter-modal/filter-modal.component';\r
+import { StatsService } from '../components/stats/stats.service';\r
+\r
+@Component({\r
+ selector: 'app-dashboard',\r
+ templateUrl: './dashboard.component.pug',\r
+ styleUrls: ['./dashboard.component.scss'],\r
+ animations: [routerTransition()]\r
+})\r
+\r
+export class DashboardComponent implements OnInit, OnDestroy {\r
+\r
+ private toDestroy: Array<Subscription> = [];\r
+\r
+ // Top of the page stats\r
+ public topStats = {\r
+ COMPLETED: 0,\r
+ UNKNOWN: 0,\r
+ FAILURE: 0,\r
+ STOPPED: 0,\r
+ UNAUTHORIZED: 0,\r
+ FAILED: 0\r
+ };\r
+\r
+ public testDefinitionList = null;\r
+ public testExecutions;\r
+ public displayedColumns = ['name', 'result', 'startTime'];\r
+ public displayedScheduleColumns = ['name', 'nextRun'];\r
+ public weekExecutions = 0;\r
+ public weekSchedules = 0;\r
+ public filter = { testResult: '' }; // for dropdown in html\r
+ public group;\r
+\r
+ public eventsSubject: Subject<void>;\r
+\r
+ public TD_selectedTDs = "All";\r
+ public TI_selectedTDs = "All";\r
+ public TI_selectedTIs = "Top 5";\r
+ public sched_selectedTIs = "All";\r
+\r
+ public viewers = [];\r
+\r
+ @ViewChild(MatPaginator) executionsPaginator: MatPaginator;\r
+ @ViewChild(MatPaginator) scheduledPaginator: MatPaginator;\r
+\r
+ constructor(\r
+ private _groups: GroupService,\r
+ private filterModal: MatDialog, \r
+ private stats: StatsService\r
+ ) { }\r
+\r
+ async ngOnInit() {\r
+\r
+ this.stats.getDefaultData(this._groups.getGroup());\r
+ this.toDestroy.push(this._groups.groupChange().subscribe(group => {\r
+ this.stats.getDefaultData(group);\r
+ }));\r
+\r
+ //this.resetData();\r
+\r
+ // this.stats.onTDExecutionChangeFinished().subscribe(res => {\r
+ // this.TD_selectedTDs = "";\r
+ // this.stats.getTDFilters().selected.forEach(item => {\r
+ // this.TD_selectedTDs += (item.viewValue + ", ");\r
+ // })\r
+ // let charLimit = 200;\r
+ // if (this.TD_selectedTDs.length > charLimit) {\r
+ // this.TD_selectedTDs = this.TD_selectedTDs.slice(0, charLimit) + "...";\r
+ // } else this.TD_selectedTDs = this.TD_selectedTDs.slice(0, this.TD_selectedTDs.length - 2);\r
+ // })\r
+\r
+ // this.stats.onTIExecutionChangeFinished().subscribe(res => {\r
+ // let selectedTIs = this.stats.getTIFilters().selectedTIs;\r
+ // let selectedTDs = this.stats.getTIFilters().selectedTDs;\r
+\r
+ // if (selectedTIs.length == 0) this.TI_selectedTIs = "All";\r
+ // else {\r
+ // this.TI_selectedTIs = "";\r
+ // this.stats.getTIFilters().selectedTIs.forEach(item => {\r
+ // this.TI_selectedTIs += (item + ", ");\r
+ // })\r
+ // let charLimit = 200;\r
+ // if (this.TI_selectedTIs.length > charLimit) {\r
+ // this.TI_selectedTIs = this.TI_selectedTIs.slice(0, charLimit) + "...";\r
+ // } else this.TI_selectedTIs = this.TI_selectedTIs.slice(0, this.TI_selectedTIs.length - 2);\r
+ // }\r
+\r
+ // if (selectedTDs.length == 0) this.TI_selectedTDs = "All";\r
+ // else {\r
+ // this.TI_selectedTDs = "";\r
+ // this.stats.getTIFilters().selectedTDs.forEach(item => {\r
+ // this.TI_selectedTDs += (item + ", ");\r
+ // })\r
+ // let charLimit = 200;\r
+ // if (this.TI_selectedTDs.length > charLimit) {\r
+ // this.TI_selectedTDs = this.TI_selectedTDs.slice(0, charLimit) + "...";\r
+ // } else this.TI_selectedTDs = this.TI_selectedTDs.slice(0, this.TI_selectedTDs.length - 2);\r
+ // }\r
+ // })\r
+\r
+ // this.stats.onScheduleChangeFinished().subscribe(res => {\r
+ // let selectedTIs = this.stats.scheduledTests.map(el => el.name);\r
+ // //console.log(selectedTIs);\r
+ // if (selectedTIs.length == 0) this.sched_selectedTIs = "All";\r
+ // else {\r
+ // this.sched_selectedTIs = "";\r
+ // this.stats.scheduledTests.map(el => el.name).forEach(item => {\r
+ // this.sched_selectedTIs += (item + ", ");\r
+ // })\r
+ // let charLimit = 200;\r
+ // if (this.sched_selectedTIs.length > charLimit) {\r
+ // this.sched_selectedTIs = this.sched_selectedTIs.slice(0, charLimit) + "...";\r
+ // } else this.sched_selectedTIs = this.sched_selectedTIs.slice(0, this.sched_selectedTIs.length - 2);\r
+ // }\r
+ // })\r
+ }\r
+\r
+ ngOnDestroy(){\r
+ this.toDestroy.forEach(elem => {\r
+ elem.unsubscribe();\r
+ });\r
+ }\r
+\r
+ openFilterModal() {\r
+ let open = this.filterModal.open(FilterModalComponent, {\r
+ width: '50%',\r
+ height: '60%',\r
+ disableClose: true\r
+ })\r
+\r
+ open.afterClosed().subscribe(res => {\r
+ this.ngOnInit();\r
+ })\r
+ }\r
+\r
+ resetData() {\r
+ //console.log("resetting");\r
+ this.TD_selectedTDs = "All";\r
+ this.TI_selectedTDs = "All";\r
+ this.TI_selectedTIs = "Top 5";\r
+ this.sched_selectedTIs = "All";\r
+ this.stats.getDefaultData(this._groups.getGroup());\r
+ }\r
+\r
+}\r
+\r