grafana/public/app/features/admin/StyleGuideCtrl.ts

30 lines
923 B
TypeScript
Raw Normal View History

2017-12-20 05:33:33 -06:00
import config from 'app/core/config';
2019-05-13 02:38:19 -05:00
import { BackendSrv } from 'app/core/services/backend_srv';
import { NavModelSrv } from 'app/core/core';
2016-02-18 09:05:15 -06:00
2018-09-10 06:38:45 -05:00
export default class StyleGuideCtrl {
theme: string;
buttonNames = ['primary', 'secondary', 'inverse', 'success', 'warning', 'danger'];
2017-12-20 05:33:33 -06:00
buttonSizes = ['btn-small', '', 'btn-large'];
buttonVariants = ['-'];
navModel: any;
/** @ngInject */
2019-05-13 02:38:19 -05:00
constructor(private $routeParams: any, private backendSrv: BackendSrv, navModelSrv: NavModelSrv) {
this.navModel = navModelSrv.getNav('admin', 'styleguide', 0);
2017-12-20 05:33:33 -06:00
this.theme = config.bootData.user.lightTheme ? 'light' : 'dark';
2017-05-02 07:50:10 -05:00
}
2016-02-18 09:05:15 -06:00
switchTheme() {
2017-12-20 05:33:33 -06:00
this.$routeParams.theme = this.theme === 'dark' ? 'light' : 'dark';
2017-05-02 08:45:34 -05:00
2018-08-26 13:19:23 -05:00
const cmd = {
2017-12-20 05:33:33 -06:00
theme: this.$routeParams.theme,
2017-05-02 08:45:34 -05:00
};
2017-12-20 05:33:33 -06:00
this.backendSrv.put('/api/user/preferences', cmd).then(() => {
window.location.href = window.location.href;
});
2016-02-18 09:05:15 -06:00
}
}