Sha256: 0d7fc4f933d78503bf56fd2adbc21f038fc15b01977799f72121a5b2a8721ee4

Contents?: true

Size: 1.9 KB

Versions: 221

Compression:

Stored size: 1.9 KB

Contents

/**
 * @ngdoc directive
 * @name Bastion.components.directive:currentTasks
 *
 * @requires $document
 * @requires authorizationService
 * @requires Task
 *
 * @description
 *  Provides a widget showing current number of runnings tasks, popping
 *  up the table of recent tasks when clicked on.
 *
 * @example
    <span current-tasks></span>
 */
angular.module('Bastion.components').directive('currentTasks',
    ['$document', 'authorizationService', 'Task',
    function ($document, authorizationService, Task) {

        return {
            restrict: 'A',
            scope: true,
            templateUrl: 'components/views/current-tasks.html',

            controller: ['$scope', function ($scope) {
                // Hide the current tasks list if the user clicks outside of it
                var currentTasksMenu = angular.element('#currentTasks');
                $scope.visible = false;
                $scope.currentUser = authorizationService.getCurrentUser();
                $scope.count = 0;

                $scope.toggleVisibility = function () {
                    $scope.visible = !$scope.visible;
                };

                $scope.updateTasks = function (tasks) {
                    $scope.count = tasks.length;
                };

                $document.bind('click', function (event) {
                    var target = angular.element(event.target);
                    if (!currentTasksMenu.find(target).length) {
                        $scope.visible = false;
                        if (!$scope.$$phase) {
                            $scope.$apply();
                        }
                    }
                });
            }],
            link: function (scope) {
                var searchParams = {'active_only': true, 'type': 'user', 'user_id': authorizationService.getCurrentUser().id};
                Task.registerSearch(searchParams, scope.updateTasks);
            }
        };
    }]);

Version data entries

221 entries across 221 versions & 2 rubygems

Version Path
katello-4.14.2 engines/bastion/app/assets/javascripts/bastion/components/current-tasks.directive.js
katello-4.15.0 engines/bastion/app/assets/javascripts/bastion/components/current-tasks.directive.js
katello-4.15.0.rc2 engines/bastion/app/assets/javascripts/bastion/components/current-tasks.directive.js
katello-4.15.0.rc1 engines/bastion/app/assets/javascripts/bastion/components/current-tasks.directive.js
katello-4.14.1 engines/bastion/app/assets/javascripts/bastion/components/current-tasks.directive.js
katello-4.14.0 engines/bastion/app/assets/javascripts/bastion/components/current-tasks.directive.js
katello-4.14.0.rc3 engines/bastion/app/assets/javascripts/bastion/components/current-tasks.directive.js
katello-4.14.0.rc2 engines/bastion/app/assets/javascripts/bastion/components/current-tasks.directive.js
katello-4.14.0.rc1.1 engines/bastion/app/assets/javascripts/bastion/components/current-tasks.directive.js
katello-4.14.0.rc1 engines/bastion/app/assets/javascripts/bastion/components/current-tasks.directive.js
katello-4.13.1 engines/bastion/app/assets/javascripts/bastion/components/current-tasks.directive.js
katello-4.13.0 engines/bastion/app/assets/javascripts/bastion/components/current-tasks.directive.js
katello-4.12.1 engines/bastion/app/assets/javascripts/bastion/components/current-tasks.directive.js
katello-4.13.0.rc1 engines/bastion/app/assets/javascripts/bastion/components/current-tasks.directive.js
katello-4.12.0 engines/bastion/app/assets/javascripts/bastion/components/current-tasks.directive.js
katello-4.12.0.rc3 engines/bastion/app/assets/javascripts/bastion/components/current-tasks.directive.js
katello-4.12.0.rc2 engines/bastion/app/assets/javascripts/bastion/components/current-tasks.directive.js
katello-4.12.0.rc1 engines/bastion/app/assets/javascripts/bastion/components/current-tasks.directive.js
katello-4.11.1 engines/bastion/app/assets/javascripts/bastion/components/current-tasks.directive.js
katello-4.11.0 engines/bastion/app/assets/javascripts/bastion/components/current-tasks.directive.js