styleguide.ts 885 B

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