github.com/hernad/nomad@v1.6.112/ui/app/services/notifications.js (about) 1 /** 2 * Copyright (c) HashiCorp, Inc. 3 * SPDX-License-Identifier: MPL-2.0 4 */ 5 6 // @ts-check 7 import { default as FlashService } from 'ember-cli-flash/services/flash-messages'; 8 9 /** 10 * @typedef {Object} NotificationObject 11 * @property {string} title 12 * @property {string} [message] 13 * @property {string} [type] 14 * @property {string} [color = 'neutral'] 15 * @property {boolean} [sticky = true] 16 * @property {boolean} [destroyOnClick = false] 17 * @property {number} [timeout = 5000] 18 */ 19 20 /** 21 * @class NotificationsService 22 * @extends FlashService 23 * A wrapper service around Ember Flash Messages, for adding notifications to the UI 24 */ 25 export default class NotificationsService extends FlashService { 26 /** 27 * @param {NotificationObject} notificationObject 28 * @returns {FlashService} 29 */ 30 add(notificationObject) { 31 // Set some defaults 32 if (!('type' in notificationObject)) { 33 notificationObject.type = notificationObject.color || 'neutral'; 34 } 35 36 if (!('destroyOnClick' in notificationObject)) { 37 notificationObject.destroyOnClick = false; 38 } 39 40 if (!('timeout' in notificationObject)) { 41 notificationObject.timeout = 5000; 42 } 43 44 return super.add(notificationObject); 45 } 46 }