mirror of https://github.com/portainer/portainer
Merge pull request #187 from cloud-inovasi/feat95-remove-errormsgfilter
feat(ui): remove the errorMsg filter and replace it with proper error…pull/188/head
commit
eac3239817
|
@ -1,6 +1,6 @@
|
||||||
angular.module('container', [])
|
angular.module('container', [])
|
||||||
.controller('ContainerController', ['$scope', '$state','$stateParams', '$filter', 'Container', 'ContainerCommit', 'ImageHelper', 'Messages', 'errorMsgFilter',
|
.controller('ContainerController', ['$scope', '$state','$stateParams', '$filter', 'Container', 'ContainerCommit', 'ImageHelper', 'Messages',
|
||||||
function ($scope, $state, $stateParams, $filter, Container, ContainerCommit, ImageHelper, Messages, errorMsgFilter) {
|
function ($scope, $state, $stateParams, $filter, Container, ContainerCommit, ImageHelper, Messages) {
|
||||||
$scope.activityTime = 0;
|
$scope.activityTime = 0;
|
||||||
$scope.portBindings = [];
|
$scope.portBindings = [];
|
||||||
$scope.config = {
|
$scope.config = {
|
||||||
|
@ -149,13 +149,18 @@ function ($scope, $state, $stateParams, $filter, Container, ContainerCommit, Ima
|
||||||
|
|
||||||
$scope.renameContainer = function () {
|
$scope.renameContainer = function () {
|
||||||
Container.rename({id: $stateParams.id, 'name': $scope.container.newContainerName}, function (d) {
|
Container.rename({id: $stateParams.id, 'name': $scope.container.newContainerName}, function (d) {
|
||||||
if (d.name) {
|
if (d.message) {
|
||||||
$scope.container.Name = d.name;
|
|
||||||
Messages.send("Container successfully renamed", d.name);
|
|
||||||
} else {
|
|
||||||
var error = errorMsgFilter(d);
|
|
||||||
$scope.container.newContainerName = $scope.container.Name;
|
$scope.container.newContainerName = $scope.container.Name;
|
||||||
Messages.error("Unable to rename container", error);
|
Messages.error("Unable to rename container", d.message);
|
||||||
|
} else {
|
||||||
|
$scope.container.Name = $scope.container.newContainerName;
|
||||||
|
Messages.send("Container successfully renamed", d.name);
|
||||||
|
}
|
||||||
|
}, function (e) {
|
||||||
|
if (e.data.message) {
|
||||||
|
Messages.error("Failure", e.data.message);
|
||||||
|
} else {
|
||||||
|
Messages.error("Failure", 'Unable to rename container');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$scope.container.edit = false;
|
$scope.container.edit = false;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
angular.module('containerConsole', [])
|
angular.module('containerConsole', [])
|
||||||
.controller('ContainerConsoleController', ['$scope', '$stateParams', 'Settings', 'Container', 'Exec', '$timeout', 'Messages', 'errorMsgFilter',
|
.controller('ContainerConsoleController', ['$scope', '$stateParams', 'Settings', 'Container', 'Exec', '$timeout', 'Messages',
|
||||||
function ($scope, $stateParams, Settings, Container, Exec, $timeout, Messages, errorMsgFilter) {
|
function ($scope, $stateParams, Settings, Container, Exec, $timeout, Messages) {
|
||||||
$scope.state = {};
|
$scope.state = {};
|
||||||
$scope.state.command = "bash";
|
$scope.state.command = "bash";
|
||||||
$scope.connected = false;
|
$scope.connected = false;
|
||||||
|
@ -33,7 +33,10 @@ function ($scope, $stateParams, Settings, Container, Exec, $timeout, Messages, e
|
||||||
};
|
};
|
||||||
|
|
||||||
Container.exec(execConfig, function(d) {
|
Container.exec(execConfig, function(d) {
|
||||||
if (d.Id) {
|
if (d.message) {
|
||||||
|
$('#loadConsoleSpinner').hide();
|
||||||
|
Messages.error('Error', d.message);
|
||||||
|
} else {
|
||||||
var execId = d.Id;
|
var execId = d.Id;
|
||||||
resizeTTY(execId, termHeight, termWidth);
|
resizeTTY(execId, termHeight, termWidth);
|
||||||
var url = window.location.href.split('#')[0] + 'ws/exec?id=' + execId;
|
var url = window.location.href.split('#')[0] + 'ws/exec?id=' + execId;
|
||||||
|
@ -43,13 +46,14 @@ function ($scope, $stateParams, Settings, Container, Exec, $timeout, Messages, e
|
||||||
url = url.replace('http://', 'ws://');
|
url = url.replace('http://', 'ws://');
|
||||||
}
|
}
|
||||||
initTerm(url, termHeight, termWidth);
|
initTerm(url, termHeight, termWidth);
|
||||||
} else {
|
|
||||||
$('#loadConsoleSpinner').hide();
|
|
||||||
Messages.error('Error', errorMsgFilter(d));
|
|
||||||
}
|
}
|
||||||
}, function (e) {
|
}, function (e) {
|
||||||
$('#loadConsoleSpinner').hide();
|
$('#loadConsoleSpinner').hide();
|
||||||
Messages.error("Failure", e.data);
|
if (e.data.message) {
|
||||||
|
Messages.error("Failure", e.data.message);
|
||||||
|
} else {
|
||||||
|
Messages.error("Failure", 'Unable to start an exec instance');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -66,10 +70,11 @@ function ($scope, $stateParams, Settings, Container, Exec, $timeout, Messages, e
|
||||||
function resizeTTY(execId, height, width) {
|
function resizeTTY(execId, height, width) {
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
Exec.resize({id: execId, height: height, width: width}, function (d) {
|
Exec.resize({id: execId, height: height, width: width}, function (d) {
|
||||||
var error = errorMsgFilter(d);
|
if (d.message) {
|
||||||
if (error) {
|
|
||||||
Messages.error('Error', 'Unable to resize TTY');
|
Messages.error('Error', 'Unable to resize TTY');
|
||||||
}
|
}
|
||||||
|
}, function (e) {
|
||||||
|
Messages.error("Failure", 'Unable to resize TTY');
|
||||||
});
|
});
|
||||||
}, 2000);
|
}, 2000);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
angular.module('containers', [])
|
angular.module('containers', [])
|
||||||
.controller('ContainersController', ['$scope', 'Container', 'ContainerHelper', 'Info', 'Settings', 'Messages', 'Config', 'errorMsgFilter',
|
.controller('ContainersController', ['$scope', 'Container', 'ContainerHelper', 'Info', 'Settings', 'Messages', 'Config',
|
||||||
function ($scope, Container, ContainerHelper, Info, Settings, Messages, Config, errorMsgFilter) {
|
function ($scope, Container, ContainerHelper, Info, Settings, Messages, Config) {
|
||||||
|
|
||||||
$scope.state = {};
|
$scope.state = {};
|
||||||
$scope.state.displayAll = Settings.displayAll;
|
$scope.state.displayAll = Settings.displayAll;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
angular.module('createContainer', [])
|
angular.module('createContainer', [])
|
||||||
.controller('CreateContainerController', ['$scope', '$state', 'Config', 'Container', 'Image', 'Volume', 'Network', 'Messages', 'errorMsgFilter',
|
.controller('CreateContainerController', ['$scope', '$state', 'Config', 'Container', 'Image', 'Volume', 'Network', 'Messages',
|
||||||
function ($scope, $state, Config, Container, Image, Volume, Network, Messages, errorMsgFilter) {
|
function ($scope, $state, Config, Container, Image, Volume, Network, Messages) {
|
||||||
|
|
||||||
$scope.state = {
|
$scope.state = {
|
||||||
alwaysPull: true
|
alwaysPull: true
|
||||||
|
@ -86,22 +86,35 @@ function ($scope, $state, Config, Container, Image, Volume, Network, Messages, e
|
||||||
// TODO: centralize, already present in templatesController
|
// TODO: centralize, already present in templatesController
|
||||||
function createContainer(config) {
|
function createContainer(config) {
|
||||||
Container.create(config, function (d) {
|
Container.create(config, function (d) {
|
||||||
if (d.Id) {
|
if (d.message) {
|
||||||
|
$('#createContainerSpinner').hide();
|
||||||
|
Messages.error('Error', d.message);
|
||||||
|
} else {
|
||||||
Container.start({id: d.Id}, {}, function (cd) {
|
Container.start({id: d.Id}, {}, function (cd) {
|
||||||
$('#createContainerSpinner').hide();
|
if (cd.message) {
|
||||||
Messages.send('Container Started', d.Id);
|
$('#createContainerSpinner').hide();
|
||||||
$state.go('containers', {}, {reload: true});
|
Messages.error('Error', cd.message);
|
||||||
|
} else {
|
||||||
|
$('#createContainerSpinner').hide();
|
||||||
|
Messages.send('Container Started', d.Id);
|
||||||
|
$state.go('containers', {}, {reload: true});
|
||||||
|
}
|
||||||
}, function (e) {
|
}, function (e) {
|
||||||
$('#createContainerSpinner').hide();
|
$('#createContainerSpinner').hide();
|
||||||
Messages.error('Error', errorMsgFilter(e));
|
if (e.data.message) {
|
||||||
|
Messages.error("Failure", e.data.message);
|
||||||
|
} else {
|
||||||
|
Messages.error("Failure", 'Unable to start container');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
$('#createContainerSpinner').hide();
|
|
||||||
Messages.error('Error', errorMsgFilter(d));
|
|
||||||
}
|
}
|
||||||
}, function (e) {
|
}, function (e) {
|
||||||
$('#createContainerSpinner').hide();
|
$('#createContainerSpinner').hide();
|
||||||
Messages.error('Error', errorMsgFilter(e));
|
if (e.data.message) {
|
||||||
|
Messages.error("Failure", e.data.message);
|
||||||
|
} else {
|
||||||
|
Messages.error("Failure", 'Unable to create container');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
angular.module('createNetwork', [])
|
angular.module('createNetwork', [])
|
||||||
.controller('CreateNetworkController', ['$scope', '$state', 'Messages', 'Network', 'errorMsgFilter',
|
.controller('CreateNetworkController', ['$scope', '$state', 'Messages', 'Network',
|
||||||
function ($scope, $state, Messages, Network, errorMsgFilter) {
|
function ($scope, $state, Messages, Network) {
|
||||||
$scope.formValues = {
|
$scope.formValues = {
|
||||||
DriverOptions: [],
|
DriverOptions: [],
|
||||||
Subnet: '',
|
Subnet: '',
|
||||||
|
@ -27,17 +27,21 @@ function ($scope, $state, Messages, Network, errorMsgFilter) {
|
||||||
function createNetwork(config) {
|
function createNetwork(config) {
|
||||||
$('#createNetworkSpinner').show();
|
$('#createNetworkSpinner').show();
|
||||||
Network.create(config, function (d) {
|
Network.create(config, function (d) {
|
||||||
if (d.Id) {
|
if (d.message) {
|
||||||
|
$('#createNetworkSpinner').hide();
|
||||||
|
Messages.error('Unable to create network', d.message);
|
||||||
|
} else {
|
||||||
Messages.send("Network created", d.Id);
|
Messages.send("Network created", d.Id);
|
||||||
$('#createNetworkSpinner').hide();
|
$('#createNetworkSpinner').hide();
|
||||||
$state.go('networks', {}, {reload: true});
|
$state.go('networks', {}, {reload: true});
|
||||||
} else {
|
|
||||||
$('#createNetworkSpinner').hide();
|
|
||||||
Messages.error('Unable to create network', errorMsgFilter(d));
|
|
||||||
}
|
}
|
||||||
}, function (e) {
|
}, function (e) {
|
||||||
$('#createNetworkSpinner').hide();
|
$('#createNetworkSpinner').hide();
|
||||||
Messages.error('Unable to create network', e.data);
|
if (e.data.message) {
|
||||||
|
Messages.error("Failure", e.data.message);
|
||||||
|
} else {
|
||||||
|
Messages.error("Failure", 'Unable to create network');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
angular.module('createVolume', [])
|
angular.module('createVolume', [])
|
||||||
.controller('CreateVolumeController', ['$scope', '$state', 'Volume', 'Messages', 'errorMsgFilter',
|
.controller('CreateVolumeController', ['$scope', '$state', 'Volume', 'Messages',
|
||||||
function ($scope, $state, Volume, Messages, errorMsgFilter) {
|
function ($scope, $state, Volume, Messages) {
|
||||||
|
|
||||||
$scope.formValues = {
|
$scope.formValues = {
|
||||||
DriverOptions: []
|
DriverOptions: []
|
||||||
|
@ -21,17 +21,21 @@ function ($scope, $state, Volume, Messages, errorMsgFilter) {
|
||||||
function createVolume(config) {
|
function createVolume(config) {
|
||||||
$('#createVolumeSpinner').show();
|
$('#createVolumeSpinner').show();
|
||||||
Volume.create(config, function (d) {
|
Volume.create(config, function (d) {
|
||||||
if (d.Name) {
|
if (d.message) {
|
||||||
|
$('#createVolumeSpinner').hide();
|
||||||
|
Messages.error('Unable to create volume', d.message);
|
||||||
|
} else {
|
||||||
Messages.send("Volume created", d.Name);
|
Messages.send("Volume created", d.Name);
|
||||||
$('#createVolumeSpinner').hide();
|
$('#createVolumeSpinner').hide();
|
||||||
$state.go('volumes', {}, {reload: true});
|
$state.go('volumes', {}, {reload: true});
|
||||||
} else {
|
|
||||||
$('#createVolumeSpinner').hide();
|
|
||||||
Messages.error('Unable to create volume', errorMsgFilter(d));
|
|
||||||
}
|
}
|
||||||
}, function (e) {
|
}, function (e) {
|
||||||
$('#createVolumeSpinner').hide();
|
$('#createVolumeSpinner').hide();
|
||||||
Messages.error('Unable to create volume', e.data);
|
if (e.data.message) {
|
||||||
|
Messages.error("Failure", e.data.message);
|
||||||
|
} else {
|
||||||
|
Messages.error("Failure", 'Unable to create volume');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
angular.module('network', [])
|
angular.module('network', [])
|
||||||
.controller('NetworkController', ['$scope', 'Network', 'Messages', '$state', '$stateParams', 'errorMsgFilter',
|
.controller('NetworkController', ['$scope', 'Network', 'Messages', '$state', '$stateParams',
|
||||||
function ($scope, Network, Messages, $state, $stateParams, errorMsgFilter) {
|
function ($scope, Network, Messages, $state, $stateParams) {
|
||||||
|
|
||||||
$scope.disconnect = function disconnect(networkId, containerId) {
|
$scope.disconnect = function disconnect(networkId, containerId) {
|
||||||
$('#loadingViewSpinner').show();
|
$('#loadingViewSpinner').show();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
angular.module('networks', [])
|
angular.module('networks', [])
|
||||||
.controller('NetworksController', ['$scope', '$state', 'Network', 'Config', 'Messages', 'errorMsgFilter',
|
.controller('NetworksController', ['$scope', '$state', 'Network', 'Config', 'Messages',
|
||||||
function ($scope, $state, Network, Config, Messages, errorMsgFilter) {
|
function ($scope, $state, Network, Config, Messages) {
|
||||||
$scope.state = {};
|
$scope.state = {};
|
||||||
$scope.state.selectedItemCount = 0;
|
$scope.state.selectedItemCount = 0;
|
||||||
$scope.state.advancedSettings = false;
|
$scope.state.advancedSettings = false;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
angular.module('templates', [])
|
angular.module('templates', [])
|
||||||
.controller('TemplatesController', ['$scope', '$q', '$state', '$filter', 'Config', 'Container', 'ContainerHelper', 'Image', 'Volume', 'Network', 'Templates', 'Messages', 'errorMsgFilter',
|
.controller('TemplatesController', ['$scope', '$q', '$state', '$filter', 'Config', 'Container', 'ContainerHelper', 'Image', 'Volume', 'Network', 'Templates', 'Messages',
|
||||||
function ($scope, $q, $state, $filter, Config, Container, ContainerHelper, Image, Volume, Network, Templates, Messages, errorMsgFilter) {
|
function ($scope, $q, $state, $filter, Config, Container, ContainerHelper, Image, Volume, Network, Templates, Messages) {
|
||||||
$scope.templates = [];
|
$scope.templates = [];
|
||||||
$scope.selectedTemplate = null;
|
$scope.selectedTemplate = null;
|
||||||
$scope.formValues = {
|
$scope.formValues = {
|
||||||
|
@ -13,25 +13,39 @@ function ($scope, $q, $state, $filter, Config, Container, ContainerHelper, Image
|
||||||
// TODO: centralize, already present in createContainerController
|
// TODO: centralize, already present in createContainerController
|
||||||
function createContainer(config) {
|
function createContainer(config) {
|
||||||
Container.create(config, function (d) {
|
Container.create(config, function (d) {
|
||||||
if (d.Id) {
|
if (d.message) {
|
||||||
|
$('#createContainerSpinner').hide();
|
||||||
|
Messages.error('Error', d.message);
|
||||||
|
} else {
|
||||||
Container.start({id: d.Id}, {}, function (cd) {
|
Container.start({id: d.Id}, {}, function (cd) {
|
||||||
$('#createContainerSpinner').hide();
|
if (cd.message) {
|
||||||
Messages.send('Container Started', d.Id);
|
$('#createContainerSpinner').hide();
|
||||||
$state.go('containers', {}, {reload: true});
|
Messages.error('Error', cd.message);
|
||||||
|
} else {
|
||||||
|
$('#createContainerSpinner').hide();
|
||||||
|
Messages.send('Container Started', d.Id);
|
||||||
|
$state.go('containers', {}, {reload: true});
|
||||||
|
}
|
||||||
}, function (e) {
|
}, function (e) {
|
||||||
$('#createContainerSpinner').hide();
|
$('#createContainerSpinner').hide();
|
||||||
Messages.error('Error', errorMsgFilter(e));
|
if (e.data.message) {
|
||||||
|
Messages.error("Failure", e.data.message);
|
||||||
|
} else {
|
||||||
|
Messages.error("Failure", 'Unable to start container');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
$('#createContainerSpinner').hide();
|
|
||||||
Messages.error('Error', errorMsgFilter(d));
|
|
||||||
}
|
}
|
||||||
}, function (e) {
|
}, function (e) {
|
||||||
$('#createContainerSpinner').hide();
|
$('#createContainerSpinner').hide();
|
||||||
Messages.error('Error', errorMsgFilter(e));
|
if (e.data.message) {
|
||||||
|
Messages.error("Failure", e.data.message);
|
||||||
|
} else {
|
||||||
|
Messages.error("Failure", 'Unable to create container');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO: centralize, already present in createContainerController
|
// TODO: centralize, already present in createContainerController
|
||||||
function pullImageAndCreateContainer(imageConfig, containerConfig) {
|
function pullImageAndCreateContainer(imageConfig, containerConfig) {
|
||||||
Image.create(imageConfig, function (data) {
|
Image.create(imageConfig, function (data) {
|
||||||
|
@ -105,15 +119,19 @@ function ($scope, $q, $state, $filter, Config, Container, ContainerHelper, Image
|
||||||
template.volumes.forEach(function (vol) {
|
template.volumes.forEach(function (vol) {
|
||||||
volumeQueries.push(
|
volumeQueries.push(
|
||||||
Volume.create({}, function (d) {
|
Volume.create({}, function (d) {
|
||||||
if (d.Name) {
|
if (d.message) {
|
||||||
|
Messages.error('Unable to create volume', d.message);
|
||||||
|
} else {
|
||||||
Messages.send("Volume created", d.Name);
|
Messages.send("Volume created", d.Name);
|
||||||
containerConfig.Volumes[vol] = {};
|
containerConfig.Volumes[vol] = {};
|
||||||
containerConfig.HostConfig.Binds.push(d.Name + ':' + vol);
|
containerConfig.HostConfig.Binds.push(d.Name + ':' + vol);
|
||||||
} else {
|
|
||||||
Messages.error('Unable to create volume', errorMsgFilter(d));
|
|
||||||
}
|
}
|
||||||
}, function (e) {
|
}, function (e) {
|
||||||
Messages.error('Unable to create volume', e.data);
|
if (e.data.message) {
|
||||||
|
Messages.error("Failure", e.data.message);
|
||||||
|
} else {
|
||||||
|
Messages.error("Failure", 'Unable to create volume');
|
||||||
|
}
|
||||||
}).$promise
|
}).$promise
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
angular.module('volumes', [])
|
angular.module('volumes', [])
|
||||||
.controller('VolumesController', ['$scope', '$state', 'Volume', 'Messages', 'errorMsgFilter',
|
.controller('VolumesController', ['$scope', '$state', 'Volume', 'Messages',
|
||||||
function ($scope, $state, Volume, Messages, errorMsgFilter) {
|
function ($scope, $state, Volume, Messages) {
|
||||||
$scope.state = {};
|
$scope.state = {};
|
||||||
$scope.state.selectedItemCount = 0;
|
$scope.state.selectedItemCount = 0;
|
||||||
$scope.sortType = 'Name';
|
$scope.sortType = 'Name';
|
||||||
|
|
|
@ -191,16 +191,4 @@ angular.module('uifordocker.filters', [])
|
||||||
return function (obj) {
|
return function (obj) {
|
||||||
return _.isEmpty(obj);
|
return _.isEmpty(obj);
|
||||||
};
|
};
|
||||||
})
|
|
||||||
|
|
||||||
.filter('errorMsg', function () {
|
|
||||||
return function (object) {
|
|
||||||
var idx = 0;
|
|
||||||
var msg = '';
|
|
||||||
while (object[idx] && typeof(object[idx]) === 'string') {
|
|
||||||
msg += object[idx];
|
|
||||||
idx++;
|
|
||||||
}
|
|
||||||
return msg;
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,13 +21,13 @@ function jsonObjectsToArrayHandler(data) {
|
||||||
return angular.fromJson(str);
|
return angular.fromJson(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The Docker API often returns an empty string on success (Docker 1.9 -> Docker 1.12).
|
// The Docker API often returns an empty string or a valid JSON object on success (Docker 1.9 -> Docker 1.12).
|
||||||
// On error, it returns either an error message as a string (Docker < 1.12) or a JSON object with the field message
|
// On error, it returns either an error message as a string (Docker < 1.12) or a JSON object with the field message
|
||||||
// container the error (Docker = 1.12).
|
// container the error (Docker = 1.12)
|
||||||
// This handler returns an empty object on success or a newly created JSON object with
|
// This handler ensure a valid JSON object is returned in any case.
|
||||||
// the field message containing the error message on failure.
|
// Used by the API in: container deletion, network deletion, network creation, volume creation,
|
||||||
// Used by the API in: container deletion, network deletion.
|
// container exec, exec resize.
|
||||||
function deleteGenericHandler(data) {
|
function genericHandler(data) {
|
||||||
var response = {};
|
var response = {};
|
||||||
// No data is returned when deletion is successful (Docker 1.9 -> 1.12)
|
// No data is returned when deletion is successful (Docker 1.9 -> 1.12)
|
||||||
if (!data) {
|
if (!data) {
|
||||||
|
|
|
@ -8,28 +8,43 @@ angular.module('uifordocker.services', ['ngResource', 'ngSanitize'])
|
||||||
}, {
|
}, {
|
||||||
query: {method: 'GET', params: {all: 0, action: 'json'}, isArray: true},
|
query: {method: 'GET', params: {all: 0, action: 'json'}, isArray: true},
|
||||||
get: {method: 'GET', params: {action: 'json'}},
|
get: {method: 'GET', params: {action: 'json'}},
|
||||||
start: {method: 'POST', params: {id: '@id', action: 'start'}},
|
|
||||||
stop: {method: 'POST', params: {id: '@id', t: 5, action: 'stop'}},
|
stop: {method: 'POST', params: {id: '@id', t: 5, action: 'stop'}},
|
||||||
restart: {method: 'POST', params: {id: '@id', t: 5, action: 'restart'}},
|
restart: {method: 'POST', params: {id: '@id', t: 5, action: 'restart'}},
|
||||||
kill: {method: 'POST', params: {id: '@id', action: 'kill'}},
|
kill: {method: 'POST', params: {id: '@id', action: 'kill'}},
|
||||||
pause: {method: 'POST', params: {id: '@id', action: 'pause'}},
|
pause: {method: 'POST', params: {id: '@id', action: 'pause'}},
|
||||||
unpause: {method: 'POST', params: {id: '@id', action: 'unpause'}},
|
unpause: {method: 'POST', params: {id: '@id', action: 'unpause'}},
|
||||||
changes: {method: 'GET', params: {action: 'changes'}, isArray: true},
|
changes: {method: 'GET', params: {action: 'changes'}, isArray: true},
|
||||||
create: {method: 'POST', params: {action: 'create'}},
|
stats: {method: 'GET', params: {id: '@id', stream: false, action: 'stats'}, timeout: 5000},
|
||||||
|
start: {
|
||||||
|
method: 'POST', params: {id: '@id', action: 'start'},
|
||||||
|
transformResponse: genericHandler
|
||||||
|
},
|
||||||
|
create: {
|
||||||
|
method: 'POST', params: {action: 'create'},
|
||||||
|
transformResponse: genericHandler
|
||||||
|
},
|
||||||
remove: {
|
remove: {
|
||||||
method: 'DELETE', params: {id: '@id', v: 0},
|
method: 'DELETE', params: {id: '@id', v: 0},
|
||||||
transformResponse: deleteGenericHandler
|
transformResponse: genericHandler
|
||||||
},
|
},
|
||||||
rename: {method: 'POST', params: {id: '@id', action: 'rename', name: '@name'}},
|
rename: {
|
||||||
stats: {method: 'GET', params: {id: '@id', stream: false, action: 'stats'}, timeout: 5000},
|
method: 'POST', params: {id: '@id', action: 'rename', name: '@name'},
|
||||||
exec: {method: 'POST', params: {id: '@id', action: 'exec'}}
|
transformResponse: genericHandler
|
||||||
|
},
|
||||||
|
exec: {
|
||||||
|
method: 'POST', params: {id: '@id', action: 'exec'},
|
||||||
|
transformResponse: genericHandler
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}])
|
}])
|
||||||
.factory('Exec', ['$resource', 'Settings', function ExecFactory($resource, Settings) {
|
.factory('Exec', ['$resource', 'Settings', function ExecFactory($resource, Settings) {
|
||||||
'use strict';
|
'use strict';
|
||||||
// https://docs.docker.com/engine/reference/api/docker_remote_api_<%= remoteApiVersion %>/#/exec-resize
|
// https://docs.docker.com/engine/reference/api/docker_remote_api_<%= remoteApiVersion %>/#/exec-resize
|
||||||
return $resource(Settings.url + '/exec/:id/:action', {}, {
|
return $resource(Settings.url + '/exec/:id/:action', {}, {
|
||||||
resize: {method: 'POST', params: {id: '@id', action: 'resize', h: '@height', w: '@width'}}
|
resize: {
|
||||||
|
method: 'POST', params: {id: '@id', action: 'resize', h: '@height', w: '@width'},
|
||||||
|
transformResponse: genericHandler
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}])
|
}])
|
||||||
.factory('ContainerCommit', ['$resource', '$http', 'Settings', function ContainerCommitFactory($resource, $http, Settings) {
|
.factory('ContainerCommit', ['$resource', '$http', 'Settings', function ContainerCommitFactory($resource, $http, Settings) {
|
||||||
|
@ -137,8 +152,8 @@ angular.module('uifordocker.services', ['ngResource', 'ngSanitize'])
|
||||||
return $resource(Settings.url + '/networks/:id/:action', {id: '@id'}, {
|
return $resource(Settings.url + '/networks/:id/:action', {id: '@id'}, {
|
||||||
query: {method: 'GET', isArray: true},
|
query: {method: 'GET', isArray: true},
|
||||||
get: {method: 'GET'},
|
get: {method: 'GET'},
|
||||||
create: {method: 'POST', params: {action: 'create'}},
|
create: {method: 'POST', params: {action: 'create'}, transformResponse: genericHandler},
|
||||||
remove: { method: 'DELETE', transformResponse: deleteGenericHandler },
|
remove: { method: 'DELETE', transformResponse: genericHandler },
|
||||||
connect: {method: 'POST', params: {action: 'connect'}},
|
connect: {method: 'POST', params: {action: 'connect'}},
|
||||||
disconnect: {method: 'POST', params: {action: 'disconnect'}}
|
disconnect: {method: 'POST', params: {action: 'disconnect'}}
|
||||||
});
|
});
|
||||||
|
@ -149,7 +164,7 @@ angular.module('uifordocker.services', ['ngResource', 'ngSanitize'])
|
||||||
return $resource(Settings.url + '/volumes/:name/:action', {name: '@name'}, {
|
return $resource(Settings.url + '/volumes/:name/:action', {name: '@name'}, {
|
||||||
query: {method: 'GET'},
|
query: {method: 'GET'},
|
||||||
get: {method: 'GET'},
|
get: {method: 'GET'},
|
||||||
create: {method: 'POST', params: {action: 'create'}},
|
create: {method: 'POST', params: {action: 'create'}, transformResponse: genericHandler},
|
||||||
remove: {method: 'DELETE'}
|
remove: {method: 'DELETE'}
|
||||||
});
|
});
|
||||||
}])
|
}])
|
||||||
|
|
|
@ -133,203 +133,4 @@ describe('filters', function () {
|
||||||
expect(repotagFilter(image)).toBe('ubuntu:latest');
|
expect(repotagFilter(image)).toBe('ubuntu:latest');
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('errorMsgFilter', function () {
|
|
||||||
it('should convert the $resource object to a string message',
|
|
||||||
inject(function (errorMsgFilter) {
|
|
||||||
var response = {
|
|
||||||
'0': 'C',
|
|
||||||
'1': 'o',
|
|
||||||
'2': 'n',
|
|
||||||
'3': 'f',
|
|
||||||
'4': 'l',
|
|
||||||
'5': 'i',
|
|
||||||
'6': 'c',
|
|
||||||
'7': 't',
|
|
||||||
'8': ',',
|
|
||||||
'9': ' ',
|
|
||||||
'10': 'T',
|
|
||||||
'11': 'h',
|
|
||||||
'12': 'e',
|
|
||||||
'13': ' ',
|
|
||||||
'14': 'n',
|
|
||||||
'15': 'a',
|
|
||||||
'16': 'm',
|
|
||||||
'17': 'e',
|
|
||||||
'18': ' ',
|
|
||||||
'19': 'u',
|
|
||||||
'20': 'b',
|
|
||||||
'21': 'u',
|
|
||||||
'22': 'n',
|
|
||||||
'23': 't',
|
|
||||||
'24': 'u',
|
|
||||||
'25': '-',
|
|
||||||
'26': 's',
|
|
||||||
'27': 'l',
|
|
||||||
'28': 'e',
|
|
||||||
'29': 'e',
|
|
||||||
'30': 'p',
|
|
||||||
'31': '-',
|
|
||||||
'32': 'r',
|
|
||||||
'33': 'u',
|
|
||||||
'34': 'n',
|
|
||||||
'35': 't',
|
|
||||||
'36': 'i',
|
|
||||||
'37': 'm',
|
|
||||||
'38': 'e',
|
|
||||||
'39': ' ',
|
|
||||||
'40': 'i',
|
|
||||||
'41': 's',
|
|
||||||
'42': ' ',
|
|
||||||
'43': 'a',
|
|
||||||
'44': 'l',
|
|
||||||
'45': 'r',
|
|
||||||
'46': 'e',
|
|
||||||
'47': 'a',
|
|
||||||
'48': 'd',
|
|
||||||
'49': 'y',
|
|
||||||
'50': ' ',
|
|
||||||
'51': 'a',
|
|
||||||
'52': 's',
|
|
||||||
'53': 's',
|
|
||||||
'54': 'i',
|
|
||||||
'55': 'g',
|
|
||||||
'56': 'n',
|
|
||||||
'57': 'e',
|
|
||||||
'58': 'd',
|
|
||||||
'59': ' ',
|
|
||||||
'60': 't',
|
|
||||||
'61': 'o',
|
|
||||||
'62': ' ',
|
|
||||||
'63': 'b',
|
|
||||||
'64': '6',
|
|
||||||
'65': '9',
|
|
||||||
'66': 'e',
|
|
||||||
'67': '5',
|
|
||||||
'68': '3',
|
|
||||||
'69': 'a',
|
|
||||||
'70': '6',
|
|
||||||
'71': '2',
|
|
||||||
'72': '2',
|
|
||||||
'73': 'c',
|
|
||||||
'74': '8',
|
|
||||||
'75': '.',
|
|
||||||
'76': ' ',
|
|
||||||
'77': 'Y',
|
|
||||||
'78': 'o',
|
|
||||||
'79': 'u',
|
|
||||||
'80': ' ',
|
|
||||||
'81': 'h',
|
|
||||||
'82': 'a',
|
|
||||||
'83': 'v',
|
|
||||||
'84': 'e',
|
|
||||||
'85': ' ',
|
|
||||||
'86': 't',
|
|
||||||
'87': 'o',
|
|
||||||
'88': ' ',
|
|
||||||
'89': 'd',
|
|
||||||
'90': 'e',
|
|
||||||
'91': 'l',
|
|
||||||
'92': 'e',
|
|
||||||
'93': 't',
|
|
||||||
'94': 'e',
|
|
||||||
'95': ' ',
|
|
||||||
'96': '(',
|
|
||||||
'97': 'o',
|
|
||||||
'98': 'r',
|
|
||||||
'99': ' ',
|
|
||||||
'100': 'r',
|
|
||||||
'101': 'e',
|
|
||||||
'102': 'n',
|
|
||||||
'103': 'a',
|
|
||||||
'104': 'm',
|
|
||||||
'105': 'e',
|
|
||||||
'106': ')',
|
|
||||||
'107': ' ',
|
|
||||||
'108': 't',
|
|
||||||
'109': 'h',
|
|
||||||
'110': 'a',
|
|
||||||
'111': 't',
|
|
||||||
'112': ' ',
|
|
||||||
'113': 'c',
|
|
||||||
'114': 'o',
|
|
||||||
'115': 'n',
|
|
||||||
'116': 't',
|
|
||||||
'117': 'a',
|
|
||||||
'118': 'i',
|
|
||||||
'119': 'n',
|
|
||||||
'120': 'e',
|
|
||||||
'121': 'r',
|
|
||||||
'122': ' ',
|
|
||||||
'123': 't',
|
|
||||||
'124': 'o',
|
|
||||||
'125': ' ',
|
|
||||||
'126': 'b',
|
|
||||||
'127': 'e',
|
|
||||||
'128': ' ',
|
|
||||||
'129': 'a',
|
|
||||||
'130': 'b',
|
|
||||||
'131': 'l',
|
|
||||||
'132': 'e',
|
|
||||||
'133': ' ',
|
|
||||||
'134': 't',
|
|
||||||
'135': 'o',
|
|
||||||
'136': ' ',
|
|
||||||
'137': 'a',
|
|
||||||
'138': 's',
|
|
||||||
'139': 's',
|
|
||||||
'140': 'i',
|
|
||||||
'141': 'g',
|
|
||||||
'142': 'n',
|
|
||||||
'143': ' ',
|
|
||||||
'144': 'u',
|
|
||||||
'145': 'b',
|
|
||||||
'146': 'u',
|
|
||||||
'147': 'n',
|
|
||||||
'148': 't',
|
|
||||||
'149': 'u',
|
|
||||||
'150': '-',
|
|
||||||
'151': 's',
|
|
||||||
'152': 'l',
|
|
||||||
'153': 'e',
|
|
||||||
'154': 'e',
|
|
||||||
'155': 'p',
|
|
||||||
'156': '-',
|
|
||||||
'157': 'r',
|
|
||||||
'158': 'u',
|
|
||||||
'159': 'n',
|
|
||||||
'160': 't',
|
|
||||||
'161': 'i',
|
|
||||||
'162': 'm',
|
|
||||||
'163': 'e',
|
|
||||||
'164': ' ',
|
|
||||||
'165': 't',
|
|
||||||
'166': 'o',
|
|
||||||
'167': ' ',
|
|
||||||
'168': 'a',
|
|
||||||
'169': ' ',
|
|
||||||
'170': 'c',
|
|
||||||
'171': 'o',
|
|
||||||
'172': 'n',
|
|
||||||
'173': 't',
|
|
||||||
'174': 'a',
|
|
||||||
'175': 'i',
|
|
||||||
'176': 'n',
|
|
||||||
'177': 'e',
|
|
||||||
'178': 'r',
|
|
||||||
'179': ' ',
|
|
||||||
'180': 'a',
|
|
||||||
'181': 'g',
|
|
||||||
'182': 'a',
|
|
||||||
'183': 'i',
|
|
||||||
'184': 'n',
|
|
||||||
'185': '.',
|
|
||||||
'186': '\n',
|
|
||||||
'$promise': {},
|
|
||||||
'$resolved': true
|
|
||||||
};
|
|
||||||
var message = 'Conflict, The name ubuntu-sleep-runtime is already assigned to b69e53a622c8. You have to delete (or rename) that container to be able to assign ubuntu-sleep-runtime to a container again.\n';
|
|
||||||
expect(errorMsgFilter(response)).toBe(message);
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue