1 /* Copyright (c) 2019 AT&T Intellectual Property. #
\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
7 # http://www.apache.org/licenses/LICENSE-2.0 #
\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
17 import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
\r
18 import 'codemirror/mode/yaml/yaml.js';
\r
19 import { TestInstanceService } from '../../services/test-instance.service';
\r
20 import { TestDefinitionService } from '../../services/test-definition.service';
\r
21 import { SchedulingService } from '../../services/scheduling.service';
\r
22 import { SelectStrategyModalComponent } from '../select-strategy-modal/select-strategy-modal.component';
\r
23 import { MatDialog, MatSnackBar } from '@angular/material';
\r
24 import { AlertModalComponent } from '../alert-modal/alert-modal.component';
\r
25 import { Router } from '@angular/router';
\r
26 import { AlertSnackbarComponent } from '../alert-snackbar/alert-snackbar.component';
\r
27 import { ListService } from 'app/shared/services/list.service';
\r
28 import { FileUploader, FileItem, ParsedResponseHeaders } from 'ng2-file-upload';
\r
29 import { HttpClient, HttpHeaders } from "@angular/common/http";
\r
30 import { AppGlobals } from "../../../app.global";
\r
31 import { CookieService } from "ngx-cookie-service";
\r
32 import * as YAML from '../../../../../../node_modules/yamljs/lib/Yaml';
\r
33 import 'codemirror/mode/javascript/javascript.js';
\r
34 import beautify from 'json-beautify';
\r
35 import { WorkflowRequest } from './instance.class';
\r
36 import { PfloInputClass } from './instance.class';
\r
37 import { GroupService } from 'app/shared/services/group.service';
\r
38 import { ExecuteService } from 'app/shared/services/execute.service';
\r
40 const URL = AppGlobals.baseAPIUrl + 'files';
\r
44 selector: 'app-create-test-instance-form',
\r
45 templateUrl: './create-test-instance-form.component.pug',
\r
46 styleUrls: ['./create-test-instance-form.component.scss']
\r
48 export class CreateTestInstanceFormComponent implements OnInit {
\r
50 //Variable sent between modules
\r
51 @Input() public existingInstance: any;
\r
53 @Output() public childEvent = new EventEmitter();
\r
54 public dataTemplate: any;
\r
55 public configTemplate: any;
\r
57 public codeConfig = {
\r
63 public codeJsonConfig = {
\r
64 mode: "application/json",
\r
69 public testDefinition;
\r
70 public testInstance;
\r
71 public createResult;
\r
72 public selectedDefinition;
\r
73 public errorCount = 0;
\r
74 public executionFailed = false;
\r
75 public editMode = false;
\r
77 public selectedBpmn;
\r
78 public uploader: FileUploader;
\r
79 public isZip = true;
\r
80 public scriptFiles = [];
\r
81 public uploaders = {};
\r
82 public vthInput = {};
\r
83 public pfloInput = {};
\r
84 public argsToAdd = {};
\r
85 public vthInputYaml = {};
\r
86 public displayYAML = false;
\r
87 public testHeadYAML = false;
\r
88 public testHeadNames = {};
\r
89 public tiNameLookup = {};
\r
92 public instanceAdded;
\r
95 public uploadOptions = {
\r
96 url: AppGlobals.baseAPIUrl + 'file-transfer',
\r
97 authTokenHeader: 'Authorization',
\r
98 authToken: 'Bearer ' + JSON.parse(this.cookie.get('access_token'))
\r
101 // , private http: HttpClient, private Params: ParamsService, private cookie: CookieService
\r
102 constructor(private router: Router, private list: ListService, private dialog: MatDialog, private execute: ExecuteService, private testInstanceService: TestInstanceService, private testDefinitionService: TestDefinitionService, private snack: MatSnackBar, private http: HttpClient, private cookie: CookieService, private groupService: GroupService) {
\r
104 this.cookie = cookie;
\r
105 // this.httpOptions = {
\r
106 // headers: new HttpHeaders({
\r
107 // 'Content-Type': 'application/json',
\r
108 // 'Authorization': 'Bearer ' + JSON.parse(this.cookie.get('access_token'))
\r
112 // testingSelect(){
\r
113 // console.log(this.selectedBpmn);
\r
116 return bpmn.isDeployed;
\r
120 this.search.testInstanceName = '';
\r
121 this.testInstance = {};
\r
122 this.selectedDefinition = {};
\r
123 this.selectedBpmn = {};
\r
124 this.testInstance.useLatestTestDefinition = true;
\r
125 this.testInstance.simulationVthInput = {};
\r
127 //options required for the file uploader
\r
128 currentGroup = this.groupService.getGroup();
\r
129 this.groupService.groupChange().subscribe(group => {
\r
130 currentGroup = group;
\r
133 this.testInstanceService.find({
\r
134 groupId: currentGroup['_id'],
\r
139 $select: ['testInstanceName']
\r
140 }).subscribe((result) => {
\r
141 this.instances = result;
\r
142 for(let i = 0; i < this.instances.length; i++){
\r
143 this.instances[i].isSelected = false;
\r
148 //this.uploader = new FileUploader(uploadOptions);
\r
149 //if the user is using this page for editing an existing instance
\r
150 if (this.existingInstance) {
\r
151 //console.log(this.existingInstance)
\r
152 if (this.existingInstance.testInstance) {
\r
153 this.testInstance = this.existingInstance.testInstance;
\r
154 this.selectedDefinition = this.existingInstance.testInstance['testDefinitionId'];
\r
156 this.convertSimulationVth('string');
\r
157 console.log(this.testInstance);
\r
159 //set the bpmn to the selected bpmn. Alert User if no bpmn versions are deployed
\r
160 if (this.testInstance.useLatestTestDefinition) {
\r
163 for (let i = 0; i < this.selectedDefinition.bpmnInstances.length; i++) {
\r
164 if (this.selectedDefinition.bpmnInstances[i].processDefintionId === this.testInstance.processDefintionId) {
\r
165 this.selectedBpmn = this.selectedDefinition.bpmnInstances[i];
\r
171 if (this.testInstance.testData === '') {
\r
172 this.displayYAML = true;
\r
175 if (!this.testInstance.simulationVthInput) {
\r
176 this.testInstance.simulationVthInput = {};
\r
180 //grab all robot test heads to assign uploaders to each and create the vthInput object
\r
181 //for(let j = 0; j < this.selectedBpmn.testHeads.length; j++){
\r
185 //console.log(this.uploaders);
\r
186 if (this.existingInstance.isEdit == true)
\r
187 this.editMode = true;
\r
188 }//if the user is creating a new instance from the test definition page
\r
189 else if (this.existingInstance.testDefinition) {
\r
190 this.selectedDefinition = this.existingInstance.testDefinition;
\r
191 this.populateTIName();
\r
192 //set the bpmn as the latest deployed version. Alert User if no bpmn versions are deployed
\r
194 this.populateVthInput();
\r
195 this.populatePfloInput();
\r
196 //grab all robot test heads to assign uploaders to each and set the vthInput object
\r
197 for (let j = 0; j < this.selectedBpmn.testHeads.length; j++) {
\r
199 if (this.selectedBpmn.testHeads[j].testHeadId['testHeadName'].toLowerCase() === 'robot') {
\r
200 this.uploaders[this.selectedBpmn.testHeads[j].bpmnVthTaskId] = new FileUploader(this.uploadOptions);
\r
204 this.testInstance = {
\r
205 "testInstanceDescription": "",
\r
206 "testDefinitionId" : this.selectedDefinition["_id"],
\r
207 "vthInput" : this.vthInput,
\r
208 "pfloInput": this.pfloInput,
\r
209 "vthInputYaml": this.vthInputYaml,
\r
210 "testData": this.selectedBpmn.testDataTemplate,
\r
211 "testDataJSON": this.selectedBpmn.testDataTemplateJSON,
\r
212 "useLatestTestDefinition": true,
\r
213 "internalTestData": {},
\r
214 "simulationVthInput": {}
\r
222 convertSimulationVth(convertTo) {
\r
223 for (let key in this.testInstance.simulationVthInput) {
\r
224 if (this.testInstance.simulationVthInput.hasOwnProperty(key)) {
\r
225 if(convertTo == 'json')
\r
226 this.testInstance.simulationVthInput[key] = JSON.parse(this.testInstance.simulationVthInput[key]);
\r
227 else if (convertTo == 'string')
\r
228 this.testInstance.simulationVthInput[key] = beautify(this.testInstance.simulationVthInput[key], null, 2, 10);
\r
238 delay: 0, response: {}
\r
240 //console.log(this.selectedBpmn);
\r
241 if (this.testInstance.simulationMode) {
\r
242 this.selectedBpmn.testHeads.forEach(e => {
\r
243 if(!this.testInstance.simulationVthInput){
\r
244 this.testInstance.simulationVthInput = {}
\r
246 if (!this.testInstance.simulationVthInput[e.bpmnVthTaskId]) {
\r
247 this.testInstance.simulationVthInput[e.bpmnVthTaskId] = beautify(def, null, 2, 10);
\r
255 this.testInstanceService.find({ $limit: -1, $select: ['testInstanceName'], testDefinitionId: this.selectedDefinition._id }).subscribe((res) => {
\r
257 //console.log(list);
\r
258 let num = list.length;
\r
260 this.testInstance.testInstanceName = this.selectedDefinition.testName;
\r
262 this.testInstance.testInstanceName = this.selectedDefinition.testName + num;
\r
264 let isTaken = true;
\r
266 let alreadyExisted = false;
\r
267 while (isTaken === true && count < 10000) {
\r
268 for (let i = 0; i < list.length; i++) {
\r
269 if (list[i]["testInstanceName"] === this.testInstance.testInstanceName) {
\r
271 this.testInstance.testInstanceName = this.selectedDefinition.testName + num;
\r
272 alreadyExisted = true;
\r
276 if (alreadyExisted) {
\r
277 alreadyExisted = false;
\r
285 //Section for implementing Paralell workflow data entry --------------------------------------------------------------------------------------
\r
286 populatePfloInput(){
\r
287 // this.pfloInput = {
\r
288 // "task123": new PfloInputClass
\r
290 //this.selectedBpmn.pflos = [{"bpmnPfloTaskId" : "task123", "label": "TestPFLO"}]
\r
292 if(this.testInstance.pfloInput){
\r
296 this.pfloInput = {};
\r
298 if(this.selectedBpmn == {} || !this.selectedBpmn.pflos){
\r
300 this.testInstance.pfloInput = this.pfloInput;
\r
304 for(let i = 0; i < this.selectedBpmn.pflos.length; i++){
\r
305 if(this.selectedBpmn.pflos[i]['bpmnPfloTaskId'] != null){
\r
306 this.pfloInput[this.selectedBpmn.pflos[i]['bpmnPfloTaskId']] = new PfloInputClass;
\r
308 //this.pfloInput[this.selectedBpmn.pflos[i]['bpmnPfloTaskId'] + "pfloName"] = this.selectedBpmn.pflos[i]['label'];
\r
311 this.testInstance.pfloInput = this.pfloInput;
\r
316 addInstancesToPflo(taskId){
\r
317 for(let i = 0; i < this.instances.length; i++){
\r
318 if(this.instances[i].isSelected){
\r
319 this.tiNameLookup[this.instances[i]._id] = this.instances[i].testInstanceName;
\r
320 this.addPfloInput(taskId, this.instances[i]._id);
\r
326 addPfloInput(taskId, instanceId){
\r
328 this.testInstance.pfloInput[taskId].args.push(new WorkflowRequest(instanceId));
\r
332 clearSelectedValues(){
\r
333 this.search.testInstanceName = '';
\r
334 for(let i = 0; i < this.instances.length; i++){
\r
335 this.instances[i].isSelected = false;
\r
339 saveTestDataOptions(event) {
\r
340 this.testInstance.testData = event.object;
\r
343 saveFormOptions(event) {
\r
344 this.testInstance.vthInput[event.taskId] = event.object;
\r
345 //console.log(this.testInstance);
\r
349 checkPfloInputLength(){
\r
351 if(this.testInstance.pfloInput != null){
\r
352 let temp = Object.keys(this.testInstance.pfloInput);
\r
354 return temp.length > 0;
\r
362 deleteWorkReq(pfloId, index){
\r
363 this.testInstance.pfloInput[pfloId].args.splice(index, 1);
\r
364 //FORCE REFRESH all connected forms to update their index
\r
367 saveWorkReqForm(event) {
\r
368 this.testInstance.pfloInput[event.taskId].args[event.index] = event.object;
\r
369 //console.log(this.testInstance);
\r
372 convertTestLevelYaml() {
\r
373 if (this.displayYAML) {
\r
374 this.testInstance.testDataJSON = YAML.parse(this.testInstance.testData);
\r
376 this.testInstance.testData = YAML.stringify(this.testInstance.testDataJSON);
\r
381 if (this.testHeadYAML) {
\r
382 for (let key in this.testInstance.vthInputYaml) {
\r
383 this.testInstance.vthInput[key] = YAML.parse(this.testInstance.vthInputYaml[key]);
\r
387 for (let key in this.testInstance.vthInput) {
\r
388 this.testInstance.vthInputYaml[key] = YAML.stringify(this.testInstance.vthInput[key]);
\r
392 //End of Paralell workflow data entry section --------------------------------------------------------------------------------------
\r
395 //populate the vth inputs when bpmn changes
\r
396 this.populateVthInput();
\r
397 this.displayYAML = !this.displayYAML;
\r
398 this.testInstance.testDataJSON = this.selectedBpmn.testDataTemplateJSON;
\r
399 this.testInstance.testData = this.selectedBpmn.testDataTemplate;
\r
400 this.convertTestLevelYaml();
\r
402 this.displayYAML = !this.displayYAML;
\r
406 //toggle Yaml for test level data
\r
408 this.convertTestLevelYaml();
\r
409 this.displayYAML = !this.displayYAML;
\r
411 //toggles Yaml for testHeads
\r
413 this.convertVTHYaml();
\r
414 this.testHeadYAML = !this.testHeadYAML;
\r
416 //onChange method for the use latest TD toggle
\r
418 if (this.testInstance.useLatestTestDefinition) {
\r
422 for (let i = 0; i < this.selectedDefinition.bpmnInstances.length; i++) {
\r
424 processKey = this.selectedDefinition.bpmnInstances[i].processDefinitionId
\r
426 orderNum = processKey.split(":");
\r
427 orderNum = orderNum[1];
\r
428 //console.log("bpmn check : " + orderNum + " bpmn current: " + temp.processDefinitionId.split(':')[1]);
\r
429 if (this.selectedDefinition.bpmnInstances[i].isDeployed && parseInt(orderNum) > parseInt(temp.processDefinitionId.split(':')[1])) {
\r
430 temp = this.selectedDefinition.bpmnInstances[i];
\r
434 if (this.selectedDefinition.bpmnInstances[i].isDeployed) {
\r
435 temp = this.selectedDefinition.bpmnInstances[i];
\r
440 if (temp.isDeployed) {
\r
441 this.selectedBpmn = temp;
\r
443 this.dialog.open(AlertModalComponent, {
\r
447 message: 'Test Definition does not contain a deployed bpmn instance. Please return to the Test Definition page and deploy.'
\r
450 this.testInstance.useLatestTestDefinition = false;
\r
452 this.populateVthInput();
\r
454 this.populatePfloInput();
\r
458 //checks if the test instance has a required Name
\r
460 if (!this.testInstance.testInstanceName) {
\r
467 //populate the vthInputYaml for newly created testInstances
\r
468 populateVthInput() {
\r
469 this.vthInputYaml = {};
\r
470 this.vthInput = {};
\r
471 for (let i = 0; i < this.selectedBpmn.testHeads.length; i++) {
\r
472 this.vthInputYaml[this.selectedBpmn.testHeads[i].bpmnVthTaskId] = this.selectedBpmn.testHeads[i].testHeadId.vthInputTemplate;
\r
473 this.vthInputYaml[this.selectedBpmn.testHeads[i].bpmnVthTaskId + "testHeadName"] = this.selectedBpmn.testHeads[i].testHeadId.testHeadName;
\r
474 if (this.selectedBpmn.testHeads[i].testHeadId.vthInputTemplateJSON) {
\r
475 this.vthInput[this.selectedBpmn.testHeads[i].bpmnVthTaskId] = this.selectedBpmn.testHeads[i].testHeadId.vthInputTemplateJSON;
\r
476 this.vthInput[this.selectedBpmn.testHeads[i].bpmnVthTaskId + "testHeadName"] = this.selectedBpmn.testHeads[i].testHeadId.testHeadName;
\r
482 //Used to grab all test definitions for the user to select.
\r
484 const dialogRef = this.dialog.open(SelectStrategyModalComponent, {
\r
489 dialogRef.afterClosed().subscribe(result => {
\r
490 //If the user already had a selected definition and selected a new one, prompt the user to be sure of change
\r
491 if (result != '' && this.selectedDefinition.testName) {
\r
492 this.dialog.open(AlertModalComponent, {
\r
495 type: 'confirmation',
\r
496 message: 'Changing the Test Definition will erase the Instance you are currently writing.'
\r
498 }).afterClosed().subscribe(response => {
\r
500 this.selectedDefinition = result;
\r
501 this.populateTIName();
\r
502 //set the bpmn as the latest deployed version. Alert User if no bpmn versions are deployed
\r
504 this.populateVthInput();
\r
505 this.populatePfloInput();
\r
506 //grab all robot test heads to assign uploaders to each and initialize vthInput
\r
507 for (let j = 0; j < this.selectedBpmn.testHeads.length; j++) {
\r
508 if (this.selectedBpmn.testHeads[j].testHeadId['vthInputTemplateJSON']) {
\r
509 this.vthInput[this.selectedBpmn.testHeads[j].bpmnVthTaskId] = this.selectedBpmn.testHeads[j].testHeadId['vthInputTemplateJSON'];
\r
512 if (this.selectedBpmn.testHeads[j].testHeadId['testHeadName'].toLowerCase() === 'robot') {
\r
513 this.uploaders[this.selectedBpmn.testHeads[j].bpmnVthTaskId] = new FileUploader(this.uploadOptions);
\r
517 this.testInstance = {
\r
518 "testInstanceDescription": "",
\r
519 "groupId": this.selectedDefinition["groupId"],
\r
520 "testDefinitionId": this.selectedDefinition["_id"],
\r
521 "vthInput": this.vthInput,
\r
522 "pfloInput": this.pfloInput,
\r
523 "vthInputYaml": this.vthInputYaml,
\r
524 "testData": this.selectedBpmn.testDataTemplate,
\r
525 "testDataJSON": this.selectedBpmn.testDataTemplateJSON,
\r
526 "useLatestTestDefinition": true,
\r
527 "internalTestData": {},
\r
528 "simulationVthInput": {}
\r
534 //else they did not have a test definition currently selected
\r
536 this.selectedDefinition = result;
\r
537 this.populateTIName();
\r
538 //set the bpmn as the latest deployed version. Alert User if no bpmn versions are deployed
\r
540 this.populateVthInput();
\r
541 this.populatePfloInput();
\r
542 //grab all robot test heads to assign uploaders to each
\r
543 for (let j = 0; j < this.selectedBpmn.testHeads.length; j++) {
\r
544 if (this.selectedBpmn.testHeads[j].testHeadId['vthInputTemplateJSON']) {
\r
545 this.vthInput[this.selectedBpmn.testHeads[j].bpmnVthTaskId] = this.selectedBpmn.testHeads[j].testHeadId['vthInputTemplateJSON'];
\r
547 if (this.selectedBpmn.testHeads[j].testHeadId['testHeadName'].toLowerCase() === 'robot') {
\r
548 this.uploaders[this.selectedBpmn.testHeads[j].bpmnVthTaskId] = new FileUploader(this.uploadOptions);
\r
554 this.testInstance = {
\r
555 "testInstanceDescription": "",
\r
556 "groupId": this.selectedDefinition["groupId"],
\r
557 "testDefinitionId": this.selectedDefinition["_id"],
\r
558 "vthInput": this.vthInput,
\r
559 "pfloInput": this.pfloInput,
\r
560 "vthInputYaml": this.vthInputYaml,
\r
561 "testData": this.selectedBpmn.testDataTemplate,
\r
562 "testDataJSON": this.selectedBpmn.testDataTemplateJSON,
\r
563 "useLatestTestDefinition": true,
\r
564 "internalTestData": {},
\r
565 "simulationVthInput": {}
\r
572 //Saves the Test Instance Object to the database
\r
574 if (!this.allNamed()) {
\r
575 this.dialog.open(AlertModalComponent, {
\r
579 message: 'The Instance is not named! Please ensure the Instance are named.'
\r
581 }).afterClosed().subscribe((result) => {
\r
586 if (!this.testInstance.processDefinitionId) {
\r
587 this.testInstance.processDefinitionId = this.selectedBpmn.processDefinitionId;
\r
589 this.errorCount = 0;
\r
590 if (!this.displayYAML) {
\r
591 this.testInstance.testData = this.testInstance.testDataJSON;
\r
593 if (this.testHeadYAML) {
\r
594 this.testInstance.vthInput = this.testInstance.vthInputYaml;
\r
597 this.convertSimulationVth('json');
\r
599 this.testInstanceService.create(this.testInstance)
\r
602 if (Object.keys(this.uploaders).length > 0)
\r
603 this.uploadFiles(result);
\r
605 this.snack.openFromComponent(AlertSnackbarComponent, {
\r
608 message: 'Test Instance Saved'
\r
611 this.dialog.closeAll();
\r
614 this.dialog.open(AlertModalComponent, {
\r
629 if (!this.testInstance.processDefinitionId) {
\r
630 this.testInstance.processDefinitionId = this.selectedBpmn.processDefinitionId;
\r
632 this.errorCount = 0;
\r
633 if (!this.displayYAML) {
\r
634 this.testInstance.testData = this.testInstance.testDataJSON;
\r
636 if (this.testHeadYAML) {
\r
637 this.testInstance.vthInput = this.testInstance.vthInputYaml;
\r
640 this.convertSimulationVth('json');
\r
642 this.testInstanceService.update(this.testInstance)
\r
643 .subscribe((result) => {
\r
644 this.snack.openFromComponent(AlertSnackbarComponent, {
\r
647 message: 'Test Instance Updated'
\r
650 this.childEvent.emit();
\r
655 this.childEvent.emit();
\r
657 uploadFiles(result) {
\r
658 for (let i = 0; i < this.selectedBpmn.testHeads.length; i++) {
\r
659 if (!this.uploaders[this.selectedBpmn.testHeads[i].bpmnVthTaskId]) {
\r
662 let key = this.selectedBpmn.testHeads[i].bpmnVthTaskId;
\r
663 let uploader = this.uploaders[key];
\r
664 if (uploader.queue.length > 0) {
\r
665 uploader.uploadAll();
\r
666 uploader.onCompleteItem = (item: FileItem, response: string, status: Number, headers: ParsedResponseHeaders) => {
\r
667 this.scriptFiles.push(JSON.parse(response)[0]);
\r
670 uploader.onCompleteAll = () => {
\r
672 let scriptFilesId = [];
\r
673 for (let i = 0; i < this.scriptFiles.length; i++) {
\r
674 scriptFilesId.push(this.scriptFiles[i]['_id']);
\r
677 for (let i = 0; i < this.selectedBpmn.testHeads.length; i++) {
\r
678 if (this.selectedBpmn.testHeads[i].testHeadId['testHeadName'].toLowerCase() === 'robot') {
\r
679 this.testInstance.internalTestData[this.selectedBpmn.testHeads[i].bpmnVthTaskId] =
\r
681 "robotFileId": scriptFilesId[0]
\r
687 'internalTestData': this.testInstance.internalTestData
\r
690 this.testInstanceService.patch(ti).subscribe(
\r
692 //console.log(res);
\r
696 // console.log(err);
\r
703 //saves instance to the database and executes the test using the agenda scheduler
\r
705 if (!this.allNamed()) {
\r
706 this.dialog.open(AlertModalComponent, {
\r
710 message: 'One or more Instance is not named! Please ensure all Instances are named.'
\r
712 }).afterClosed().subscribe((result) => {
\r
717 if (!this.testInstance.processDefinitionId) {
\r
718 this.testInstance.processDefinitionId = this.selectedBpmn.processDefinitionId;
\r
720 this.errorCount = 0;
\r
721 if (!this.displayYAML) {
\r
722 this.testInstance.testData = this.testInstance.testDataJSON;
\r
724 if (this.testHeadYAML) {
\r
725 this.testInstance.vthInput = this.testInstance.vthInputYaml;
\r
728 this.convertSimulationVth('json')
\r
730 this.testInstanceService.create(this.testInstance)
\r
733 this.executionFailed = false;
\r
734 this.createResult = result;
\r
735 if (Object.keys(this.uploaders).length > 0)
\r
736 this.uploadFiles(result);
\r
739 this.execute.create({
\r
740 _id: this.createResult._id,
\r
746 this.childEvent.emit();
\r
747 this.snack.openFromComponent(AlertSnackbarComponent, {
\r
750 message: 'Test Instance Saved and Executed'
\r
753 this.router.navigateByUrl('/dashboard');
\r
756 this.executionFailed = true;
\r
757 this.dialog.open(AlertModalComponent, {
\r
761 message: "Execution error: " + error
\r
767 this.dialog.open(AlertModalComponent, {
\r
771 message: "Save Error: " + error
\r
778 createNewInstance() {
\r
779 this.testInstance = {
\r
780 'testInstanceName': '',
\r
781 'testInstanceDescription': '',
\r
782 'testDefinitionId': this.selectedDefinition._id,
\r
784 'simulationVthInput': {}
\r