added svcapi ui and camunda code
[it/otf.git] / otf-frontend / client / src / app / shared / modules / test-instance-modal / test-instance-modal.component.ts
diff --git a/otf-frontend/client/src/app/shared/modules/test-instance-modal/test-instance-modal.component.ts b/otf-frontend/client/src/app/shared/modules/test-instance-modal/test-instance-modal.component.ts
new file mode 100644 (file)
index 0000000..9fb4f43
--- /dev/null
@@ -0,0 +1,80 @@
+/*  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, Inject, Output, Input } from '@angular/core';\r
+import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';\r
+import { AppGlobals } from 'app/app.global';\r
+import { HttpClient } from '@angular/common/http';\r
+import { TestInstanceService } from '../../services/test-instance.service';\r
+import { TestDefinitionService } from '../../services/test-definition.service';\r
+\r
+@Component({\r
+  selector: 'app-test-instance-modal',\r
+  templateUrl: './test-instance-modal.component.pug',\r
+  styleUrls: ['./test-instance-modal.component.scss']\r
+})\r
+export class TestInstanceModalComponent implements OnInit {\r
+\r
+  @Output() editInstance;\r
+  public findInstance = true;\r
+  @Input() childEvent;\r
+\r
+\r
+  constructor(\r
+      public dialogRef: MatDialogRef<TestInstanceModalComponent>,\r
+      private http: HttpClient,\r
+      private testDefintionService: TestDefinitionService,\r
+      private testInstanceService: TestInstanceService,\r
+    @Inject(MAT_DIALOG_DATA) public inputInstanceId) { }\r
+\r
+  ngOnInit() {\r
+    if(!this.inputInstanceId){\r
+      this.findInstance = false;\r
+    }\r
+    //if the user is creating an Instance from a test definition page. Pull all data and populate testHeads\r
+    else if(this.inputInstanceId["td"]){\r
+      this.testDefintionService.get(this.inputInstanceId.td,{$populate: ['bpmnInstances.testHeads.testHeadId']}).subscribe((result) => {\r
+        this.editInstance = {\r
+          \r
+          testDefinition: result,\r
+          isEdit: false\r
+        };\r
+        \r
+        this.findInstance = false;\r
+      });\r
+\r
+    }\r
+    else if (this.inputInstanceId["ti"]) {\r
+      this.testInstanceService.get(this.inputInstanceId.ti, {$populate: ['testDefinitionId']}).subscribe((result) => {\r
+        \r
+        this.editInstance = {};\r
+        this.editInstance.testInstance = result;\r
+        if(this.inputInstanceId.isEdit){\r
+          this.editInstance.isEdit = true;\r
+        }else{\r
+          this.editInstance.isEdit = false;\r
+        }\r
+        this.findInstance = false;\r
+      });\r
+    }else{\r
+      this.findInstance = false\r
+    }\r
+  }\r
+\r
+  close() {\r
+    this.dialogRef.close();\r
+  }\r
+}
\ No newline at end of file