update UX: badge→modal flow, orange update button, Update All, toast notifications, workflow triggers
This commit is contained in:
@@ -10,9 +10,10 @@ const { success } = require('../response-helpers');
|
||||
* @param {Object} deps.docker - Docker client wrapper (client, pull methods)
|
||||
* @param {Object} deps.log - Logger instance
|
||||
* @param {Function} deps.asyncHandler - Async route handler wrapper
|
||||
* @param {Object} deps.workflowEngine - WorkflowEngine instance (optional)
|
||||
* @returns {express.Router}
|
||||
*/
|
||||
module.exports = function({ docker, log, asyncHandler }) {
|
||||
module.exports = function({ docker, log, asyncHandler, workflowEngine }) {
|
||||
const router = express.Router();
|
||||
|
||||
// Helper: verify container exists before operating on it
|
||||
@@ -66,6 +67,11 @@ module.exports = function({ docker, log, asyncHandler }) {
|
||||
log.info('docker', `Pulling latest image: ${imageName}`);
|
||||
await docker.pull(imageName);
|
||||
|
||||
// Trigger pre-update workflow (backup before update)
|
||||
if (workflowEngine) {
|
||||
try { await workflowEngine.triggerEvent('pre-update', { containerId: containerId, containerName, imageName }); } catch (w) { log.warn('workflow', 'pre-update trigger failed: ' + w.message); }
|
||||
}
|
||||
|
||||
// Get current container config for recreation
|
||||
const hostConfig = containerInfo.HostConfig;
|
||||
const config = {
|
||||
@@ -135,10 +141,15 @@ module.exports = function({ docker, log, asyncHandler }) {
|
||||
}
|
||||
|
||||
success(res, {
|
||||
message: `Container ${containerName} updated successfully`,
|
||||
newContainerId: newContainerInfo.Id
|
||||
});
|
||||
}, 'container-update'));
|
||||
message: `Container ${containerName} updated successfully`,
|
||||
newContainerId: newContainerInfo.Id
|
||||
});
|
||||
|
||||
// Trigger post-update workflow
|
||||
if (workflowEngine) {
|
||||
try { await workflowEngine.triggerEvent('post-update', { containerId: containerId, containerName, imageName, newContainerId: newContainerInfo.Id }); } catch (w) { log.warn('workflow', 'post-update trigger failed: ' + w.message); }
|
||||
}
|
||||
}, 'container-update'));
|
||||
|
||||
// Check for available updates (compares local and remote image digests)
|
||||
router.get('/:id/check-update', asyncHandler(async (req, res) => {
|
||||
|
||||
Reference in New Issue
Block a user