move dashboard setting into dashboard.js

This commit is contained in:
Girish Ramakrishnan
2023-08-11 19:41:05 +05:30
parent 27ce8f9351
commit eee49a8291
25 changed files with 157 additions and 156 deletions
+6 -4
View File
@@ -28,10 +28,10 @@ const assert = require('assert'),
BoxError = require('./boxerror.js'),
changelog = require('./changelog.js'),
constants = require('./constants.js'),
dashboard = require('./dashboard.js'),
database = require('./database.js'),
eventlog = require('./eventlog.js'),
mailer = require('./mailer.js'),
settings = require('./settings.js'),
users = require('./users.js');
const NOTIFICATION_FIELDS = [ 'id', 'eventId', 'title', 'message', 'creationTime', 'acknowledged' ];
@@ -129,6 +129,7 @@ async function oomEvent(eventId, containerId, app, addonName /*, event*/) {
assert(app || addonName);
const { fqdn:dashboardFqdn } = await dashboard.getLocation();
let title, message;
if (addonName) {
if (app) {
@@ -136,10 +137,10 @@ async function oomEvent(eventId, containerId, app, addonName /*, event*/) {
} else {
title = `The ${addonName} service ran out of memory`;
}
message = `The service has been restarted automatically. If you see this notification often, consider increasing the [memory limit](https://${settings.dashboardFqdn()}/#/services)`;
message = `The service has been restarted automatically. If you see this notification often, consider increasing the [memory limit](https://${dashboardFqdn}/#/services)`;
} else if (app) {
title = `The app at ${app.fqdn} ran out of memory.`;
message = `The app has been restarted automatically. If you see this notification often, consider increasing the [memory limit](https://${settings.dashboardFqdn()}/#/app/${app.id}/resources)`;
message = `The app has been restarted automatically. If you see this notification often, consider increasing the [memory limit](https://${dashboardFqdn}/#/app/${app.id}/resources)`;
}
await add(title, message, { eventId });
@@ -218,9 +219,10 @@ async function backupFailed(eventId, taskId, errorMessage) {
}
if (count !== 3) return; // less than 3 failures
const { fqdn:dashboardFqdn } = await dashboard.getLocation();
const superadmins = await users.getSuperadmins();
for (const superadmin of superadmins) {
await mailer.backupFailed(superadmin.email, errorMessage, `https://${settings.dashboardFqdn()}/logs.html?taskId=${taskId}`);
await mailer.backupFailed(superadmin.email, errorMessage, `https://${dashboardFqdn}/logs.html?taskId=${taskId}`);
}
}