Sha256: 8db4020bc4a2421fb51257a541629378be9ae14ab518a88ad7adceecdfbae2fa

Contents?: true

Size: 1.3 KB

Versions: 67

Compression:

Stored size: 1.3 KB

Contents

/**
 * @ngdoc service
 * @name  Bastion.components.service:Notification
 *
 * @description
 *  Service to display a foreman toast notification
 */
angular.module('Bastion.components').service("Notification", ['$interpolate', 'foreman', function ($interpolate, foreman) {
    function interpolateIfNeeded(message, context) {
        var result = message;

        if (context) {
            result = $interpolate(message)(context);
        }

        return result;
    }

    this.setSuccessMessage = function (message, options) {
        var baseOptions, fullOptions;
        /* eslint-disable no-unused-expressions */
        (angular.isUndefined(options)) && (options = {});
        /* eslint-enable no-unused-expressions */
        baseOptions = { message: interpolateIfNeeded(message, options.context), type: 'success' };
        delete options.context;
        fullOptions = _.extend(baseOptions, options);
        foreman.toastNotifications.notify(fullOptions);
    };

    this.setWarningMessage = function (message, context) {
        foreman.toastNotifications.notify({message: interpolateIfNeeded(message, context), type: 'warning'});
    };

    this.setErrorMessage = function (message, context) {
        foreman.toastNotifications.notify({message: interpolateIfNeeded(message, context), type: 'error'});
    };
}]);

Version data entries

67 entries across 67 versions & 1 rubygems

Version Path
katello-4.6.2.1 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-4.6.2 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-4.6.1 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-4.4.2.2 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-4.4.2.1 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-4.4.2 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-4.5.1 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-4.6.0 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-4.6.0.rc2 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-4.6.0.rc1 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-4.5.0 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-4.5.0.rc2 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-4.4.1 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-4.5.0.rc1 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-4.4.0.2 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-4.4.0.1 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-4.3.1 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-4.4.0 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-4.4.0.rc2 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-4.4.0.rc1 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js