1 /* Copyright (c) 2019 AT&T Intellectual Property. #
\r
3 # Licensed under the Apache License, Version 2.0 (the "License"); #
\r
4 # you may not use this file except in compliance with the License. #
\r
5 # You may obtain a copy of the License at #
\r
7 # http://www.apache.org/licenses/LICENSE-2.0 #
\r
9 # Unless required by applicable law or agreed to in writing, software #
\r
10 # distributed under the License is distributed on an "AS IS" BASIS, #
\r
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
\r
12 # See the License for the specific language governing permissions and #
\r
13 # limitations under the License. #
\r
14 ##############################################################################*/
\r
17 import { Component, OnInit, ViewChild, HostListener, EventEmitter, OnDestroy } from '@angular/core';
\r
18 import { routerTransition } from '../../router.animations';
\r
19 import { MatPaginator, MatDialog } from '@angular/material';
\r
20 import { ListService } from 'app/shared/services/list.service';
\r
21 import { TestExecutionService } from 'app/shared/services/test-execution.service';
\r
22 import { TestDefinitionService } from 'app/shared/services/test-definition.service';
\r
23 import { SchedulingService } from 'app/shared/services/scheduling.service';
\r
24 import { Subject, Observable, Subscription } from 'rxjs';
\r
25 import { UserService } from 'app/shared/services/user.service';
\r
26 import { FeathersService } from 'app/shared/services/feathers.service';
\r
27 import { GroupService } from 'app/shared/services/group.service';
\r
28 import { FilterModalComponent } from '../components/stats/filter-modal/filter-modal.component';
\r
29 import { StatsService } from '../components/stats/stats.service';
\r
32 selector: 'app-dashboard',
\r
33 templateUrl: './dashboard.component.pug',
\r
34 styleUrls: ['./dashboard.component.scss'],
\r
35 animations: [routerTransition()]
\r
38 export class DashboardComponent implements OnInit, OnDestroy {
\r
40 private toDestroy: Array<Subscription> = [];
\r
42 // Top of the page stats
\r
52 public testDefinitionList = null;
\r
53 public testExecutions;
\r
54 public displayedColumns = ['name', 'result', 'startTime'];
\r
55 public displayedScheduleColumns = ['name', 'nextRun'];
\r
56 public weekExecutions = 0;
\r
57 public weekSchedules = 0;
\r
58 public filter = { testResult: '' }; // for dropdown in html
\r
61 public eventsSubject: Subject<void>;
\r
63 public TD_selectedTDs = "All";
\r
64 public TI_selectedTDs = "All";
\r
65 public TI_selectedTIs = "Top 5";
\r
66 public sched_selectedTIs = "All";
\r
68 public viewers = [];
\r
70 @ViewChild(MatPaginator) executionsPaginator: MatPaginator;
\r
71 @ViewChild(MatPaginator) scheduledPaginator: MatPaginator;
\r
74 private _groups: GroupService,
\r
75 private filterModal: MatDialog,
\r
76 private stats: StatsService
\r
81 this.stats.getDefaultData(this._groups.getGroup());
\r
82 this.toDestroy.push(this._groups.groupChange().subscribe(group => {
\r
83 this.stats.getDefaultData(group);
\r
88 // this.stats.onTDExecutionChangeFinished().subscribe(res => {
\r
89 // this.TD_selectedTDs = "";
\r
90 // this.stats.getTDFilters().selected.forEach(item => {
\r
91 // this.TD_selectedTDs += (item.viewValue + ", ");
\r
93 // let charLimit = 200;
\r
94 // if (this.TD_selectedTDs.length > charLimit) {
\r
95 // this.TD_selectedTDs = this.TD_selectedTDs.slice(0, charLimit) + "...";
\r
96 // } else this.TD_selectedTDs = this.TD_selectedTDs.slice(0, this.TD_selectedTDs.length - 2);
\r
99 // this.stats.onTIExecutionChangeFinished().subscribe(res => {
\r
100 // let selectedTIs = this.stats.getTIFilters().selectedTIs;
\r
101 // let selectedTDs = this.stats.getTIFilters().selectedTDs;
\r
103 // if (selectedTIs.length == 0) this.TI_selectedTIs = "All";
\r
105 // this.TI_selectedTIs = "";
\r
106 // this.stats.getTIFilters().selectedTIs.forEach(item => {
\r
107 // this.TI_selectedTIs += (item + ", ");
\r
109 // let charLimit = 200;
\r
110 // if (this.TI_selectedTIs.length > charLimit) {
\r
111 // this.TI_selectedTIs = this.TI_selectedTIs.slice(0, charLimit) + "...";
\r
112 // } else this.TI_selectedTIs = this.TI_selectedTIs.slice(0, this.TI_selectedTIs.length - 2);
\r
115 // if (selectedTDs.length == 0) this.TI_selectedTDs = "All";
\r
117 // this.TI_selectedTDs = "";
\r
118 // this.stats.getTIFilters().selectedTDs.forEach(item => {
\r
119 // this.TI_selectedTDs += (item + ", ");
\r
121 // let charLimit = 200;
\r
122 // if (this.TI_selectedTDs.length > charLimit) {
\r
123 // this.TI_selectedTDs = this.TI_selectedTDs.slice(0, charLimit) + "...";
\r
124 // } else this.TI_selectedTDs = this.TI_selectedTDs.slice(0, this.TI_selectedTDs.length - 2);
\r
128 // this.stats.onScheduleChangeFinished().subscribe(res => {
\r
129 // let selectedTIs = this.stats.scheduledTests.map(el => el.name);
\r
130 // //console.log(selectedTIs);
\r
131 // if (selectedTIs.length == 0) this.sched_selectedTIs = "All";
\r
133 // this.sched_selectedTIs = "";
\r
134 // this.stats.scheduledTests.map(el => el.name).forEach(item => {
\r
135 // this.sched_selectedTIs += (item + ", ");
\r
137 // let charLimit = 200;
\r
138 // if (this.sched_selectedTIs.length > charLimit) {
\r
139 // this.sched_selectedTIs = this.sched_selectedTIs.slice(0, charLimit) + "...";
\r
140 // } else this.sched_selectedTIs = this.sched_selectedTIs.slice(0, this.sched_selectedTIs.length - 2);
\r
146 this.toDestroy.forEach(elem => {
\r
147 elem.unsubscribe();
\r
151 openFilterModal() {
\r
152 let open = this.filterModal.open(FilterModalComponent, {
\r
158 open.afterClosed().subscribe(res => {
\r
164 //console.log("resetting");
\r
165 this.TD_selectedTDs = "All";
\r
166 this.TI_selectedTDs = "All";
\r
167 this.TI_selectedTIs = "Top 5";
\r
168 this.sched_selectedTIs = "All";
\r
169 this.stats.getDefaultData(this._groups.getGroup());
\r