mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 15:29:42 +02:00
refactor(app): introduce new project structure for the frontend (#1623)
This commit is contained in:
parent
e6422a6d75
commit
27dceadba1
354 changed files with 1518 additions and 1755 deletions
|
@ -1,62 +0,0 @@
|
|||
angular.module('portainer.helpers')
|
||||
.factory('ContainerHelper', [function ContainerHelperFactory() {
|
||||
'use strict';
|
||||
var helper = {};
|
||||
|
||||
helper.commandStringToArray = function(command) {
|
||||
return splitargs(command);
|
||||
};
|
||||
|
||||
helper.commandArrayToString = function(array) {
|
||||
return array.map(function(elem) {
|
||||
return '\'' + elem + '\'';
|
||||
}).join(' ');
|
||||
};
|
||||
|
||||
helper.configFromContainer = function(container) {
|
||||
var config = container.Config;
|
||||
// HostConfig
|
||||
config.HostConfig = container.HostConfig;
|
||||
// Name
|
||||
config.name = container.Name.replace(/^\//g, '');
|
||||
// Network
|
||||
var mode = config.HostConfig.NetworkMode;
|
||||
config.NetworkingConfig = {
|
||||
'EndpointsConfig': {}
|
||||
};
|
||||
config.NetworkingConfig.EndpointsConfig = container.NetworkSettings.Networks;
|
||||
if (mode.indexOf('container:') !== -1) {
|
||||
delete config.Hostname;
|
||||
delete config.ExposedPorts;
|
||||
}
|
||||
// Set volumes
|
||||
var binds = [];
|
||||
var volumes = {};
|
||||
for (var v in container.Mounts) {
|
||||
if ({}.hasOwnProperty.call(container.Mounts, v)) {
|
||||
var mount = container.Mounts[v];
|
||||
var volume = {
|
||||
'type': mount.Type,
|
||||
'name': mount.Name || mount.Source,
|
||||
'containerPath': mount.Destination,
|
||||
'readOnly': mount.RW === false
|
||||
};
|
||||
var name = mount.Name || mount.Source;
|
||||
var containerPath = mount.Destination;
|
||||
if (name && containerPath) {
|
||||
var bind = name + ':' + containerPath;
|
||||
volumes[containerPath] = {};
|
||||
if (mount.RW === false) {
|
||||
bind += ':ro';
|
||||
}
|
||||
binds.push(bind);
|
||||
}
|
||||
}
|
||||
}
|
||||
config.HostConfig.Binds = binds;
|
||||
config.Volumes = volumes;
|
||||
return config;
|
||||
};
|
||||
|
||||
return helper;
|
||||
}]);
|
Loading…
Add table
Add a link
Reference in a new issue