added svcapi ui and camunda code
[it/otf.git] / otf-frontend / client / src / app / layout / robot-report / robot-report.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, Input, ViewChild, ElementRef, Renderer2, NgModule, Compiler, ViewContainerRef, Inject, Sanitizer } from '@angular/core';\r
18 import { FileTransferService } from 'app/shared/services/file-transfer.service';\r
19 import { DomSanitizer } from '@angular/platform-browser'\r
20 import * as $ from 'jquery';\r
21 import 'codemirror/mode/xml/xml.js';\r
22 \r
23 \r
24 \r
25 @Component({\r
26   selector: 'app-robot-report',\r
27   templateUrl: './robot-report.component.pug',\r
28   styleUrls: ['./robot-report.component.scss'],\r
29 })\r
30 export class RobotReportComponent implements OnInit {\r
31 \r
32   @Input() public response;\r
33 \r
34   @ViewChild('srcipts') scripts: ElementRef;\r
35   @ViewChild('frame1') frame1: ElementRef;\r
36   @ViewChild('frame2') frame2: ElementRef;\r
37   @ViewChild('codeMirror') codeMirror: ElementRef;\r
38 \r
39   @ViewChild('container', {read: ViewContainerRef}) public container;\r
40 \r
41   public reports = {\r
42     log: null,\r
43     report: null,\r
44     output: null\r
45   };\r
46 \r
47   public codeConfig = {\r
48     mode: "application/xml",\r
49     theme: "eclipse",\r
50     readonly: true,\r
51     lineNumbers: true\r
52   };\r
53 \r
54   public isRefreshed = false;\r
55   public noClick = "<script>$(document).ready(function(){ $('div a').removeAttr('href');}); $(document).click(function(){$('div a').removeAttr('href');} )</script>";\r
56 \r
57   constructor(private fileTransfer: FileTransferService, private compiler: Compiler, private sanitizer: DomSanitizer) { }\r
58 \r
59   ngOnInit() {\r
60     if(this.response){\r
61       if(this.response.vthResponse && this.response.vthResponse.resultData){\r
62         let fileId = this.response.vthResponse.resultData.robotResultFileId;\r
63         if(fileId){\r
64           this.fileTransfer.get(fileId, {robot: true}).subscribe(result => {\r
65             this.reports.log = this.sanitizer.bypassSecurityTrustHtml(result['log.html'] + this.noClick);\r
66             this.reports.report = this.sanitizer.bypassSecurityTrustHtml(result['report.html'] + this.noClick);\r
67             this.reports.output = result['output.xml'];\r
68           });\r
69         }\r
70       }\r
71     }\r
72 \r
73   }\r
74 \r
75   refresh(){\r
76     this.isRefreshed = false;\r
77     setTimeout(() => {\r
78       this.isRefreshed = true;\r
79     }, 500);\r
80   }\r
81 \r
82 }\r