]>
Commit | Line | Data |
---|---|---|
32f469f3 EK |
1 | /* Popup a message window |
2 | * where the user has to manually enter the ressource ID | |
3 | * to enable the destroy button | |
4 | */ | |
5 | Ext.define('PVE.window.SafeDestroy', { | |
6 | extend: 'Ext.window.Window', | |
7 | alias: 'widget.pveSafeDestroy', | |
8 | title: gettext('Are you sure ?'), | |
9 | modal: true, | |
10 | buttonAlign: 'center', | |
11 | ||
12 | items: [ | |
13 | { | |
14 | itemId: 'safepanel', | |
15 | xtype: 'container', | |
16 | padding: 10, | |
17 | width: 450, | |
18 | layout: { | |
19 | type: 'vbox', | |
20 | align: 'stretch' | |
21 | }, | |
22 | items: [ | |
23 | { | |
24 | itemId: 'message', | |
25 | xtype: 'textarea', | |
26 | editable: false, | |
27 | }, | |
28 | { | |
29 | itemId: 'input', | |
30 | xtype: 'numberfield', | |
31 | name: 'VM id', | |
32 | fieldLabel: gettext('Please enter the VM ID to confirm'), | |
33 | hideTrigger:true, | |
34 | allowBlank: false, | |
35 | listeners: { | |
36 | change: function(f, value) { | |
37 | if (value === this.vmid) { | |
38 | this.submitBtn.enable(); | |
39 | } else { | |
40 | this.submitBtn.disable(); | |
41 | } | |
42 | } | |
43 | } | |
44 | } | |
45 | ] | |
46 | } | |
47 | ], | |
48 | buttons: [ | |
49 | { | |
50 | id: 'removeButton', | |
51 | text: gettext('Remove'), | |
52 | disabled: true, | |
53 | handler: function () { | |
54 | var me = this; | |
55 | PVE.Utils.API2Request({ | |
56 | url: me.base_url, | |
57 | method: 'DELETE', | |
58 | waitMsgTarget: me, | |
59 | failure: function(response, opts) { | |
60 | Ext.Msg.alert('Error', response.htmlStatus); | |
61 | } | |
62 | }); | |
63 | me.up('window').close(); | |
64 | } | |
65 | }, { | |
66 | text: gettext('Cancel'), | |
67 | handler: function() { | |
68 | this.up('window').close(); | |
69 | } | |
70 | } | |
71 | ], | |
72 | ||
73 | initComponent: function() { | |
74 | var me = this; | |
75 | me.callParent(); | |
76 | ||
77 | var msg = Ext.String.format(gettext('Are you sure you want to remove VM {0}? This will permanently erase all VM data.'), me.vmid); | |
78 | me.getComponent('safepanel').getComponent('message').setValue(msg); | |
79 | ||
80 | var submitBtn = me.down('toolbar').getComponent('removeButton'); | |
81 | submitBtn.base_url= me.base_url; | |
82 | ||
83 | me.getComponent('safepanel').getComponent('input').vmid = me.vmid; | |
84 | me.getComponent('safepanel').getComponent('input').submitBtn = submitBtn; | |
85 | } | |
86 | }); |