summaryrefslogtreecommitdiffstats
path: root/web_src/js/features
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-10-17 07:29:26 +0800
committerGitHub <noreply@github.com>2022-10-17 07:29:26 +0800
commitf860a6d2e4177ed4f4c2a58a07882bd00a1a52ad (patch)
tree93abb2f354576e50c87d70b0b4bb46369fb3a1f1 /web_src/js/features
parent5d3dbffa150d832d2f9aedd9f90ca91178a95f9c (diff)
downloadgitea-f860a6d2e4177ed4f4c2a58a07882bd00a1a52ad.tar.gz
gitea-f860a6d2e4177ed4f4c2a58a07882bd00a1a52ad.zip
Add system setting table with cache and also add cache supports for user setting (#18058)
Diffstat (limited to 'web_src/js/features')
-rw-r--r--web_src/js/features/admin/common.js (renamed from web_src/js/features/admin-common.js)0
-rw-r--r--web_src/js/features/admin/config.js37
-rw-r--r--web_src/js/features/admin/emails.js (renamed from web_src/js/features/admin-emails.js)0
-rw-r--r--web_src/js/features/admin/users.js (renamed from web_src/js/features/admin-users.js)0
4 files changed, 37 insertions, 0 deletions
diff --git a/web_src/js/features/admin-common.js b/web_src/js/features/admin/common.js
index 2438fcf62b..2438fcf62b 100644
--- a/web_src/js/features/admin-common.js
+++ b/web_src/js/features/admin/common.js
diff --git a/web_src/js/features/admin/config.js b/web_src/js/features/admin/config.js
new file mode 100644
index 0000000000..f5d8fae8fa
--- /dev/null
+++ b/web_src/js/features/admin/config.js
@@ -0,0 +1,37 @@
+import $ from 'jquery';
+import {showTemporaryTooltip} from '../../modules/tippy.js';
+
+const {appSubUrl, csrfToken, pageData} = window.config;
+
+export function initAdminConfigs() {
+ const isAdminConfigPage = pageData?.adminConfigPage;
+ if (!isAdminConfigPage) return;
+
+ $("input[type='checkbox']").on('change', (e) => {
+ const $this = $(e.currentTarget);
+ $.ajax({
+ url: `${appSubUrl}/admin/config`,
+ type: 'POST',
+ data: {
+ _csrf: csrfToken,
+ key: $this.attr('name'),
+ value: $this.is(':checked'),
+ version: $this.attr('version'),
+ }
+ }).done((resp) => {
+ if (resp) {
+ if (resp.redirect) {
+ window.location.href = resp.redirect;
+ } else if (resp.version) {
+ $this.attr('version', resp.version);
+ } else if (resp.err) {
+ showTemporaryTooltip(e.currentTarget, resp.err);
+ $this.prop('checked', !$this.is(':checked'));
+ }
+ }
+ });
+
+ e.preventDefault();
+ return false;
+ });
+}
diff --git a/web_src/js/features/admin-emails.js b/web_src/js/features/admin/emails.js
index 46fafa7eff..46fafa7eff 100644
--- a/web_src/js/features/admin-emails.js
+++ b/web_src/js/features/admin/emails.js
diff --git a/web_src/js/features/admin-users.js b/web_src/js/features/admin/users.js
index 2221fc4929..2221fc4929 100644
--- a/web_src/js/features/admin-users.js
+++ b/web_src/js/features/admin/users.js