| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame^] | 1 | /* |
| 2 | Copyright 2020 TATA ELXSI |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the 'License'); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | |
| 16 | Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in) |
| 17 | */ |
| 18 | /** |
| 19 | * @file Info SDN Controller Info Component |
| 20 | */ |
| 21 | import { Component, Injector, Input, OnInit } from '@angular/core'; |
| 22 | import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; |
| 23 | import { CONFIGCONSTANT, ERRORDATA, URLPARAMS } from 'CommonModel'; |
| 24 | import { environment } from 'environment'; |
| 25 | import { RestService } from 'RestService'; |
| 26 | import { SDNControllerModel } from 'SDNControllerModel'; |
| 27 | import { SharedService } from 'SharedService'; |
| 28 | |
| 29 | /** |
| 30 | * Creating component |
| 31 | * @Component takes SDNControllerInfoComponent.html as template url |
| 32 | */ |
| 33 | @Component({ |
| 34 | templateUrl: './SDNControllerInfoComponent.html', |
| 35 | styleUrls: ['./SDNControllerInfoComponent.scss'] |
| 36 | }) |
| 37 | /** Exporting a class @exports SDNControllerInfoComponent */ |
| 38 | export class SDNControllerInfoComponent implements OnInit { |
| 39 | /** To inject services @public */ |
| 40 | public injector: Injector; |
| 41 | |
| 42 | /** Input contains component objects @public */ |
| 43 | @Input() public params: URLPARAMS; |
| 44 | |
| 45 | /** Contains sdn details @public */ |
| 46 | public sdnDetails: SDNControllerModel; |
| 47 | |
| 48 | /** Instance for active modal service @public */ |
| 49 | public activeModal: NgbActiveModal; |
| 50 | |
| 51 | /** Check the loading results for loader status @public */ |
| 52 | public isLoadingResults: boolean = true; |
| 53 | |
| 54 | /** Give the message for the loading @public */ |
| 55 | public message: string = 'PLEASEWAIT'; |
| 56 | |
| 57 | /** operational State init data @public */ |
| 58 | public operationalStateFirstStep: string = CONFIGCONSTANT.sdnOperationalStateFirstStep; |
| 59 | |
| 60 | /** operational State running data @public */ |
| 61 | public operationalStateSecondStep: string = CONFIGCONSTANT.sdnOperationalStateStateSecondStep; |
| 62 | |
| 63 | /** operational State failed data @public */ |
| 64 | public operationalStateThirdStep: string = CONFIGCONSTANT.sdnOperationalStateThirdStep; |
| 65 | |
| 66 | /** Instance of the rest service @private */ |
| 67 | private restService: RestService; |
| 68 | |
| 69 | /** Contains all methods related to shared @private */ |
| 70 | private sharedService: SharedService; |
| 71 | |
| 72 | constructor(injector: Injector) { |
| 73 | this.injector = injector; |
| 74 | this.restService = this.injector.get(RestService); |
| 75 | this.activeModal = this.injector.get(NgbActiveModal); |
| 76 | this.sharedService = this.injector.get(SharedService); |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Lifecyle Hooks the trigger before component is instantiate |
| 81 | */ |
| 82 | public ngOnInit(): void { |
| 83 | this.generateData(); |
| 84 | } |
| 85 | |
| 86 | /** Generate Data function @public */ |
| 87 | public generateData(): void { |
| 88 | this.restService.getResource(environment.SDNCONTROLLER_URL + '/' + this.params.id).subscribe((sdnDetails: SDNControllerModel) => { |
| 89 | this.sdnDetails = sdnDetails; |
| 90 | this.isLoadingResults = false; |
| 91 | }, (error: ERRORDATA) => { |
| 92 | this.restService.handleError(error, 'get'); |
| 93 | this.isLoadingResults = false; |
| 94 | }); |
| 95 | } |
| 96 | } |