mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* webpack poc, this is not going to work for plugins, dam * tech: webpack and systemjs for plugins starting to work * tech: webpack and systemjs combo starting to work * tech: webpack + karma tests progress * tech: webpack + karma progress * tech: working on tests * tech: webpack * tech: webpack + karma, all tests pass * tech: webpack + karma, all tests pass * tech: webpack all tests pass * webpack: getting closer * tech: webpack progress * webpack: further build refinements * webpack: ng annotate fixes * webpack: optimized build fix * tech: minor fix for elasticsearch * tech: webpack + ace editor * tech: restored lodash move mixin compatability * tech: added enzyme react test and upgraded to react v16 * tech: package version fix * tech: added testdata to built in bundle * webpack: sass progress * tech: prod & dev build is working for the sass * tech: clean up unused grunt stuff and moved to scripts folder * tech: added vendor and manifest chunks, updated readme and docs * tech: webpack finishing touches
67 lines
1.6 KiB
TypeScript
67 lines
1.6 KiB
TypeScript
|
|
import coreModule from 'app/core/core_module';
|
|
import config from 'app/core/config';
|
|
import _ from 'lodash';
|
|
|
|
class StyleGuideCtrl {
|
|
colors: any = [];
|
|
theme: string;
|
|
buttonNames = ['primary', 'secondary', 'inverse', 'success', 'warning', 'danger'];
|
|
buttonSizes = ['btn-small', '', 'btn-large'];
|
|
buttonVariants = ['-', '-outline-'];
|
|
icons: any = [];
|
|
page: any;
|
|
pages = ['colors', 'buttons', 'icons', 'plugins'];
|
|
navModel: any;
|
|
|
|
/** @ngInject **/
|
|
constructor(private $http, private $routeParams, private backendSrv, navModelSrv) {
|
|
this.navModel = navModelSrv.getAdminNav();
|
|
this.theme = config.bootData.user.lightTheme ? 'light': 'dark';
|
|
this.page = {};
|
|
|
|
if ($routeParams.page) {
|
|
this.page[$routeParams.page] = 1;
|
|
} else {
|
|
this.page.colors = true;
|
|
}
|
|
|
|
if (this.page.colors) {
|
|
this.loadColors();
|
|
}
|
|
|
|
if (this.page.icons) {
|
|
this.loadIcons();
|
|
}
|
|
}
|
|
|
|
loadColors() {
|
|
this.$http.get('public/build/styleguide.json').then(res => {
|
|
this.colors = _.map(res.data[this.theme], (value, key) => {
|
|
return {name: key, value: value};
|
|
});
|
|
});
|
|
}
|
|
|
|
loadIcons() {
|
|
this.$http.get('public/sass/icons.json').then(res => {
|
|
this.icons = res.data;
|
|
});
|
|
}
|
|
|
|
switchTheme() {
|
|
this.$routeParams.theme = this.theme === 'dark' ? 'light' : 'dark';
|
|
|
|
var cmd = {
|
|
theme: this.$routeParams.theme
|
|
};
|
|
|
|
this.backendSrv.put('/api/user/preferences', cmd).then(() => {
|
|
window.location.href = window.location.href;
|
|
});
|
|
}
|
|
|
|
}
|
|
|
|
coreModule.controller('StyleGuideCtrl', StyleGuideCtrl);
|