mirror of
https://github.com/bingohuang/docker-labs.git
synced 2025-10-04 01:17:49 +08:00
Add expiration clock to sessions
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
$scope.idx = {};
|
||||
$scope.selectedInstance = null;
|
||||
$scope.isAlive = true;
|
||||
$scope.ttl = '--:--:--';
|
||||
|
||||
angular.element($window).bind('resize', function(){
|
||||
if ($scope.selectedInstance) {
|
||||
@@ -68,6 +69,13 @@
|
||||
method: 'GET',
|
||||
url: '/sessions/' + $scope.sessionId,
|
||||
}).then(function(response) {
|
||||
if (response.data.created_at) {
|
||||
$scope.expiresAt = moment(response.data.expires_at);
|
||||
setInterval(function() {
|
||||
$scope.ttl = moment.utc($scope.expiresAt.diff(moment())).format('HH:mm:ss');
|
||||
$scope.$apply();
|
||||
}, 1000);
|
||||
}
|
||||
var socket = io({path: '/sessions/' + sessionId + '/ws'});
|
||||
|
||||
socket.on('terminal out', function(name, data) {
|
||||
|
@@ -1,3 +1,5 @@
|
||||
@import url('http://fonts.googleapis.com/css?family=Rationale');
|
||||
|
||||
.selected button {
|
||||
background-color: rgba(158,158,158,0.2);
|
||||
}
|
||||
@@ -18,3 +20,10 @@ md-card-content.terminal {
|
||||
.terminal .xterm-rows {
|
||||
background-color: #000;
|
||||
}
|
||||
|
||||
.clock {
|
||||
font-family: 'Rationale', sans-serif;
|
||||
font-size: 3.0em;
|
||||
color: #1da4eb;
|
||||
text-align: center;
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@
|
||||
md-whiteframe="4" layout="column">
|
||||
|
||||
<md-toolbar class="md-theme-indigo">
|
||||
<span class="clock">{{ttl}}</span>
|
||||
<md-button class="md-warn md-raised" ng-click="closeSession()">Close session</md-button>
|
||||
<h1 class="md-toolbar-tools">Instances</h1>
|
||||
</md-toolbar>
|
||||
@@ -89,6 +90,7 @@
|
||||
<script src="/assets/xterm.js"></script>
|
||||
<script src="/assets/xterm-addons/fit.js"></script>
|
||||
<script src="/assets/attach.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.16.0/moment.min.js"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
window.onbeforeunload = function (e) {
|
||||
e = e || window.event;
|
||||
|
Reference in New Issue
Block a user