Fixed bug in grafana url setting
[src/xds/xds-agent.git] / webapp / src / app / @core-xds / services / config.service.ts
index beeeea8..23a9593 100644 (file)
@@ -57,7 +57,7 @@ export class ConfigService {
       }
       if (tm.name !== this.confStore.theme) {
         this.confStore.theme = tm.name;
-        this.save();
+        this.save(this.confStore);
       }
     });
 
@@ -75,16 +75,13 @@ export class ConfigService {
       this.confSubject.next(Object.assign({}, this.confStore));
     } else {
       // Set default config
-      this.confStore = this.confDefault;
-      this.save();
+      this.save(null);
     }
   }
 
   // Save config into cookie
-  save(cfg?: IConfig) {
-    if (typeof cfg !== 'undefined') {
-      this.confStore = this.confDefault;
-    }
+  save(cfg: IConfig | null) {
+    this.confStore = (cfg !== null) ? cfg : this.confDefault;
 
     // Notify subscribers
     this.confSubject.next(Object.assign({}, this.confStore));