mirror of
https://github.com/portainer/portainer.git
synced 2025-08-05 13:55:21 +02:00
feat(global): swarm mode support (#213)
feat(global): swarm mode support
This commit is contained in:
parent
da6f39b137
commit
37863e3f74
29 changed files with 1318 additions and 89 deletions
|
@ -18,6 +18,24 @@ angular.module('portainer.filters', [])
|
|||
}
|
||||
};
|
||||
})
|
||||
.filter('taskstatusbadge', function () {
|
||||
'use strict';
|
||||
return function (text) {
|
||||
var status = _.toLower(text);
|
||||
if (status.indexOf('new') !== -1 || status.indexOf('allocated') !== -1 ||
|
||||
status.indexOf('assigned') !== -1 || status.indexOf('accepted') !== -1) {
|
||||
return 'info';
|
||||
} else if (status.indexOf('pending') !== -1) {
|
||||
return 'warning';
|
||||
} else if (status.indexOf('shutdown') !== -1 || status.indexOf('failed') !== -1 ||
|
||||
status.indexOf('rejected') !== -1) {
|
||||
return 'danger';
|
||||
} else if (status.indexOf('complete') !== -1) {
|
||||
return 'primary';
|
||||
}
|
||||
return 'success';
|
||||
};
|
||||
})
|
||||
.filter('containerstatusbadge', function () {
|
||||
'use strict';
|
||||
return function (text) {
|
||||
|
|
|
@ -34,4 +34,18 @@ angular.module('portainer.helpers', [])
|
|||
});
|
||||
}
|
||||
};
|
||||
}])
|
||||
.factory('ServiceHelper', [function ServiceHelperFactory() {
|
||||
'use strict';
|
||||
return {
|
||||
serviceToConfig: function(service) {
|
||||
return {
|
||||
Name: service.Spec.Name,
|
||||
TaskTemplate: service.Spec.TaskTemplate,
|
||||
Mode: service.Spec.Mode,
|
||||
Networks: service.Spec.Networks,
|
||||
EndpointSpec: service.Spec.EndpointSpec
|
||||
};
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
|
|
@ -37,6 +37,25 @@ angular.module('portainer.services', ['ngResource', 'ngSanitize'])
|
|||
}
|
||||
});
|
||||
}])
|
||||
.factory('Service', ['$resource', 'Settings', function ServiceFactory($resource, Settings) {
|
||||
'use strict';
|
||||
// https://docs.docker.com/engine/reference/api/docker_remote_api_<%= remoteApiVersion %>/#/3-9-services
|
||||
return $resource(Settings.url + '/services/:id/:action', {}, {
|
||||
get: { method: 'GET', params: {id: '@id'} },
|
||||
query: { method: 'GET', isArray: true },
|
||||
create: { method: 'POST', params: {action: 'create'} },
|
||||
update: { method: 'POST', params: {id: '@id', action: 'update', version: '@version'} },
|
||||
remove: { method: 'DELETE', params: {id: '@id'} }
|
||||
});
|
||||
}])
|
||||
.factory('Task', ['$resource', 'Settings', function TaskFactory($resource, Settings) {
|
||||
'use strict';
|
||||
// https://docs.docker.com/engine/reference/api/docker_remote_api_<%= remoteApiVersion %>/#/3-9-services
|
||||
return $resource(Settings.url + '/tasks/:id', {}, {
|
||||
get: { method: 'GET', params: {id: '@id'} },
|
||||
query: { method: 'GET', isArray: true, params: {filters: '@filters'} }
|
||||
});
|
||||
}])
|
||||
.factory('Exec', ['$resource', 'Settings', function ExecFactory($resource, Settings) {
|
||||
'use strict';
|
||||
// https://docs.docker.com/engine/reference/api/docker_remote_api_<%= remoteApiVersion %>/#/exec-resize
|
||||
|
@ -131,6 +150,22 @@ angular.module('portainer.services', ['ngResource', 'ngSanitize'])
|
|||
get: {method: 'GET'}
|
||||
});
|
||||
}])
|
||||
.factory('Node', ['$resource', 'Settings', function NodeFactory($resource, Settings) {
|
||||
'use strict';
|
||||
// https://docs.docker.com/engine/reference/api/docker_remote_api_<%= remoteApiVersion %>/#/3-7-nodes
|
||||
return $resource(Settings.url + '/nodes', {}, {
|
||||
query: {
|
||||
method: 'GET', isArray: true
|
||||
}
|
||||
});
|
||||
}])
|
||||
.factory('Swarm', ['$resource', 'Settings', function SwarmFactory($resource, Settings) {
|
||||
'use strict';
|
||||
// https://docs.docker.com/engine/reference/api/docker_remote_api_<%= remoteApiVersion %>/#/3-8-swarm
|
||||
return $resource(Settings.url + '/swarm', {}, {
|
||||
get: {method: 'GET'}
|
||||
});
|
||||
}])
|
||||
.factory('Auth', ['$resource', 'Settings', function AuthFactory($resource, Settings) {
|
||||
'use strict';
|
||||
// http://docs.docker.com/reference/api/docker_remote_api_<%= remoteApiVersion %>/#check-auth-configuration
|
||||
|
|
|
@ -8,6 +8,47 @@ function ImageViewModel(data) {
|
|||
this.VirtualSize = data.VirtualSize;
|
||||
}
|
||||
|
||||
function TaskViewModel(data, node_data) {
|
||||
this.Id = data.ID;
|
||||
this.Created = data.CreatedAt;
|
||||
this.Updated = data.UpdatedAt;
|
||||
this.Slot = data.Slot;
|
||||
this.Status = data.Status.State;
|
||||
if (node_data) {
|
||||
for (var i = 0; i < node_data.length; ++i) {
|
||||
if (data.NodeID === node_data[i].ID) {
|
||||
this.Node = node_data[i].Description.Hostname;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ServiceViewModel(data) {
|
||||
this.Model = data;
|
||||
this.Id = data.ID;
|
||||
this.Name = data.Spec.Name;
|
||||
this.Image = data.Spec.TaskTemplate.ContainerSpec.Image;
|
||||
this.Version = data.Version.Index;
|
||||
if (data.Spec.Mode.Replicated) {
|
||||
this.Mode = 'replicated' ;
|
||||
this.Replicas = data.Spec.Mode.Replicated.Replicas;
|
||||
} else {
|
||||
this.Mode = 'global';
|
||||
}
|
||||
if (data.Spec.Labels) {
|
||||
this.Labels = data.Spec.Labels;
|
||||
}
|
||||
if (data.Spec.TaskTemplate.ContainerSpec.Env) {
|
||||
this.Env = data.Spec.TaskTemplate.ContainerSpec.Env;
|
||||
}
|
||||
if (data.Endpoint.Ports) {
|
||||
this.Ports = data.Endpoint.Ports;
|
||||
}
|
||||
this.Checked = false;
|
||||
this.Scale = false;
|
||||
this.EditName = false;
|
||||
}
|
||||
|
||||
function ContainerViewModel(data) {
|
||||
this.Id = data.Id;
|
||||
this.Status = data.Status;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue