]> git.proxmox.com Git - proxmox-widget-toolkit.git/blame - src/window/ThemeEdit.js
theme edit: ensure that the saved theme is actually valid
[proxmox-widget-toolkit.git] / src / window / ThemeEdit.js
CommitLineData
15fddc20
DT
1Ext.define('Proxmox.window.ThemeEditWindow', {
2 extend: 'Ext.window.Window',
3 alias: 'widget.pmxThemeEditWindow',
4
5 viewModel: {
6 parent: null,
5835bc4c 7 data: {},
15fddc20
DT
8 },
9 controller: {
10 xclass: 'Ext.app.ViewController',
11 init: function(view) {
5835bc4c
TL
12 let theme = '__default__';
13
14 let savedTheme = Ext.util.Cookies.get(view.cookieName);
15 if (savedTheme && savedTheme in Proxmox.Utils.theme_map) {
16 theme = savedTheme;
17 }
15fddc20
DT
18 this.getViewModel().set('theme', theme);
19 },
20 applyTheme: function(button) {
21 let view = this.getView();
22 let vm = this.getViewModel();
23
24 let expire = Ext.Date.add(new Date(), Ext.Date.YEAR, 10);
25 Ext.util.Cookies.set(view.cookieName, vm.get('theme'), expire);
26 view.mask(gettext('Please wait...'), 'x-mask-loading');
27 window.location.reload();
28 },
29 },
30
31 cookieName: 'PVEThemeCookie',
32
5afec12b 33 title: gettext('Color Theme'),
15fddc20
DT
34 modal: true,
35 bodyPadding: 10,
36 resizable: false,
37 items: [
38 {
39 xtype: 'proxmoxThemeSelector',
5afec12b 40 fieldLabel: gettext('Color Theme'),
15fddc20
DT
41 bind: {
42 value: '{theme}',
43 },
44 },
45 ],
46 buttons: [
47 {
48 text: gettext('Apply'),
49 handler: 'applyTheme',
50 },
51 ],
52});