mirror of
https://github.com/bingohuang/docker-labs.git
synced 2025-07-14 01:57:32 +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")
|
||||
|
||||
s := services.GetSession(sessionId)
|
||||
|
||||
if len(s.Instances) >= 5 {
|
||||
rw.WriteHeader(http.StatusConflict)
|
||||
return
|
||||
}
|
||||
|
||||
i, err := services.NewInstance(s)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
|
@ -3,11 +3,22 @@
|
||||
|
||||
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.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.newInstance = function() {
|
||||
$http({
|
||||
method: 'POST',
|
||||
@ -17,7 +28,9 @@
|
||||
$scope.instances.push(i);
|
||||
$scope.showInstance(i);
|
||||
}, 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" />
|
||||
</head>
|
||||
<body>
|
||||
<div layout="column" style="height:100%;" ng-cloak>
|
||||
<div layout="column" style="height:100%;" ng-cloak>
|
||||
|
||||
<section layout="row" flex>
|
||||
|
||||
@ -44,7 +44,7 @@
|
||||
|
||||
<div flex></div>
|
||||
</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-title>
|
||||
<md-card-title-text>
|
||||
|
Loading…
x
Reference in New Issue
Block a user