* switch to xhr.post() almost everywhere

* call App.handlerpcjson() automatically on json request (if possible)
 * show net/log indicators in prefs
This commit is contained in:
Andrew Dolgov 2021-02-19 13:44:56 +03:00
parent bb4e4282f4
commit 660a1bbe01
34 changed files with 275 additions and 204 deletions

View File

@ -832,8 +832,7 @@ class Pref_Feeds extends Handler_Protected {
print "<label>" . __('Place in category:') . "</label> "; print "<label>" . __('Place in category:') . "</label> ";
print_feed_cat_select("cat_id", false, print \Controls\select_feeds_cats("cat_id", null, ['disabled' => '1']);
'disabled="1" dojoType="fox.form.Select"');
$this->batch_edit_cbox("cat_id"); $this->batch_edit_cbox("cat_id");

View File

@ -295,8 +295,8 @@ class Pref_Prefs extends Handler_Protected {
evt.preventDefault(); evt.preventDefault();
if (this.validate()) { if (this.validate()) {
Notify.progress('Saving data...', true); Notify.progress('Saving data...', true);
xhrPost("backend.php", this.getValues(), (transport) => { xhr.post("backend.php", this.getValues(), (reply) => {
Notify.info(transport.responseText); Notify.info(reply);
}) })
} }
</script> </script>
@ -351,16 +351,16 @@ class Pref_Prefs extends Handler_Protected {
evt.preventDefault(); evt.preventDefault();
if (this.validate()) { if (this.validate()) {
Notify.progress('Saving data...', true); Notify.progress('Saving data...', true);
xhrPost("backend.php", this.getValues(), (transport) => { xhr.post("backend.php", this.getValues(), (reply) => {
Notify.close(); Notify.close();
if (transport.responseText.indexOf('ERROR: ') == 0) { if (reply.indexOf('ERROR: ') == 0) {
App.byId('pwd_change_infobox').innerHTML = App.byId('pwd_change_infobox').innerHTML =
transport.responseText.replace('ERROR: ', ''); reply.replace('ERROR: ', '');
} else { } else {
App.byId('pwd_change_infobox').innerHTML = App.byId('pwd_change_infobox').innerHTML =
transport.responseText.replace('ERROR: ', ''); reply.replace('ERROR: ', '');
const warn = App.byId('default_pass_warning'); const warn = App.byId('default_pass_warning');
if (warn) Element.hide(warn); if (warn) Element.hide(warn);
@ -456,11 +456,11 @@ class Pref_Prefs extends Handler_Protected {
evt.preventDefault(); evt.preventDefault();
if (this.validate()) { if (this.validate()) {
Notify.progress('Saving data...', true); Notify.progress('Saving data...', true);
xhrPost("backend.php", this.getValues(), (transport) => { xhr.post("backend.php", this.getValues(), (reply) => {
Notify.close(); Notify.close();
if (transport.responseText.indexOf('ERROR: ') == 0) { if (reply.indexOf('ERROR: ') == 0) {
Notify.error(transport.responseText.replace('ERROR: ', '')); Notify.error(reply.replace('ERROR: ', ''));
} else { } else {
window.location.reload(); window.location.reload();
} }
@ -515,11 +515,11 @@ class Pref_Prefs extends Handler_Protected {
evt.preventDefault(); evt.preventDefault();
if (this.validate()) { if (this.validate()) {
Notify.progress('Saving data...', true); Notify.progress('Saving data...', true);
xhrPost("backend.php", this.getValues(), (transport) => { xhr.post("backend.php", this.getValues(), (reply) => {
Notify.close(); Notify.close();
if (transport.responseText.indexOf('ERROR:') == 0) { if (reply.indexOf('ERROR:') == 0) {
Notify.error(transport.responseText.replace('ERROR:', '')); Notify.error(reply.replace('ERROR:', ''));
} else { } else {
window.location.reload(); window.location.reload();
} }
@ -797,16 +797,14 @@ class Pref_Prefs extends Handler_Protected {
<script type="dojo/method" event="onSubmit" args="evt, quit"> <script type="dojo/method" event="onSubmit" args="evt, quit">
if (evt) evt.preventDefault(); if (evt) evt.preventDefault();
if (this.validate()) { if (this.validate()) {
xhrPost("backend.php", this.getValues(), (transport) => { xhr.post("backend.php", this.getValues(), (reply) => {
if (quit) { if (quit) {
document.location.href = 'index.php'; document.location.href = 'index.php';
} else { } else {
const msg = transport.responseText; if (reply == 'PREFS_NEED_RELOAD') {
if (msg == 'PREFS_NEED_RELOAD') {
window.location.reload(); window.location.reload();
} else { } else {
Notify.info(msg); Notify.info(reply);
} }
} }
}) })
@ -942,7 +940,7 @@ class Pref_Prefs extends Handler_Protected {
<script type="dojo/method" event="onSubmit" args="evt"> <script type="dojo/method" event="onSubmit" args="evt">
evt.preventDefault(); evt.preventDefault();
if (this.validate()) { if (this.validate()) {
xhrPost("backend.php", this.getValues(), (transport) => { xhr.post("backend.php", this.getValues(), () => {
Notify.close(); Notify.close();
if (confirm(__('Selected plugins have been enabled. Reload?'))) { if (confirm(__('Selected plugins have been enabled. Reload?'))) {
window.location.reload(); window.location.reload();
@ -1009,8 +1007,8 @@ class Pref_Prefs extends Handler_Protected {
<script type='dojo/method' event='onSelected' args='evt'> <script type='dojo/method' event='onSelected' args='evt'>
if (this.domNode.querySelector('.loading')) if (this.domNode.querySelector('.loading'))
window.setTimeout(() => { window.setTimeout(() => {
xhrPost("backend.php", {op: 'pref-prefs', method: 'index_auth'}, (transport) => { xhr.post("backend.php", {op: 'pref-prefs', method: 'index_auth'}, (reply) => {
this.attr('content', transport.responseText); this.attr('content', reply);
}); });
}, 100); }, 100);
</script> </script>
@ -1023,8 +1021,8 @@ class Pref_Prefs extends Handler_Protected {
<script type='dojo/method' event='onSelected' args='evt'> <script type='dojo/method' event='onSelected' args='evt'>
if (this.domNode.querySelector('.loading')) if (this.domNode.querySelector('.loading'))
window.setTimeout(() => { window.setTimeout(() => {
xhrPost("backend.php", {op: 'pref-prefs', method: 'index_plugins'}, (transport) => { xhr.post("backend.php", {op: 'pref-prefs', method: 'index_plugins'}, (reply) => {
this.attr('content', transport.responseText); this.attr('content', reply);
}); });
}, 200); }, 200);
</script> </script>

View File

@ -64,6 +64,14 @@ class RPC extends Handler_Protected {
print json_encode(array("message" => "UPDATE_COUNTERS")); print json_encode(array("message" => "UPDATE_COUNTERS"));
} }
function getRuntimeInfo() {
$reply = [
'runtime-info' => $this->make_runtime_info()
];
print json_encode($reply);
}
function getAllCounters() { function getAllCounters() {
@$seq = (int) $_REQUEST['seq']; @$seq = (int) $_REQUEST['seq'];

View File

@ -2,7 +2,7 @@
/* eslint-disable new-cap */ /* eslint-disable new-cap */
/* global __, Article, Headlines, Filters, fox */ /* global __, Article, Headlines, Filters, fox */
/* global xhrPost, xhr, dojo, dijit, PluginHost, Notify, Feeds, Cookie */ /* global xhr, dojo, dijit, PluginHost, Notify, Feeds, Cookie */
/* global CommonDialogs, Plugins */ /* global CommonDialogs, Plugins */
const App = { const App = {
@ -371,72 +371,57 @@ const App = {
dialog.show(); dialog.show();
}); });
}, },
handleRpcJson: function(transport) { handleRpcJson: function(reply) {
const netalert = App.findAll("#toolbar .net-alert")[0]; const netalert = App.find(".net-alert");
try {
const reply = JSON.parse(transport.responseText);
if (reply) { if (reply) {
const error = reply['error']; const error = reply['error'];
const seq = reply['seq'];
const message = reply['message'];
const counters = reply['counters'];
const runtime_info = reply['runtime-info'];
if (error) { if (error) {
const code = error['code']; const code = error['code'];
if (code && code != 0) {
const msg = error['message']; const msg = error['message'];
console.warn("[handleRpcJson] received fatal error ", code, msg); console.warn("[handleRpcJson] received fatal error ", code, msg);
if (code != 0) {
/* global ERRORS */ /* global ERRORS */
this.Error.fatal(ERRORS[code], {info: msg, code: code}); this.Error.fatal(ERRORS[code], {info: msg, code: code});
return false; return false;
} }
} }
const seq = reply['seq'];
if (seq && this.get_seq() != seq) { if (seq && this.get_seq() != seq) {
console.log("[handleRpcJson] sequence mismatch: ", seq, '!=', this.get_seq()); console.warn("[handleRpcJson] sequence mismatch: ", seq, '!=', this.get_seq());
return true; return;
} }
const message = reply['message']; // not in preferences
if (typeof Feeds != "undefined") {
if (message == "UPDATE_COUNTERS") { if (message == "UPDATE_COUNTERS") {
console.log("need to refresh counters..."); console.log("need to refresh counters...");
Feeds.requestCounters(true); Feeds.requestCounters(true);
} }
const counters = reply['counters'];
if (counters) if (counters)
Feeds.parseCounters(counters); Feeds.parseCounters(counters);
}
const runtime_info = reply['runtime-info'];
if (runtime_info) if (runtime_info)
this.parseRuntimeInfo(runtime_info); this.parseRuntimeInfo(runtime_info);
if (netalert) netalert.hide(); if (netalert) netalert.hide();
return reply;
} else { } else {
if (netalert) netalert.show(); if (netalert) netalert.show();
Notify.error("Communication problem with server."); Notify.error("Communication problem with server.");
} }
} catch (e) {
if (netalert) netalert.show();
Notify.error("Communication problem with server.");
console.error(e);
}
return false;
}, },
parseRuntimeInfo: function(data) { parseRuntimeInfo: function(data) {
Object.keys(data).forEach((k) => { Object.keys(data).forEach((k) => {
@ -450,7 +435,7 @@ const App = {
} }
if (k == "recent_log_events") { if (k == "recent_log_events") {
const alert = App.findAll(".log-alert")[0]; const alert = App.find(".log-alert");
if (alert) { if (alert) {
v > 0 ? alert.show() : alert.hide(); v > 0 ? alert.show() : alert.hide();
@ -462,12 +447,14 @@ const App = {
return; return;
} }
if (typeof Feeds != "undefined") {
if (k == "max_feed_id" || k == "num_feeds") { if (k == "max_feed_id" || k == "num_feeds") {
if (this.getInitParam(k) != v) { if (this.getInitParam(k) && this.getInitParam(k) != v) {
console.log("feed count changed, need to reload feedlist."); console.log("feed count changed, need to reload feedlist:", this.getInitParam(k), v);
Feeds.reload(); Feeds.reload();
} }
} }
}
this.setInitParam(k, v); this.setInitParam(k, v);
}); });
@ -668,6 +655,11 @@ const App = {
return errorMsg == ""; return errorMsg == "";
}, },
updateRuntimeInfo: function() {
xhr.json("backend.php", {op: "rpc", method: "getruntimeinfo"}, () => {
// handled by xhr.json()
});
},
initSecondStage: function() { initSecondStage: function() {
document.onkeydown = (event) => this.hotkeyHandler(event); document.onkeydown = (event) => this.hotkeyHandler(event);
@ -685,14 +677,18 @@ const App = {
if (tab) { if (tab) {
dijit.byId("pref-tabs").selectChild(tab); dijit.byId("pref-tabs").selectChild(tab);
switch (this.urlParam('method')) { const method = this.urlParam("method");
if (method) {
switch (method) {
case "editfeed": case "editfeed":
window.setTimeout(() => { window.setTimeout(() => {
CommonDialogs.editFeed(this.urlParam('methodparam')) CommonDialogs.editFeed(this.urlParam('methodparam'))
}, 100); }, 100);
break; break;
default: default:
console.warn("initSecondStage, unknown method:", this.urlParam("method")); console.warn("initSecondStage, unknown method:", method);
}
} }
} }
} else { } else {
@ -708,8 +704,14 @@ const App = {
dojo.connect(dijit.byId("pref-tabs"), "selectChild", function (elem) { dojo.connect(dijit.byId("pref-tabs"), "selectChild", function (elem) {
localStorage.setItem("ttrss:prefs-tab", elem.id); localStorage.setItem("ttrss:prefs-tab", elem.id);
App.updateRuntimeInfo();
}); });
if (!this.getInitParam("bw_limit"))
window.setInterval(() => {
App.updateRuntimeInfo();
}, 60 * 1000)
} else { } else {
Feeds.reload(); Feeds.reload();

View File

@ -430,8 +430,8 @@ const CommonDialogs = {
const tmph = dojo.connect(dialog, 'onShow', function () { const tmph = dojo.connect(dialog, 'onShow', function () {
dojo.disconnect(tmph); dojo.disconnect(tmph);
xhrPost("backend.php", {op: "pref-feeds", method: "editfeed", id: feed}, (transport) => { xhr.post("backend.php", {op: "pref-feeds", method: "editfeed", id: feed}, (reply) => {
dialog.attr('content', transport.responseText); dialog.attr('content', reply);
}) })
}); });

View File

@ -39,12 +39,12 @@ const Filters = {
createNewRuleElement: function(parentNode, replaceNode) { createNewRuleElement: function(parentNode, replaceNode) {
const rule = dojo.formToJson("filter_new_rule_form"); const rule = dojo.formToJson("filter_new_rule_form");
xhrPost("backend.php", {op: "pref-filters", method: "printrulename", rule: rule}, (transport) => { xhr.post("backend.php", {op: "pref-filters", method: "printrulename", rule: rule}, (reply) => {
try { try {
const li = document.createElement('li'); const li = document.createElement('li');
li.innerHTML = `<input dojoType='dijit.form.CheckBox' type='checkbox' onclick='Lists.onRowChecked(this)'> li.innerHTML = `<input dojoType='dijit.form.CheckBox' type='checkbox' onclick='Lists.onRowChecked(this)'>
<span onclick='App.dialogOf(this).editRule(this)'>${transport.responseText}</span> <span onclick='App.dialogOf(this).editRule(this)'>${reply}</span>
${App.FormFields.hidden_tag("rule[]", rule)}`; ${App.FormFields.hidden_tag("rule[]", rule)}`;
dojo.parser.parse(li); dojo.parser.parse(li);
@ -70,12 +70,12 @@ const Filters = {
const action = dojo.formToJson(form); const action = dojo.formToJson(form);
xhrPost("backend.php", { op: "pref-filters", method: "printactionname", action: action }, (transport) => { xhr.post("backend.php", { op: "pref-filters", method: "printactionname", action: action }, (reply) => {
try { try {
const li = document.createElement('li'); const li = document.createElement('li');
li.innerHTML = `<input dojoType='dijit.form.CheckBox' type='checkbox' onclick='Lists.onRowChecked(this)'> li.innerHTML = `<input dojoType='dijit.form.CheckBox' type='checkbox' onclick='Lists.onRowChecked(this)'>
<span onclick='App.dialogOf(this).editAction(this)'>${transport.responseText}</span> <span onclick='App.dialogOf(this).editAction(this)'>${reply}</span>
${App.FormFields.hidden_tag("action[]", action)}`; ${App.FormFields.hidden_tag("action[]", action)}`;
dojo.parser.parse(li); dojo.parser.parse(li);
@ -107,8 +107,8 @@ const Filters = {
const tmph = dojo.connect(dialog, "onShow", null, function (/* e */) { const tmph = dojo.connect(dialog, "onShow", null, function (/* e */) {
dojo.disconnect(tmph); dojo.disconnect(tmph);
xhrPost("backend.php", {op: 'pref-filters', method: 'newrule', rule: ruleStr}, (transport) => { xhr.post("backend.php", {op: 'pref-filters', method: 'newrule', rule: ruleStr}, (reply) => {
dialog.attr('content', transport.responseText); dialog.attr('content', reply);
}); });
}); });
@ -128,8 +128,8 @@ const Filters = {
const tmph = dojo.connect(dialog, "onShow", null, function (/* e */) { const tmph = dojo.connect(dialog, "onShow", null, function (/* e */) {
dojo.disconnect(tmph); dojo.disconnect(tmph);
xhrPost("backend.php", {op: 'pref-filters', method: 'newaction', action: actionStr}, (transport) => { xhr.post("backend.php", {op: 'pref-filters', method: 'newaction', action: actionStr}, (reply) => {
dialog.attr('content', transport.responseText); dialog.attr('content', reply);
}); });
}); });
@ -149,10 +149,8 @@ const Filters = {
console.log("getTestResults:" + offset); console.log("getTestResults:" + offset);
xhrPost("backend.php", params, (transport) => { xhr.json("backend.php", params, (result) => {
try { try {
const result = JSON.parse(transport.responseText);
if (result && dialog && dialog.open) { if (result && dialog && dialog.open) {
dialog.results += result.length; dialog.results += result.length;
@ -239,7 +237,7 @@ const Filters = {
console.log('Filters.edit', query); console.log('Filters.edit', query);
xhrPost("backend.php", query, function (transport) { xhr.post("backend.php", query, function (reply) {
try { try {
const dialog = new fox.SingleUseDialog({ const dialog = new fox.SingleUseDialog({
id: "filterEditDlg", id: "filterEditDlg",
@ -311,7 +309,7 @@ const Filters = {
}); });
} }
}, },
content: transport.responseText content: reply
}); });
if (!App.isPrefs()) { if (!App.isPrefs()) {
@ -334,9 +332,7 @@ const Filters = {
const query = {op: "article", method: "getmetadatabyid", id: Article.getActive()}; const query = {op: "article", method: "getmetadatabyid", id: Article.getActive()};
xhrPost("backend.php", query, (transport) => { xhr.json("backend.php", query, (reply) => {
const reply = JSON.parse(transport.responseText);
let title = false; let title = false;
if (reply && reply.title) title = reply.title; if (reply && reply.title) title = reply.title;

View File

@ -130,8 +130,8 @@ const Feeds = {
this.reloadCurrent(); this.reloadCurrent();
}, },
requestCounters: function() { requestCounters: function() {
xhrPost("backend.php", {op: "rpc", method: "getAllCounters", seq: App.next_seq()}, (transport) => { xhr.json("backend.php", {op: "rpc", method: "getAllCounters", seq: App.next_seq()}, () => {
App.handleRpcJson(transport); //
}); });
}, },
reload: function() { reload: function() {
@ -260,7 +260,7 @@ const Feeds = {
// bw_limit disables timeout() so we request initial counters separately // bw_limit disables timeout() so we request initial counters separately
if (App.getInitParam("bw_limit")) { if (App.getInitParam("bw_limit")) {
this.requestCounters(true); App.requestCounters(true);
} else { } else {
setTimeout(() => { setTimeout(() => {
this.requestCounters(true); this.requestCounters(true);
@ -361,8 +361,6 @@ const Feeds = {
query.m = "ForceUpdate"; query.m = "ForceUpdate";
} }
//Form.enable("toolbar-main");
if (!delayed) if (!delayed)
if (!this.setExpando(feed, is_cat, if (!this.setExpando(feed, is_cat,
(is_cat) ? 'images/indicator_tiny.gif' : 'images/indicator_white.gif')) (is_cat) ? 'images/indicator_tiny.gif' : 'images/indicator_white.gif'))
@ -374,11 +372,11 @@ const Feeds = {
window.clearTimeout(this._viewfeed_wait_timeout); window.clearTimeout(this._viewfeed_wait_timeout);
this._viewfeed_wait_timeout = window.setTimeout(() => { this._viewfeed_wait_timeout = window.setTimeout(() => {
xhrPost("backend.php", query, (transport) => { xhr.json("backend.php", query, (reply) => {
try { try {
window.clearTimeout(this._infscroll_timeout); window.clearTimeout(this._infscroll_timeout);
this.setExpando(feed, is_cat, 'images/blank_icon.gif'); this.setExpando(feed, is_cat, 'images/blank_icon.gif');
Headlines.onLoaded(transport, offset, append); Headlines.onLoaded(reply, offset, append);
PluginHost.run(PluginHost.HOOK_FEED_LOADED, [feed, is_cat]); PluginHost.run(PluginHost.HOOK_FEED_LOADED, [feed, is_cat]);
} catch (e) { } catch (e) {
App.Error.report(e); App.Error.report(e);
@ -439,9 +437,7 @@ const Feeds = {
Notify.progress("Loading, please wait...", true); Notify.progress("Loading, please wait...", true);
xhrPost("backend.php", catchup_query, (transport) => { xhr.json("backend.php", catchup_query, () => {
App.handleRpcJson(transport);
const show_next_feed = App.getInitParam("on_catchup_show_next_feed"); const show_next_feed = App.getInitParam("on_catchup_show_next_feed");
// only select next unread feed if catching up entirely (as opposed to last week etc) // only select next unread feed if catching up entirely (as opposed to last week etc)
@ -633,8 +629,8 @@ const Feeds = {
updateRandom: function() { updateRandom: function() {
console.log("in update_random_feed"); console.log("in update_random_feed");
xhrPost("backend.php", {op: "rpc", method: "updaterandomfeed"}, (transport) => { xhr.json("backend.php", {op: "rpc", method: "updaterandomfeed"}, () => {
App.handleRpcJson(transport, true); //
}); });
}, },
}; };

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
/* global __, ngettext, Article, App */ /* global __, ngettext, Article, App */
/* global xhrPost, dojo, dijit, PluginHost, Notify, $$, Feeds */ /* global dojo, dijit, PluginHost, Notify, xhr, Feeds */
/* global CommonDialogs */ /* global CommonDialogs */
const Headlines = { const Headlines = {
@ -149,26 +149,26 @@ const Headlines = {
const promises = []; const promises = [];
if (ops.tmark.length != 0) if (ops.tmark.length != 0)
promises.push(xhrPost("backend.php", promises.push(xhr.post("backend.php",
{op: "rpc", method: "markSelected", ids: ops.tmark.toString(), cmode: 2})); {op: "rpc", method: "markSelected", ids: ops.tmark.toString(), cmode: 2}));
if (ops.tpub.length != 0) if (ops.tpub.length != 0)
promises.push(xhrPost("backend.php", promises.push(xhr.post("backend.php",
{op: "rpc", method: "publishSelected", ids: ops.tpub.toString(), cmode: 2})); {op: "rpc", method: "publishSelected", ids: ops.tpub.toString(), cmode: 2}));
if (ops.read.length != 0) if (ops.read.length != 0)
promises.push(xhrPost("backend.php", promises.push(xhr.post("backend.php",
{op: "rpc", method: "catchupSelected", ids: ops.read.toString(), cmode: 0})); {op: "rpc", method: "catchupSelected", ids: ops.read.toString(), cmode: 0}));
if (ops.unread.length != 0) if (ops.unread.length != 0)
promises.push(xhrPost("backend.php", promises.push(xhr.post("backend.php",
{op: "rpc", method: "catchupSelected", ids: ops.unread.toString(), cmode: 1})); {op: "rpc", method: "catchupSelected", ids: ops.unread.toString(), cmode: 1}));
const scores = Object.keys(ops.rescore); const scores = Object.keys(ops.rescore);
if (scores.length != 0) { if (scores.length != 0) {
scores.forEach((score) => { scores.forEach((score) => {
promises.push(xhrPost("backend.php", promises.push(xhr.post("backend.php",
{op: "article", method: "setScore", id: ops.rescore[score].toString(), score: score})); {op: "article", method: "setScore", id: ops.rescore[score].toString(), score: score}));
}); });
} }
@ -622,9 +622,7 @@ const Headlines = {
dojo.parser.parse(target.domNode); dojo.parser.parse(target.domNode);
}, },
onLoaded: function (transport, offset, append) { onLoaded: function (reply, offset, append) {
const reply = App.handleRpcJson(transport);
console.log("Headlines.onLoaded: offset=", offset, "append=", append); console.log("Headlines.onLoaded: offset=", offset, "append=", append);
let is_cat = false; let is_cat = false;
@ -785,7 +783,6 @@ const Headlines = {
}); });
} else { } else {
console.error("Invalid object received: " + transport.responseText);
dijit.byId("headlines-frame").attr('content', "<div class='whiteBox'>" + dijit.byId("headlines-frame").attr('content', "<div class='whiteBox'>" +
__('Could not update headlines (invalid object received - see error console for details)') + __('Could not update headlines (invalid object received - see error console for details)') +
"</div>"); "</div>");
@ -1011,9 +1008,8 @@ const Headlines = {
ids: ids.toString(), lid: id ids: ids.toString(), lid: id
}; };
xhrPost("backend.php", query, (transport) => { xhr.json("backend.php", query, (reply) => {
App.handleRpcJson(transport); this.onLabelsUpdated(reply);
this.onLabelsUpdated(transport);
}); });
}, },
selectionAssignLabel: function (id, ids) { selectionAssignLabel: function (id, ids) {
@ -1029,9 +1025,8 @@ const Headlines = {
ids: ids.toString(), lid: id ids: ids.toString(), lid: id
}; };
xhrPost("backend.php", query, (transport) => { xhr.json("backend.php", query, (reply) => {
App.handleRpcJson(transport); this.onLabelsUpdated(reply);
this.onLabelsUpdated(transport);
}); });
}, },
deleteSelection: function () { deleteSelection: function () {
@ -1060,8 +1055,7 @@ const Headlines = {
const query = {op: "rpc", method: "delete", ids: rows.toString()}; const query = {op: "rpc", method: "delete", ids: rows.toString()};
xhrPost("backend.php", query, (transport) => { xhr.json("backend.php", query, () => {
App.handleRpcJson(transport);
Feeds.reloadCurrent(); Feeds.reloadCurrent();
}); });
}, },
@ -1246,9 +1240,7 @@ const Headlines = {
} }
} }
}, },
onLabelsUpdated: function (transport) { onLabelsUpdated: function (data) {
const data = JSON.parse(transport.responseText);
if (data) { if (data) {
data['info-for-headlines'].forEach(function (elem) { data['info-for-headlines'].forEach(function (elem) {
App.findAll(".HLLCTR-" + elem.id).forEach(function (ctr) { App.findAll(".HLLCTR-" + elem.id).forEach(function (ctr) {

View File

@ -129,8 +129,8 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b
const searchElem = App.byId("feed_search"); const searchElem = App.byId("feed_search");
const search = (searchElem) ? searchElem.value : ""; const search = (searchElem) ? searchElem.value : "";
xhrPost("backend.php", { op: "pref-feeds", search: search }, (transport) => { xhr.post("backend.php", { op: "pref-feeds", search: search }, (reply) => {
dijit.byId('feedsTab').attr('content', transport.responseText); dijit.byId('feedsTab').attr('content', reply);
Notify.close(); Notify.close();
}); });
}, },
@ -295,7 +295,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b
Notify.progress("Loading, please wait..."); Notify.progress("Loading, please wait...");
xhrPost("backend.php", {op: "pref-feeds", method: "editfeeds", ids: rows.toString()}, (transport) => { xhr.post("backend.php", {op: "pref-feeds", method: "editfeeds", ids: rows.toString()}, (reply) => {
Notify.close(); Notify.close();
try { try {
@ -347,7 +347,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b
}); });
} }
}, },
content: transport.responseText content: reply
}); });
dialog.show(); dialog.show();

View File

@ -1,5 +1,5 @@
/* eslint-disable prefer-rest-params */ /* eslint-disable prefer-rest-params */
/* global __, define, lib, dijit, dojo, xhr, Notify */ /* global __, define, lib, dijit, dojo, xhr, App, Notify */
define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], function (declare, domConstruct) { define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], function (declare, domConstruct) {
@ -91,8 +91,8 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio
let search = ""; let search = "";
if (user_search) { search = user_search.value; } if (user_search) { search = user_search.value; }
xhrPost("backend.php", { op: "pref-filters", search: search }, (transport) => { xhr.post("backend.php", { op: "pref-filters", search: search }, (reply) => {
dijit.byId('filtersTab').attr('content', transport.responseText); dijit.byId('filtersTab').attr('content', reply);
Notify.close(); Notify.close();
}); });
}, },

View File

@ -19,8 +19,8 @@ const Helpers = {
alert("No passwords selected."); alert("No passwords selected.");
} else if (confirm(__("Remove selected app passwords?"))) { } else if (confirm(__("Remove selected app passwords?"))) {
xhrPost("backend.php", {op: "pref-prefs", method: "deleteAppPassword", ids: rows.toString()}, (transport) => { xhr.post("backend.php", {op: "pref-prefs", method: "deleteAppPassword", ids: rows.toString()}, (reply) => {
this.updateContent(transport.responseText); this.updateContent(reply);
Notify.close(); Notify.close();
}); });
@ -31,8 +31,8 @@ const Helpers = {
const title = prompt("Password description:") const title = prompt("Password description:")
if (title) { if (title) {
xhrPost("backend.php", {op: "pref-prefs", method: "generateAppPassword", title: title}, (transport) => { xhr.post("backend.php", {op: "pref-prefs", method: "generateAppPassword", title: title}, (reply) => {
this.updateContent(transport.responseText); this.updateContent(reply);
Notify.close(); Notify.close();
}); });
@ -63,8 +63,13 @@ const Helpers = {
this.update(); this.update();
}, },
update: function() { update: function() {
xhrPost("backend.php", { op: "pref-system", severity: dijit.byId("severity").attr('value'), page: Helpers.EventLog.log_page }, (transport) => { xhr.post("backend.php", {
dijit.byId('systemTab').attr('content', transport.responseText); op: "pref-system",
severity: dijit.byId("severity").attr('value'),
page: Helpers.EventLog.log_page
}, (reply) => {
dijit.byId('systemTab').attr('content', reply);
Notify.close(); Notify.close();
}); });
}, },
@ -164,8 +169,8 @@ const Helpers = {
`<span dojoType='dijit.InlineEditBox' width='300px' autoSave='false' `<span dojoType='dijit.InlineEditBox' width='300px' autoSave='false'
profile-id='${profile.id}'>${profile.title} profile-id='${profile.id}'>${profile.title}
<script type='dojo/method' event='onChange' args='value'> <script type='dojo/method' event='onChange' args='value'>
xhrPost("backend.php", xhr.post("backend.php",
{op: 'pref-prefs', method: 'saveprofile', value: value, id: this.attr('profile-id')}, (transport) => { {op: 'pref-prefs', method: 'saveprofile', value: value, id: this.attr('profile-id')}, () => {
// //
}); });
</script> </script>
@ -267,9 +272,9 @@ const Helpers = {
}, },
confirmReset: function() { confirmReset: function() {
if (confirm(__("Reset to defaults?"))) { if (confirm(__("Reset to defaults?"))) {
xhrPost("backend.php", {op: "pref-prefs", method: "resetconfig"}, (transport) => { xhr.post("backend.php", {op: "pref-prefs", method: "resetconfig"}, (reply) => {
Helpers.Prefs.refresh(); Helpers.Prefs.refresh();
Notify.info(transport.responseText); Notify.info(reply);
}); });
} }
}, },
@ -283,8 +288,8 @@ const Helpers = {
} }
}, },
refresh: function() { refresh: function() {
xhrPost("backend.php", { op: "pref-prefs" }, (transport) => { xhr.post("backend.php", { op: "pref-prefs" }, (reply) => {
dijit.byId('prefsTab').attr('content', transport.responseText); dijit.byId('prefsTab').attr('content', reply);
Notify.close(); Notify.close();
}); });
}, },

View File

@ -55,8 +55,8 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f
return rv; return rv;
}, },
reload: function() { reload: function() {
xhrPost("backend.php", { op: "pref-labels" }, (transport) => { xhr.post("backend.php", { op: "pref-labels" }, (reply) => {
dijit.byId('labelsTab').attr('content', transport.responseText); dijit.byId('labelsTab').attr('content', reply);
Notify.close(); Notify.close();
}); });
}, },

View File

@ -8,8 +8,8 @@ const Users = {
const user_search = App.byId("user_search"); const user_search = App.byId("user_search");
const search = user_search ? user_search.value : ""; const search = user_search ? user_search.value : "";
xhrPost("backend.php", { op: "pref-users", sort: sort, search: search }, (transport) => { xhr.post("backend.php", { op: "pref-users", sort: sort, search: search }, (reply) => {
dijit.byId('usersTab').attr('content', transport.responseText); dijit.byId('usersTab').attr('content', reply);
Notify.close(); Notify.close();
}); });
}, },
@ -19,8 +19,8 @@ const Users = {
if (login) { if (login) {
Notify.progress("Adding user..."); Notify.progress("Adding user...");
xhrPost("backend.php", {op: "pref-users", method: "add", login: login}, (transport) => { xhr.post("backend.php", {op: "pref-users", method: "add", login: login}, (reply) => {
alert(transport.responseText); alert(reply);
Users.reload(); Users.reload();
}); });
@ -99,8 +99,8 @@ const Users = {
<div dojoType="dijit.layout.ContentPane" title="${__('User details')}"> <div dojoType="dijit.layout.ContentPane" title="${__('User details')}">
<script type='dojo/method' event='onShow' args='evt'> <script type='dojo/method' event='onShow' args='evt'>
if (this.domNode.querySelector('.loading')) { if (this.domNode.querySelector('.loading')) {
xhrPost("backend.php", {op: 'pref-users', method: 'userdetails', id: ${user.id}}, (transport) => { xhr.post("backend.php", {op: 'pref-users', method: 'userdetails', id: ${user.id}}, (reply) => {
this.attr('content', transport.responseText); this.attr('content', reply);
}); });
} }
</script> </script>
@ -141,9 +141,9 @@ const Users = {
const id = rows[0]; const id = rows[0];
xhrPost("backend.php", {op: "pref-users", method: "resetPass", id: id}, (transport) => { xhr.post("backend.php", {op: "pref-users", method: "resetPass", id: id}, (reply) => {
Notify.close(); Notify.close();
Notify.info(transport.responseText, true); Notify.info(reply, true);
}); });
} }

View File

@ -155,7 +155,7 @@ const xhr = {
reject(error); reject(error);
}, },
load: function(data, ioargs) { load: function(data, ioargs) {
//console.log('xhr.post', '<<<', data, ioargs); console.log('xhr.post', '<<<', ioargs.xhr);
if (complete != undefined) if (complete != undefined)
complete(data, ioargs.xhr); complete(data, ioargs.xhr);
@ -179,6 +179,9 @@ const xhr = {
console.log('xhr.json', '<<<', obj); console.log('xhr.json', '<<<', obj);
if (obj && typeof App != "undefined")
App.handleRpcJson(obj);
if (complete != undefined) complete(obj); if (complete != undefined) complete(obj);
resolve(obj); resolve(obj);

View File

@ -41,6 +41,7 @@ require(["dojo/_base/kernel",
"dojo/data/ItemFileWriteStore", "dojo/data/ItemFileWriteStore",
"lib/CheckBoxStoreModel", "lib/CheckBoxStoreModel",
"lib/CheckBoxTree", "lib/CheckBoxTree",
"fox/PluginHost",
"fox/CommonDialogs", "fox/CommonDialogs",
"fox/CommonFilters", "fox/CommonFilters",
"fox/PrefUsers", "fox/PrefUsers",

View File

@ -221,8 +221,8 @@ class Af_Proxy_Http extends Plugin {
<script type="dojo/method" event="onSubmit" args="evt"> <script type="dojo/method" event="onSubmit" args="evt">
evt.preventDefault(); evt.preventDefault();
if (this.validate()) { if (this.validate()) {
xhrPost("backend.php", this.getValues(), (transport) => { xhr.post("backend.php", this.getValues(), (reply) => {
Notify.info(transport.responseText); Notify.info(reply);
}) })
} }
</script> </script>

View File

@ -1,4 +1,4 @@
/* global dijit, dojo, Plugins, xhrPost, __ */ /* global dijit, dojo, Plugins, xhr, __ */
Plugins.Psql_Trgm = { Plugins.Psql_Trgm = {
showRelated: function (id) { showRelated: function (id) {
@ -10,8 +10,8 @@ Plugins.Psql_Trgm = {
const tmph = dojo.connect(dialog, "onShow", null, function (/* e */) { const tmph = dojo.connect(dialog, "onShow", null, function (/* e */) {
dojo.disconnect(tmph); dojo.disconnect(tmph);
xhrPost("backend.php", {op: 'pluginhandler', plugin: 'af_psql_trgm', method: 'showrelated', id: id}, (transport) => { xhr.post("backend.php", {op: 'pluginhandler', plugin: 'af_psql_trgm', method: 'showrelated', id: id}, (reply) => {
dialog.attr('content', transport.responseText); dialog.attr('content', reply);
}); });
}); });

View File

@ -152,8 +152,8 @@ class Af_Psql_Trgm extends Plugin {
evt.preventDefault(); evt.preventDefault();
if (this.validate()) { if (this.validate()) {
Notify.progress('Saving data...', true); Notify.progress('Saving data...', true);
xhrPost("backend.php", this.getValues(), (transport) => { xhr.post("backend.php", this.getValues(), (reply) => {
Notify.info(transport.responseText); Notify.info(reply);
}) })
} }
</script> </script>

View File

@ -71,8 +71,8 @@ class Af_Readability extends Plugin {
evt.preventDefault(); evt.preventDefault();
if (this.validate()) { if (this.validate()) {
Notify.progress('Saving data...', true); Notify.progress('Saving data...', true);
xhrPost("backend.php", this.getValues(), (transport) => { xhr.post("backend.php", this.getValues(), (reply) => {
Notify.info(transport.responseText); Notify.info(reply);
}) })
} }
</script> </script>

View File

@ -47,8 +47,8 @@ class Af_RedditImgur extends Plugin {
evt.preventDefault(); evt.preventDefault();
if (this.validate()) { if (this.validate()) {
Notify.progress('Saving data...', true); Notify.progress('Saving data...', true);
xhrPost("backend.php", this.getValues(), (transport) => { xhr.post("backend.php", this.getValues(), (reply) => {
Notify.info(transport.responseText); Notify.info(reply);
}) })
} }
</script> </script>

View File

@ -51,8 +51,8 @@ class Mail extends Plugin {
evt.preventDefault(); evt.preventDefault();
if (this.validate()) { if (this.validate()) {
Notify.progress('Saving data...', true); Notify.progress('Saving data...', true);
xhrPost("backend.php", this.getValues(), (transport) => { xhr.post("backend.php", this.getValues(), (reply) => {
Notify.info(transport.responseText); Notify.info(reply);
}) })
} }
</script> </script>

View File

@ -1,4 +1,4 @@
/* global Plugins, Headlines, dojo, xhrPost, xhrJson, Notify, fox, __ */ /* global Plugins, Headlines, dojo, App, xhr, Notify, fox, __ */
Plugins.Mail = { Plugins.Mail = {
send: function(id) { send: function(id) {
@ -38,8 +38,8 @@ Plugins.Mail = {
const tmph = dojo.connect(dialog, 'onShow', function () { const tmph = dojo.connect(dialog, 'onShow', function () {
dojo.disconnect(tmph); dojo.disconnect(tmph);
xhrPost("backend.php", App.getPhArgs("mail", "emailArticle", {ids: id}), (transport) => { xhr.post("backend.php", App.getPhArgs("mail", "emailArticle", {ids: id}), (reply) => {
dialog.attr('content', transport.responseText); dialog.attr('content', reply);
}); });
}); });

View File

@ -1,4 +1,4 @@
/* global Plugins, Headlines, xhrPost, dojo, fox, __ */ /* global Plugins, Headlines, xhr, dojo, fox, __ */
Plugins.Mailto = { Plugins.Mailto = {
send: function (id) { send: function (id) {
@ -21,8 +21,8 @@ Plugins.Mailto = {
const tmph = dojo.connect(dialog, 'onShow', function () { const tmph = dojo.connect(dialog, 'onShow', function () {
dojo.disconnect(tmph); dojo.disconnect(tmph);
xhrPost("backend.php", App.getPhArgs("mailto", "emailArticle", {ids: id}), (transport) => { xhr.post("backend.php", App.getPhArgs("mailto", "emailArticle", {ids: id}), (reply) => {
dialog.attr('content', transport.responseText); dialog.attr('content', reply);
}); });
}); });

View File

@ -1,4 +1,4 @@
/* global dojo, xhrPost, Plugins, xhrJson, Notify, fox, __ */ /* global dojo, Plugins, xhr, App, Notify, fox, __ */
Plugins.Note = { Plugins.Note = {
edit: function(id) { edit: function(id) {
@ -33,8 +33,8 @@ Plugins.Note = {
const tmph = dojo.connect(dialog, 'onShow', function () { const tmph = dojo.connect(dialog, 'onShow', function () {
dojo.disconnect(tmph); dojo.disconnect(tmph);
xhrPost("backend.php", App.getPhArgs("note", "edit", {id: id}), (transport) => { xhr.post("backend.php", App.getPhArgs("note", "edit", {id: id}), (reply) => {
dialog.attr('content', transport.responseText); dialog.attr('content', reply);
}); });
}); });

View File

@ -56,8 +56,8 @@ class NSFW extends Plugin {
evt.preventDefault(); evt.preventDefault();
if (this.validate()) { if (this.validate()) {
Notify.progress('Saving data...', true); Notify.progress('Saving data...', true);
xhrPost("backend.php", this.getValues(), (transport) => { xhr.post("backend.php", this.getValues(), (reply) => {
Notify.info(transport.responseText); Notify.info(reply);
}) })
} }
</script> </script>

View File

@ -1,4 +1,4 @@
/* global dojo, Effect, Plugins, xhrJson, Notify, fox, xhrPost, __ */ /* global dojo, Plugins, App, Notify, fox, xhr, __ */
Plugins.Share = { Plugins.Share = {
shareArticle: function(id) { shareArticle: function(id) {
@ -40,8 +40,8 @@ Plugins.Share = {
}, },
unshare: function () { unshare: function () {
if (confirm(__("Remove sharing for this article?"))) { if (confirm(__("Remove sharing for this article?"))) {
xhrPost("backend.php", App.getPhArgs("share", "unshare", {id: id}), (transport) => { xhr.post("backend.php", App.getPhArgs("share", "unshare", {id: id}), (reply) => {
Notify.info(transport.responseText); Notify.info(reply);
const icon = document.querySelector(".share-icon-" + id); const icon = document.querySelector(".share-icon-" + id);
@ -59,8 +59,8 @@ Plugins.Share = {
const tmph = dojo.connect(dialog, 'onShow', function () { const tmph = dojo.connect(dialog, 'onShow', function () {
dojo.disconnect(tmph); dojo.disconnect(tmph);
xhrPost("backend.php", App.getPhArgs("share", "shareDialog", {id: id}), (transport) => { xhr.post("backend.php", App.getPhArgs("share", "shareDialog", {id: id}), (reply) => {
dialog.attr('content', transport.responseText) dialog.attr('content', reply)
const icon = document.querySelector(".share-icon-" + id); const icon = document.querySelector(".share-icon-" + id);

View File

@ -1,12 +1,12 @@
/* global Plugins, Notify, xhrPost */ /* global Plugins, Notify, xhr, App */
Plugins.Share = { Plugins.Share = {
clearKeys: function() { clearKeys: function() {
if (confirm(__("This will invalidate all previously shared article URLs. Continue?"))) { if (confirm(__("This will invalidate all previously shared article URLs. Continue?"))) {
Notify.progress("Clearing URLs..."); Notify.progress("Clearing URLs...");
xhrPost("backend.php", App.getPhArgs("share", "clearArticleKeys"), (transport) => { xhr.post("backend.php", App.getPhArgs("share", "clearArticleKeys"), (reply) => {
Notify.info(transport.responseText); Notify.info(reply);
}); });
} }

View File

@ -124,7 +124,10 @@
</div> </div>
<div id="header"> <div id="header">
<!-- <a href='#' onclick="showHelp()"><?= __("Keyboard shortcuts") ?></a> | --> <i class="material-icons net-alert" style="display : none"
title="<?= __("Communication problem with server.") ?>">error_outline</i>
<i class="material-icons log-alert" style="display : none" onclick="App.openPreferences('system')"
title="<?= __("Recent entries found in event log.") ?>">warning</i>
<a href="#" onclick="document.location.href = 'index.php'"><?= __('Exit preferences') ?></a> <a href="#" onclick="document.location.href = 'index.php'"><?= __('Exit preferences') ?></a>
</div> </div>

View File

@ -754,6 +754,17 @@ body.ttrss_main #header {
top: 0px; top: 0px;
z-index: 5; z-index: 5;
} }
body.ttrss_main #header i.net-alert,
body.ttrss_main #header .left i.icon-error {
color: red;
}
body.ttrss_main #header i.log-alert {
color: #ddba1c;
cursor: pointer;
}
body.ttrss_main #header i {
margin: 0 4px;
}
body.ttrss_main #content-insert { body.ttrss_main #content-insert {
padding: 0px; padding: 0px;
border-color: #ddd; border-color: #ddd;

View File

@ -754,6 +754,17 @@ body.ttrss_main #header {
top: 0px; top: 0px;
z-index: 5; z-index: 5;
} }
body.ttrss_main #header i.net-alert,
body.ttrss_main #header .left i.icon-error {
color: red;
}
body.ttrss_main #header i.log-alert {
color: #ddba1c;
cursor: pointer;
}
body.ttrss_main #header i {
margin: 0 4px;
}
body.ttrss_main #content-insert { body.ttrss_main #content-insert {
padding: 0px; padding: 0px;
border-color: #222; border-color: #222;

View File

@ -754,6 +754,17 @@ body.ttrss_main #header {
top: 0px; top: 0px;
z-index: 5; z-index: 5;
} }
body.ttrss_main #header i.net-alert,
body.ttrss_main #header .left i.icon-error {
color: red;
}
body.ttrss_main #header i.log-alert {
color: #ddba1c;
cursor: pointer;
}
body.ttrss_main #header i {
margin: 0 4px;
}
body.ttrss_main #content-insert { body.ttrss_main #content-insert {
padding: 0px; padding: 0px;
border-color: #ddd; border-color: #ddd;

View File

@ -877,6 +877,19 @@ body.ttrss_main {
right : 0px; right : 0px;
top : 0px; top : 0px;
z-index : 5; z-index : 5;
i.net-alert, .left i.icon-error {
color : red;
}
i.log-alert {
color : #ddba1c;
cursor : pointer;
}
i {
margin : 0 4px;
}
} }
#content-insert { #content-insert {

View File

@ -755,6 +755,17 @@ body.ttrss_main #header {
top: 0px; top: 0px;
z-index: 5; z-index: 5;
} }
body.ttrss_main #header i.net-alert,
body.ttrss_main #header .left i.icon-error {
color: red;
}
body.ttrss_main #header i.log-alert {
color: #ddba1c;
cursor: pointer;
}
body.ttrss_main #header i {
margin: 0 4px;
}
body.ttrss_main #content-insert { body.ttrss_main #content-insert {
padding: 0px; padding: 0px;
border-color: #222; border-color: #222;

View File

@ -755,6 +755,17 @@ body.ttrss_main #header {
top: 0px; top: 0px;
z-index: 5; z-index: 5;
} }
body.ttrss_main #header i.net-alert,
body.ttrss_main #header .left i.icon-error {
color: red;
}
body.ttrss_main #header i.log-alert {
color: #ddba1c;
cursor: pointer;
}
body.ttrss_main #header i {
margin: 0 4px;
}
body.ttrss_main #content-insert { body.ttrss_main #content-insert {
padding: 0px; padding: 0px;
border-color: #222; border-color: #222;