mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-19 11:01:29 +00:00
implement instance edit & save
This commit is contained in:
@@ -866,6 +866,13 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($subop == "genHash") {
|
||||||
|
$hash = sha1(uniqid(rand(), true));
|
||||||
|
|
||||||
|
print json_encode(array("hash" => $hash));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
print json_encode(array("error" => array("code" => 7,
|
print json_encode(array("error" => array("code" => 7,
|
||||||
"message" => "Unknown method: $subop")));
|
"message" => "Unknown method: $subop")));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,70 @@
|
|||||||
|
|
||||||
if ($subop == "edit") {
|
if ($subop == "edit") {
|
||||||
|
|
||||||
print "TODO: function not implemented.";
|
$id = db_escape_string($_REQUEST["id"]);
|
||||||
|
|
||||||
|
$result = db_query($link, "SELECT * FROM ttrss_linked_instances WHERE
|
||||||
|
id = '$id'");
|
||||||
|
|
||||||
|
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"$id\">";
|
||||||
|
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-instances\">";
|
||||||
|
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"subop\" value=\"editSave\">";
|
||||||
|
|
||||||
|
print "<div class=\"dlgSec\">".__("Instance")."</div>";
|
||||||
|
|
||||||
|
print "<div class=\"dlgSecCont\">";
|
||||||
|
|
||||||
|
/* URL */
|
||||||
|
|
||||||
|
$access_url = htmlspecialchars(db_fetch_result($result, 0, "access_url"));
|
||||||
|
|
||||||
|
print __("URL:") . " ";
|
||||||
|
|
||||||
|
print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"
|
||||||
|
placeHolder=\"".__("Instance URL")."\"
|
||||||
|
regExp='^(http|https)://.*'
|
||||||
|
style=\"font-size : 16px; width: 20em\" name=\"access_url\"
|
||||||
|
value=\"$access_url\">";
|
||||||
|
|
||||||
|
print "<hr/>";
|
||||||
|
|
||||||
|
$access_key = htmlspecialchars(db_fetch_result($result, 0, "access_key"));
|
||||||
|
|
||||||
|
/* Access key */
|
||||||
|
|
||||||
|
print __("Access key:") . " ";
|
||||||
|
|
||||||
|
print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"
|
||||||
|
placeHolder=\"".__("Access key")."\"
|
||||||
|
style=\"width: 20em\" name=\"access_key\" id=\"instance_edit_key\"
|
||||||
|
value=\"$access_key\">";
|
||||||
|
|
||||||
|
print "</div>";
|
||||||
|
|
||||||
|
print "<div class=\"dlgButtons\">
|
||||||
|
<div style='float : left'>
|
||||||
|
<button dojoType=\"dijit.form.Button\"
|
||||||
|
onclick=\"return dijit.byId('instanceEditDlg').regenKey()\">".
|
||||||
|
__('Generate new key')."</button>
|
||||||
|
</div>
|
||||||
|
<button dojoType=\"dijit.form.Button\"
|
||||||
|
onclick=\"return dijit.byId('instanceEditDlg').execute()\">".
|
||||||
|
__('Save')."</button>
|
||||||
|
<button dojoType=\"dijit.form.Button\"
|
||||||
|
onclick=\"return dijit.byId('instanceEditDlg').hide()\"\">".
|
||||||
|
__('Cancel')."</button></div>";
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($subop == "editSave") {
|
||||||
|
$id = db_escape_string($_REQUEST["id"]);
|
||||||
|
$access_url = db_escape_string($_REQUEST["access_url"]);
|
||||||
|
$access_key = db_escape_string($_REQUEST["access_key"]);
|
||||||
|
|
||||||
|
db_query($link, "UPDATE ttrss_linked_instances SET
|
||||||
|
access_key = '$access_key', access_url = '$access_url'
|
||||||
|
WHERE id = '$id'");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
24
prefs.js
24
prefs.js
@@ -1810,6 +1810,30 @@ function editInstance(id, event) {
|
|||||||
id: "instanceEditDlg",
|
id: "instanceEditDlg",
|
||||||
title: __("Edit Instance"),
|
title: __("Edit Instance"),
|
||||||
style: "width: 600px",
|
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,
|
href: query,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user