StyleGuideCtrl.ts 923 B

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