summaryrefslogtreecommitdiff
path: root/prefs.js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2011-04-20 14:25:02 +0400
committerAndrew Dolgov <[email protected]>2011-04-20 14:25:02 +0400
commit323103323b5ca370bd64e96b77b49f0b48bc05ed (patch)
treeee2aa64bf9ed0c295238179dbebdbb0f11f0ebbc /prefs.js
parent9104a3e65afdb884dd2a6289ac62161d8176c555 (diff)
implement instance adding and deleting
Diffstat (limited to 'prefs.js')
-rw-r--r--prefs.js61
1 files changed, 59 insertions, 2 deletions
diff --git a/prefs.js b/prefs.js
index 5c7131d2f..1cf294329 100644
--- a/prefs.js
+++ b/prefs.js
@@ -1785,8 +1785,43 @@ function getSelectedInstances() {
function addInstance() {
try {
- alert("TODO: function not implemented.");
+ var query = "backend.php?op=dlg&id=addInstance";
+ if (dijit.byId("instanceAddDlg"))
+ dijit.byId("instanceAddDlg").destroyRecursive();
+
+ dialog = new dijit.Dialog({
+ id: "instanceAddDlg",
+ title: __("Link Instance"),
+ style: "width: 600px",
+ regenKey: function() {
+ new Ajax.Request("backend.php", {
+ parameters: "?op=rpc&subop=genHash",
+ onComplete: function(transport) {
+ var reply = JSON.parse(transport.responseText);
+ if (reply)
+ dijit.byId('instance_add_key').attr('value', reply.hash);
+
+ } });
+ },
+ execute: function() {
+ if (this.validate()) {
+ console.warn(dojo.objectToQuery(this.attr('value')));
+
+ notify_progress('Saving data...', true);
+ new Ajax.Request("backend.php", {
+ parameters: dojo.objectToQuery(this.attr('value')),
+ onComplete: function(transport) {
+ dialog.hide();
+ notify('');
+ updateInstanceList();
+ } });
+ }
+ },
+ href: query,
+ });
+
+ dialog.show();
} catch (e) {
exception_error("addInstance", e);
@@ -1853,7 +1888,29 @@ function editInstance(id, event) {
function removeSelectedInstances() {
try {
- alert("TODO: function not implemented.");
+ var sel_rows = getSelectedInstances();
+
+ if (sel_rows.length > 0) {
+
+ var ok = confirm(__("Remove selected instances?"));
+
+ if (ok) {
+ notify_progress("Removing selected instances...");
+
+ var query = "?op=pref-instances&subop=remove&ids="+
+ param_escape(sel_rows.toString());
+
+ new Ajax.Request("backend.php", {
+ parameters: query,
+ onComplete: function(transport) {
+ notify('');
+ updateInstanceList();
+ } });
+ }
+
+ } else {
+ alert(__("No instances are selected."));
+ }
} catch (e) {
exception_error("removeInstance", e);