Use O-RAN-SC
[portal/ric-dashboard.git] / webapp-frontend / src / app / ui / config-event / config-event.component.ts
1 /*-
2  * ========================LICENSE_START=================================
3  * O-RAN-SC
4  * %%
5  * Copyright (C) 2019 AT&T Intellectual Property and Nokia
6  * %%
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ========================LICENSE_END===================================
19  */
20 import { Component, OnInit } from '@angular/core';
21 import { FormControl, Validators } from '@angular/forms';
22 import { StatsService } from '../../services/stats/stats.service';
23
24 @Component({
25   selector: 'app-config-event',
26   templateUrl: './config-event.component.html',
27   styleUrls: ['./config-event.component.scss']
28 })
29 export class ConfigEventComponent implements OnInit {
30
31     public renderValue;
32
33     contactFormModalJsonUrl = new FormControl('', Validators.required);
34     contactFormModalHost = new FormControl('', Validators.required);
35     contactFormModalMetrics = new FormControl('', Validators.required);
36     contactFormModalDelay = new FormControl('', Validators.required);
37     contactFormModalLoad = new FormControl('', Validators.required);
38     contactFormModalDelayMax = new FormControl('', Validators.required);
39     contactFormModalLoadMax = new FormControl('', Validators.required);
40     onOpened(event: any) {
41         this.service.loadConfig();
42         this.contactFormModalJsonUrl.setValue(this.service.jsonURL);
43         this.contactFormModalHost.setValue(this.service.hostURL);
44         this.contactFormModalMetrics.setValue(this.service.metricsPath);
45         this.contactFormModalDelay.setValue(this.service.delayPath);
46         this.contactFormModalLoad.setValue(this.service.loadPath);
47         this.contactFormModalDelayMax.setValue(this.service.delayMax);
48         this.contactFormModalLoadMax.setValue(this.service.loadMax);
49         console.log(event);
50     }
51
52
53     constructor(private service: StatsService) {  }
54
55     ngOnInit() {
56         // load from file
57        this.service.loadConfig();
58        // console.log(this.service.hostURL);
59        //this.contactFormModalHost.setValue(this.service.hostURL);
60        //this.contactFormModalJsonUrl.setValue(this.service.jsonURL);
61     }
62
63     save() {
64         // save to file
65         this.service.saveConfig('jsonURL', this.contactFormModalJsonUrl.value);
66         this.service.saveConfig('host', this.contactFormModalHost.value);
67         this.service.saveConfig('metricspath', this.contactFormModalMetrics.value);
68         this.service.saveConfig('delaypath', this.contactFormModalDelay.value);
69         this.service.saveConfig('loadpath', this.contactFormModalLoad.value);
70         this.service.saveConfig('delaymax', this.contactFormModalDelayMax.value);
71         this.service.saveConfig('loadmax', this.contactFormModalLoadMax.value);
72         this.service.loadConfig();
73     }
74
75
76 }