]>
Commit | Line | Data |
---|---|---|
6cbe53c9 AD |
1 | function addInstance() { |
2 | try { | |
7a5103ae | 3 | var query = "backend.php?op=pluginhandler&plugin=instances&method=addInstance"; |
6cbe53c9 AD |
4 | |
5 | if (dijit.byId("instanceAddDlg")) | |
6 | dijit.byId("instanceAddDlg").destroyRecursive(); | |
7 | ||
8 | dialog = new dijit.Dialog({ | |
9 | id: "instanceAddDlg", | |
10 | title: __("Link Instance"), | |
11 | style: "width: 600px", | |
12 | regenKey: function() { | |
13 | new Ajax.Request("backend.php", { | |
76f2113b | 14 | parameters: "op=pluginhandler&plugin=instances&method=genHash", |
6cbe53c9 AD |
15 | onComplete: function(transport) { |
16 | var reply = JSON.parse(transport.responseText); | |
17 | if (reply) | |
18 | dijit.byId('instance_add_key').attr('value', reply.hash); | |
19 | ||
20 | } }); | |
21 | }, | |
22 | execute: function() { | |
23 | if (this.validate()) { | |
24 | console.warn(dojo.objectToQuery(this.attr('value'))); | |
25 | ||
26 | notify_progress('Saving data...', true); | |
27 | new Ajax.Request("backend.php", { | |
28 | parameters: dojo.objectToQuery(this.attr('value')), | |
29 | onComplete: function(transport) { | |
30 | dialog.hide(); | |
31 | notify(''); | |
32 | updateInstanceList(); | |
33 | } }); | |
34 | } | |
35 | }, | |
36 | href: query, | |
37 | }); | |
38 | ||
39 | dialog.show(); | |
40 | ||
41 | } catch (e) { | |
42 | exception_error("addInstance", e); | |
43 | } | |
44 | } | |
45 | ||
46 | // *** INS *** | |
47 | ||
48 | function updateInstanceList(sort_key) { | |
49 | new Ajax.Request("backend.php", { | |
76f2113b | 50 | parameters: "op=pluginhandler&plugin=instances&sort=" + param_escape(sort_key), |
6cbe53c9 AD |
51 | onComplete: function(transport) { |
52 | dijit.byId('instanceConfigTab').attr('content', transport.responseText); | |
53 | selectTab("instanceConfig", true); | |
54 | notify(""); | |
55 | } }); | |
56 | } | |
57 | ||
58 | function editInstance(id, event) { | |
59 | try { | |
60 | if (!event || !event.ctrlKey) { | |
61 | ||
62 | selectTableRows('prefInstanceList', 'none'); | |
63 | selectTableRowById('LIRR-'+id, 'LICHK-'+id, true); | |
64 | ||
76f2113b | 65 | var query = "backend.php?op=pluginhandler&plugin=instances&method=edit&id=" + |
6cbe53c9 AD |
66 | param_escape(id); |
67 | ||
68 | if (dijit.byId("instanceEditDlg")) | |
69 | dijit.byId("instanceEditDlg").destroyRecursive(); | |
70 | ||
71 | dialog = new dijit.Dialog({ | |
72 | id: "instanceEditDlg", | |
73 | title: __("Edit Instance"), | |
74 | style: "width: 600px", | |
75 | regenKey: function() { | |
76 | new Ajax.Request("backend.php", { | |
76f2113b | 77 | parameters: "op=pluginhandler&plugin=instances&method=genHash", |
6cbe53c9 AD |
78 | onComplete: function(transport) { |
79 | var reply = JSON.parse(transport.responseText); | |
80 | if (reply) | |
81 | dijit.byId('instance_edit_key').attr('value', reply.hash); | |
82 | ||
83 | } }); | |
84 | }, | |
85 | execute: function() { | |
86 | if (this.validate()) { | |
87 | // console.warn(dojo.objectToQuery(this.attr('value'))); | |
88 | ||
89 | notify_progress('Saving data...', true); | |
90 | new Ajax.Request("backend.php", { | |
91 | parameters: dojo.objectToQuery(this.attr('value')), | |
92 | onComplete: function(transport) { | |
93 | dialog.hide(); | |
94 | notify(''); | |
95 | updateInstanceList(); | |
96 | } }); | |
97 | } | |
98 | }, | |
99 | href: query, | |
100 | }); | |
101 | ||
102 | dialog.show(); | |
103 | ||
104 | } else if (event.ctrlKey) { | |
105 | var cb = $('LICHK-' + id); | |
106 | cb.checked = !cb.checked; | |
107 | toggleSelectRow(cb); | |
108 | } | |
109 | ||
110 | ||
111 | } catch (e) { | |
112 | exception_error("editInstance", e); | |
113 | } | |
114 | } | |
115 | ||
116 | function removeSelectedInstances() { | |
117 | try { | |
118 | var sel_rows = getSelectedInstances(); | |
119 | ||
120 | if (sel_rows.length > 0) { | |
121 | ||
122 | var ok = confirm(__("Remove selected instances?")); | |
123 | ||
124 | if (ok) { | |
125 | notify_progress("Removing selected instances..."); | |
126 | ||
76f2113b | 127 | var query = "op=pluginhandler&plugin=instances&method=remove&ids="+ |
6cbe53c9 AD |
128 | param_escape(sel_rows.toString()); |
129 | ||
130 | new Ajax.Request("backend.php", { | |
131 | parameters: query, | |
132 | onComplete: function(transport) { | |
133 | notify(''); | |
134 | updateInstanceList(); | |
135 | } }); | |
136 | } | |
137 | ||
138 | } else { | |
139 | alert(__("No instances are selected.")); | |
140 | } | |
141 | ||
142 | } catch (e) { | |
143 | exception_error("removeInstance", e); | |
144 | } | |
145 | } | |
146 | ||
147 | function editSelectedInstance() { | |
148 | var rows = getSelectedInstances(); | |
149 | ||
150 | if (rows.length == 0) { | |
151 | alert(__("No instances are selected.")); | |
152 | return; | |
153 | } | |
154 | ||
155 | if (rows.length > 1) { | |
156 | alert(__("Please select only one instance.")); | |
157 | return; | |
158 | } | |
159 | ||
160 | notify(""); | |
161 | ||
162 | editInstance(rows[0]); | |
163 | } | |
164 | ||
165 | function getSelectedInstances() { | |
166 | return getSelectedTableRowIds("prefInstanceList"); | |
167 | } | |
168 | ||
169 |