--- /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, OnDestroy } from '@angular/core';\r
+import { ActivatedRoute } from '@angular/router';\r
+import { Subscription } from 'rxjs';\r
+import { TestDefinitionService } from 'app/shared/services/test-definition.service';\r
+import { TestDefinition } from 'app/shared/models/test-definition.model';\r
+import { StatsService } from 'app/layout/components/stats/stats.service';\r
+\r
+@Component({\r
+ selector: 'app-test-definition-details',\r
+ templateUrl: './test-definition-details.component.pug',\r
+ styleUrls: ['./test-definition-details.component.scss']\r
+})\r
+export class TestDefinitionDetailsComponent implements OnInit, OnDestroy {\r
+\r
+ private toDestroy: Array<Subscription> = [];\r
+\r
+ public testDefinition: TestDefinition;\r
+ \r
+ constructor(\r
+ private route: ActivatedRoute, \r
+ private _testDefinition: TestDefinitionService,\r
+ public stats: StatsService\r
+ ) { }\r
+\r
+ ngOnInit() {\r
+ this.toDestroy.push(this.route.params.subscribe(params => {\r
+ \r
+ if(params.id){\r
+ this._testDefinition.get(params.id).subscribe(\r
+ res => {\r
+ \r
+ this.testDefinition = res as TestDefinition;\r
+ },\r
+ err => {\r
+ \r
+ })\r
+\r
+ this.getData(params.id);\r
+ }\r
+ }));\r
+ }\r
+\r
+ get numOfVersions(){\r
+ if(this.testDefinition['bpmnInstances']){\r
+ return this.testDefinition['bpmnInstances'].length;\r
+ }\r
+ return 0;\r
+ }\r
+\r
+ ngOnDestroy() {\r
+ this.toDestroy.forEach(elem => elem.unsubscribe());\r
+ }\r
+\r
+ getData(testDefinitionId?){\r
+ if(!testDefinitionId){\r
+ testDefinitionId = this.testDefinition._id\r
+ }\r
+\r
+ if(!testDefinitionId){\r
+ return;\r
+ }\r
+\r
+ this.stats.getDefaultData(1, {\r
+ 'historicTestDefinition._id': testDefinitionId,\r
+ $select: [\r
+ 'startTime',\r
+ 'endTime',\r
+ "historicTestDefinition._id",\r
+ "historicTestDefinition.testName",\r
+ "historicTestInstance._id",\r
+ "historicTestInstance.testInstanceName",\r
+ "testHeadResults.startTime",\r
+ "testHeadResults.endTime",\r
+ "testHeadResults.testHeadName",\r
+ "testHeadResults.testHeadId",\r
+ "testHeadResults.testHeadGroupId",\r
+ "testHeadResults.statusCode",\r
+ 'testResult'\r
+ ],\r
+ $limit: -1,\r
+ $sort: {\r
+ startTime: 1\r
+ },\r
+ startTime: {\r
+ $gte: this.stats.filters.startDate,\r
+ $lte: this.stats.filters.endDate\r
+ }\r
+ });\r
+ }\r
+\r
+}\r