mirror of https://github.com/portainer/portainer
20 lines
683 B
JavaScript
20 lines
683 B
JavaScript
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';
|
|
}
|
|
}
|