StyleGuideCtrl.ts 788 B

123456789101112131415161718192021222324252627
  1. import config from 'app/core/config';
  2. export default class StyleGuideCtrl {
  3. theme: string;
  4. buttonNames = ['primary', 'secondary', 'inverse', 'success', 'warning', 'danger'];
  5. buttonSizes = ['btn-small', '', 'btn-large'];
  6. buttonVariants = ['-'];
  7. navModel: any;
  8. /** @ngInject */
  9. constructor(private $routeParams, private backendSrv, navModelSrv) {
  10. this.navModel = navModelSrv.getNav('admin', 'styleguide', 0);
  11. this.theme = config.bootData.user.lightTheme ? 'light' : 'dark';
  12. }
  13. switchTheme() {
  14. this.$routeParams.theme = this.theme === 'dark' ? 'light' : 'dark';
  15. const cmd = {
  16. theme: this.$routeParams.theme,
  17. };
  18. this.backendSrv.put('/api/user/preferences', cmd).then(() => {
  19. window.location.href = window.location.href;
  20. });
  21. }
  22. }