Sha256: 223d164ff7318d2ab03b3941cec65494c8d9f481d4bd83e02afcc10e8e1f842b

Contents?: true

Size: 1.3 KB

Versions: 107

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: 'danger'});
    };
}]);

Version data entries

107 entries across 107 versions & 2 rubygems

Version Path
katello-3.16.0.rc5 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-3.16.0.rc4.1 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-3.15.3.1 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-3.15.3 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-3.16.0.rc4 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-3.16.0.rc3.1 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-3.15.2 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-3.16.0.rc3 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-3.16.0.rc2.1 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-3.16.0.rc2 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-3.15.1.1 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-3.16.0.rc1.1 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-3.15.1 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-3.16.0.rc1 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-3.15.0.1 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-3.15.0 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-3.15.0.rc2 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-3.15.0.rc1.3 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-3.15.0.rc1.2 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js
katello-3.15.0.rc1.1 engines/bastion/app/assets/javascripts/bastion/components/notification.service.js