]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/api/configuration.service.ts
import 15.2.0 Octopus source
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / api / configuration.service.ts
index 3355b8fb7723886e98c0aaaa551a50208877f12f..68be515101db17788f37452205cb5977ca3114a0 100644 (file)
@@ -10,6 +10,30 @@ import { ApiModule } from './api.module';
 export class ConfigurationService {
   constructor(private http: HttpClient) {}
 
+  private findValue(config: any, section: string) {
+    if (!config.value) {
+      return undefined;
+    }
+    return config.value.find((v: any) => v.section === section);
+  }
+
+  getValue(config: any, section: string) {
+    let val = this.findValue(config, section);
+    if (!val) {
+      const indexOfDot = section.indexOf('.');
+      if (indexOfDot !== -1) {
+        val = this.findValue(config, section.substring(0, indexOfDot));
+      }
+    }
+    if (!val) {
+      val = this.findValue(config, 'global');
+    }
+    if (val) {
+      return val.value;
+    }
+    return config.default;
+  }
+
   getConfigData() {
     return this.http.get('api/cluster_conf/');
   }
@@ -30,7 +54,7 @@ export class ConfigurationService {
     return this.http.delete(`api/cluster_conf/${configOption}?section=${section}`);
   }
 
-  bulkCreate(configOptions: Object) {
+  bulkCreate(configOptions: object) {
     return this.http.put('api/cluster_conf/', configOptions);
   }
 }