forked from forgejo/forgejo
Add system setting table with cache and also add cache supports for user setting (#18058)
This commit is contained in:
parent
5d3dbffa15
commit
f860a6d2e4
59 changed files with 1117 additions and 436 deletions
37
web_src/js/features/admin/config.js
Normal file
37
web_src/js/features/admin/config.js
Normal file
|
@ -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;
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue