2017-12-20 19:33:33 +08:00
|
|
|
import coreModule from 'app/core/core_module';
|
|
|
|
|
import config from 'app/core/config';
|
2016-02-18 23:05:15 +08:00
|
|
|
|
|
|
|
|
class StyleGuideCtrl {
|
2016-02-19 00:25:11 +08:00
|
|
|
theme: string;
|
2017-12-21 15:39:31 +08:00
|
|
|
buttonNames = ['primary', 'secondary', 'inverse', 'success', 'warning', 'danger'];
|
2017-12-20 19:33:33 +08:00
|
|
|
buttonSizes = ['btn-small', '', 'btn-large'];
|
|
|
|
|
buttonVariants = ['-'];
|
2017-06-02 20:00:42 +08:00
|
|
|
navModel: any;
|
2016-02-19 00:25:11 +08:00
|
|
|
|
|
|
|
|
/** @ngInject **/
|
2017-12-21 19:31:04 +08:00
|
|
|
constructor(private $routeParams, private backendSrv, navModelSrv) {
|
2017-12-20 19:33:33 +08:00
|
|
|
this.navModel = navModelSrv.getNav('cfg', 'admin', 'styleguide', 1);
|
|
|
|
|
this.theme = config.bootData.user.lightTheme ? 'light' : 'dark';
|
2017-05-02 20:50:10 +08:00
|
|
|
}
|
|
|
|
|
|
2016-02-18 23:05:15 +08:00
|
|
|
switchTheme() {
|
2017-12-20 19:33:33 +08:00
|
|
|
this.$routeParams.theme = this.theme === 'dark' ? 'light' : 'dark';
|
2017-05-02 21:45:34 +08:00
|
|
|
|
|
|
|
|
var cmd = {
|
2017-12-20 19:33:33 +08:00
|
|
|
theme: this.$routeParams.theme,
|
2017-05-02 21:45:34 +08:00
|
|
|
};
|
|
|
|
|
|
2017-12-20 19:33:33 +08:00
|
|
|
this.backendSrv.put('/api/user/preferences', cmd).then(() => {
|
2016-09-21 15:10:25 +08:00
|
|
|
window.location.href = window.location.href;
|
|
|
|
|
});
|
2016-02-18 23:05:15 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 19:33:33 +08:00
|
|
|
coreModule.controller('StyleGuideCtrl', StyleGuideCtrl);
|