2016-12-15 03:33:47 +00:00
|
|
|
angular.module('sidebar', [])
|
2017-01-22 23:14:34 +00:00
|
|
|
.controller('SidebarController', ['$scope', '$state', 'Settings', 'Config', 'EndpointService', 'StateManager', 'Messages',
|
|
|
|
function ($scope, $state, Settings, Config, EndpointService, StateManager, Messages) {
|
2016-12-15 03:33:47 +00:00
|
|
|
|
|
|
|
Config.$promise.then(function (c) {
|
|
|
|
$scope.logo = c.logo;
|
|
|
|
});
|
|
|
|
|
|
|
|
$scope.uiVersion = Settings.uiVersion;
|
2016-12-25 20:34:02 +00:00
|
|
|
|
|
|
|
$scope.switchEndpoint = function(endpoint) {
|
|
|
|
EndpointService.setActive(endpoint.Id).then(function success(data) {
|
2017-01-22 23:14:34 +00:00
|
|
|
StateManager.updateEndpointState(true)
|
|
|
|
.then(function success() {
|
|
|
|
$state.reload();
|
|
|
|
}, function error(err) {
|
|
|
|
Messages.error("Failure", err, "Unable to connect to the Docker endpoint");
|
|
|
|
});
|
2016-12-25 20:34:02 +00:00
|
|
|
}, function error(err) {
|
|
|
|
Messages.error("Failure", err, "Unable to switch to new endpoint");
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
function fetchEndpoints() {
|
|
|
|
EndpointService.endpoints().then(function success(data) {
|
|
|
|
$scope.endpoints = data;
|
|
|
|
EndpointService.getActive().then(function success(data) {
|
|
|
|
angular.forEach($scope.endpoints, function (endpoint) {
|
|
|
|
if (endpoint.Id === data.Id) {
|
|
|
|
$scope.activeEndpoint = endpoint;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}, function error(err) {
|
|
|
|
Messages.error("Failure", err, "Unable to retrieve active endpoint");
|
|
|
|
});
|
|
|
|
}, function error(err) {
|
|
|
|
$scope.endpoints = [];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
fetchEndpoints();
|
2016-12-15 03:33:47 +00:00
|
|
|
}]);
|