]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/api/settings.service.ts
import 15.2.0 Octopus source
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / api / settings.service.ts
index 9403b5769858208bd2d390ce4620cdc0f0e406c5..05a46caec610aa0ae701e7984f1d05da7a877225 100644 (file)
@@ -2,8 +2,18 @@ import { HttpClient } from '@angular/common/http';
 import { Injectable } from '@angular/core';
 
 import * as _ from 'lodash';
+import { Observable } from 'rxjs';
+import { map } from 'rxjs/operators';
+
 import { ApiModule } from './api.module';
 
+class SettingResponse {
+  name: string;
+  default: any;
+  type: string;
+  value: any;
+}
+
 @Injectable({
   providedIn: ApiModule
 })
@@ -12,6 +22,21 @@ export class SettingsService {
 
   private settings: { [url: string]: string } = {};
 
+  getValues(names: string | string[]): Observable<{ [key: string]: any }> {
+    if (_.isArray(names)) {
+      names = names.join(',');
+    }
+    return this.http.get(`api/settings?names=${names}`).pipe(
+      map((resp: SettingResponse[]) => {
+        const result = {};
+        _.forEach(resp, (option: SettingResponse) => {
+          _.set(result, option.name, option.value);
+        });
+        return result;
+      })
+    );
+  }
+
   ifSettingConfigured(url: string, fn: (value?: string) => void, elseFn?: () => void): void {
     const setting = this.settings[url];
     if (setting === undefined) {
@@ -36,7 +61,7 @@ export class SettingsService {
   }
 
   // Easiest way to stop reloading external content that can't be reached
-  disableSetting(url) {
+  disableSetting(url: string) {
     this.settings[url] = '';
   }
 
@@ -44,7 +69,11 @@ export class SettingsService {
     return data.value || data.instance || '';
   }
 
-  validateGrafanaDashboardUrl(uid) {
+  validateGrafanaDashboardUrl(uid: string) {
     return this.http.get(`api/grafana/validation/${uid}`);
   }
+
+  getStandardSettings(): Observable<{ [key: string]: any }> {
+    return this.http.get('ui-api/standard_settings');
+  }
 }