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

feat(global): introduce user teams and new UAC system (#868)

This commit is contained in:
Anthony Lapenna 2017-05-23 20:56:10 +02:00 committed by GitHub
parent a380fd9adc
commit 5523fc9023
160 changed files with 7112 additions and 3166 deletions

View file

@ -0,0 +1,11 @@
function EndpointAccessUserViewModel(data) {
this.Id = data.Id;
this.Name = data.Username;
this.Type = 'user';
}
function EndpointAccessTeamViewModel(data) {
this.Id = data.Id;
this.Name = data.Name;
this.Type = 'team';
}

View file

@ -0,0 +1,19 @@
function ResourceControlViewModel(data) {
this.Id = data.Id;
this.Type = data.Type;
this.ResourceId = data.ResourceId;
this.UserAccesses = data.UserAccesses;
this.TeamAccesses = data.TeamAccesses;
this.AdministratorsOnly = data.AdministratorsOnly;
this.Ownership = determineOwnership(this);
}
function determineOwnership(resourceControl) {
if (resourceControl.AdministratorsOnly) {
return 'administrators';
} else if (resourceControl.UserAccesses.length === 1 && resourceControl.TeamAccesses.length === 0) {
return 'private';
} else if (resourceControl.UserAccesses.length > 1 || resourceControl.TeamAccesses.length > 0) {
return 'restricted';
}
}

5
app/models/api/team.js Normal file
View file

@ -0,0 +1,5 @@
function TeamViewModel(data) {
this.Id = data.Id;
this.Name = data.Name;
this.Checked = false;
}

View file

@ -0,0 +1,6 @@
function TeamMembershipModel(data) {
this.Id = data.Id;
this.UserId = data.UserID;
this.TeamId = data.TeamID;
this.Role = data.Role;
}

View file

@ -1,11 +1,11 @@
function UserViewModel(data) {
this.Id = data.Id;
this.Username = data.Username;
this.RoleId = data.Role;
this.Role = data.Role;
if (data.Role === 1) {
this.RoleName = "administrator";
this.RoleName = 'administrator';
} else {
this.RoleName = "user";
this.RoleName = 'user';
}
this.Checked = false;
}

View file

@ -20,11 +20,8 @@ function ContainerViewModel(data) {
}
}
if (data.Portainer) {
this.Metadata = {};
if (data.Portainer.ResourceControl) {
this.Metadata.ResourceControl = {
OwnerId: data.Portainer.ResourceControl.OwnerId
};
this.ResourceControl = new ResourceControlViewModel(data.Portainer.ResourceControl);
}
}
}

View file

@ -0,0 +1,15 @@
function ContainerDetailsViewModel(data) {
this.Id = data.Id;
this.State = data.State;
this.Name = data.Name;
this.NetworkSettings = data.NetworkSettings;
this.Args = data.Args;
this.Image = data.Image;
this.Config = data.Config;
this.HostConfig = data.HostConfig;
if (data.Portainer) {
if (data.Portainer.ResourceControl) {
this.ResourceControl = new ResourceControlViewModel(data.Portainer.ResourceControl);
}
}
}

View file

@ -80,11 +80,8 @@ function ServiceViewModel(data, runningTasks, nodes) {
this.EditName = false;
if (data.Portainer) {
this.Metadata = {};
if (data.Portainer.ResourceControl) {
this.Metadata.ResourceControl = {
OwnerId: data.Portainer.ResourceControl.OwnerId
};
this.ResourceControl = new ResourceControlViewModel(data.Portainer.ResourceControl);
}
}
}

10
app/models/docker/task.js Normal file
View file

@ -0,0 +1,10 @@
function TaskViewModel(data) {
this.Id = data.ID;
this.Created = data.CreatedAt;
this.Updated = data.UpdatedAt;
this.Slot = data.Slot;
this.Spec = data.Spec;
this.Status = data.Status;
this.ServiceId = data.ServiceID;
this.NodeId = data.NodeID;
}

View file

@ -1,14 +1,13 @@
function VolumeViewModel(data) {
this.Id = data.Id;
this.Name = data.Name;
this.Id = data.Name;
this.Driver = data.Driver;
this.Options = data.Options;
this.Labels = data.Labels;
this.Mountpoint = data.Mountpoint;
if (data.Portainer) {
this.Metadata = {};
if (data.Portainer.ResourceControl) {
this.Metadata.ResourceControl = {
OwnerId: data.Portainer.ResourceControl.OwnerId
};
this.ResourceControl = new ResourceControlViewModel(data.Portainer.ResourceControl);
}
}
}

View file

@ -1,15 +0,0 @@
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;
this.Image = data.Spec.ContainerSpec ? data.Spec.ContainerSpec.Image : '';
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;
}
}
}
}