From c36b2adf8488cdf88b0ef05d211c16815f8c5407 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 13 Feb 2021 21:57:02 +0300 Subject: [PATCH] feeds with errors: use client dialog --- classes/pref/feeds.php | 53 ++------------------ js/CommonDialogs.js | 111 ++++++++++++++++++++++++++++------------- 2 files changed, 79 insertions(+), 85 deletions(-) diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index 03e8b1b81..f337d7f4e 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -1500,58 +1500,13 @@ class Pref_Feeds extends Handler_Protected { FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ?"); $sth->execute([$_SESSION['uid']]); - print "
"; - print "
". - "" . __('Select').""; - print "
"; - print "
".__('All')."
"; - print "
".__('None')."
"; - print "
"; - print "
"; #toolbar + $rv = []; - print "
"; - print ""; - - $lnum = 1; - - while ($line = $sth->fetch()) { - - $feed_id = $line["id"]; - - print ""; - - print ""; - print ""; - print ""; - - ++$lnum; + while ($row = $sth->fetch()) { + array_push($rv, $row); } - print "
"; - - print "". - htmlspecialchars($line["title"]).": "; - - print ""; - print htmlspecialchars($line["last_error"]); - print ""; - - print "
"; - print "
"; - - print ""; + print json_encode($rv); } private function remove_feed_category($id, $owner_uid) { diff --git a/js/CommonDialogs.js b/js/CommonDialogs.js index 70596539b..5a72f705b 100644 --- a/js/CommonDialogs.js +++ b/js/CommonDialogs.js @@ -188,52 +188,91 @@ const CommonDialogs = { }); }, showFeedsWithErrors: function() { - const dialog = new fox.SingleUseDialog({ - id: "errorFeedsDlg", - title: __("Feeds with update errors"), - getSelectedFeeds: function () { - return Tables.getSelected("error-feeds-list"); - }, - removeSelected: function () { - const sel_rows = this.getSelectedFeeds(); - if (sel_rows.length > 0) { - if (confirm(__("Remove selected feeds?"))) { - Notify.progress("Removing selected feeds...", true); + xhrJson("backend.php", {op: "pref-feeds", method: "feedsWithErrors"}, (reply) => { - const query = { - op: "pref-feeds", method: "remove", - ids: sel_rows.toString() - }; + const dialog = new fox.SingleUseDialog({ + id: "errorFeedsDlg", + title: __("Feeds with update errors"), + getSelectedFeeds: function () { + return Tables.getSelected("error-feeds-list"); + }, + removeSelected: function () { + const sel_rows = this.getSelectedFeeds(); - xhrPost("backend.php", query, () => { - Notify.close(); - dialog.hide(); + if (sel_rows.length > 0) { + if (confirm(__("Remove selected feeds?"))) { + Notify.progress("Removing selected feeds...", true); - if (App.isPrefs()) - dijit.byId("feedTree").reload(); - else - Feeds.reload(); + const query = { + op: "pref-feeds", method: "remove", + ids: sel_rows.toString() + }; - }); + xhrPost("backend.php", query, () => { + Notify.close(); + dialog.hide(); + + if (App.isPrefs()) + dijit.byId("feedTree").reload(); + else + Feeds.reload(); + + }); + } + + } else { + alert(__("No feeds selected.")); } + }, + content: ` +
+
+ ${__('Select')} +
+
${__('All')}
+
${__('None')}
+
+
+
- } else { - alert(__("No feeds selected.")); - } - }, - content: __("Loading, please wait...") - }); +
+ - const tmph = dojo.connect(dialog, 'onShow', function () { - dojo.disconnect(tmph); + ${reply.map((row) => ` + + + + + + `).join("")} +
+ + + + ${App.escapeHtml(row.title)} + + + ${App.escapeHtml(row.last_error)} +
+
- xhrPost("backend.php", {op: "pref-feeds", method: "feedsWithErrors"}, (transport) => { - dialog.attr('content', transport.responseText); - }) - }); + + ` + }); - dialog.show(); + dialog.show(); + }) }, addLabel: function(select, callback) { const caption = prompt(__("Please enter label caption:"), "");