mirror of
https://github.com/bingohuang/docker-labs.git
synced 2025-10-04 09:23:21 +08:00
Add visual state of New instance and Delete buttons (#75)
The buttons now get disabled when pressed and their text changes to the action being made. If the action ends (either with success or failure), state is reverted to the normal one. Signed-off-by: Antonis Kalipetis <akalipetis@gmail.com>
This commit is contained in:
committed by
Marcos Nils
parent
fd52a544d1
commit
81280517bf
@@ -20,6 +20,10 @@
|
||||
$scope.isAlive = true;
|
||||
$scope.ttl = '--:--:--';
|
||||
$scope.connected = true;
|
||||
$scope.isInstanceBeingCreated = false;
|
||||
$scope.newInstanceBtnText = '+ Add new instance';
|
||||
$scope.deleteInstanceBtnText = 'Delete';
|
||||
$scope.isInstanceBeingDeleted = false;
|
||||
|
||||
angular.element($window).bind('resize', function() {
|
||||
if ($scope.selectedInstance) {
|
||||
@@ -62,6 +66,7 @@
|
||||
}
|
||||
|
||||
$scope.newInstance = function() {
|
||||
updateNewInstanceBtnState(true);
|
||||
$http({
|
||||
method: 'POST',
|
||||
url: '/sessions/' + $scope.sessionId + '/instances',
|
||||
@@ -72,6 +77,8 @@
|
||||
if (response.status == 409) {
|
||||
$scope.showAlert('Max instances reached', 'Maximum number of instances reached')
|
||||
}
|
||||
}).finally(function() {
|
||||
updateNewInstanceBtnState(false);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -203,6 +210,7 @@
|
||||
}
|
||||
|
||||
$scope.deleteInstance = function(instance) {
|
||||
updateDeleteInstanceBtnState(true);
|
||||
$http({
|
||||
method: 'DELETE',
|
||||
url: '/sessions/' + $scope.sessionId + '/instances/' + instance.name,
|
||||
@@ -210,6 +218,8 @@
|
||||
$scope.removeInstance(instance.name);
|
||||
}, function(response) {
|
||||
console.log('error', response);
|
||||
}).finally(function() {
|
||||
updateDeleteInstanceBtnState(false);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -256,6 +266,26 @@
|
||||
cb();
|
||||
}
|
||||
}
|
||||
|
||||
function updateNewInstanceBtnState(isInstanceBeingCreated) {
|
||||
if (isInstanceBeingCreated === true) {
|
||||
$scope.newInstanceBtnText = '+ Creating...';
|
||||
$scope.isInstanceBeingCreated = true;
|
||||
} else {
|
||||
$scope.newInstanceBtnText = '+ Add new instance';
|
||||
$scope.isInstanceBeingCreated = false;
|
||||
}
|
||||
}
|
||||
|
||||
function updateDeleteInstanceBtnState(isInstanceBeingDeleted) {
|
||||
if (isInstanceBeingDeleted === true) {
|
||||
$scope.deleteInstanceBtnText = 'Deleting...';
|
||||
$scope.isInstanceBeingDeleted = true;
|
||||
} else {
|
||||
$scope.deleteInstanceBtnText = 'Delete';
|
||||
$scope.isInstanceBeingDeleted = false;
|
||||
}
|
||||
}
|
||||
}])
|
||||
|
||||
.config(['$mdIconProvider', function($mdIconProvider) {
|
||||
|
Reference in New Issue
Block a user