mirror of
https://github.com/portainer/portainer.git
synced 2025-08-02 20:35:25 +02:00
Move startContainer to its own submodule.
This commit is contained in:
parent
3a28cb9889
commit
57fef1c958
5 changed files with 49 additions and 47 deletions
47
app/components/startContainer/startContainerController.js
Normal file
47
app/components/startContainer/startContainerController.js
Normal file
|
@ -0,0 +1,47 @@
|
|||
angular.module('startContainer', [])
|
||||
.controller('StartContainerController', ['$scope', '$routeParams', '$location', 'Container', 'Messages',
|
||||
function($scope, $routeParams, $location, Container, Messages) {
|
||||
$scope.template = 'app/components/startContainer/startcontainer.html';
|
||||
$scope.config = {
|
||||
name: '',
|
||||
memory: 0,
|
||||
memorySwap: 0,
|
||||
cpuShares: 1024,
|
||||
env: '',
|
||||
commands: '',
|
||||
volumesFrom: ''
|
||||
};
|
||||
$scope.commandPlaceholder = '["/bin/echo", "Hello world"]';
|
||||
|
||||
$scope.create = function() {
|
||||
var cmds = null;
|
||||
if ($scope.config.commands !== '') {
|
||||
cmds = angular.fromJson($scope.config.commands);
|
||||
}
|
||||
var id = $routeParams.id;
|
||||
var ctor = Container;
|
||||
var loc = $location;
|
||||
var s = $scope;
|
||||
|
||||
Container.create({
|
||||
Image: id,
|
||||
name: $scope.config.name,
|
||||
Memory: $scope.config.memory,
|
||||
MemorySwap: $scope.config.memorySwap,
|
||||
CpuShares: $scope.config.cpuShares,
|
||||
Cmd: cmds,
|
||||
VolumesFrom: $scope.config.volumesFrom
|
||||
}, function(d) {
|
||||
if (d.Id) {
|
||||
ctor.start({id: d.Id}, function(cd) {
|
||||
$('#create-modal').modal('hide');
|
||||
loc.path('/containers/' + d.Id + '/');
|
||||
}, function(e) {
|
||||
failedRequestHandler(e, Messages);
|
||||
});
|
||||
}
|
||||
}, function(e) {
|
||||
failedRequestHandler(e, Messages);
|
||||
});
|
||||
};
|
||||
}]);
|
44
app/components/startContainer/startcontainer.html
Normal file
44
app/components/startContainer/startcontainer.html
Normal file
|
@ -0,0 +1,44 @@
|
|||
<div id="create-modal" class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3>Create And Start Container From Image</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form role="form">
|
||||
<fieldset>
|
||||
<div class="form-group">
|
||||
<label>Cmd:</label>
|
||||
<input type="text" placeholder="{{ commandPlaceholder }}" ng-model="config.commands" class="form-control"/>
|
||||
<small>Input commands as an array</small>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Name:</label>
|
||||
<input type="text" ng-model="config.name" class="form-control"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Memory:</label>
|
||||
<input type="number" ng-model="config.memory" class="form-control"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Memory Swap:</label>
|
||||
<input type="number" ng-model="config.memorySwap" class="form-control"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>CPU Shares:</label>
|
||||
<input type="number" ng-model="config.cpuShares" class="form-control"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Volumes From:</label>
|
||||
<input type="text" ng-model="config.volumesFrom" class="form-control"/>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="" class="btn btn-primary" ng-click="create()">Create</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue