From 373266eb0394cd879e74db009e1629828a47eb33 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 20 Apr 2011 12:11:24 +0400 Subject: implement instances tab --- prefs.js | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) (limited to 'prefs.js') diff --git a/prefs.js b/prefs.js index d22686cee..f0a9de5db 100644 --- a/prefs.js +++ b/prefs.js @@ -5,6 +5,16 @@ var hotkey_prefix_pressed = false; var seq = ""; +function instancelist_callback2(transport) { + try { + dijit.byId('instanceConfigTab').attr('content', transport.responseText); + selectTab("instanceConfig", true); + notify(""); + } catch (e) { + exception_error("instancelist_callback2", e); + } +} + function feedlist_callback2(transport) { try { dijit.byId('feedConfigTab').attr('content', transport.responseText); @@ -61,6 +71,14 @@ function updateFeedList(sort_key) { } }); } +function updateInstanceList(sort_key) { + new Ajax.Request("backend.php", { + parameters: "?op=pref-instances&sort=" + param_escape(sort_key), + onComplete: function(transport) { + instancelist_callback2(transport); + } }); +} + function updateUsersList(sort_key) { try { @@ -1755,3 +1773,79 @@ function insertSSLserial(value) { exception_error("insertSSLcerial", e); } } + +function getSelectedInstances() { + return getSelectedTableRowIds("prefInstanceList"); +} + +function addInstance() { + try { + alert("TODO: function not implemented."); + + + } catch (e) { + exception_error("addInstance", e); + } +} + +function editInstance(id, event) { + try { + if (!event || !event.ctrlKey) { + + selectTableRows('prefInstanceList', 'none'); + selectTableRowById('LIRR-'+id, 'LICHK-'+id, true); + + var query = "backend.php?op=pref-instances&subop=edit&id=" + + param_escape(id); + + if (dijit.byId("instanceEditDlg")) + dijit.byId("instanceEditDlg").destroyRecursive(); + + dialog = new dijit.Dialog({ + id: "instanceEditDlg", + title: __("Edit Instance"), + style: "width: 600px", + href: query, + }); + + dialog.show(); + + } else if (event.ctrlKey) { + var cb = $('LICHK-' + id); + cb.checked = !cb.checked; + toggleSelectRow(cb); + } + + + } catch (e) { + exception_error("editInstance", e); + } +} + +function removeSelectedInstances() { + try { + alert("TODO: function not implemented."); + + } catch (e) { + exception_error("removeInstance", e); + } +} + +function editSelectedInstance() { + var rows = getSelectedInstances(); + + if (rows.length == 0) { + alert(__("No instances are selected.")); + return; + } + + if (rows.length > 1) { + alert(__("Please select only one instance.")); + return; + } + + notify(""); + + editInstance(rows[0]); +} + -- cgit v1.2.3 From 16270276cf27620d72974eb7e71f089ea8bc3bd5 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 20 Apr 2011 13:32:40 +0400 Subject: implement search in pref-feeds (closes #332) --- prefs.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'prefs.js') diff --git a/prefs.js b/prefs.js index f0a9de5db..c13f0e0d4 100644 --- a/prefs.js +++ b/prefs.js @@ -64,8 +64,13 @@ function notify_callback2(transport) { } function updateFeedList(sort_key) { + + var user_search = $("feed_search"); + var search = ""; + if (user_search) { search = user_search.value; } + new Ajax.Request("backend.php", { - parameters: "?op=pref-feeds", + parameters: "?op=pref-feeds&search=" + param_escape(search), onComplete: function(transport) { feedlist_callback2(transport); } }); -- cgit v1.2.3 From 9104a3e65afdb884dd2a6289ac62161d8176c555 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 20 Apr 2011 14:11:15 +0400 Subject: implement instance edit & save --- prefs.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'prefs.js') diff --git a/prefs.js b/prefs.js index c13f0e0d4..5c7131d2f 100644 --- a/prefs.js +++ b/prefs.js @@ -1810,6 +1810,30 @@ function editInstance(id, event) { id: "instanceEditDlg", title: __("Edit 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_edit_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, }); -- cgit v1.2.3 From 323103323b5ca370bd64e96b77b49f0b48bc05ed Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 20 Apr 2011 14:25:02 +0400 Subject: implement instance adding and deleting --- prefs.js | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) (limited to 'prefs.js') 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); -- cgit v1.2.3