Initial Commit - NG UI
[osm/NG-UI.git] / src / app / wim-accounts / wim-account-info / WIMAccountInfoComponent.ts
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 WIM Page
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 { SharedService } from 'SharedService';
27 import { WIMAccountModel } from 'WIMAccountModel';
28
29 /**
30  * Creating component
31  * @Component takes WIMAccountInfoComponent.html as template url
32  */
33 @Component({
34   templateUrl: './WIMAccountInfoComponent.html',
35   styleUrls: ['./WIMAccountInfoComponent.scss']
36 })
37 /** Exporting a class @exports WIMAccountInfoComponent */
38 export class WIMAccountInfoComponent 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 WIM details @public */
46   public wimDetails: WIMAccountModel;
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   /** operational State init data @public */
55   public operationalStateFirstStep: string = CONFIGCONSTANT.wimOperationalStateFirstStep;
56
57   /** operational State running data @public */
58   public operationalStateSecondStep: string = CONFIGCONSTANT.wimOperationalStateStateSecondStep;
59
60   /** operational State failed data @public */
61   public operationalStateThirdStep: string = CONFIGCONSTANT.wimOperationalStateThirdStep;
62
63   /** Give the message for the loading @public */
64   public message: string = 'PLEASEWAIT';
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.WIMACCOUNTS_URL + '/' + this.params.id).subscribe((wimDetails: WIMAccountModel) => {
89       this.wimDetails = wimDetails;
90       this.isLoadingResults = false;
91     }, (error: ERRORDATA) => {
92       this.restService.handleError(error, 'get');
93       this.isLoadingResults = false;
94     });
95   }
96 }