Release v2.11.1
This commit is contained in:
@@ -6,6 +6,7 @@ const renderWeatherLocationAddPage = require('./weather/add');
|
||||
const renderWeatherLocationEditPage = require('./weather/edit');
|
||||
const { buildDuplicateWeatherLocationName, buildDuplicateWeatherLocation } = require('./weather/duplicate');
|
||||
const { fetchAppSettings } = require('../../../data/app-settings');
|
||||
const { buildAuditChanges } = require('../../../data/audit-log');
|
||||
|
||||
async function getWeatherLocationUsageIds(pool, common) {
|
||||
const [slides] = await pool.query('SELECT content_json FROM c_slides WHERE content_json IS NOT NULL');
|
||||
@@ -42,6 +43,7 @@ module.exports = function registerWeatherRoutes(app, deps) {
|
||||
const dataSourceTasks = deps.dataSourceTasks;
|
||||
const backgroundTaskQueue = deps.backgroundTaskQueue;
|
||||
const requirePermission = deps.requirePermission;
|
||||
const recordRequestAuditEvent = deps.recordRequestAuditEvent;
|
||||
const listPageSize = 25;
|
||||
async function getProviderAvailability() {
|
||||
const settings = await fetchAppSettings(pool);
|
||||
@@ -121,6 +123,7 @@ module.exports = function registerWeatherRoutes(app, deps) {
|
||||
return dataSourceTasks.refreshWeatherLocationInBackground(result.insertId, null);
|
||||
});
|
||||
await backgroundTaskQueue.enqueueTask({ key: 'weather-location-refresh:' + result.insertId, title: 'Weather location refresh', category: 'data-source', taskType: 'data-source-refresh', payload: { sourceType: 'weather-location', sourceId: result.insertId, sourceName: payload.name, actorId: actorId }, metadata: { sourceType: 'weather-location', sourceId: result.insertId, sourceName: payload.name } });
|
||||
if (typeof recordRequestAuditEvent === 'function') await recordRequestAuditEvent(pool, req, { category: 'weather', eventType: 'weather-location.created', actorUserId: actorId, targetType: 'weather-location', targetId: result.insertId, targetLabel: payload.name });
|
||||
redirectAfterSave(req, res, '/data-sources/weather/' + result.insertId + '/edit', { closeUrl: '/data-sources/weather', newUrl: '/data-sources/weather/new', message: 'Weather location created.' });
|
||||
} catch (error) {
|
||||
try { await connection.rollback(); } catch (_rollbackError) { }
|
||||
@@ -143,6 +146,7 @@ module.exports = function registerWeatherRoutes(app, deps) {
|
||||
} else {
|
||||
dataSourceTasks.removeRecurringRefresh('weather-location', location.id);
|
||||
}
|
||||
if (typeof recordRequestAuditEvent === 'function') await recordRequestAuditEvent(pool, req, { category: 'weather', eventType: enabled ? 'weather-location.enabled' : 'weather-location.disabled', actorUserId: getAuditUserId(req), targetType: 'weather-location', targetId: location.id, targetLabel: location.name });
|
||||
return res.redirect('/data-sources/weather/' + location.id + '/edit?message=' + encodeURIComponent(enabled ? 'Weather location enabled.' : 'Weather location disabled.'));
|
||||
}
|
||||
const payload = common.buildWeatherLocationPayload(req, location);
|
||||
@@ -159,6 +163,7 @@ module.exports = function registerWeatherRoutes(app, deps) {
|
||||
return dataSourceTasks.refreshWeatherLocationInBackground(location.id, null);
|
||||
});
|
||||
}
|
||||
if (typeof recordRequestAuditEvent === 'function') await recordRequestAuditEvent(pool, req, { category: 'weather', eventType: 'weather-location.updated', actorUserId: getAuditUserId(req), targetType: 'weather-location', targetId: location.id, targetLabel: payload.name, details: { changes: buildAuditChanges({ name: location.name, locationLabel: location.location_label, latitude: location.latitude, longitude: location.longitude, timezone: location.timezone, provider: location.provider, temperatureUnit: location.temperature_unit, windUnit: location.wind_unit, precipitationUnit: location.precipitation_unit, updateIntervalValue: location.update_interval_value, updateIntervalUnit: location.update_interval_unit }, payload) } });
|
||||
redirectAfterSave(req, res, '/data-sources/weather/' + location.id + '/edit', { closeUrl: '/data-sources/weather', newUrl: '/data-sources/weather/new', message: 'Weather location updated.' });
|
||||
} catch (error) {
|
||||
try { await connection.rollback(); } catch (_rollbackError) { }
|
||||
@@ -174,6 +179,7 @@ module.exports = function registerWeatherRoutes(app, deps) {
|
||||
return res.redirect('/data-sources/weather/' + location.id + '/edit?message=' + encodeURIComponent('Weather location is disabled.'));
|
||||
}
|
||||
await backgroundTaskQueue.enqueueTask({ key: 'weather-location-refresh:' + location.id, title: 'Weather location refresh', category: 'data-source', taskType: 'data-source-refresh', payload: { sourceType: 'weather-location', sourceId: location.id, sourceName: location.name, actorId: getAuditUserId(req) }, metadata: { sourceType: 'weather-location', sourceId: location.id, sourceName: location.name } });
|
||||
if (typeof recordRequestAuditEvent === 'function') await recordRequestAuditEvent(pool, req, { category: 'weather', eventType: 'weather-location.refresh_requested', actorUserId: getAuditUserId(req), targetType: 'weather-location', targetId: location.id, targetLabel: location.name });
|
||||
res.redirect('/data-sources/weather/' + location.id + '/edit?message=' + encodeURIComponent('Weather refresh queued.'));
|
||||
} catch (error) { next(error); }
|
||||
});
|
||||
@@ -187,6 +193,7 @@ module.exports = function registerWeatherRoutes(app, deps) {
|
||||
}
|
||||
await pool.query('DELETE FROM i_weather_locations WHERE id = ?', [location.id]);
|
||||
dataSourceTasks.removeRecurringRefresh('weather-location', location.id);
|
||||
if (typeof recordRequestAuditEvent === 'function') await recordRequestAuditEvent(pool, req, { category: 'weather', eventType: 'weather-location.deleted', actorUserId: getAuditUserId(req), targetType: 'weather-location', targetId: location.id, targetLabel: location.name });
|
||||
res.redirect('/data-sources/weather?message=' + encodeURIComponent('Weather location deleted.'));
|
||||
} catch (error) { next(error); }
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user