parent
d9bafa478b
commit
dcf8922799
5 changed files with 100 additions and 0 deletions
35
static/js/directives/ui/feedback-bar.js
Normal file
35
static/js/directives/ui/feedback-bar.js
Normal file
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
* An element which displays a feedback bar when an action has been taken.
|
||||
*/
|
||||
angular.module('quay').directive('feedbackBar', function () {
|
||||
var directiveDefinitionObject = {
|
||||
priority: 0,
|
||||
templateUrl: '/static/directives/feedback-bar.html',
|
||||
replace: false,
|
||||
transclude: true,
|
||||
restrict: 'C',
|
||||
scope: {
|
||||
'feedback': '=feedback'
|
||||
},
|
||||
controller: function($scope, $element, AvatarService, Config, UIService, $timeout) {
|
||||
$scope.viewCounter = 0;
|
||||
|
||||
$scope.$watch('feedback', function(feedback) {
|
||||
if (feedback) {
|
||||
$scope.viewCounter++;
|
||||
} else {
|
||||
$scope.viewCounter = 0;
|
||||
}
|
||||
});
|
||||
|
||||
$($element).find('.feedback-bar-element')
|
||||
.on('webkitAnimationEnd oanimationend oAnimationEnd msAnimationEnd animationend',
|
||||
function(e) {
|
||||
$scope.$apply(function() {
|
||||
$scope.viewCounter = 0;
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
return directiveDefinitionObject;
|
||||
});
|
|
@ -22,6 +22,7 @@ angular.module('quay').directive('robotsManager', function () {
|
|||
$scope.shownRobot = null;
|
||||
$scope.showRobotCounter = 0;
|
||||
$scope.Config = Config;
|
||||
$scope.feedback = null;
|
||||
|
||||
// Listen for route changes and update the tabs accordingly.
|
||||
var locationListener = $rootScope.$on('$routeUpdate', function(){
|
||||
|
@ -117,6 +118,10 @@ angular.module('quay').directive('robotsManager', function () {
|
|||
created.teams = [];
|
||||
created.repositories = [];
|
||||
$scope.robots.push(created);
|
||||
$scope.feedback = {
|
||||
'kind': 'info',
|
||||
'message': 'Robot account ' + name + ' was created'
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -126,6 +131,10 @@ angular.module('quay').directive('robotsManager', function () {
|
|||
var index = $scope.findRobotIndexByName(info.name);
|
||||
if (index >= 0) {
|
||||
$scope.robots.splice(index, 1);
|
||||
$scope.feedback = {
|
||||
'kind': 'info',
|
||||
'message': 'Robot account ' + info.name + ' was deleted'
|
||||
};
|
||||
}
|
||||
}, ApiService.errorDisplay('Cannot delete robot account'));
|
||||
};
|
||||
|
|
Reference in a new issue