not letting admins control this via dashboard, it is a config only setting
This commit is contained in:
@@ -615,12 +615,10 @@ export default (router, tpl) => {
|
|||||||
router.post(/^\/admin\/settings\/?$/, lib.auth, async (req, res) => {
|
router.post(/^\/admin\/settings\/?$/, lib.auth, async (req, res) => {
|
||||||
const manual_approval = req.post.manual_approval === 'on' ? 'true' : 'false';
|
const manual_approval = req.post.manual_approval === 'on' ? 'true' : 'false';
|
||||||
const registration_open = req.post.registration_open === 'on' ? 'true' : 'false';
|
const registration_open = req.post.registration_open === 'on' ? 'true' : 'false';
|
||||||
const enable_cleanup = req.post.enable_cleanup === 'on' ? 'true' : 'false';
|
|
||||||
const min_tags = isNaN(parseInt(req.post.min_tags)) ? 3 : Math.max(0, parseInt(req.post.min_tags));
|
const min_tags = isNaN(parseInt(req.post.min_tags)) ? 3 : Math.max(0, parseInt(req.post.min_tags));
|
||||||
const trusted_uploads = Math.max(0, parseInt(req.post.trusted_uploads) ?? 3);
|
const trusted_uploads = Math.max(0, parseInt(req.post.trusted_uploads) ?? 3);
|
||||||
|
|
||||||
await db`INSERT INTO site_settings (key, value) VALUES ('manual_approval', ${manual_approval}) ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value`;
|
await db`INSERT INTO site_settings (key, value) VALUES ('manual_approval', ${manual_approval}) ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value`;
|
||||||
await db`INSERT INTO site_settings (key, value) VALUES ('enable_cleanup', ${enable_cleanup}) ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value`;
|
|
||||||
|
|
||||||
if (cfg.websrv.open_registration_web_toggle !== false) {
|
if (cfg.websrv.open_registration_web_toggle !== false) {
|
||||||
await db`INSERT INTO site_settings (key, value) VALUES ('registration_open', ${registration_open}) ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value`;
|
await db`INSERT INTO site_settings (key, value) VALUES ('registration_open', ${registration_open}) ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value`;
|
||||||
@@ -631,7 +629,6 @@ export default (router, tpl) => {
|
|||||||
await db`INSERT INTO site_settings (key, value) VALUES ('trusted_uploads', ${trusted_uploads.toString()}) ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value`;
|
await db`INSERT INTO site_settings (key, value) VALUES ('trusted_uploads', ${trusted_uploads.toString()}) ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value`;
|
||||||
|
|
||||||
setManualApproval(manual_approval === 'true');
|
setManualApproval(manual_approval === 'true');
|
||||||
setEnableCleanup(enable_cleanup === 'true');
|
|
||||||
setMinTags(min_tags);
|
setMinTags(min_tags);
|
||||||
setTrustedUploads(trusted_uploads);
|
setTrustedUploads(trusted_uploads);
|
||||||
|
|
||||||
@@ -672,15 +669,12 @@ export default (router, tpl) => {
|
|||||||
|
|
||||||
router.post(/^\/admin\/cleanup\/?$/, lib.auth, async (req, res) => {
|
router.post(/^\/admin\/cleanup\/?$/, lib.auth, async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const enable_cleanup = req.post.enable_cleanup === 'on' ? 'true' : 'false';
|
|
||||||
const cleanup_start_date = req.post.cleanup_start_date || '';
|
const cleanup_start_date = req.post.cleanup_start_date || '';
|
||||||
const cleanup_end_date = req.post.cleanup_end_date || '';
|
const cleanup_end_date = req.post.cleanup_end_date || '';
|
||||||
|
|
||||||
await db`INSERT INTO site_settings (key, value) VALUES ('enable_cleanup', ${enable_cleanup}) ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value`;
|
|
||||||
await db`INSERT INTO site_settings (key, value) VALUES ('cleanup_start_date', ${cleanup_start_date}) ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value`;
|
await db`INSERT INTO site_settings (key, value) VALUES ('cleanup_start_date', ${cleanup_start_date}) ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value`;
|
||||||
await db`INSERT INTO site_settings (key, value) VALUES ('cleanup_end_date', ${cleanup_end_date}) ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value`;
|
await db`INSERT INTO site_settings (key, value) VALUES ('cleanup_end_date', ${cleanup_end_date}) ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value`;
|
||||||
|
|
||||||
setEnableCleanup(enable_cleanup === 'true');
|
|
||||||
setCleanupStartDate(cleanup_start_date);
|
setCleanupStartDate(cleanup_start_date);
|
||||||
setCleanupEndDate(cleanup_end_date);
|
setCleanupEndDate(cleanup_end_date);
|
||||||
|
|
||||||
|
|||||||
@@ -44,18 +44,7 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if(typeof enable_cleanup_config === "undefined" || enable_cleanup_config !== false)
|
|
||||||
<div class="settings-toggle" style="background: rgba(0,0,0,0.2); padding: 15px; border-radius: 4px; display: flex; align-items: center; justify-content: space-between; margin-top: 10px;">
|
|
||||||
<div>
|
|
||||||
<label style="display: block; font-weight: bold; color: var(--accent);">Enable Cleanup Action</label>
|
|
||||||
<p style="margin: 2px 0 0 0; font-size: 0.8em; color: #aaa;">Enable the automated cleanup system and manager.</p>
|
|
||||||
</div>
|
|
||||||
<label class="switch">
|
|
||||||
<input type="checkbox" id="enable_cleanup_toggle" {{ enable_cleanup ? 'checked' : '' }} onchange="saveAdminSettings()">
|
|
||||||
<span class="slider round"></span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
@if(registration_web_toggle_enabled)
|
@if(registration_web_toggle_enabled)
|
||||||
<div class="settings-toggle" style="background: rgba(0,0,0,0.2); padding: 15px; border-radius: 4px; display: flex; align-items: center; justify-content: space-between; margin-top: 10px;">
|
<div class="settings-toggle" style="background: rgba(0,0,0,0.2); padding: 15px; border-radius: 4px; display: flex; align-items: center; justify-content: space-between; margin-top: 10px;">
|
||||||
@@ -115,7 +104,6 @@
|
|||||||
const status = document.getElementById('settings-status');
|
const status = document.getElementById('settings-status');
|
||||||
const approvalToggle = document.getElementById('manual_approval_toggle');
|
const approvalToggle = document.getElementById('manual_approval_toggle');
|
||||||
const registrationToggle = document.getElementById('registration_open_toggle');
|
const registrationToggle = document.getElementById('registration_open_toggle');
|
||||||
const cleanupToggle = document.getElementById('enable_cleanup_toggle');
|
|
||||||
const minTagsInput = document.getElementById('min_tags_input');
|
const minTagsInput = document.getElementById('min_tags_input');
|
||||||
const trustedUploadsInput = document.getElementById('trusted_uploads_input');
|
const trustedUploadsInput = document.getElementById('trusted_uploads_input');
|
||||||
|
|
||||||
@@ -131,7 +119,6 @@
|
|||||||
},
|
},
|
||||||
body: new URLSearchParams({
|
body: new URLSearchParams({
|
||||||
manual_approval: approvalToggle.checked ? 'on' : 'off',
|
manual_approval: approvalToggle.checked ? 'on' : 'off',
|
||||||
enable_cleanup: cleanupToggle.checked ? 'on' : 'off',
|
|
||||||
...(registrationToggle ? { registration_open: registrationToggle.checked ? 'on' : 'off' } : {}),
|
...(registrationToggle ? { registration_open: registrationToggle.checked ? 'on' : 'off' } : {}),
|
||||||
min_tags: minTagsInput.value,
|
min_tags: minTagsInput.value,
|
||||||
trusted_uploads: trustedUploadsInput.value,
|
trusted_uploads: trustedUploadsInput.value,
|
||||||
|
|||||||
@@ -9,16 +9,7 @@
|
|||||||
<form id="cleanup-form" action="/admin/cleanup" method="POST" onsubmit="event.preventDefault(); saveCleanupSettings(this);">
|
<form id="cleanup-form" action="/admin/cleanup" method="POST" onsubmit="event.preventDefault(); saveCleanupSettings(this);">
|
||||||
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
|
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
|
||||||
|
|
||||||
<div class="settings-toggle" style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 25px; padding-bottom: 20px; border-bottom: 1px solid rgba(255,255,255,0.05);">
|
|
||||||
<div>
|
|
||||||
<label style="display: block; font-weight: bold; color: var(--accent); font-size: 1.1em;">Enable Cleanup Action</label>
|
|
||||||
<p style="margin: 5px 0 0 0; font-size: 0.9em; color: #aaa;">This must be enabled to allow running the manual cleanup process.</p>
|
|
||||||
</div>
|
|
||||||
<label class="switch">
|
|
||||||
<input type="checkbox" name="enable_cleanup" id="enable_cleanup_toggle" {{ enable_cleanup ? 'checked' : '' }}>
|
|
||||||
<span class="slider round"></span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="settings-item" style="margin-bottom: 30px;">
|
<div class="settings-item" style="margin-bottom: 30px;">
|
||||||
<label style="display: block; font-weight: bold; color: var(--accent); margin-bottom: 10px;">Cleanup Date Range</label>
|
<label style="display: block; font-weight: bold; color: var(--accent); margin-bottom: 10px;">Cleanup Date Range</label>
|
||||||
@@ -79,12 +70,6 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const formData = new FormData(form);
|
const formData = new FormData(form);
|
||||||
if (!document.getElementById('enable_cleanup_toggle').checked) {
|
|
||||||
formData.delete('enable_cleanup');
|
|
||||||
formData.append('enable_cleanup', 'off');
|
|
||||||
} else {
|
|
||||||
formData.set('enable_cleanup', 'on');
|
|
||||||
}
|
|
||||||
|
|
||||||
const res = await fetch(form.action, {
|
const res = await fetch(form.action, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|||||||
Reference in New Issue
Block a user