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