3120 persist admin value
This commit is contained in:
1 parent
fb3795bd70
commit
ab4cc80628
5 files changed
+17
-12
No files matched your search
@@ -80,11 +80,6 @@ const Settings = () => {
|
|||||||
const handleChange = async (e) => {
|
const handleChange = async (e) => {
|
||||||
const { name, value, checked } = e.target;
|
const { name, value, checked } = e.target;
|
||||||
|
|
||||||
// Special case for showURL until handled properly in the backend
|
|
||||||
if (name === "showURL") {
|
|
||||||
dispatch(setShowURL(value));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let newValue;
|
let newValue;
|
||||||
if (
|
if (
|
||||||
name === "systemEmailIgnoreTLS" ||
|
name === "systemEmailIgnoreTLS" ||
|
||||||
@@ -167,6 +162,11 @@ const Settings = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setSettingsData(newSettingsData);
|
setSettingsData(newSettingsData);
|
||||||
|
|
||||||
|
// Update Redux immediately for UI feedback
|
||||||
|
if (name === "showURL") {
|
||||||
|
dispatch(setShowURL(newValue ?? value));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSave = () => {
|
const handleSave = () => {
|
||||||
|
|||||||
@@ -57,6 +57,10 @@ class SettingsController {
|
|||||||
};
|
};
|
||||||
|
|
||||||
updateAppSettings = async (req: Request, res: Response, next: NextFunction) => {
|
updateAppSettings = async (req: Request, res: Response, next: NextFunction) => {
|
||||||
|
// Diagnostics: capture inbound payload
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log("=== SETTINGS CONTROLLER REQUEST BODY ===", req.body);
|
||||||
|
|
||||||
await updateAppSettingsBodyValidation.validateAsync(req.body);
|
await updateAppSettingsBodyValidation.validateAsync(req.body);
|
||||||
|
|
||||||
const updatedSettings = await this.db.settingsModule.updateAppSettings(req.body);
|
const updatedSettings = await this.db.settingsModule.updateAppSettings(req.body);
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ class StatusPageModule {
|
|||||||
showUptimePercentage: 1,
|
showUptimePercentage: 1,
|
||||||
timezone: 1,
|
timezone: 1,
|
||||||
showAdminLoginLink: 1,
|
showAdminLoginLink: 1,
|
||||||
url: { $cond: [{ $eq: ["$statusPage.showMonitorUrl", true] }, "$monitors.url", "$$REMOVE"] },
|
url: 1,
|
||||||
},
|
},
|
||||||
monitors: {
|
monitors: {
|
||||||
_id: 1,
|
_id: 1,
|
||||||
@@ -261,12 +261,12 @@ class StatusPageModule {
|
|||||||
const { statusPage, monitors } = statusPageQuery[0];
|
const { statusPage, monitors } = statusPageQuery[0];
|
||||||
|
|
||||||
const appSettings = await this.AppSettings.findOne({ singleton: true }).lean();
|
const appSettings = await this.AppSettings.findOne({ singleton: true }).lean();
|
||||||
const showURL = appSettings?.showURL === true;
|
const showURL = appSettings?.showURL === true || appSettings?.showURL === "true";
|
||||||
|
|
||||||
const normalizedMonitors = monitors.map((monitor) => {
|
const normalizedMonitors = monitors.map((monitor) => {
|
||||||
const normalizedChecks = this.NormalizeData(monitor.checks, 10, 100);
|
const normalizedChecks = this.NormalizeData(monitor.checks, 10, 100);
|
||||||
if (showURL !== true) {
|
if (showURL !== true) {
|
||||||
const { url, ...rest } = monitor;
|
const { url, port, secret, notifications, ...rest } = monitor;
|
||||||
return { ...rest, checks: normalizedChecks };
|
return { ...rest, checks: normalizedChecks };
|
||||||
}
|
}
|
||||||
return { ...monitor, checks: normalizedChecks };
|
return { ...monitor, checks: normalizedChecks };
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ class SettingsService {
|
|||||||
await this.AppSettings.create({});
|
await this.AppSettings.create({});
|
||||||
settings = await this.AppSettings.findOne({ singleton: true }).select("-__v -_id -createdAt -updatedAt -singleton").lean();
|
settings = await this.AppSettings.findOne({ singleton: true }).select("-__v -_id -createdAt -updatedAt -singleton").lean();
|
||||||
}
|
}
|
||||||
|
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -413,7 +413,7 @@ const updateAppSettingsBodyValidation = joi.object({
|
|||||||
pagespeedApiKey: joi.string().allow(""),
|
pagespeedApiKey: joi.string().allow(""),
|
||||||
language: joi.string().allow(""),
|
language: joi.string().allow(""),
|
||||||
timezone: joi.string().allow(""),
|
timezone: joi.string().allow(""),
|
||||||
// showURL: joi.bool().required(),
|
showURL: joi.bool().optional(),
|
||||||
systemEmailHost: joi.string().allow(""),
|
systemEmailHost: joi.string().allow(""),
|
||||||
systemEmailPort: joi.number().allow(""),
|
systemEmailPort: joi.number().allow(""),
|
||||||
systemEmailAddress: joi.string().allow(""),
|
systemEmailAddress: joi.string().allow(""),
|
||||||
|
|||||||
Reference in new issue
Block a user