mirror of
https://github.com/dobin/lxd-webgui
synced 2025-10-05 23:52:43 +02:00
@@ -249,7 +249,7 @@ angular.module('myApp.container', ['ngRoute'])
|
||||
})
|
||||
|
||||
|
||||
.controller('containerCreateCtrl', function ($scope, $routeParams, $filter, $location,
|
||||
.controller('containerCreateCtrl', function ($scope, $routeParams, $filter, $location, $interval,
|
||||
ContainerServices, ImageServices, profiles, images) {
|
||||
$scope.containerName = "";
|
||||
|
||||
@@ -271,17 +271,36 @@ angular.module('myApp.container', ['ngRoute'])
|
||||
$scope.isSubmitted = true;
|
||||
|
||||
if (isValid) {
|
||||
// convert from selected profiles with full information
|
||||
// to an array
|
||||
var profiles = [];
|
||||
for(var n=0; n<$scope.selected.profile.length; n++) {
|
||||
profiles.push($scope.selected.profile[n].name);
|
||||
}
|
||||
|
||||
ContainerServices.create(
|
||||
$scope.containerName,
|
||||
$scope.selected.image.fingerprint,
|
||||
$scope.selected.profile.name,
|
||||
profiles,
|
||||
$scope.selected.ephemeral)
|
||||
.then(function(data) {
|
||||
window.location = "#/containers";
|
||||
}, function(error) {
|
||||
var errorMsg = error.error;
|
||||
console.log("Error: " + errorMsg);
|
||||
});
|
||||
var operationUrl = data.data.operation;
|
||||
var refreshInterval;
|
||||
|
||||
// Try until operation is finished
|
||||
refreshInterval = $interval(
|
||||
function() {
|
||||
ContainerServices.isOperationFinished(operationUrl).then(function(data) {
|
||||
// I dont really care if the operation is still runnging
|
||||
}, function(error) {
|
||||
// Operation returned 404, so its finished
|
||||
$interval.cancel(refreshInterval);
|
||||
// TODO: check if successful
|
||||
window.location = "#/containers";
|
||||
});
|
||||
}, 500
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -47,10 +47,10 @@ angular.module('myApp.container')
|
||||
|
||||
|
||||
// Create container:
|
||||
obj.create = function (containerName, imageFingerprint, profileName, ephemeralState) {
|
||||
obj.create = function (containerName, imageFingerprint, profiles, ephemeralState) {
|
||||
var containerData = {
|
||||
name: containerName,
|
||||
profiles: [ profileName ],
|
||||
profiles: profiles,
|
||||
ephemeral: ephemeralState,
|
||||
source: {
|
||||
type: "image",
|
||||
@@ -58,15 +58,7 @@ angular.module('myApp.container')
|
||||
}
|
||||
};
|
||||
// Async
|
||||
return $http.post(SettingServices.getLxdApiUrl() + '/containers', containerData).then(function(data) {
|
||||
data = data.data;
|
||||
|
||||
if (data.status != "Success") {
|
||||
return($q.reject(data.metadata));
|
||||
}
|
||||
|
||||
data = data.metadata;
|
||||
});
|
||||
return $http.post(SettingServices.getLxdApiUrl() + '/containers', containerData)
|
||||
};
|
||||
|
||||
|
||||
|
@@ -62,17 +62,17 @@
|
||||
<div class="form-group" ng-class="{ 'has-error' : userForm.name.$invalid && (!userForm.name.$pristine || isSubmitted )}">
|
||||
|
||||
<div class="col-md-2">
|
||||
<label>Profile</label>
|
||||
<label>Profile(s)</label>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<ui-select ng-model="selected.profile" required>
|
||||
<ui-select multiple sortable="true" ng-model="selected.profile" required class="form-control">
|
||||
<ui-select-match>
|
||||
<span ng-bind="$select.selected.name"></span>
|
||||
{{$item.name}}
|
||||
</ui-select-match>
|
||||
<ui-select-choices repeat="profile in (profiles | filter: $select.search)">
|
||||
|
||||
<span ng-bind="profile.name"></span>
|
||||
<ui-select-choices repeat="profile in profiles | filter: $select.search">
|
||||
<span ng-bind-html="profile.name | highlight: $select.search"></span>
|
||||
</ui-select-choices>
|
||||
</ui-select>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user