diff --git a/dashboard/src/js/client.js b/dashboard/src/js/client.js index 21ca90962..24bc06e66 100644 --- a/dashboard/src/js/client.js +++ b/dashboard/src/js/client.js @@ -5,6 +5,24 @@ /* global EventSource */ /* global async */ +// keep in sync with box/src/notfications.js +const NOTIFICATION_TYPES = { + ALERT_CLOUDRON_INSTALLED: 'cloudronInstalled', + ALERT_CLOUDRON_UPDATED: 'cloudronUpdated', + ALERT_CLOUDRON_UPDATE_FAILED: 'cloudronUpdateFailed', + ALERT_CERTIFICATE_RENEWAL_FAILED: 'certificateRenewalFailed', + ALERT_BACKUP_CONFIG: 'backupConfig', + ALERT_DISK_SPACE: 'diskSpace', + ALERT_MAIL_STATUS: 'mailStatus', + ALERT_REBOOT: 'reboot', + ALERT_BOX_UPDATE: 'boxUpdate', + ALERT_UPDATE_UBUNTU: 'ubuntuUpdate', + ALERT_MANUAL_APP_UPDATE: 'manualAppUpdate', + ALERT_APP_OOM: 'appOutOfMemory', + ALERT_APP_UPDATED: 'appUpdated', + ALERT_BACKUP_FAILED: 'backupFailed', +}; + // keep in sync with box/src/apps.js var ISTATES = { PENDING_INSTALL: 'pending_install', diff --git a/dashboard/src/js/index.js b/dashboard/src/js/index.js index d70c73d9b..6ec784177 100644 --- a/dashboard/src/js/index.js +++ b/dashboard/src/js/index.js @@ -2,7 +2,7 @@ /* global angular:false */ /* global $:false */ -/* global ERROR,ISTATES,HSTATES,RSTATES,APP_TYPES */ +/* global ERROR,ISTATES,HSTATES,RSTATES,APP_TYPES,NOTIFICATION_TYPES */ // deal with accessToken in the query, this is passed for example on password reset and account setup upon invite var search = decodeURIComponent(window.location.search).slice(1).split('&').map(function (item) { return item.split('='); }).reduce(function (o, k) { o[k[0]] = k[1]; return o; }, {}); @@ -118,6 +118,25 @@ app.config(['$routeProvider', function ($routeProvider) { }).otherwise({ redirectTo: '/'}); }]); +app.filter('notificadtionTypeToColor', function () { + return function (n) { + switch (n.type) { + case NOTIFICATION_TYPES.ALERT_REBOOT: + case NOTIFICATION_TYPES.ALERT_APP_OOM: + case NOTIFICATION_TYPES.ALERT_MAIL_STATUS: + case NOTIFICATION_TYPES.ALERT_CERTIFICATE_RENEWAL_FAILED: + case NOTIFICATION_TYPES.ALERT_DISK_SPACE: + case NOTIFICATION_TYPES.ALERT_BACKUP_CONFIG: + return '#ff4c4c'; + case NOTIFICATION_TYPES.ALERT_BOX_UPDATE: + case NOTIFICATION_TYPES.ALERT_MANUAL_APP_UPDATE: + return '#f0ad4e'; + default: + return '#2196f3'; + } + }; +}); + app.filter('capitalize', function () { return function (s) { return s.charAt(0).toUpperCase() + s.slice(1); diff --git a/dashboard/src/views/notifications.html b/dashboard/src/views/notifications.html index 3d5eaae48..243dc55c9 100644 --- a/dashboard/src/views/notifications.html +++ b/dashboard/src/views/notifications.html @@ -23,7 +23,7 @@ -