]>
Commit | Line | Data |
---|---|---|
4d6215bc DC |
1 | Ext.define('PVE.window.ScheduleSimulator', { |
2 | extend: 'Ext.window.Window', | |
3 | ||
4 | title: gettext('Simulate Schedule'), | |
5 | ||
6 | controller: { | |
7 | xclass: 'Ext.app.ViewController', | |
8 | close: function() { this.getView().close(); }, | |
9 | simulate: function() { | |
10 | let me = this; | |
11 | let schedule = me.lookup('schedule').getValue(); | |
12 | if (!schedule) { | |
13 | return; | |
14 | } | |
584a57ea | 15 | let iterations = me.lookup('iterations').getValue() || 10; |
4d6215bc DC |
16 | Proxmox.Utils.API2Request({ |
17 | url: '/cluster/jobs/schedule-analyze', | |
18 | method: 'GET', | |
19 | params: { | |
20 | schedule, | |
584a57ea | 21 | iterations, |
4d6215bc DC |
22 | }, |
23 | failure: function(response, opts) { | |
24 | Ext.Msg.alert(gettext('Error'), response.htmlStatus); | |
25 | }, | |
26 | success: function(response) { | |
27 | let schedules = response.result.data; | |
28 | me.lookup('grid').getStore().setData(schedules); | |
29 | }, | |
30 | }); | |
31 | }, | |
32 | ||
33 | scheduleChanged: function(field, value) { | |
34 | this.lookup('simulateBtn').setDisabled(!value); | |
35 | }, | |
36 | ||
37 | renderTimestamp: function(value) { | |
38 | let date = new Date(value*1000); | |
39 | return date.toLocaleString(); | |
40 | }, | |
41 | ||
42 | init: function(view) { | |
43 | let me = this; | |
44 | if (view.schedule) { | |
45 | me.lookup('schedule').setValue(view.schedule); | |
46 | } | |
47 | }, | |
48 | }, | |
49 | ||
50 | bodyPadding: 10, | |
51 | modal: true, | |
52 | resizable: false, | |
53 | width: 600, | |
54 | ||
55 | layout: 'fit', | |
56 | ||
57 | items: [ | |
58 | { | |
59 | xtype: 'inputpanel', | |
60 | column1: [ | |
61 | { | |
62 | xtype: 'pveCalendarEvent', | |
63 | reference: 'schedule', | |
64 | fieldLabel: gettext('Schedule'), | |
65 | listeners: { | |
66 | change: 'scheduleChanged', | |
67 | }, | |
68 | }, | |
69 | { | |
70 | xtype: 'proxmoxintegerfield', | |
71 | minValue: 1, | |
72 | maxValue: 100, | |
73 | value: 10, | |
584a57ea TL |
74 | reference: 'iterations', |
75 | fieldLabel: gettext('Iterations'), | |
4d6215bc DC |
76 | }, |
77 | { | |
78 | xtype: 'button', | |
79 | reference: 'simulateBtn', | |
80 | text: gettext('Simulate'), | |
81 | handler: 'simulate', | |
82 | align: 'right', | |
83 | disabled: true, | |
84 | }, | |
85 | ], | |
86 | ||
87 | column2: [ | |
88 | { | |
89 | xtype: 'grid', | |
90 | reference: 'grid', | |
91 | emptyText: Proxmox.Utils.NoneText, | |
92 | scrollable: true, | |
93 | height: 300, | |
94 | columns: [ | |
95 | { | |
96 | text: gettext('Local Time'), | |
97 | renderer: 'renderTimestamp', | |
98 | dataIndex: 'timestamp', | |
99 | flex: 1, | |
100 | }, | |
101 | ], | |
102 | store: { | |
103 | fields: ['timestamp'], | |
104 | data: [], | |
105 | sorter: 'timestamp', | |
106 | }, | |
107 | }, | |
108 | ], | |
109 | }, | |
110 | ], | |
111 | ||
112 | buttons: [ | |
113 | { | |
114 | text: gettext('OK'), | |
115 | handler: 'close', | |
116 | }, | |
117 | ], | |
118 | }); |