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