mirror of
https://github.com/bingohuang/docker-labs.git
synced 2025-07-14 10:17:26 +08:00
Show alert if more than 5 instances are created
This commit is contained in:
parent
62936fcfc9
commit
a0ffe28be9
@ -13,6 +13,12 @@ func NewInstance(rw http.ResponseWriter, req *http.Request) {
|
|||||||
sessionId := bone.GetValue(req, "sessionId")
|
sessionId := bone.GetValue(req, "sessionId")
|
||||||
|
|
||||||
s := services.GetSession(sessionId)
|
s := services.GetSession(sessionId)
|
||||||
|
|
||||||
|
if len(s.Instances) >= 5 {
|
||||||
|
rw.WriteHeader(http.StatusConflict)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
i, err := services.NewInstance(s)
|
i, err := services.NewInstance(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
|
@ -3,11 +3,22 @@
|
|||||||
|
|
||||||
var app = angular.module('DockerPlay', ['ngMaterial']);
|
var app = angular.module('DockerPlay', ['ngMaterial']);
|
||||||
|
|
||||||
app.controller('PlayController', ['$scope', '$log', '$http', '$location', '$timeout', function($scope, $log, $http, $location, $timeout) {
|
app.controller('PlayController', ['$scope', '$log', '$http', '$location', '$timeout', '$mdDialog', function($scope, $log, $http, $location, $timeout, $mdDialog) {
|
||||||
$scope.sessionId = window.location.pathname.replace('/p/', '');
|
$scope.sessionId = window.location.pathname.replace('/p/', '');
|
||||||
$scope.instances = [];
|
$scope.instances = [];
|
||||||
$scope.selectedInstance = null;
|
$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.newInstance = function() {
|
$scope.newInstance = function() {
|
||||||
$http({
|
$http({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@ -17,7 +28,9 @@
|
|||||||
$scope.instances.push(i);
|
$scope.instances.push(i);
|
||||||
$scope.showInstance(i);
|
$scope.showInstance(i);
|
||||||
}, function(response) {
|
}, function(response) {
|
||||||
console.log('error', response);
|
if (response.status == 409) {
|
||||||
|
$scope.showAlert('Max instances reached', 'Maximum number of instances reached')
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<link rel="stylesheet" href="/assets/style.css" />
|
<link rel="stylesheet" href="/assets/style.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div layout="column" style="height:100%;" ng-cloak>
|
<div layout="column" style="height:100%;" ng-cloak>
|
||||||
|
|
||||||
<section layout="row" flex>
|
<section layout="row" flex>
|
||||||
|
|
||||||
@ -44,7 +44,7 @@
|
|||||||
|
|
||||||
<div flex></div>
|
<div flex></div>
|
||||||
</md-content>
|
</md-content>
|
||||||
<md-content flex layout-padding ng-repeat="instance in instances" ng-show="instance.name == selectedInstance.name">
|
<md-content id="popupContainer" flex layout-padding ng-repeat="instance in instances" ng-show="instance.name == selectedInstance.name">
|
||||||
<md-card md-theme="default" md-theme-watch>
|
<md-card md-theme="default" md-theme-watch>
|
||||||
<md-card-title>
|
<md-card-title>
|
||||||
<md-card-title-text>
|
<md-card-title-text>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user