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 } from '@angular/core';
\r
18 import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
\r
19 import { FormControl } from '@angular/forms';
\r
20 import * as moment from 'moment';
\r
22 import { StatsService } from '../stats.service';
\r
23 import { TestDefinitionService } from 'app/shared/services/test-definition.service';
\r
24 import { TestInstanceService } from 'app/shared/services/test-instance.service';
\r
25 import { GroupService } from 'app/shared/services/group.service';
\r
28 selector: 'app-filter-modal',
\r
29 templateUrl: './filter-modal.component.pug',
\r
30 styleUrls: ['./filter-modal.component.scss']
\r
33 export class FilterModalComponent implements OnInit {
\r
36 public allFilters = {
\r
40 public tdFilters = {
\r
45 public tiFilters = {
\r
52 public scheduleFilters = {
\r
57 selectedInstances: [],
\r
59 // public vthFilters = {
\r
68 public testDefinitions: Array<any> = [];
\r
69 public testInstances: Array<any> = [];
\r
70 //public scheduleInstances: Array<any> = [];
\r
74 public dialogRef: MatDialogRef<FilterModalComponent>,
\r
75 public statsService: StatsService,
\r
76 public tdService: TestDefinitionService,
\r
77 public groupService: GroupService,
\r
78 public tiService: TestInstanceService
\r
80 this.minDate = new Date(moment().subtract(1, 'year').format('L'));
\r
81 this.maxDate = new Date(moment().format('L'));
\r
86 //populate the td, ti, and vth arrays up there. or import them?
\r
92 this.tdService.find({
\r
93 groupId: this.groupService.getGroup()["_id"],
\r
94 $select: ['testName', 'testDescription', "_id"],
\r
99 }).subscribe(result => {
\r
100 for (let index in result) {
\r
101 this.testDefinitions.push({id: result[index]._id, viewValue: result[index].testName });
\r
107 this.tiService.find({
\r
108 groupId: this.groupService.getGroup()["_id"],
\r
109 $select: ['testInstanceName', 'testInstanceDescription', "_id"],
\r
114 }).subscribe(result => {
\r
115 //console.log(result);
\r
116 for (let index in result) {
\r
117 this.testInstances.push({ id: result[index]._id, viewValue: result[index].testInstanceName })
\r
119 //this.testInstances.sort((a, b) => b.viewValue - a.viewValue);
\r
126 if (this.scheduleFilters.startDate > this.scheduleFilters.endDate) {
\r
128 alert("Schedule Filters: Your end date cannot be earlier than your start date.");
\r
129 } else if (this.tdFilters.startDate > this.tdFilters.endDate) {
\r
131 alert("Test Definition Filters: Your end date cannot be earlier than your start date.");
\r
132 } else if (this.tiFilters.startDate > this.tiFilters.endDate) {
\r
134 alert("Test Instance Filters: Your end date cannot be earlier than your start date.");
\r
140 if (this.checkDates() == true) {
\r
142 this.statsService.filterData(this.allFilters, this.tdFilters, this.tiFilters, this.scheduleFilters);
\r
143 //console.log(this.tdFilters);
\r
148 this.dialogRef.close();
\r