X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?p=it%2Fotf.git;a=blobdiff_plain;f=otf-frontend%2Fclient%2Fsrc%2Fapp%2Flayout%2Fcomponents%2Fstats%2Ffilter-modal%2Ffilter-modal.component.ts;fp=otf-frontend%2Fclient%2Fsrc%2Fapp%2Flayout%2Fcomponents%2Fstats%2Ffilter-modal%2Ffilter-modal.component.ts;h=c1ab2c7ed80fce960ee50bb309c9cd6f82df5cba;hp=0000000000000000000000000000000000000000;hb=14f6f95c84a4a1fa8774190db4a03fd0214ec55f;hpb=f49bd1efeaaddd4891c1f329b18d8cfb28b3e75b diff --git a/otf-frontend/client/src/app/layout/components/stats/filter-modal/filter-modal.component.ts b/otf-frontend/client/src/app/layout/components/stats/filter-modal/filter-modal.component.ts new file mode 100644 index 0000000..c1ab2c7 --- /dev/null +++ b/otf-frontend/client/src/app/layout/components/stats/filter-modal/filter-modal.component.ts @@ -0,0 +1,151 @@ +/* Copyright (c) 2019 AT&T Intellectual Property. # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +##############################################################################*/ + + +import { Component, OnInit } from '@angular/core'; +import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material'; +import { FormControl } from '@angular/forms'; +import * as moment from 'moment'; + +import { StatsService } from '../stats.service'; +import { TestDefinitionService } from 'app/shared/services/test-definition.service'; +import { TestInstanceService } from 'app/shared/services/test-instance.service'; +import { GroupService } from 'app/shared/services/group.service'; + +@Component({ + selector: 'app-filter-modal', + templateUrl: './filter-modal.component.pug', + styleUrls: ['./filter-modal.component.scss'] +}) + +export class FilterModalComponent implements OnInit { + + public group; + public allFilters = { + startDate: "", + endDate: "" + }; + public tdFilters = { + selected: [], + startDate: "", + endDate: "", + }; + public tiFilters = { + selectedTDs: [], + selectedTIs: [], + startDate: "", + endDate: "", + multiLineLimit: 5 + }; + public scheduleFilters = { + startDate: "", + endDate: "", + timeRangeStart: "", + timeRangeEnd: "", + selectedInstances: [], + } + // public vthFilters = { + // selected: [], + // startDate: "", + // endDate: "", + // }; + + public minDate; + public maxDate; + + public testDefinitions: Array = []; + public testInstances: Array = []; + //public scheduleInstances: Array = []; + //public vths = []; + + constructor( + public dialogRef: MatDialogRef, + public statsService: StatsService, + public tdService: TestDefinitionService, + public groupService: GroupService, + public tiService: TestInstanceService + ) { + this.minDate = new Date(moment().subtract(1, 'year').format('L')); + this.maxDate = new Date(moment().format('L')); + + } + + ngOnInit() { + //populate the td, ti, and vth arrays up there. or import them? + this.setTDList(); + this.setTIList(); + } + + setTDList() { + this.tdService.find({ + groupId: this.groupService.getGroup()["_id"], + $select: ['testName', 'testDescription', "_id"], + $limit: -1, + $sort:{ + testName:1 + } + }).subscribe(result => { + for (let index in result) { + this.testDefinitions.push({id: result[index]._id, viewValue: result[index].testName }); + } + }) + } + + setTIList() { + this.tiService.find({ + groupId: this.groupService.getGroup()["_id"], + $select: ['testInstanceName', 'testInstanceDescription', "_id"], + $limit: -1, + $sort:{ + testInstanceName:1 + } + }).subscribe(result => { + //console.log(result); + for (let index in result) { + this.testInstances.push({ id: result[index]._id, viewValue: result[index].testInstanceName }) + } + //this.testInstances.sort((a, b) => b.viewValue - a.viewValue); + }) + } + + checkDates() { + let allSet = true; + + if (this.scheduleFilters.startDate > this.scheduleFilters.endDate) { + allSet = false; + alert("Schedule Filters: Your end date cannot be earlier than your start date."); + } else if (this.tdFilters.startDate > this.tdFilters.endDate) { + allSet = false; + alert("Test Definition Filters: Your end date cannot be earlier than your start date."); + } else if (this.tiFilters.startDate > this.tiFilters.endDate) { + allSet = false; + alert("Test Instance Filters: Your end date cannot be earlier than your start date."); + } + return allSet; + } + + onConfirm() { + if (this.checkDates() == true) { + this.close(); + this.statsService.filterData(this.allFilters, this.tdFilters, this.tiFilters, this.scheduleFilters); + //console.log(this.tdFilters); + } + } + + close() { + this.dialogRef.close(); + } + +}