]> git.proxmox.com Git - pmg-gui.git/blame - js/RelayDomains.js
avoid to many gettext entries
[pmg-gui.git] / js / RelayDomains.js
CommitLineData
20c9b1f2
DM
1Ext.define('pmg-domains', {
2 extend: 'Ext.data.Model',
3 fields: [ 'domain', 'comment' ],
4 proxy: {
5 type: 'proxmox',
6 url: "/api2/json/config/domains"
7 },
8 idProperty: 'domain'
9});
10
11Ext.define('PMG.RelayDomains', {
12 extend: 'Ext.grid.GridPanel',
13 alias: ['widget.pmgRelayDomains'],
14
15 initComponent : function() {
16 var me = this;
17
18 var store = new Ext.data.Store({
19 model: 'pmg-domains',
20 sorters: {
21 property: 'domain',
22 order: 'DESC'
23 }
24 });
25
26 var reload = function() {
27 store.load();
28 };
29
d80ddaf7 30 me.selModel = Ext.create('Ext.selection.RowModel', {});
20c9b1f2
DM
31
32 var remove_btn = Ext.createWidget('proxmoxButton', {
33 text: gettext('Remove'),
34 disabled: true,
d80ddaf7 35 selModel: me.selModel,
20c9b1f2
DM
36 confirmMsg: function (rec) {
37 return Ext.String.format(
38 gettext('Are you sure you want to remove entry {0}'),
39 "'" + rec.data.domain + "'");
40 },
41 handler: function(btn, event, rec) {
42 Proxmox.Utils.API2Request({
43 url: '/config/domains/' + rec.data.domain,
44 method: 'DELETE',
45 waitMsgTarget: me,
46 callback: function() {
47 reload();
48 },
49 failure: function (response, opts) {
50 Ext.Msg.alert(gettext('Error'), response.htmlStatus);
51 }
52 });
53 }
54 });
55
597c19d8
DM
56 var run_editor = function() {
57 var rec = me.selModel.getSelection()[0];
58 if (!rec) {
59 return;
60 }
61
62 var config = {
63 url: "/api2/extjs/config/domains/" + rec.data.domain,
64 method: 'PUT',
65 subject: gettext("Relay Domain"),
66 items: [
67 {
68 xtype: 'displayfield',
69 name: 'domain',
70 fieldLabel: gettext("Relay Domain")
71 },
72 {
73 xtype: 'textfield',
74 name: 'comment',
75 fieldLabel: gettext("Comment")
76 }
77 ]
78 };
79
80 var win = Ext.createWidget('proxmoxWindowEdit', config);
81
82 win.load();
83 win.on('destroy', reload);
84 win.show();
85 };
86
20c9b1f2 87 var tbar = [
597c19d8
DM
88 {
89 xtype: 'proxmoxButton',
90 text: gettext('Edit'),
91 disabled: true,
92 selModel: me.selModel,
93 handler: run_editor
94 },
20c9b1f2
DM
95 {
96 text: gettext('Create'),
97 handler: function() {
98 var config = {
99 method: 'POST',
20c9b1f2 100 url: "/api2/extjs/config/domains",
597c19d8 101 create: true,
20c9b1f2 102 subject: gettext("Relay Domain"),
597c19d8
DM
103 items: [
104 {
105 xtype: 'proxmoxtextfield',
106 name: 'domain',
107 fieldLabel: gettext("Relay Domain")
108 },
109 {
110 xtype: 'proxmoxtextfield',
111 name: 'comment',
112 fieldLabel: gettext("Comment")
113 }
114 ]
20c9b1f2
DM
115 };
116
117 var win = Ext.createWidget('proxmoxWindowEdit', config);
597c19d8 118
20c9b1f2
DM
119 win.on('destroy', reload);
120 win.show();
121 }
122 },
123 remove_btn
124 ];
125
126 Proxmox.Utils.monStoreErrors(me, store);
127
128 Ext.apply(me, {
129 store: store,
20c9b1f2
DM
130 tbar: tbar,
131 viewConfig: {
132 trackOver: false
133 },
134 columns: [
135 {
136 header: gettext('Relay Domain'),
137 width: 200,
138 sortable: true,
139 dataIndex: 'domain'
140 },
141 {
142 header: gettext('Comment'),
143 sortable: false,
144 renderer: Ext.String.htmlEncode,
145 dataIndex: 'comment',
146 flex: 1
147 }
148 ],
149 listeners: {
597c19d8 150 itemdblclick: run_editor,
20c9b1f2
DM
151 activate: reload
152 }
153 });
154
155 me.callParent();
156 }
157});