diff options
| author | Yoshie Muranaka <yoshiemuranaka@gmail.com> | 2019-10-16 08:13:53 -0700 |
|---|---|---|
| committer | Yoshie Muranaka <yoshiemuranaka@gmail.com> | 2019-10-22 09:45:35 -0700 |
| commit | 5e930c0aeb5b66df2c357be4d5c33d4828c2783f (patch) | |
| tree | 56fe47b702eab9ab6cbd9c6b6acc8d9c56fc2e86 /app/common/services | |
| parent | d11b9277aea0baeafa4488084d27cfef0e607480 (diff) | |
| download | phosphor-webui-5e930c0aeb5b66df2c357be4d5c33d4828c2783f.tar.gz phosphor-webui-5e930c0aeb5b66df2c357be4d5c33d4828c2783f.zip | |
Update toast notification
Added new toast notification types, warn and info,
and updated visual styling. All toasts will need
to be manually closed by clicking the 'X' close icon,
except a success toast which will be dismissed
automatically after 10 secs.
- Small updates to critical and success/on icon
- Added new colors for toast status background colors
Signed-off-by: Yoshie Muranaka <yoshiemuranaka@gmail.com>
Change-Id: I9077109042621b2d3346b4121d6344da502b6b26
Diffstat (limited to 'app/common/services')
| -rw-r--r-- | app/common/services/toastService.js | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/app/common/services/toastService.js b/app/common/services/toastService.js index c199e96..0718e4d 100644 --- a/app/common/services/toastService.js +++ b/app/common/services/toastService.js @@ -13,15 +13,39 @@ window.angular && (function(angular) { angular.module('app.common.services').service('toastService', [ 'ngToast', '$sce', function(ngToast, $sce) { + function initToast( + type = 'create', title = '', message = '', dismissOnTimeout = false) { + const iconStatus = type === 'success' ? + 'on' : + type === 'danger' ? 'error' : type === 'warning' ? 'warn' : null; + const content = $sce.trustAsHtml(` + <div role="alert" class="alert-content-container"> + <status-icon ng-if="${iconStatus !== null}" + status="${iconStatus}" + class="status-icon"> + </status-icon> + <div class="alert-content"> + <h2 class="alert-content__header">${title}</h2> + <p class="alert-content__body">${message}</p> + </div> + </div>`); + ngToast[type]({content, dismissOnTimeout, compileContent: true}); + }; + this.error = function(message) { - var errorMessage = $sce.trustAsHtml( - '<div role="alert"><b>Error</b><br>' + message + '</div>'); - ngToast.create({className: 'danger', content: errorMessage}); + initToast('danger', 'Error', message); }; + this.success = function(message) { - var successMessage = $sce.trustAsHtml( - '<div role="alert"><b>Success!</b><br>' + message + '</div>'); - ngToast.create({className: 'success', content: successMessage}); + initToast('success', 'Success!', message, true); + }; + + this.warn = function(message) { + initToast('warning', 'Warning', message); + }; + + this.info = function(title, message) { + initToast('info', title, message); }; } ]); |

