]>
Commit | Line | Data |
---|---|---|
4ea89615 DC |
1 | Ext.define('PBS.window.DatastoreRepoInfo', { |
2 | extend: 'Ext.window.Window', | |
3 | alias: 'widget.pbsDatastoreRepoInfo', | |
4 | mixins: ['Proxmox.Mixin.CBind'], | |
5 | ||
6 | title: gettext('Connection Information'), | |
7 | ||
8 | modal: true, | |
9 | resizable: false, | |
10 | width: 600, | |
11 | layout: 'anchor', | |
12 | bodyPadding: 10, | |
13 | ||
14 | cbindData: function() { | |
15 | let me = this; | |
a662274e | 16 | let fingerprint = Proxmox.Fingerprint; |
4ea89615 DC |
17 | let host = window.location.hostname; |
18 | let hostname = host; | |
19 | if (window.location.port.toString() !== "8007") { | |
20 | host += `:${window.location.port}`; | |
21 | } | |
22 | let datastore = me.datastore; | |
23 | let user = Proxmox.UserName; | |
24 | let repository = `${host}:${datastore}`; | |
25 | let repositoryWithUser = `${user}@${host}:${datastore}`; | |
26 | ||
27 | return { | |
28 | datastore, | |
29 | hostname, | |
a662274e | 30 | fingerprint, |
4ea89615 DC |
31 | repository, |
32 | repositoryWithUser, | |
33 | }; | |
34 | }, | |
35 | ||
36 | defaults: { | |
37 | xtype: 'pbsCopyField', | |
38 | labelWidth: 120, | |
39 | }, | |
40 | ||
41 | items: [ | |
42 | { | |
43 | fieldLabel: gettext('Datastore'), | |
44 | cbind: { | |
45 | value: '{datastore}', | |
46 | }, | |
47 | }, | |
48 | { | |
49 | fieldLabel: gettext('Hostname/IP'), | |
50 | cbind: { | |
51 | value: '{hostname}', | |
52 | }, | |
53 | }, | |
a662274e DC |
54 | { |
55 | fieldLabel: gettext('Fingerprint'), | |
56 | cbind: { | |
57 | value: '{fingerprint}', | |
58 | hidden: '{!fingerprint}', | |
59 | }, | |
60 | }, | |
4ea89615 DC |
61 | { |
62 | xtype: 'displayfield', | |
63 | value: '', | |
64 | labelWidth: 500, | |
65 | fieldLabel: gettext('Repository for CLI and API'), | |
66 | padding: '10 0 0 0', | |
67 | }, | |
68 | { | |
69 | fieldLabel: gettext('Repository'), | |
70 | cbind: { | |
71 | value: '{repository}', | |
72 | }, | |
73 | }, | |
74 | { | |
75 | fieldLabel: gettext('With Current User'), | |
76 | cbind: { | |
77 | value: '{repositoryWithUser}', | |
78 | }, | |
79 | }, | |
80 | ], | |
81 | buttons: [ | |
82 | { | |
83 | xtype: 'proxmoxHelpButton', | |
84 | onlineHelp: 'client_repository', | |
85 | hidden: false, | |
86 | }, | |
87 | '->', | |
88 | { | |
89 | text: gettext('Ok'), | |
90 | handler: function() { | |
91 | this.up('window').close(); | |
92 | }, | |
93 | }, | |
94 | ], | |
95 | }); | |
96 | ||
97 | Ext.define('PBS.form.CopyField', { | |
98 | extend: 'Ext.form.FieldContainer', | |
99 | alias: 'widget.pbsCopyField', | |
100 | ||
101 | layout: 'hbox', | |
102 | ||
103 | items: [ | |
104 | { | |
105 | xtype: 'textfield', | |
106 | itemId: 'inputField', | |
107 | editable: false, | |
108 | flex: 1, | |
109 | }, | |
110 | { | |
111 | xtype: 'button', | |
112 | margin: '0 0 0 10', | |
113 | iconCls: 'fa fa-clipboard x-btn-icon-el-default-toolbar-small', | |
114 | baseCls: 'x-btn', | |
115 | cls: 'x-btn-default-toolbar-small proxmox-inline-button', | |
e66d75ca | 116 | handler: async function() { |
4ea89615 DC |
117 | let me = this; |
118 | let field = me.up('pbsCopyField'); | |
119 | let el = field.getComponent('inputField')?.inputEl; | |
120 | if (!el?.dom) { | |
121 | return; | |
122 | } | |
e66d75ca | 123 | await navigator.clipboard.writeText(el.dom.value); |
4ea89615 DC |
124 | }, |
125 | text: gettext('Copy'), | |
126 | }, | |
127 | ], | |
128 | ||
129 | initComponent: function() { | |
130 | let me = this; | |
131 | me.callParent(); | |
132 | me.getComponent('inputField').setValue(me.value); | |
133 | }, | |
134 | }); |