Feedback bar for showing response to user actions

Fixes #215
This commit is contained in:
Joseph Schorr 2015-07-13 15:34:46 +03:00
parent d9bafa478b
commit dcf8922799
5 changed files with 100 additions and 0 deletions

View file

@ -0,0 +1,52 @@
.feedback-bar {
position: absolute;
top: 0px;
left: 0px;
right: 0px;
z-index: 50;
overflow: hidden;
text-align: center;
height: 42px;
}
@keyframes flow-down-up {
0% {
top: -40px;
}
25% {
top: 0px;
}
75% {
top: 0px;
}
100% {
top: -40px;
}
}
.feedback-bar-element {
position: relative;
top: -40px;
text-align: center;
display: inline-block;
background: #eee;
padding: 10px;
border: 1px solid #eee;
border-top: 0px;
animation-name: flow-down-up;
animation-duration: 5s;
}
.feedback-bar .feedback-bar-element.info {
background-color: #F0FAFF;
}
.feedback-bar .feedback-bar-element.warning {
background-color: #FFFBF0;
}

View file

@ -0,0 +1,3 @@
<div class="feedback-bar-element" ng-class="feedback.kind" ng-show="viewCounter">
{{ feedback.message }}
</div>

View file

@ -1,4 +1,5 @@
<div class="robots-manager-element">
<div class="feedback-bar" feedback="feedback"></div>
<div class="cor-loader" ng-show="loading"></div>
<div ng-show="!loading">

View 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;
});

View file

@ -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'));
};