added svcapi ui and camunda code
[it/otf.git] / otf-frontend / client / src / app / layout / virtual-test-heads / virtual-test-head-details / virtual-test-head-details.component.ts
1 /*  Copyright (c) 2019 AT&T Intellectual Property.                             #\r
2 #                                                                              #\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
6 #                                                                              #\r
7 #       http://www.apache.org/licenses/LICENSE-2.0                             #\r
8 #                                                                              #\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
15 \r
16 \r
17 import { Component, OnInit } from '@angular/core';\r
18 import {ActivatedRoute} from "@angular/router";\r
19 import {TestHead} from "app/shared/models/test-head.model";\r
20 import {TestHeadService} from "app/shared/services/test-head.service";\r
21 import { Subscription } from 'rxjs';\r
22 import { StatsService } from 'app/layout/components/stats/stats.service';\r
23 \r
24 \r
25 @Component({\r
26   selector: 'app-virtual-test-head-details',\r
27   templateUrl: './virtual-test-head-details.component.pug',\r
28   styleUrls: ['./virtual-test-head-details.component.scss']\r
29 })\r
30 export class VirtualTestHeadDetailsComponent implements OnInit {\r
31 \r
32   private toDestroy : Array<Subscription> = [];\r
33   testHead : TestHead;\r
34   public totalExecutions;\r
35   constructor(\r
36     private route: ActivatedRoute, \r
37     private testHeadService : TestHeadService,\r
38     public stats: StatsService\r
39   ) { }\r
40 \r
41   ngOnInit() {\r
42     this.toDestroy.push(this.route.params.subscribe(param => {\r
43       if(param.id){\r
44         this.toDestroy.push(this.testHeadService.get(param.id).subscribe(res => {\r
45           this.testHead = res as TestHead;\r
46           \r
47         }, err=>{\r
48           console.log(err);\r
49         }));\r
50 \r
51         this.getData(param.id);\r
52       }\r
53     }));\r
54     \r
55   }\r
56 \r
57   ngOnDestroy(){\r
58     this.toDestroy.forEach(e => {\r
59       e.unsubscribe()\r
60     });\r
61   }\r
62 \r
63   getData(testHeadId?){\r
64     if(!testHeadId){\r
65       testHeadId = this.testHead._id\r
66     }\r
67 \r
68     if(!testHeadId){\r
69       return;\r
70     }\r
71 \r
72     this.stats.getDefaultData(1, {\r
73       'testHeadResults.testHeadId': testHeadId,\r
74       $select: [\r
75         'startTime',\r
76         'endTime',\r
77         "historicTestDefinition._id",\r
78         "historicTestDefinition.testName",\r
79         "historicTestInstance._id",\r
80         "historicTestInstance.testInstanceName",\r
81         "testHeadResults.startTime",\r
82         "testHeadResults.endTime",\r
83         "testHeadResults.testHeadName",\r
84         "testHeadResults.testHeadId",\r
85         "testHeadResults.testHeadGroupId",\r
86         "testHeadResults.statusCode",\r
87         'testResult'\r
88       ],\r
89       $limit: -1,\r
90       $sort: {\r
91         startTime: 1\r
92       },\r
93       startTime: {\r
94         $gte: this.stats.filters.startDate,\r
95         $lte: this.stats.filters.endDate\r
96       }\r
97     });\r
98   }\r
99 \r
100 \r
101   setTotalExecutions(event){\r
102     this.totalExecutions = event;\r
103   }\r
104 }\r