]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/qemu/SSHKey.js
update shipped appliance info index
[pve-manager.git] / www / manager6 / qemu / SSHKey.js
CommitLineData
0aa9d113
DC
1Ext.define('PVE.qemu.SSHKeyInputPanel', {
2 extend: 'Proxmox.panel.InputPanel',
3 xtype: 'pveQemuSSHKeyInputPanel',
4
5 insideWizard: false,
6
7 onGetValues: function(values) {
8 var me = this;
9 if (values.sshkeys) {
10 values.sshkeys.trim();
11 }
12 if (!values.sshkeys.length) {
13 values = {};
399ffa76 14 values.delete = 'sshkeys';
0aa9d113
DC
15 return values;
16 } else {
17 values.sshkeys = encodeURIComponent(values.sshkeys);
18 }
19 return values;
20 },
21
22 items: [
23 {
24 xtype: 'textarea',
25 itemId: 'sshkeys',
26 name: 'sshkeys',
f6710aac 27 height: 250,
0aa9d113
DC
28 },
29 {
30 xtype: 'filebutton',
31 itemId: 'filebutton',
32 name: 'file',
33 text: gettext('Load SSH Key File'),
34 fieldLabel: 'test',
35 listeners: {
36 change: function(btn, e, value) {
46d9a35c 37 let view = this.up('inputpanel');
0aa9d113
DC
38 e = e.event;
39 Ext.Array.each(e.target.files, function(file) {
40 PVE.Utils.loadSSHKeyFromFile(file, function(res) {
46d9a35c 41 let keysField = view.down('#sshkeys');
0aa9d113
DC
42 var old = keysField.getValue();
43 keysField.setValue(old + res);
44 });
45 });
46 btn.reset();
f6710aac
TL
47 },
48 },
49 },
0aa9d113
DC
50 ],
51
52 initComponent: function() {
53 var me = this;
54
55 me.callParent();
56 if (!window.FileReader) {
57 me.down('#filebutton').setVisible(false);
58 }
f6710aac 59 },
0aa9d113
DC
60});
61
62Ext.define('PVE.qemu.SSHKeyEdit', {
63 extend: 'Proxmox.window.Edit',
64
65 width: 800,
66
8058410f 67 initComponent: function() {
0aa9d113
DC
68 var me = this;
69
70 var ipanel = Ext.create('PVE.qemu.SSHKeyInputPanel');
71
72 Ext.apply(me, {
73 subject: gettext('SSH Keys'),
8058410f 74 items: [ipanel],
0aa9d113
DC
75 });
76
77 me.callParent();
78
79 if (!me.create) {
80 me.load({
81 success: function(response, options) {
82 var data = response.result.data;
83 if (data.sshkeys) {
84 data.sshkeys = decodeURIComponent(data.sshkeys);
85 ipanel.setValues(data);
86 }
f6710aac 87 },
0aa9d113
DC
88 });
89 }
f6710aac 90 },
0aa9d113 91});