]>
Commit | Line | Data |
---|---|---|
40120a31 CE |
1 | Ext.define('PVE.FirewallLograteInputPanel', { |
2 | extend: 'Proxmox.panel.InputPanel', | |
3 | xtype: 'pveFirewallLograteInputPanel', | |
4 | ||
5 | viewModel: {}, | |
6 | ||
7 | items: [ | |
8 | { | |
9 | xtype: 'proxmoxcheckbox', | |
10 | name: 'enable', | |
11 | reference: 'enable', | |
12 | fieldLabel: gettext('Enable'), | |
f6710aac | 13 | value: true, |
40120a31 CE |
14 | }, |
15 | { | |
16 | layout: 'hbox', | |
17 | border: false, | |
18 | items: [ | |
19 | { | |
20 | xtype: 'numberfield', | |
21 | name: 'rate', | |
22 | fieldLabel: gettext('Log rate limit'), | |
23 | minValue: 1, | |
24 | maxValue: 99, | |
25 | allowBlank: false, | |
26 | flex: 2, | |
f6710aac | 27 | value: 1, |
40120a31 CE |
28 | }, |
29 | { | |
df93368f | 30 | xtype: 'box', |
f6710aac | 31 | html: '<div style="margin: auto; padding: 2.5px;"><b>/</b></div>', |
40120a31 CE |
32 | }, |
33 | { | |
34 | xtype: 'proxmoxKVComboBox', | |
35 | name: 'unit', | |
75728a88 TL |
36 | comboItems: [ |
37 | ['second', 'second'], | |
38 | ['minute', 'minute'], | |
39 | ['hour', 'hour'], | |
40 | ['day', 'day'], | |
41 | ], | |
40120a31 CE |
42 | allowBlank: false, |
43 | flex: 1, | |
f6710aac TL |
44 | value: 'second', |
45 | }, | |
46 | ], | |
40120a31 CE |
47 | }, |
48 | { | |
49 | xtype: 'numberfield', | |
50 | name: 'burst', | |
51 | fieldLabel: gettext('Log burst limit'), | |
52 | minValue: 1, | |
53 | maxValue: 99, | |
f6710aac TL |
54 | value: 5, |
55 | }, | |
40120a31 CE |
56 | ], |
57 | ||
58 | onGetValues: function(values) { | |
75728a88 | 59 | let me = this; |
40120a31 | 60 | |
75728a88 TL |
61 | let cfg = { |
62 | enable: values.enable !== undefined ? 1 : 0, | |
63 | rate: values.rate + '/' + values.unit, | |
64 | burst: values.burst, | |
65 | }; | |
66 | let properties = PVE.Parser.printPropertyString(cfg, undefined); | |
67 | if (properties === '') { | |
40120a31 CE |
68 | return { 'delete': 'log_ratelimit' }; |
69 | } | |
70 | return { log_ratelimit: properties }; | |
71 | }, | |
72 | ||
73 | setValues: function(values) { | |
75728a88 | 74 | let me = this; |
40120a31 | 75 | |
75728a88 | 76 | let properties = {}; |
40120a31 | 77 | if (values.log_ratelimit !== undefined) { |
f6632d26 TL |
78 | properties = PVE.Parser.parsePropertyString(values.log_ratelimit, 'enable'); |
79 | if (properties.rate) { | |
80 | var matches = properties.rate.match(/^(\d+)\/(second|minute|hour|day)$/); | |
81 | if (matches) { | |
82 | properties.rate = matches[1]; | |
83 | properties.unit = matches[2]; | |
84 | } | |
40120a31 CE |
85 | } |
86 | } | |
87 | me.callParent([properties]); | |
f6710aac | 88 | }, |
40120a31 CE |
89 | }); |
90 | ||
91 | Ext.define('PVE.FirewallLograteEdit', { | |
92 | extend: 'Proxmox.window.Edit', | |
93 | xtype: 'pveFirewallLograteEdit', | |
94 | ||
95 | subject: gettext('Log rate limit'), | |
96 | ||
97 | items: [{ | |
f6710aac | 98 | xtype: 'pveFirewallLograteInputPanel', |
40120a31 | 99 | }], |
f6710aac | 100 | autoLoad: true, |
40120a31 | 101 | }); |