mirror of
https://github.com/portainer/portainer.git
synced 2025-08-05 05:45:22 +02:00
feat(global): introduce user teams and new UAC system (#868)
This commit is contained in:
parent
a380fd9adc
commit
5523fc9023
160 changed files with 7112 additions and 3166 deletions
11
app/models/api/endpointAccess.js
Normal file
11
app/models/api/endpointAccess.js
Normal 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';
|
||||
}
|
19
app/models/api/resourceControl.js
Normal file
19
app/models/api/resourceControl.js
Normal 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
5
app/models/api/team.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
function TeamViewModel(data) {
|
||||
this.Id = data.Id;
|
||||
this.Name = data.Name;
|
||||
this.Checked = false;
|
||||
}
|
6
app/models/api/teamMembership.js
Normal file
6
app/models/api/teamMembership.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
function TeamMembershipModel(data) {
|
||||
this.Id = data.Id;
|
||||
this.UserId = data.UserID;
|
||||
this.TeamId = data.TeamID;
|
||||
this.Role = data.Role;
|
||||
}
|
35
app/models/api/template.js
Normal file
35
app/models/api/template.js
Normal file
|
@ -0,0 +1,35 @@
|
|||
function TemplateViewModel(data) {
|
||||
this.Title = data.title;
|
||||
this.Description = data.description;
|
||||
this.Note = data.note;
|
||||
this.Categories = data.categories ? data.categories : [];
|
||||
this.Platform = data.platform ? data.platform : '';
|
||||
this.Logo = data.logo;
|
||||
this.Image = data.image;
|
||||
this.Registry = data.registry ? data.registry : '';
|
||||
this.Command = data.command ? data.command : '';
|
||||
this.Network = data.network ? data.network : '';
|
||||
this.Env = data.env ? data.env : [];
|
||||
this.Privileged = data.privileged ? data.privileged : false;
|
||||
this.Volumes = [];
|
||||
this.Interactive = data.interactive ? data.interactive : false;
|
||||
if (data.volumes) {
|
||||
this.Volumes = data.volumes.map(function (v) {
|
||||
return {
|
||||
readOnly: false,
|
||||
containerPath: v,
|
||||
type: 'auto'
|
||||
};
|
||||
});
|
||||
}
|
||||
this.Ports = [];
|
||||
if (data.ports) {
|
||||
this.Ports = data.ports.map(function (p) {
|
||||
var portAndProtocol = _.split(p, '/');
|
||||
return {
|
||||
containerPort: portAndProtocol[0],
|
||||
protocol: portAndProtocol[1]
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
33
app/models/api/templateLinuxServer.js
Normal file
33
app/models/api/templateLinuxServer.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
function TemplateLSIOViewModel(data) {
|
||||
this.Title = data.title;
|
||||
this.Note = data.description;
|
||||
this.Categories = data.category ? data.category : [];
|
||||
this.Platform = data.platform ? data.platform : 'linux';
|
||||
this.Logo = data.logo;
|
||||
this.Image = data.image;
|
||||
this.Registry = data.registry ? data.registry : '';
|
||||
this.Command = data.command ? data.command : '';
|
||||
this.Network = data.network ? data.network : '';
|
||||
this.Env = data.env ? data.env : [];
|
||||
this.Privileged = data.privileged ? data.privileged : false;
|
||||
this.Volumes = [];
|
||||
if (data.volumes) {
|
||||
this.Volumes = data.volumes.map(function (v) {
|
||||
return {
|
||||
readOnly: false,
|
||||
containerPath: v,
|
||||
type: 'auto'
|
||||
};
|
||||
});
|
||||
}
|
||||
this.Ports = [];
|
||||
if (data.ports) {
|
||||
this.Ports = data.ports.map(function (p) {
|
||||
var portAndProtocol = _.split(p, '/');
|
||||
return {
|
||||
containerPort: portAndProtocol[0],
|
||||
protocol: portAndProtocol[1]
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
11
app/models/api/user.js
Normal file
11
app/models/api/user.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
function UserViewModel(data) {
|
||||
this.Id = data.Id;
|
||||
this.Username = data.Username;
|
||||
this.Role = data.Role;
|
||||
if (data.Role === 1) {
|
||||
this.RoleName = 'administrator';
|
||||
} else {
|
||||
this.RoleName = 'user';
|
||||
}
|
||||
this.Checked = false;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue