mirror of
https://github.com/bingohuang/docker-labs.git
synced 2025-10-04 17:33:21 +08:00
Show when session has expired
This commit is contained in:
@@ -8,16 +8,16 @@
|
||||
$scope.instances = [];
|
||||
$scope.selectedInstance = null;
|
||||
|
||||
$scope.showAlert = function(title, content) {
|
||||
$mdDialog.show(
|
||||
$mdDialog.alert()
|
||||
.parent(angular.element(document.querySelector('#popupContainer')))
|
||||
.clickOutsideToClose(true)
|
||||
.title(title)
|
||||
.textContent(content)
|
||||
.ok('Got it!')
|
||||
);
|
||||
}
|
||||
$scope.showAlert = function(title, content) {
|
||||
$mdDialog.show(
|
||||
$mdDialog.alert()
|
||||
.parent(angular.element(document.querySelector('#popupContainer')))
|
||||
.clickOutsideToClose(true)
|
||||
.title(title)
|
||||
.textContent(content)
|
||||
.ok('Got it!')
|
||||
);
|
||||
}
|
||||
|
||||
$scope.newInstance = function() {
|
||||
$http({
|
||||
@@ -48,11 +48,14 @@
|
||||
if ($scope.instances.length) {
|
||||
$scope.showInstance($scope.instances[0]);
|
||||
}
|
||||
|
||||
// Since session exists, we check it still exists every 10 seconds
|
||||
$scope.checkHandler = setInterval(checkSession, 10*1000);
|
||||
}, function(response) {
|
||||
if (response.status == 404) {
|
||||
document.write('session not found');
|
||||
return
|
||||
}
|
||||
if (response.status == 404) {
|
||||
document.write('session not found');
|
||||
return
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -79,5 +82,17 @@
|
||||
}
|
||||
|
||||
$scope.getSession($scope.sessionId);
|
||||
|
||||
function checkSession() {
|
||||
$http({
|
||||
method: 'GET',
|
||||
url: '/sessions/' + $scope.sessionId,
|
||||
}).then(function(response) {}, function(response) {
|
||||
if (response.status == 404) {
|
||||
clearInterval($scope.checkHandler);
|
||||
$scope.showAlert('Session timedout!', 'Your session has expire and all your instances has been deleted.')
|
||||
}
|
||||
});
|
||||
}
|
||||
}]);
|
||||
})();
|
||||
|
@@ -40,6 +40,9 @@
|
||||
<p>
|
||||
Add instances to your playground.
|
||||
</p>
|
||||
<p>
|
||||
<strong>Sessions and all their instances are deleted after 1 hour.</strong>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div flex></div>
|
||||
|
Reference in New Issue
Block a user