Git with a cup of tea, painless self-hosted git service Mirror for internal git.with.parts use https://git.with.parts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gitea/web_src/js/features/admin/config.js

38 lines
1015 B

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;
});
}