From 8464c619e413b4aabacb802e1afe49a7c960506a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 13 Feb 2021 21:41:38 +0300 Subject: inactive feeds: use client dialog --- classes/pref/feeds.php | 52 +++-------------------- js/PrefFeedTree.js | 109 +++++++++++++++++++++++++++++++++---------------- 2 files changed, 78 insertions(+), 83 deletions(-) diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index d8495a59c..03e8b1b81 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -1485,56 +1485,14 @@ class Pref_Feeds extends Handler_Protected { ORDER BY last_article"); $sth->execute([$_SESSION['uid']]); - print "
"; - print "
". - "" . __('Select').""; - print "
"; - print "
".__('All')."
"; - print "
".__('None')."
"; - print "
"; - print "
"; #toolbar - - print "
"; - print ""; - - $lnum = 1; - - while ($line = $sth->fetch()) { - - $feed_id = $line["id"]; - - print ""; - - print ""; - print ""; - print ""; + $rv = []; - ++$lnum; + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { + $row['last_article'] = TimeHelper::make_local_datetime($row['last_article'], false); + array_push($rv, $row); } - print "
"; - - print "". - htmlspecialchars($line["title"]).""; - - print ""; - print TimeHelper::make_local_datetime($line['last_article'], false); - print "
"; - print "
"; - - print ""; - + print json_encode($rv); } function feedsWithErrors() { diff --git a/js/PrefFeedTree.js b/js/PrefFeedTree.js index 7684c7f9d..3e3584a9a 100644 --- a/js/PrefFeedTree.js +++ b/js/PrefFeedTree.js @@ -1,5 +1,5 @@ /* eslint-disable prefer-rest-params */ -/* global __, lib, dijit, define, dojo, CommonDialogs, Notify, Tables, xhrPost, fox, App */ +/* global __, lib, dijit, define, dojo, CommonDialogs, Notify, Tables, xhrPost, xhrJson, fox, App */ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_base/array", "dojo/cookie"], function (declare, domConstruct, checkBoxTree, array, cookie) { @@ -409,50 +409,87 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b dialog.show(); }, showInactiveFeeds: function() { - const dialog = new fox.SingleUseDialog({ - id: "inactiveFeedsDlg", - title: __("Feeds without recent updates"), - getSelectedFeeds: function () { - return Tables.getSelected("inactive-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: 'inactivefeeds'}, function (reply) { + + const dialog = new fox.SingleUseDialog({ + id: "inactiveFeedsDlg", + title: __("Feeds without recent updates"), + getSelectedFeeds: function () { + return Tables.getSelected("inactive-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); + + const query = { + op: "pref-feeds", method: "remove", + ids: sel_rows.toString() + }; - const query = { - op: "pref-feeds", method: "remove", - ids: sel_rows.toString() - }; + xhrPost("backend.php", query, () => { + Notify.close(); - xhrPost("backend.php", query, () => { - Notify.close(); + const tree = dijit.byId("feedTree"); + if (tree) tree.reload(); - const tree = dijit.byId("feedTree"); - if (tree) tree.reload(); + dialog.hide(); + }); + } - dialog.hide(); - }); + } else { + alert(__("No feeds selected.")); } + }, + content: ` +
+
+ ${__('Select')} +
+
${__('All')}
+
${__('None')}
+
+
+
+ +
+ + ${reply.map((row) => ` + + + + + `).join("")} +
+ + + + ${App.escapeHtml(row.title)} + + + ${row.last_article} +
+
+ + + ` + }); - } else { - alert(__("No feeds selected.")); - } - }, - content: __("Loading, please wait...") - }); - - const tmph = dojo.connect(dialog, 'onShow', function () { - dojo.disconnect(tmph); + dialog.show(); - xhrPost("backend.php", {op: "pref-feeds", method: "inactivefeeds"}, (transport) => { - dialog.attr('content', transport.responseText); - }) }); - dialog.show(); } }); }); -- cgit v1.2.3