summaryrefslogtreecommitdiff
path: root/js/prefs.js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2018-12-02 16:17:36 +0300
committerAndrew Dolgov <[email protected]>2018-12-02 16:17:36 +0300
commitb9869dbc01f505e87def7463e032914cab49f26c (patch)
treeca6ac2261fa163b3735e4d740d7edebc0e54dce5 /js/prefs.js
parent58e54282d36d54c2be0e50f78fbc500772a3b762 (diff)
prefs: remove some more stuff from global context (user management, etc)
Diffstat (limited to 'js/prefs.js')
-rwxr-xr-xjs/prefs.js269
1 files changed, 100 insertions, 169 deletions
diff --git a/js/prefs.js b/js/prefs.js
index fd9e3d380..2245f518f 100755
--- a/js/prefs.js
+++ b/js/prefs.js
@@ -132,6 +132,17 @@ const App = {
};
const Prefs = {
+ clearFeedAccessKeys: function() {
+ if (confirm(__("This will invalidate all previously generated feed URLs. Continue?"))) {
+ notify_progress("Clearing URLs...");
+
+ xhrPost("backend.php", {op: "pref-feeds", method: "clearKeys"}, () => {
+ notify_info("Generated URLs cleared.");
+ });
+ }
+
+ return false;
+ },
clearEventLog: function() {
if (confirm(__("Clear event log?"))) {
@@ -264,187 +275,120 @@ const Prefs = {
}
};
-function notify_callback2(transport, sticky) {
- notify_info(transport.responseText, sticky);
-}
+const Users = {
+ reload: function(sort) {
+ const user_search = $("user_search");
+ const search = user_search ? user_search.value : "";
-function updateFeedList() {
+ xhrPost("backend.php", { op: "pref-users", sort: sort, search: search }, (transport) => {
+ dijit.byId('userConfigTab').attr('content', transport.responseText);
+ notify("");
+ });
+ },
+ add: function() {
+ const login = prompt(__("Please enter username:"), "");
- const user_search = $("feed_search");
- let search = "";
- if (user_search) { search = user_search.value; }
+ if (login) {
+ notify_progress("Adding user...");
- xhrPost("backend.php", { op: "pref-feeds", search: search }, (transport) => {
- dijit.byId('feedConfigTab').attr('content', transport.responseText);
- notify("");
- });
-}
+ xhrPost("backend.php", {op: "pref-users", method: "add", login: login}, (transport) => {
+ alert(transport.responseText);
+ Users.reload();
+ });
-function updateUsersList(sort_key) {
- const user_search = $("user_search");
- const search = user_search ? user_search.value : "";
+ }
+ },
+ edit: function(id) {
+ const query = "backend.php?op=pref-users&method=edit&id=" +
+ param_escape(id);
- const query = { op: "pref-users", sort: sort_key, search: search };
+ if (dijit.byId("userEditDlg"))
+ dijit.byId("userEditDlg").destroyRecursive();
- xhrPost("backend.php", query, (transport) => {
- dijit.byId('userConfigTab').attr('content', transport.responseText);
- notify("");
- });
-}
+ const dialog = new dijit.Dialog({
+ id: "userEditDlg",
+ title: __("User Editor"),
+ style: "width: 600px",
+ execute: function () {
+ if (this.validate()) {
+ notify_progress("Saving data...", true);
-function addUser() {
- const login = prompt(__("Please enter login:"), "");
+ xhrPost("backend.php", dojo.formToObject("user_edit_form"), (transport) => {
+ dialog.hide();
+ Users.reload();
+ });
+ }
+ },
+ href: query
+ });
- if (login == null) {
- return false;
- }
+ dialog.show();
+ },
+ resetSelected: function() {
+ const rows = this.getSelection();
- if (login == "") {
- alert(__("Can't create user: no login specified."));
- return false;
- }
+ if (rows.length == 0) {
+ alert(__("No users are selected."));
+ return;
+ }
- notify_progress("Adding user...");
+ if (rows.length > 1) {
+ alert(__("Please select one user."));
+ return;
+ }
- xhrPost("backend.php", { op: "pref-users", method: "add", login: login }, (transport) => {
- notify_callback2(transport);
- updateUsersList();
- });
+ if (confirm(__("Reset password of selected user?"))) {
+ notify_progress("Resetting password for selected user...");
-}
+ const id = rows[0];
-function editUser(id) {
+ xhrPost("backend.php", {op: "pref-users", method: "resetPass", id: id}, (transport) => {
+ notify('');
+ alert(transport.responseText);
+ });
- const query = "backend.php?op=pref-users&method=edit&id=" +
- param_escape(id);
+ }
+ },
+ removeSelected: function() {
+ const sel_rows = this.getSelection();
- if (dijit.byId("userEditDlg"))
- dijit.byId("userEditDlg").destroyRecursive();
+ if (sel_rows.length > 0) {
+ if (confirm(__("Remove selected users? Neither default admin nor your account will be removed."))) {
+ notify_progress("Removing selected users...");
- const dialog = new dijit.Dialog({
- id: "userEditDlg",
- title: __("User Editor"),
- style: "width: 600px",
- execute: function () {
- if (this.validate()) {
- notify_progress("Saving data...", true);
+ const query = {
+ op: "pref-users", method: "remove",
+ ids: sel_rows.toString()
+ };
- xhrPost("backend.php", dojo.formToObject("user_edit_form"), (transport) => {
- dialog.hide();
- updateUsersList();
+ xhrPost("backend.php", query, () => {
+ this.reload();
});
}
- },
- href: query
- });
-
- dialog.show();
-}
-
-function getSelectedUsers() {
- return Tables.getSelected("prefUserList");
-}
-
-
-function removeSelectedUsers() {
-
- const sel_rows = getSelectedUsers();
-
- if (sel_rows.length > 0) {
- if (confirm(__("Remove selected users? Neither default admin nor your account will be removed."))) {
- notify_progress("Removing selected users...");
-
- const query = { op: "pref-users", method: "remove",
- ids: sel_rows.toString() };
-
- xhrPost("backend.php", query, () => {
- updateUsersList();
- });
+ } else {
+ alert(__("No users are selected."));
}
+ },
+ editSelected: function() {
+ const rows = this.getSelection();
- } else {
- alert(__("No users are selected."));
- }
-
- return false;
-}
-
-function editSelectedUser() {
- const rows = getSelectedUsers();
-
- if (rows.length == 0) {
- alert(__("No users are selected."));
- return;
- }
-
- if (rows.length > 1) {
- alert(__("Please select only one user."));
- return;
- }
-
- notify("");
-
- editUser(rows[0]);
-}
-
-function resetSelectedUserPass() {
-
- const rows = getSelectedUsers();
-
- if (rows.length == 0) {
- alert(__("No users are selected."));
- return;
- }
-
- if (rows.length > 1) {
- alert(__("Please select only one user."));
- return;
- }
-
- if (confirm(__("Reset password of selected user?"))) {
- notify_progress("Resetting password for selected user...");
-
- const id = rows[0];
-
- xhrPost("backend.php", { op: "pref-users", method: "resetPass", id: id }, (transport) => {
- notify_info(transport.responseText, true);
- });
-
- }
-}
-
-function selectedUserDetails() {
-
- const rows = getSelectedUsers();
+ if (rows.length == 0) {
+ alert(__("No users are selected."));
+ return;
+ }
- if (rows.length == 0) {
- alert(__("No users are selected."));
- return;
- }
+ if (rows.length > 1) {
+ alert(__("Please select one user."));
+ return;
+ }
- if (rows.length > 1) {
- alert(__("Please select only one user."));
- return;
+ this.edit(rows[0]);
+ },
+ getSelection :function() {
+ return Tables.getSelected("prefUserList");
}
-
- const query = "backend.php?op=pref-users&method=userdetails&id=" + param_escape(rows[0]);
-
- if (dijit.byId("userDetailsDlg"))
- dijit.byId("userDetailsDlg").destroyRecursive();
-
- const dialog = new dijit.Dialog({
- id: "userDetailsDlg",
- title: __("User details"),
- style: "width: 600px",
- execute: function () {
- dialog.hide();
- },
- href: query
- });
-
- dialog.show();
-}
+};
function opmlImportComplete(iframe) {
if (!iframe.contentDocument.body.innerHTML) return false;
@@ -541,19 +485,6 @@ function opmlRegenKey() {
return false;
}
-function clearFeedAccessKeys() {
-
- if (confirm(__("This will invalidate all previously generated feed URLs. Continue?"))) {
- notify_progress("Clearing URLs...");
-
- xhrPost("backend.php", { op: "pref-feeds", method: "clearKeys" }, () => {
- notify_info("Generated URLs cleared.");
- });
- }
-
- return false;
-}
-
function gotoExportOpml(filename, settings) {
const tmp = settings ? 1 : 0;
document.location.href = "backend.php?op=opml&method=export&filename=" + filename + "&settings=" + tmp;