Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 1 | /* |
| 2 | ============LICENSE_START========================================== |
| 3 | =================================================================== |
| 4 | Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. |
| 5 | =================================================================== |
| 6 | |
| 7 | Unless otherwise specified, all software contained herein is licensed |
| 8 | under the Apache License, Version 2.0 (the License); |
| 9 | you may not use this software except in compliance with the License. |
| 10 | You may obtain a copy of the License at |
| 11 | |
| 12 | http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | |
| 14 | Unless required by applicable law or agreed to in writing, software |
| 15 | distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | See the License for the specific language governing permissions and |
| 18 | limitations under the License. |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 19 | ============LICENSE_END============================================ |
| 20 | */ |
| 21 | |
| 22 | import { Component, OnInit } from '@angular/core'; |
| 23 | |
| 24 | import { saveAs } from 'file-saver'; |
| 25 | import { Location } from '@angular/common'; |
| 26 | import { ActivatedRoute, Router } from '@angular/router'; |
| 27 | import { NotificationService } from '.././shared/services/notification.service'; |
| 28 | import { ParamShareService } from '.././shared/services/paramShare.service'; |
| 29 | import { MappingEditorService } from '.././shared/services/mapping-editor.service'; |
| 30 | import { NotificationsService } from 'angular2-notifications'; |
| 31 | import { HttpUtilService } from '.././shared/services/httpUtil/http-util.service'; |
| 32 | import 'rxjs/add/observable/interval'; |
| 33 | import { Observable } from 'rxjs/Observable'; |
| 34 | import { environment } from '../.././environments/environment'; |
| 35 | import { UtilityService } from '.././shared/services/utilityService/utility.service'; |
| 36 | import 'rxjs/add/operator/map'; |
| 37 | import * as XLSX from 'xlsx'; |
| 38 | import { NgProgress } from 'ngx-progressbar'; |
| 39 | |
| 40 | |
| 41 | let YAML = require('yamljs'); |
| 42 | |
| 43 | type AOA = Array<Array<any>>; |
| 44 | declare var $: any; |
| 45 | |
| 46 | @Component({ selector: 'test', templateUrl: './test.component.html', styleUrls: ['./test.component.css'] }) |
| 47 | export class TestComponent implements OnInit { |
| 48 | public displayParamObjects; |
| 49 | options = { |
| 50 | timeOut: 1000, |
| 51 | showProgressBar: true, |
| 52 | pauseOnHover: true, |
| 53 | clickToClose: true, |
| 54 | maxLength: 200 |
| 55 | }; |
| 56 | public action: any; |
| 57 | public vnfId: any; |
| 58 | public item: any = {}; |
| 59 | |
| 60 | public vnfType: any; |
| 61 | vnfcType: any; |
| 62 | protocol: any; |
| 63 | mode: any = 'NORMAL'; |
| 64 | force: any = 'True'; |
| 65 | ttl: any; |
| 66 | public formattedNameValuePairs = {}; |
| 67 | public requestId = ''; |
| 68 | public enableBrowse: boolean = true; |
| 69 | public enableSpinner: boolean = false; |
| 70 | host: any; |
| 71 | public refNameObj = {}; |
| 72 | |
| 73 | public artifactName; |
| 74 | public type; |
| 75 | public transactions = ''; |
| 76 | public uploadFileName; |
| 77 | |
| 78 | public payload = {}; |
| 79 | public lastvmJson = {}; |
| 80 | public vmPayload = []; |
| 81 | public subPayload = {}; |
| 82 | public vmJson = {}; |
| 83 | public vnfcJson = {}; |
| 84 | public flag = 1; |
| 85 | public oldListName1 = ''; |
| 86 | public actionIdentifiers = {}; |
| 87 | public apiRequest = ''; |
| 88 | public apiResponse = ''; |
| 89 | public statusResponse; |
| 90 | public outputTimeStamp; |
| 91 | public status; |
| 92 | public statusReason; |
| 93 | public errorResponse; |
| 94 | public timer; |
| 95 | public subscribe; |
| 96 | public enableTestButton: boolean = false; |
| 97 | public enableAbort: boolean = false; |
| 98 | public showStatusResponseDiv: boolean = false; |
| 99 | public enablePollButton: boolean = true; |
| 100 | public pollCounter = 0; |
| 101 | public enableCounterDiv: boolean = false; |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 102 | public enableDownload: boolean = false; |
Mohamed Asgar Samiulla(ma926a) | d7dffc2 | 2018-04-02 19:00:49 +0530 | [diff] [blame] | 103 | private userId = localStorage['userId']; |
Kumar, Amaresh (ak583p) | 6c7ccba | 2018-05-09 22:29:45 +0530 | [diff] [blame^] | 104 | constructor (private location: Location, private activeRoutes: ActivatedRoute, private notificationService: NotificationService, private nService: NotificationsService, private router: Router, private paramShareService: ParamShareService, private mappingEditorService: MappingEditorService, private httpUtil: HttpUtilService, |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 105 | private utiltiy: UtilityService, private ngProgress: NgProgress) { |
| 106 | |
| 107 | } |
| 108 | |
| 109 | ngOnInit() { |
| 110 | |
| 111 | |
| 112 | } |
| 113 | |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 114 | |
| 115 | public download() { |
| 116 | if (this.apiRequest) { |
| 117 | var fileName = 'test_' + this.action + '_' + this.actionIdentifiers['vnf-id'] + '_request'; |
| 118 | var theJSON = this.apiRequest; |
| 119 | if (fileName != null || fileName != '') { |
| 120 | var blob = new Blob([theJSON], { |
| 121 | type: 'text/json' |
| 122 | }); |
| 123 | saveAs(blob, fileName); |
| 124 | } |
| 125 | } |
| 126 | else { |
| 127 | this.nService.error('Error', 'Please upload spreadsheet to download the request and response'); |
| 128 | } |
| 129 | |
| 130 | if (this.apiResponse) { |
| 131 | var fileName = 'test_' + this.action + '_' + this.actionIdentifiers['vnf-id'] + '_response'; |
| 132 | var theJSON = this.apiResponse; |
| 133 | if (fileName != null || fileName != '') { |
| 134 | var blob = new Blob([theJSON], { |
| 135 | type: 'text/json' |
| 136 | }); |
| 137 | saveAs(blob, fileName); |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | } |
| 142 | |
| 143 | |
| 144 | public abortTest() { |
| 145 | //this.apiResponse = ""; |
| 146 | this.enableBrowse = true; |
| 147 | this.enableTestButton = true; |
| 148 | this.enablePollButton = true; |
sj108s | 9017464 | 2018-03-15 20:26:47 +0530 | [diff] [blame] | 149 | if (this.subscribe && this.subscribe != undefined) this.subscribe.unsubscribe(); |
Kumar, Amaresh (ak583p) | 6c7ccba | 2018-05-09 22:29:45 +0530 | [diff] [blame^] | 150 | this.nService.info("Information", "Test has been abandoned and polling stopped"); |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 154 | excelBrowseOption() { |
| 155 | $('#excelInputFile').trigger('click'); |
| 156 | } |
| 157 | |
| 158 | |
| 159 | upload(evt: any) { |
| 160 | /* wire up file reader */ |
| 161 | $('#filesparam').trigger('click'); |
| 162 | const target: DataTransfer = <DataTransfer>(evt.target); |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 163 | this.pollCounter = 0; |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 164 | this.uploadFileName = evt.target.files[0].name; |
| 165 | var fileExtension = this.uploadFileName.substr(this.uploadFileName.lastIndexOf('.') + 1); |
| 166 | |
| 167 | if (target.files.length != 1) { |
| 168 | throw new Error('Cannot upload multiple files on the entry'); |
| 169 | } |
| 170 | if (fileExtension.toUpperCase() === 'XLS' || fileExtension.toUpperCase() === 'XLSX') { |
| 171 | const reader = new FileReader(); |
| 172 | reader.onload = (e: any) => { |
| 173 | /* read workbook */ |
| 174 | const bstr = e.target.result; |
| 175 | const wb = XLSX.read(bstr, { type: 'binary' }); |
| 176 | /* grab first sheet */ |
| 177 | const wsname = wb.SheetNames[0]; |
| 178 | const ws = wb.Sheets[wsname]; |
| 179 | |
| 180 | /* save data */ |
| 181 | this.requestId = '' |
| 182 | this.enableTestButton = true; |
| 183 | this.enableAbort = true; |
| 184 | this.enablePollButton = true; |
| 185 | |
| 186 | if (this.subscribe && this.subscribe != undefined) { |
| 187 | this.enableCounterDiv = false; |
| 188 | this.subscribe.unsubscribe(); |
| 189 | } |
| 190 | this.apiRequest = ''; |
| 191 | this.apiResponse = ''; |
| 192 | this.showStatusResponseDiv = false; |
| 193 | this.errorResponse = ''; |
| 194 | this.statusResponse = ''; |
sj108s | b694d95 | 2018-03-21 21:25:39 +0530 | [diff] [blame] | 195 | this.enableDownload = true; |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 196 | let arrData = (<AOA>(XLSX.utils.sheet_to_json(ws, { blankrows: false }))); |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 197 | |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 198 | |
| 199 | |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 200 | this.vmPayload = []; |
| 201 | this.subPayload = {}; |
| 202 | this.vmJson = {}; |
| 203 | this.flag = 1; |
| 204 | this.payload = {}; |
| 205 | this.oldListName1 = ''; |
| 206 | this.actionIdentifiers = {}; |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 207 | // Refactor |
| 208 | this.payload = this.processUploadedFile(arrData); |
| 209 | this.uploadedFileResult(); |
sj108s | b694d95 | 2018-03-21 21:25:39 +0530 | [diff] [blame] | 210 | }; |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 211 | |
| 212 | reader.readAsBinaryString(target.files[0]); |
sj108s | b694d95 | 2018-03-21 21:25:39 +0530 | [diff] [blame] | 213 | |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 214 | |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 215 | } |
| 216 | else { |
| 217 | this.nService.error('Error', 'Incorrect spreadsheet uploaded'); |
| 218 | this.flag = 1; |
| 219 | this.oldListName1 = ''; |
| 220 | this.vmJson = {}; |
| 221 | this.vnfcJson = {}; |
| 222 | this.subPayload = {}; |
| 223 | this.vmPayload = []; |
| 224 | this.payload = {}; |
| 225 | this.action = ''; |
| 226 | this.actionIdentifiers = {}; |
| 227 | this.apiRequest = ''; |
| 228 | this.apiResponse = ''; |
| 229 | this.enableCounterDiv = false; |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 230 | this.enableAbort = false; |
| 231 | this.enableTestButton = false; |
| 232 | this.enableDownload = false; |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 233 | } |
| 234 | } |
| 235 | |
sj108s | b694d95 | 2018-03-21 21:25:39 +0530 | [diff] [blame] | 236 | processUploadedFile(arrData) { |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 237 | let tempPayload = {}; |
| 238 | for (var i = 0; i < arrData.length; i++) { |
| 239 | var element = arrData[i]; |
| 240 | if (element['TagName'] === 'action') { |
| 241 | this.action = element['Value']; |
| 242 | } |
| 243 | if (element['List Name'] === 'action-identifiers') { |
| 244 | this.vnfId = element['Value']; |
| 245 | var key = element['TagName']; |
| 246 | var value = element['Value']; |
| 247 | if (key && value) { |
| 248 | this.actionIdentifiers[key] = value; |
| 249 | |
| 250 | } |
| 251 | } |
sj108s | b694d95 | 2018-03-21 21:25:39 +0530 | [diff] [blame] | 252 | |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 253 | if (element['List Name'] === 'payload') { |
| 254 | var listName1 = element['List Name_1']; |
| 255 | var listName2 = element['List Name_2']; |
| 256 | var listName3 = element['List Name_3']; |
| 257 | var key = element['TagName']; |
| 258 | var value = element['Value']; |
| 259 | if (listName1) { |
| 260 | if (this.oldListName1 == '' || (listName1 === this.oldListName1)) { |
| 261 | this.constructTestPayload(listName2, listName3, key, value); |
| 262 | tempPayload[listName1] = this.subPayload; |
| 263 | } |
| 264 | else { |
| 265 | this.subPayload = {}; |
| 266 | this.constructTestPayload(listName2, listName3, key, value); |
| 267 | tempPayload[listName1] = this.subPayload; |
| 268 | } |
| 269 | this.oldListName1 = listName1; |
| 270 | } |
| 271 | else { |
| 272 | tempPayload[key] = value; |
| 273 | } |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | return tempPayload; |
| 278 | } |
| 279 | |
sj108s | b694d95 | 2018-03-21 21:25:39 +0530 | [diff] [blame] | 280 | uploadedFileResult() { |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 281 | if (this.action && this.actionIdentifiers['vnf-id']) { |
| 282 | this.nService.success('Success', 'SpreadSheet uploaded successfully'); |
| 283 | } |
| 284 | else { |
| 285 | this.flag = 1; |
| 286 | this.oldListName1 = ''; |
| 287 | this.vmJson = {}; |
| 288 | this.vnfcJson = {}; |
| 289 | this.subPayload = {}; |
| 290 | this.vmPayload = []; |
| 291 | this.payload = {}; |
| 292 | this.action = ''; |
| 293 | this.actionIdentifiers = {}; |
| 294 | this.apiRequest = ''; |
| 295 | this.apiResponse = ''; |
| 296 | this.enableCounterDiv = false; |
| 297 | this.enableAbort = false; |
| 298 | this.enableTestButton = false; |
| 299 | this.enableDownload = false; |
| 300 | this.nService.error("Error", "Please check the contents of the file uploaded") |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | |
| 305 | |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 306 | constructTestPayload(listName2, listName3, key, value) { |
| 307 | if (listName2 == undefined && listName3 == undefined) { |
| 308 | this.subPayload[key] = value; |
| 309 | } |
| 310 | if (listName2) { |
| 311 | |
| 312 | if (!listName3) { |
| 313 | |
| 314 | //vmPayload.push(vmJson) |
| 315 | this.vmJson = {}; |
| 316 | this.vnfcJson = {}; |
| 317 | this.vmJson[key] = value; |
| 318 | this.flag = 0; |
| 319 | } |
| 320 | else { |
| 321 | this.vnfcJson[key] = value; |
| 322 | this.vmJson['vnfc'] = this.vnfcJson; |
| 323 | this.flag = 1; |
| 324 | } |
| 325 | if (this.vmJson) this.lastvmJson = this.vmJson; |
| 326 | if (this.flag == 0) { |
| 327 | this.vmPayload.push(this.lastvmJson); |
| 328 | if (this.vmPayload) this.subPayload['vm'] = this.vmPayload; |
| 329 | } |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | constructRequest() { |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 334 | let timeStamp = new Date().toISOString(); |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 335 | let reqId; |
| 336 | this.requestId = reqId = new Date().getTime().toString(); |
| 337 | let data = { |
| 338 | 'input': { |
| 339 | 'common-header': { |
| 340 | 'timestamp': timeStamp, |
| 341 | 'api-ver': '2.00', |
Mohamed Asgar Samiulla(ma926a) | d7dffc2 | 2018-04-02 19:00:49 +0530 | [diff] [blame] | 342 | 'originator-id': this.userId, |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 343 | 'request-id': this.requestId, |
| 344 | 'sub-request-id': this.requestId, |
| 345 | 'flags': { |
| 346 | 'mode': 'NORMAL', |
| 347 | 'force': 'TRUE', |
| 348 | 'ttl': 3600 |
| 349 | } |
| 350 | }, |
| 351 | 'action': this.action, |
| 352 | 'action-identifiers': this.actionIdentifiers, |
| 353 | 'payload': JSON.stringify(this.payload) |
| 354 | } |
| 355 | }; |
| 356 | |
| 357 | return data; |
| 358 | } |
| 359 | |
| 360 | testVnf() { |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 361 | this.enableBrowse = false; |
| 362 | this.enableTestButton = false; |
| 363 | this.enablePollButton = false; |
| 364 | this.timer = Observable.interval(10000); |
| 365 | this.subscribe = this.timer.subscribe((t) => this.pollTestStatus()); |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 366 | this.ngProgress.start(); |
| 367 | this.apiRequest = JSON.stringify(this.constructRequest()); |
Mohamed Asgar Samiulla(ma926a) | d7dffc2 | 2018-04-02 19:00:49 +0530 | [diff] [blame] | 368 | |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 369 | this.httpUtil.post( |
| 370 | { |
Kumar, Amaresh (ak583p) | 6c7ccba | 2018-05-09 22:29:45 +0530 | [diff] [blame^] | 371 | url: environment.testVnf + "?urlAction=" + this.getUrlEndPoint(this.action.toLowerCase()), |
| 372 | data: this.apiRequest |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 373 | }) |
| 374 | .subscribe(resp => { |
| 375 | this.apiResponse = JSON.stringify(resp); |
| 376 | this.enableBrowse = true; |
| 377 | this.enableTestButton = true; |
| 378 | this.ngProgress.done(); |
| 379 | }, |
Kumar, Amaresh (ak583p) | 6c7ccba | 2018-05-09 22:29:45 +0530 | [diff] [blame^] | 380 | error => { |
| 381 | this.nService.error('Error', 'Error in connecting to APPC Server'); |
| 382 | this.enableBrowse = true; |
| 383 | this.enableTestButton = true; |
| 384 | this.enablePollButton = true; |
| 385 | this.enableCounterDiv = false; |
| 386 | if (this.subscribe && this.subscribe != undefined) this.subscribe.unsubscribe(); |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 387 | |
Kumar, Amaresh (ak583p) | 6c7ccba | 2018-05-09 22:29:45 +0530 | [diff] [blame^] | 388 | }); |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 389 | |
| 390 | setTimeout(() => { |
| 391 | this.ngProgress.done(); |
| 392 | }, 3500); |
| 393 | } |
| 394 | |
| 395 | |
| 396 | pollTestStatus() { |
| 397 | if (this.requestId && this.actionIdentifiers['vnf-id']) { |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 398 | let timeStamp = new Date().toISOString(); |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 399 | let reqId = new Date().getTime().toString(); |
| 400 | let data = { |
| 401 | 'input': { |
| 402 | 'common-header': { |
| 403 | 'timestamp': timeStamp, |
| 404 | 'api-ver': '2.00', |
Mohamed Asgar Samiulla(ma926a) | d7dffc2 | 2018-04-02 19:00:49 +0530 | [diff] [blame] | 405 | 'originator-id': this.userId, |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 406 | 'request-id': reqId, |
| 407 | 'sub-request-id': reqId, |
| 408 | 'flags': { |
| 409 | 'mode': 'NORMAL', |
| 410 | 'force': 'TRUE', |
| 411 | 'ttl': 3600 |
| 412 | } |
| 413 | }, |
| 414 | 'action': 'ActionStatus', |
Kumar, Amaresh (ak583p) | 6c7ccba | 2018-05-09 22:29:45 +0530 | [diff] [blame^] | 415 | 'action-identifiers': { |
| 416 | 'vnf-id': this.actionIdentifiers['vnf-id'] |
Mohamed Asgar Samiulla(ma926a) | d7dffc2 | 2018-04-02 19:00:49 +0530 | [diff] [blame] | 417 | }, |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 418 | 'payload': '{"request-id":' + this.requestId + '}' |
| 419 | } |
| 420 | }; |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 421 | this.httpUtil.post( |
| 422 | { |
| 423 | url: environment.checkTestStatus, data: data |
| 424 | |
| 425 | }) |
| 426 | .subscribe(resp => { |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 427 | this.statusResponse = JSON.stringify(resp); |
| 428 | var status = '' |
| 429 | var statusReason = '' |
| 430 | this.enableCounterDiv = true; |
| 431 | this.pollCounter++; |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 432 | if (resp.output) var timeStamp = resp.output['common-header'].timestamp; |
| 433 | if (resp.output.payload) { |
| 434 | var payload = resp.output.payload.replace(/\\/g, "") |
| 435 | try { |
| 436 | payload = JSON.parse(payload) |
| 437 | status = payload['status']; |
| 438 | statusReason = payload['status-reason']; |
| 439 | } |
| 440 | catch (err) { |
| 441 | console.log("error" + err) |
| 442 | } |
| 443 | } |
| 444 | if (timeStamp && status && statusReason) { |
| 445 | this.showStatusResponseDiv = true; |
| 446 | this.outputTimeStamp = timeStamp; |
| 447 | this.status = status; |
| 448 | this.statusReason = statusReason; |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 449 | if (status.toUpperCase() === 'SUCCESS' || status.toUpperCase() === 'SUCCESSFUL') { |
sj108s | 9017464 | 2018-03-15 20:26:47 +0530 | [diff] [blame] | 450 | if (this.subscribe && this.subscribe != undefined) this.subscribe.unsubscribe(); |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 451 | this.enablePollButton = true; |
| 452 | } |
| 453 | if (status.toUpperCase() === 'FAILED') { |
sj108s | 9017464 | 2018-03-15 20:26:47 +0530 | [diff] [blame] | 454 | if (this.subscribe && this.subscribe != undefined) this.subscribe.unsubscribe(); |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 455 | this.enablePollButton = true; |
| 456 | } |
| 457 | } |
| 458 | else { |
| 459 | this.showStatusResponseDiv = false; |
sj108s | b694d95 | 2018-03-21 21:25:39 +0530 | [diff] [blame] | 460 | if (this.subscribe && this.subscribe != undefined) { |
| 461 | this.subscribe.unsubscribe(); |
| 462 | this.enablePollButton = true; |
| 463 | } |
| 464 | |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 465 | } |
| 466 | |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 467 | }, |
Kumar, Amaresh (ak583p) | 6c7ccba | 2018-05-09 22:29:45 +0530 | [diff] [blame^] | 468 | error => { |
| 469 | this.statusResponse = null; |
| 470 | this.showStatusResponseDiv = false; |
| 471 | this.errorResponse = 'Error Connecting to APPC server'; |
| 472 | this.enableCounterDiv = false; |
| 473 | if (this.subscribe && this.subscribe != undefined) { |
| 474 | this.subscribe.unsubscribe(); |
| 475 | this.enablePollButton = true; |
| 476 | } |
| 477 | }); |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 478 | } |
| 479 | else { |
| 480 | this.nService.error("Error", "Please enter vnf Id & request Id"); |
| 481 | } |
sj108s | b694d95 | 2018-03-21 21:25:39 +0530 | [diff] [blame] | 482 | |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 483 | } |
| 484 | |
| 485 | getUrlEndPoint(action) { |
| 486 | switch (action) { |
| 487 | case 'configmodify': |
| 488 | return 'config-modify'; |
| 489 | case 'configbackup': |
| 490 | return 'config-backup'; |
| 491 | case 'configrestore': |
| 492 | return 'config-restore'; |
| 493 | case 'healthcheck': |
| 494 | return 'health-check'; |
| 495 | case 'quiescetraffic': |
| 496 | return 'quiesce-traffic'; |
| 497 | case 'resumetraffic': |
| 498 | return 'resume-traffic'; |
| 499 | case 'startapplication': |
| 500 | return 'start-application'; |
| 501 | case 'stopapplication': |
| 502 | return 'stop-application'; |
| 503 | case 'upgradebackout': |
| 504 | return 'upgrade-backout'; |
| 505 | case 'upgradepostcheck': |
| 506 | return 'upgrade-post-check'; |
| 507 | case 'upgradeprecheck': |
| 508 | return 'upgrade-pre-check'; |
| 509 | case 'upgradesoftware': |
| 510 | return 'upgrade-software'; |
Mohamed Asgar Samiulla(ma926a) | d7dffc2 | 2018-04-02 19:00:49 +0530 | [diff] [blame] | 511 | case 'upgradebackup': |
| 512 | return 'upgrade-backup'; |
| 513 | case 'attachvolume': |
| 514 | return 'attach-volume'; |
| 515 | case 'detachvolume': |
| 516 | return 'detach-volume'; |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 517 | default: |
| 518 | return action.toLowerCase(); |
| 519 | } |
| 520 | |
| 521 | } |
| 522 | |
| 523 | } |