1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-02 20:35:25 +02:00

Add settings page and badge filters

This commit is contained in:
Michael Crosby 2013-06-09 16:31:05 -09:00
parent 665e750c7b
commit 406f06cb3e
6 changed files with 188 additions and 8 deletions

View file

@ -38,12 +38,56 @@ function HomeController() {
}
function SettingsController($scope, Settings) {
function SettingsController($scope, Auth, System, Docker, Settings) {
$scope.auth = {};
$scope.info = {};
$scope.docker = {};
$('#response').hide();
$scope.alertClass = 'block';
var showAndHide = function(hide) {
$('#response').show();
if (hide) {
setTimeout(function() { $('#response').hide();}, 5000);
}
};
$scope.updateAuthInfo = function() {
if ($scope.auth.password != $scope.auth.cpassword) {
$scope.response = 'Your passwords do not match.';
showAndHide(true);
return;
}
Auth.update(
{username: $scope.auth.username, email: $scope.auth.email, password: $scope.auth.password}, function(d) {
console.log(d);
$scope.alertClass = 'success';
$scope.response = 'Auth information updated.';
showAndHide(true);
}, function(e) {
console.log(e);
$scope.alertClass = 'error';
$scope.response = e.data;
showAndHide(false);
});
};
Auth.get({}, function(d) {
$scope.auth = d;
});
Docker.get({}, function(d) {
$scope.docker = d;
});
System.get({}, function(d) {
$scope.info = d;
});
}
// Controls the page that displays a single container and actions on that container.
function ContainerController($scope, $routeParams, Container) {
function ContainerController($scope, $routeParams, $location, Container) {
$('#response').hide();
$scope.alertClass = 'block';
@ -82,6 +126,20 @@ function ContainerController($scope, $routeParams, Container) {
});
};
$scope.kill = function() {
Container.kill({id: $routeParams.id}, function(d) {
console.log(d);
$scope.alertClass = 'success';
$scope.response = 'Container killed.';
showAndHide(true);
}, function(e) {
console.log(e);
$scope.alertClass = 'error';
$scope.response = e.data;
showAndHide(false);
});
};
$scope.remove = function() {
if (confirm("Are you sure you want to remove the container?")) {
Container.remove({id: $routeParams.id}, function(d) {
@ -108,6 +166,9 @@ function ContainerController($scope, $routeParams, Container) {
Container.get({id: $routeParams.id}, function(d) {
$scope.container = d;
}, function(e) {
console.log(e);
$location.path('/containers/');
});
$scope.getChanges();
@ -148,7 +209,7 @@ function ImagesController($scope, Image) {
}
// Controller for a single image and actions on that image
function ImageController($scope, $routeParams, Image) {
function ImageController($scope, $routeParams, $location, Image) {
$scope.history = [];
$scope.tag = {repo: '', force: false};
@ -201,6 +262,9 @@ function ImageController($scope, $routeParams, Image) {
Image.get({id: $routeParams.id}, function(d) {
$scope.image = d;
}, function(e) {
console.log(e);
$location.path('/images/');
});
$scope.getHistory();

View file

@ -27,6 +27,32 @@ angular.module('dockerui.filters', [])
return 'success';
};
})
.filter('getstatetext', function() {
return function(state) {
if (state == undefined) return '';
if (state.Ghost && state.Running) {
return 'Ghost';
}
if (state.Running) {
return 'Running';
}
return 'Stopped';
};
})
.filter('getstatelabel', function() {
return function(state) {
if (state == undefined) return '';
if (state.Ghost && state.Running) {
return 'label-important';
}
if (state.Running) {
return 'label-success';
}
return '';
};
})
.filter('getdate', function() {
return function(data) {
//Multiply by 1000 for the unix format

View file

@ -31,6 +31,28 @@ angular.module('dockerui.services', ['ngResource'])
delete :{id: '@id', method: 'DELETE'}
});
})
.factory('Docker', function($resource, DOCKER_ENDPOINT) {
// Information for docker
// http://docs.docker.io/en/latest/api/docker_remote_api.html#display-system-wide-information
return $resource(DOCKER_ENDPOINT + '/version', {}, {
get: {method: 'GET'}
});
})
.factory('Auth', function($resource, DOCKER_ENDPOINT) {
// Auto Information for docker
// http://docs.docker.io/en/latest/api/docker_remote_api.html#set-auth-configuration
return $resource(DOCKER_ENDPOINT + '/auth', {}, {
get: {method: 'GET'},
update: {method: 'POST'}
});
})
.factory('System', function($resource, DOCKER_ENDPOINT) {
// System for docker
// http://docs.docker.io/en/latest/api/docker_remote_api.html#display-system-wide-information
return $resource(DOCKER_ENDPOINT + '/info', {}, {
get: {method: 'GET'}
});
})
.factory('Settings', function() {
return {
displayAll: false