浏览代码

fix theme switching in style guide

Andrei Stefan 8 年之前
父节点
当前提交
53ccc6f48f
共有 2 个文件被更改,包括 7 次插入7 次删除
  1. 0 4
      public/app/features/styleguide/styleguide.html
  2. 7 3
      public/app/features/styleguide/styleguide.ts

+ 0 - 4
public/app/features/styleguide/styleguide.html

@@ -9,10 +9,6 @@
 			<i class="fa fa-random"></i>
 			<i class="fa fa-random"></i>
 			Switch theme
 			Switch theme
 		</a>
 		</a>
-		<a class="btn btn-inverse" ng-click="ctrl.switchTheme()">
-			<i class="fa fa-refresh"></i>
-			Reload
-		</a>
 
 
 		<div class="page-header-tabs">
 		<div class="page-header-tabs">
 			<ul class="gf-tabs">
 			<ul class="gf-tabs">

+ 7 - 3
public/app/features/styleguide/styleguide.ts

@@ -14,7 +14,7 @@ class StyleGuideCtrl {
   pages = ['colors', 'buttons', 'icons', 'plugins'];
   pages = ['colors', 'buttons', 'icons', 'plugins'];
 
 
   /** @ngInject **/
   /** @ngInject **/
-  constructor(private $http, private $routeParams, private $location) {
+  constructor(private $http, private $routeParams, private $location, private backendSrv) {
     this.theme = config.bootData.user.lightTheme ? 'light': 'dark';
     this.theme = config.bootData.user.lightTheme ? 'light': 'dark';
     this.page = {};
     this.page = {};
 
 
@@ -49,8 +49,12 @@ class StyleGuideCtrl {
 
 
   switchTheme() {
   switchTheme() {
     this.$routeParams.theme = this.theme === 'dark' ? 'light' : 'dark';
     this.$routeParams.theme = this.theme === 'dark' ? 'light' : 'dark';
-    this.$location.search(this.$routeParams);
-    setTimeout(() => {
+
+    var cmd = {
+      theme: this.$routeParams.theme
+    };
+
+    this.backendSrv.put('/api/user/preferences', cmd).then(() => {
       window.location.href = window.location.href;
       window.location.href = window.location.href;
     });
     });
   }
   }