diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2022-10-17 07:29:26 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-17 07:29:26 +0800 |
commit | f860a6d2e4177ed4f4c2a58a07882bd00a1a52ad (patch) | |
tree | 93abb2f354576e50c87d70b0b4bb46369fb3a1f1 /web_src | |
parent | 5d3dbffa150d832d2f9aedd9f90ca91178a95f9c (diff) | |
download | gitea-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')
-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.js | 37 | ||||
-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 | ||||
-rw-r--r-- | web_src/js/index.js | 8 | ||||
-rw-r--r-- | web_src/less/_base.less | 1 | ||||
-rw-r--r-- | web_src/less/_form.less | 2 | ||||
-rw-r--r-- | web_src/less/themes/theme-arc-green.less | 1 |
8 files changed, 45 insertions, 4 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 diff --git a/web_src/js/index.js b/web_src/js/index.js index b13ad0e13a..a829deaf11 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -16,7 +16,8 @@ import initRepoMigration from './features/repo-migration.js'; import initRepoProject from './features/repo-projects.js'; import initServiceWorker from './features/serviceworker.js'; import initTableSort from './features/tablesort.js'; -import {initAdminUserListSearchForm} from './features/admin-users.js'; +import {initAdminUserListSearchForm} from './features/admin/users.js'; +import {initAdminConfigs} from './features/admin/config.js'; import {initMarkupAnchors} from './markup/anchors.js'; import {initNotificationCount, initNotificationsTable} from './features/notification.js'; import {initRepoIssueContentHistory} from './features/repo-issue-content.js'; @@ -60,8 +61,8 @@ import { initGlobalTooltips, } from './features/common-global.js'; import {initRepoTopicBar} from './features/repo-home.js'; -import {initAdminEmails} from './features/admin-emails.js'; -import {initAdminCommon} from './features/admin-common.js'; +import {initAdminEmails} from './features/admin/emails.js'; +import {initAdminCommon} from './features/admin/common.js'; import {initRepoTemplateSearch} from './features/repo-template.js'; import {initRepoCodeView} from './features/repo-code.js'; import {initSshKeyFormParser} from './features/sshkey-helper.js'; @@ -139,6 +140,7 @@ $(document).ready(() => { initAdminCommon(); initAdminEmails(); initAdminUserListSearchForm(); + initAdminConfigs(); initDashboardRepoList(); diff --git a/web_src/less/_base.less b/web_src/less/_base.less index 2abebe5c7d..bfc6e0cf96 100644 --- a/web_src/less/_base.less +++ b/web_src/less/_base.less @@ -131,6 +131,7 @@ --color-timeline: #ececec; --color-input-text: #212121; --color-input-background: #ffffff; + --color-input-toggle-background: #dedede; --color-input-border: #dedede; --color-input-border-hover: #cecece; --color-navbar: #f8f8f8; diff --git a/web_src/less/_form.less b/web_src/less/_form.less index 08e1f324b4..3d2ec9fb8a 100644 --- a/web_src/less/_form.less +++ b/web_src/less/_form.less @@ -113,7 +113,7 @@ textarea:focus, } .ui.toggle.checkbox label::before { - background: var(--color-input-background); + background: var(--color-input-toggle-background); } .ui.toggle.checkbox label, diff --git a/web_src/less/themes/theme-arc-green.less b/web_src/less/themes/theme-arc-green.less index 12dba79266..fe83162154 100644 --- a/web_src/less/themes/theme-arc-green.less +++ b/web_src/less/themes/theme-arc-green.less @@ -106,6 +106,7 @@ --color-timeline: #4c525e; --color-input-text: #d5dbe6; --color-input-background: #232933; + --color-input-toggle-background: #454a57; --color-input-border: #454a57; --color-input-border-hover: #505667; --color-navbar: #2a2e3a; |