Update build and msg paritals

pull/2/head
Michael Crosby 2013-06-22 09:23:25 -09:00
parent 980bc6612e
commit 38f859f52d
7 changed files with 77 additions and 71 deletions

View File

@ -110,6 +110,7 @@
} }
.messages { .messages {
overflow: scroll;
max-height: 50px; max-height: 50px;
overflow-y: scroll;
overflow-x: hidden;
} }

View File

@ -14,4 +14,4 @@ angular.module('dockerui', ['dockerui.services', 'dockerui.filters'])
.constant('DOCKER_ENDPOINT', 'http://192.168.1.9') .constant('DOCKER_ENDPOINT', 'http://192.168.1.9')
.constant('DOCKER_PORT', ':4243') .constant('DOCKER_PORT', ':4243')
.constant('UI_VERSION', 'v0.2') .constant('UI_VERSION', 'v0.2')
.constant('DOCKER_API_VERSION', 'v1.1'); .constant('DOCKER_API_VERSION', 'v1.2');

View File

@ -17,7 +17,7 @@ function MessageController($scope, Messages) {
$scope.messages.push(msg); $scope.messages.push(msg);
setTimeout(function() { setTimeout(function() {
$('#message-display').hide('slow'); $('#message-display').hide('slow');
}, 10000); }, 30000);
}); });
} }
@ -38,70 +38,62 @@ function SideBarController($scope, Container, Settings) {
}); });
} }
function SettingsController($scope, Auth, System, Docker, Settings, Messages) { function SettingsController($scope, System, Docker, Settings, Messages) {
$scope.auth = {};
$scope.info = {}; $scope.info = {};
$scope.docker = {}; $scope.docker = {};
$scope.endpoint = Settings.endpoint; $scope.endpoint = Settings.endpoint;
$scope.apiVersion = Settings.version; $scope.apiVersion = Settings.version;
$scope.updateAuthInfo = function() {
if ($scope.auth.password != $scope.auth.cpassword) {
alert('Your passwords do not match.');
return;
}
Auth.update({
username: $scope.auth.username,
email: $scope.auth.email,
password: $scope.auth.password
}, function(d) {
Messages.send({class: 'text-success', data: 'Auth information updated.'});
}, function(e) {
Messages.send({class: 'text-error', data: e.data});
});
};
Auth.get({}, function(d) { $scope.auth = d; });
Docker.get({}, function(d) { $scope.docker = d; }); Docker.get({}, function(d) { $scope.docker = d; });
System.get({}, function(d) { $scope.info = d; }); System.get({}, function(d) { $scope.info = d; });
} }
// Controls the page that displays a single container and actions on that container. // Controls the page that displays a single container and actions on that container.
function ContainerController($scope, $routeParams, $location, Container, Messages) { function ContainerController($scope, $routeParams, $location, Container, Messages, ViewSpinner) {
$scope.changes = []; $scope.changes = [];
$scope.start = function(){ $scope.start = function(){
ViewSpinner.spin();
Container.start({id: $routeParams.id}, function(d) { Container.start({id: $routeParams.id}, function(d) {
Messages.send({class: 'text-success', data: 'Container started.'}); Messages.send({class: 'text-success', data: 'Container started.'});
ViewSpinner.stop();
}, function(e) { }, function(e) {
failedRequestHandler(e, Messages); failedRequestHandler(e, Messages);
ViewSpinner.stop();
}); });
}; };
$scope.stop = function() { $scope.stop = function() {
ViewSpinner.spin();
Container.stop({id: $routeParams.id}, function(d) { Container.stop({id: $routeParams.id}, function(d) {
Messages.send({class: 'text-success', data: 'Container stopped.'}); Messages.send({class: 'text-success', data: 'Container stopped.'});
ViewSpinner.stop();
}, function(e) { }, function(e) {
failedRequestHandler(e, Messages); failedRequestHandler(e, Messages);
ViewSpinner.stop();
}); });
}; };
$scope.kill = function() { $scope.kill = function() {
ViewSpinner.spin();
Container.kill({id: $routeParams.id}, function(d) { Container.kill({id: $routeParams.id}, function(d) {
Messages.send({class: 'text-success', data: 'Container killed.'}); Messages.send({class: 'text-success', data: 'Container killed.'});
ViewSpinner.stop();
}, function(e) { }, function(e) {
failedRequestHandler(e, Messages); failedRequestHandler(e, Messages);
ViewSpinner.stop();
}); });
}; };
$scope.remove = function() { $scope.remove = function() {
if (confirm("Are you sure you want to remove the container?")) { ViewSpinner.spin();
Container.remove({id: $routeParams.id}, function(d) { Container.remove({id: $routeParams.id}, function(d) {
Messages.send({class: 'text-success', data: 'Container removed.'}); Messages.send({class: 'text-success', data: 'Container removed.'});
ViewSpinner.stop();
}, function(e){ }, function(e){
failedRequestHandler(e, Messages); failedRequestHandler(e, Messages);
ViewSpinner.stop();
}); });
}
}; };
$scope.hasContent = function(data) { $scope.hasContent = function(data) {
@ -141,12 +133,25 @@ function ContainersController($scope, Container, Settings, Messages, ViewSpinner
}; };
var batch = function(items, action) { var batch = function(items, action) {
ViewSpinner.spin();
var counter = 0;
var complete = function() {
counter = counter -1;
if (counter === 0) {
ViewSpinner.stop();
}
};
angular.forEach(items, function(c) { angular.forEach(items, function(c) {
if (c.Checked) { if (c.Checked) {
counter = counter + 1;
action({id: c.Id}, function(d) { action({id: c.Id}, function(d) {
Messages.send({class: 'text-success', data: d}); Messages.send({class: 'text-success', data: 'Container ' + c.Id + ' Removed.'});
var index = $scope.containers.indexOf(c);
$scope.containers.splice(index, 1);
complete();
}, function(e) { }, function(e) {
failedRequestHandler(e, Messages); failedRequestHandler(e, Messages);
complete();
}); });
} }
}); });
@ -190,6 +195,7 @@ function ContainersController($scope, Container, Settings, Messages, ViewSpinner
// Controller for the list of images // Controller for the list of images
function ImagesController($scope, Image, ViewSpinner, Messages) { function ImagesController($scope, Image, ViewSpinner, Messages) {
$scope.toggle = false; $scope.toggle = false;
$scope.predicate = '-Created';
$scope.showBuilder = function() { $scope.showBuilder = function() {
$('#build-modal').modal('show'); $('#build-modal').modal('show');
@ -245,13 +251,11 @@ function ImageController($scope, $routeParams, $location, Image, Messages) {
$scope.tag = {repo: '', force: false}; $scope.tag = {repo: '', force: false};
$scope.remove = function() { $scope.remove = function() {
if (confirm("Are you sure you want to delete this image?")) {
Image.remove({id: $routeParams.id}, function(d) { Image.remove({id: $routeParams.id}, function(d) {
Messages.send({class: 'text-success', data: 'Image removed.'}); Messages.send({class: 'text-success', data: 'Image removed.'});
}, function(e) { }, function(e) {
failedRequestHandler(e, Messages); failedRequestHandler(e, Messages);
}); });
}
}; };
$scope.getHistory = function() { $scope.getHistory = function() {
@ -331,12 +335,19 @@ function BuilderController($scope, Dockerfile, Messages) {
$scope.template = '/partials/builder.html'; $scope.template = '/partials/builder.html';
ace.config.set('basePath', '/lib/ace-builds/src-noconflict/'); ace.config.set('basePath', '/lib/ace-builds/src-noconflict/');
var spinner = new Spinner();
$scope.build = function() { $scope.build = function() {
spinner.spin(document.getElementById('build-modal'));
Dockerfile.build(editor.getValue(), function(d) { Dockerfile.build(editor.getValue(), function(d) {
Messages.send({class:'text-info', data: d}); console.log(d.currentTarget.response);
$scope.messages = d.currentTarget.response;
$scope.$apply();
spinner.stop();
}, function(e) { }, function(e) {
Messages.send({class:'text-error', data: e}); $scope.messages = e;
$scope.$apply();
spinner.stop();
}); });
}; };
} }

View File

@ -5,6 +5,7 @@
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div id="editor"></div> <div id="editor"></div>
<p>{{ messages }}</p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<a href="" class="btn btn-primary" ng-click="build()">Build</a> <a href="" class="btn btn-primary" ng-click="build()">Build</a>

View File

@ -23,6 +23,11 @@
<td>Container:</td> <td>Container:</td>
<td><a href="/#/containers/{{ image.container }}/">{{ image.container }}</a></td> <td><a href="/#/containers/{{ image.container }}/">{{ image.container }}</a></td>
</tr> </tr>
<tr>
<td>Size:</td>
<td>{{ image.Size|humansize }}</td>
</tr>
<tr> <tr>
<td>Hostname:</td> <td>Hostname:</td>
<td>{{ image.container_config.Hostname }}</td> <td>{{ image.container_config.Hostname }}</td>
@ -43,6 +48,10 @@
<td>Volumes from:</td> <td>Volumes from:</td>
<td>{{ image.container_config.VolumesFrom }}</td> <td>{{ image.container_config.VolumesFrom }}</td>
</tr> </tr>
<tr>
<td>Comment:</td>
<td>{{ image.comment }}</td>
</tr>
</tbody> </tbody>
</table> </table>

View File

@ -46,20 +46,4 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<form>
<fieldset>
<legend>Auth Information</legend>
<label>Username:</label>
<input type="text" ng-model="auth.username" required>
<label>Email:</label>
<input type="text" ng-model="auth.email" required>
<label>Password:</label>
<input type="password" ng-model="auth.password" required>
<label>Confirm Password:</label>
<input type="password" ng-model="auth.cpassword" required>
<br />
<input type="button" ng-click="updateAuthInfo()" value="Update"/>
</fieldset>
</form>
</div> </div>