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
diff --git a/otf-frontend/client/src/app/layout/virtual-test-heads/virtual-test-head-details/virtual-test-head-details.component.ts b/otf-frontend/client/src/app/layout/virtual-test-heads/virtual-test-head-details/virtual-test-head-details.component.ts
new file mode 100644 (file)
index 0000000..4c1fe5c
--- /dev/null
@@ -0,0 +1,104 @@
+/*  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 } from '@angular/core';\r
+import {ActivatedRoute} from "@angular/router";\r
+import {TestHead} from "app/shared/models/test-head.model";\r
+import {TestHeadService} from "app/shared/services/test-head.service";\r
+import { Subscription } from 'rxjs';\r
+import { StatsService } from 'app/layout/components/stats/stats.service';\r
+\r
+\r
+@Component({\r
+  selector: 'app-virtual-test-head-details',\r
+  templateUrl: './virtual-test-head-details.component.pug',\r
+  styleUrls: ['./virtual-test-head-details.component.scss']\r
+})\r
+export class VirtualTestHeadDetailsComponent implements OnInit {\r
+\r
+  private toDestroy : Array<Subscription> = [];\r
+  testHead : TestHead;\r
+  public totalExecutions;\r
+  constructor(\r
+    private route: ActivatedRoute, \r
+    private testHeadService : TestHeadService,\r
+    public stats: StatsService\r
+  ) { }\r
+\r
+  ngOnInit() {\r
+    this.toDestroy.push(this.route.params.subscribe(param => {\r
+      if(param.id){\r
+        this.toDestroy.push(this.testHeadService.get(param.id).subscribe(res => {\r
+          this.testHead = res as TestHead;\r
+          \r
+        }, err=>{\r
+          console.log(err);\r
+        }));\r
+\r
+        this.getData(param.id);\r
+      }\r
+    }));\r
+    \r
+  }\r
+\r
+  ngOnDestroy(){\r
+    this.toDestroy.forEach(e => {\r
+      e.unsubscribe()\r
+    });\r
+  }\r
+\r
+  getData(testHeadId?){\r
+    if(!testHeadId){\r
+      testHeadId = this.testHead._id\r
+    }\r
+\r
+    if(!testHeadId){\r
+      return;\r
+    }\r
+\r
+    this.stats.getDefaultData(1, {\r
+      'testHeadResults.testHeadId': testHeadId,\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
+  setTotalExecutions(event){\r
+    this.totalExecutions = event;\r
+  }\r
+}\r