Initial commit of RIC Dashboard webapp
[portal/ric-dashboard.git] / webapp-frontend / src / app / ui / config-event / config-event.component.ts
diff --git a/webapp-frontend/src/app/ui/config-event/config-event.component.ts b/webapp-frontend/src/app/ui/config-event/config-event.component.ts
new file mode 100644 (file)
index 0000000..6a4b631
--- /dev/null
@@ -0,0 +1,76 @@
+/*-
+ * ========================LICENSE_START=================================
+ * ORAN-OSC
+ * %%
+ * Copyright (C) 2019 AT&T Intellectual Property and Nokia
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ========================LICENSE_END===================================
+ */
+import { Component, OnInit } from '@angular/core';
+import { FormControl, Validators } from '@angular/forms';
+import { StatsService } from '../../services/stats/stats.service';
+
+@Component({
+  selector: 'app-config-event',
+  templateUrl: './config-event.component.html',
+  styleUrls: ['./config-event.component.scss']
+})
+export class ConfigEventComponent implements OnInit {
+
+    public renderValue;
+
+    contactFormModalJsonUrl = new FormControl('', Validators.required);
+    contactFormModalHost = new FormControl('', Validators.required);
+    contactFormModalMetrics = new FormControl('', Validators.required);
+    contactFormModalDelay = new FormControl('', Validators.required);
+    contactFormModalLoad = new FormControl('', Validators.required);
+    contactFormModalDelayMax = new FormControl('', Validators.required);
+    contactFormModalLoadMax = new FormControl('', Validators.required);
+    onOpened(event: any) {
+        this.service.loadConfig();
+        this.contactFormModalJsonUrl.setValue(this.service.jsonURL);
+        this.contactFormModalHost.setValue(this.service.hostURL);
+        this.contactFormModalMetrics.setValue(this.service.metricsPath);
+        this.contactFormModalDelay.setValue(this.service.delayPath);
+        this.contactFormModalLoad.setValue(this.service.loadPath);
+        this.contactFormModalDelayMax.setValue(this.service.delayMax);
+        this.contactFormModalLoadMax.setValue(this.service.loadMax);
+        console.log(event);
+    }
+
+
+    constructor(private service: StatsService) {  }
+
+    ngOnInit() {
+        // load from file
+       this.service.loadConfig();
+       // console.log(this.service.hostURL);
+       //this.contactFormModalHost.setValue(this.service.hostURL);
+       //this.contactFormModalJsonUrl.setValue(this.service.jsonURL);
+    }
+
+    save() {
+        // save to file
+        this.service.saveConfig('jsonURL', this.contactFormModalJsonUrl.value);
+        this.service.saveConfig('host', this.contactFormModalHost.value);
+        this.service.saveConfig('metricspath', this.contactFormModalMetrics.value);
+        this.service.saveConfig('delaypath', this.contactFormModalDelay.value);
+        this.service.saveConfig('loadpath', this.contactFormModalLoad.value);
+        this.service.saveConfig('delaymax', this.contactFormModalDelayMax.value);
+        this.service.saveConfig('loadmax', this.contactFormModalLoadMax.value);
+        this.service.loadConfig();
+    }
+
+
+}