grafana/public/app/features/styleguide/styleguide.ts

31 lines
884 B
TypeScript
Raw Normal View History

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 {
theme: string;
buttonNames = ['primary', 'secondary', 'inverse', 'success', 'warning', 'danger'];
2017-12-20 19:33:33 +08:00
buttonSizes = ['btn-small', '', 'btn-large'];
buttonVariants = ['-'];
navModel: any;
/** @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(() => {
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);