mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
ui: Update ISO permissions (#4017)
Update ISO permissions Co-Authored-By: Abhishek Kumar <abhishek.mrt22@gmail.com> Co-authored-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
parent
c3e3f0f0b3
commit
f72b61edb8
@ -12458,6 +12458,14 @@ div.ui-dialog div.autoscaler div.field-group div.form-container form div.form-it
|
||||
background-position: -165px -704px;
|
||||
}
|
||||
|
||||
.shareISO .icon {
|
||||
background-position: -165px -122px;
|
||||
}
|
||||
|
||||
.shareISO:hover .icon {
|
||||
background-position: -165px -704px;
|
||||
}
|
||||
|
||||
.createVolume .icon {
|
||||
background-position: -70px -124px;
|
||||
}
|
||||
|
||||
@ -286,6 +286,7 @@ var dictionary = {
|
||||
"label.action.run.diagnostics":"Run Diagnostics",
|
||||
"label.action.secure.host":"Provision Host Security Keys",
|
||||
"label.action.start.instance":"Start Instance",
|
||||
"label.action.share.iso": "Update ISO Permissions",
|
||||
"label.action.share.template": "Update Template Permissions",
|
||||
"label.action.start.instance.processing":"Starting Instance....",
|
||||
"label.action.start.router":"Start Router",
|
||||
|
||||
@ -3357,6 +3357,319 @@
|
||||
notification: {
|
||||
poll: pollAsyncJobResult
|
||||
}
|
||||
},
|
||||
|
||||
shareISO: {
|
||||
label: 'label.action.share.iso',
|
||||
messages: {
|
||||
notification: function (args) {
|
||||
return 'label.action.share.iso';
|
||||
}
|
||||
},
|
||||
|
||||
createForm: {
|
||||
title: 'label.action.share.iso',
|
||||
desc: '',
|
||||
fields: {
|
||||
operation: {
|
||||
label: 'label.operation',
|
||||
docID: 'helpUpdateTemplateOperation',
|
||||
validation: {
|
||||
required: true
|
||||
},
|
||||
select: function (args) {
|
||||
var items = [];
|
||||
items.push({
|
||||
id: "add",
|
||||
description: "Add"
|
||||
});
|
||||
items.push({
|
||||
id: "remove",
|
||||
description: "Remove"
|
||||
});
|
||||
items.push({
|
||||
id: "reset",
|
||||
description: "Reset"
|
||||
});
|
||||
|
||||
args.response.success({
|
||||
data: items
|
||||
});
|
||||
|
||||
// Select change
|
||||
args.$select.change(function () {
|
||||
var $form = $(this).closest('form');
|
||||
var selectedOperation = $(this).val();
|
||||
if (selectedOperation === "reset") {
|
||||
$form.find('[rel=projects]').hide();
|
||||
$form.find('[rel=sharewith]').hide();
|
||||
$form.find('[rel=accounts]').hide();
|
||||
$form.find('[rel=accountlist]').hide();
|
||||
} else {
|
||||
// allow.user.view.domain.accounts = true
|
||||
// Populate List of accounts in domain as dropdown multiselect
|
||||
$form.find('[rel=sharewith]').css('display', 'inline-block');
|
||||
if (!isUser() || g_allowUserViewAllDomainAccounts === true) {
|
||||
$form.find('[rel=projects]').css('display', 'inline-block');
|
||||
$form.find('[rel=accounts]').css('display', 'inline-block');
|
||||
$form.find('[rel=accountlist]').hide();
|
||||
} else {
|
||||
// If users are not allowed to see accounts in the domain, show input text field for Accounts
|
||||
// Projects will always be shown as dropdown multiselect
|
||||
$form.find('[rel=projects]').css('display', 'inline-block');
|
||||
$form.find('[rel=accountslist]').css('display', 'inline-block');
|
||||
$form.find('[rel=accounts]').hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
shareWith: {
|
||||
label: 'label.share.with',
|
||||
docID: 'helpUpdateTemplateShareWith',
|
||||
validation: {
|
||||
required: true
|
||||
},
|
||||
dependsOn: 'operation',
|
||||
select: function (args) {
|
||||
var items = [];
|
||||
items.push({
|
||||
id: "account",
|
||||
description: "Account"
|
||||
});
|
||||
items.push({
|
||||
id: "project",
|
||||
description: "Project"
|
||||
});
|
||||
|
||||
args.response.success({ data: items });
|
||||
|
||||
// Select change
|
||||
args.$select.change(function () {
|
||||
var $form = $(this).closest('form');
|
||||
var sharedWith = $(this).val();
|
||||
if (args.operation !== "reset") {
|
||||
if (sharedWith === "project") {
|
||||
$form.find('[rel=accounts]').hide();
|
||||
$form.find('[rel=accountlist]').hide();
|
||||
$form.find('[rel=projects]').css('display', 'inline-block');
|
||||
} else {
|
||||
// allow.user.view.domain.accounts = true
|
||||
// Populate List of accounts in domain as dropdown multiselect
|
||||
if (!isUser() || g_allowUserViewAllDomainAccounts === true) {
|
||||
$form.find('[rel=projects]').hide();
|
||||
$form.find('[rel=accountlist]').hide();
|
||||
$form.find('[rel=accounts]').css('display', 'inline-block');
|
||||
} else {
|
||||
// If users are not allowed to see accounts in the domain, show input text field for Accounts
|
||||
// Projects will always be shown as dropdown multiselect
|
||||
$form.find('[rel=projects]').hide();
|
||||
$form.find('[rel=accounts]').hide();
|
||||
$form.find('[rel=accountlist]').css('display', 'inline-block');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
accountlist: {
|
||||
label: 'label.accounts',
|
||||
docID: 'helpUpdateTemplateAccountList'
|
||||
},
|
||||
|
||||
accounts: {
|
||||
label: 'label.accounts',
|
||||
docID: 'helpUpdateTemplateAccounts',
|
||||
dependsOn: 'shareWith',
|
||||
isMultiple: true,
|
||||
select: function (args) {
|
||||
var operation = args.operation;
|
||||
if (operation !== "reset") {
|
||||
$.ajax({
|
||||
url: createURL("listAccounts&listall=true"),
|
||||
dataType: "json",
|
||||
async: true,
|
||||
success: function (jsonAccounts) {
|
||||
var accountByName = {};
|
||||
$.each(jsonAccounts.listaccountsresponse.account, function(idx, account) {
|
||||
// Only add current domain's accounts for add as update template permissions supports that
|
||||
if (account.domainid === g_domainid && operation === "add") {
|
||||
accountByName[account.name] = {
|
||||
projName: account.name,
|
||||
hasPermission: false
|
||||
};
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
url: createURL('listIsoPermissions&id=' + args.context.isos[0].id),
|
||||
dataType: "json",
|
||||
async: true,
|
||||
success: function (json) {
|
||||
items = json.listtemplatepermissionsresponse.templatepermission.account;
|
||||
$.each(items, function(idx, accountName) {
|
||||
if (accountByName[accountName]) {
|
||||
accountByName[accountName].hasPermission = true;
|
||||
}
|
||||
});
|
||||
|
||||
var accountObjs = [];
|
||||
if (operation === "add") {
|
||||
// Skip already permitted accounts
|
||||
$.each(Object.keys(accountByName), function(idx, accountName) {
|
||||
if (accountByName[accountName].hasPermission == false) {
|
||||
accountObjs.push({
|
||||
name: accountName,
|
||||
description: accountName
|
||||
});
|
||||
}
|
||||
});
|
||||
} else if (items != null) {
|
||||
$.each(items, function(idx, accountName) {
|
||||
if (accountName !== g_account) {
|
||||
accountObjs.push({
|
||||
name: accountName,
|
||||
description: accountName
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
args.$select.html('');
|
||||
args.response.success({data: accountObjs});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
projects: {
|
||||
label: 'label.projects',
|
||||
docID: 'helpUpdateTemplateProjectIds',
|
||||
dependsOn: 'shareWith',
|
||||
isMultiple: true,
|
||||
select: function (args) {
|
||||
var operation = args.operation;
|
||||
if (operation !== "reset") {
|
||||
$.ajax({
|
||||
url: createURL("listProjects&listall=true"),
|
||||
dataType: "json",
|
||||
async: true,
|
||||
success: function (jsonProjects) {
|
||||
var projectsByIds = {};
|
||||
$.each(jsonProjects.listprojectsresponse.project, function(idx, project) {
|
||||
// Only add current domain's projects for add operation as update template permissions supports that
|
||||
if ((project.domainid === g_domainid && operation === "add") || operation === "remove") {
|
||||
projectsByIds[project.id] = {
|
||||
projName: project.name,
|
||||
hasPermission: false
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: createURL('listIsoPermissions&id=' + args.context.isos[0].id),
|
||||
dataType: "json",
|
||||
async: true,
|
||||
success: function (json) {
|
||||
items = json.listtemplatepermissionsresponse.templatepermission.projectids;
|
||||
$.each(items, function(idx, projectId) {
|
||||
if (projectsByIds[projectId]) {
|
||||
projectsByIds[projectId].hasPermission = true;
|
||||
}
|
||||
});
|
||||
|
||||
var projectObjs = [];
|
||||
if (operation === "add") {
|
||||
// Skip already permitted accounts
|
||||
$.each(Object.keys(projectsByIds), function(idx, projectId) {
|
||||
if (projectsByIds[projectId].hasPermission == false) {
|
||||
projectObjs.push({
|
||||
id: projectId,
|
||||
description: projectsByIds[projectId].projName
|
||||
});
|
||||
}
|
||||
});
|
||||
} else if (items != null) {
|
||||
$.each(items, function(idx, projectId) {
|
||||
if (projectId !== g_account) {
|
||||
projectObjs.push({
|
||||
id: projectId,
|
||||
description: projectsByIds[projectId] ? projectsByIds[projectId].projName : projectId
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
args.$select.html('');
|
||||
args.response.success({data: projectObjs});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
action: function (args) {
|
||||
// Load data from form
|
||||
var data = {
|
||||
id: args.context.isos[0].id,
|
||||
op: args.data.operation
|
||||
};
|
||||
var selectedOperation = args.data.operation;
|
||||
if (selectedOperation === "reset") {
|
||||
// Do not append Project ID or Account to data object
|
||||
} else {
|
||||
var projects = args.data.projects;
|
||||
var accounts = args.data.accounts;
|
||||
var accountList = args.data.accountlist;
|
||||
|
||||
if (accounts !== undefined || (accountList !== undefined && accountList.length > 0)) {
|
||||
var accountNames = "";
|
||||
if (accountList !== undefined && accounts === undefined) {
|
||||
accountNames = accountList;
|
||||
} else {
|
||||
if (Object.prototype.toString.call(accounts) === '[object Array]') {
|
||||
accountNames = accounts.join(",");
|
||||
} else {
|
||||
accountNames = accounts;
|
||||
}
|
||||
}
|
||||
$.extend(data, {
|
||||
accounts: accountNames
|
||||
});
|
||||
}
|
||||
|
||||
if (projects !== undefined) {
|
||||
var projectIds = "";
|
||||
if (Object.prototype.toString.call(projects) === '[object Array]') {
|
||||
projectIds = projects.join(",");
|
||||
} else {
|
||||
projectIds = projects;
|
||||
}
|
||||
|
||||
$.extend(data, {
|
||||
projectids: projectIds
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: createURL('updateIsoPermissions'),
|
||||
data: data,
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function (json) {
|
||||
var item = json.updateisopermissionsresponse.success;
|
||||
args.response.success({
|
||||
data: item
|
||||
});
|
||||
}
|
||||
}); //end ajax
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -3873,8 +4186,11 @@
|
||||
) {
|
||||
//do nothing
|
||||
} else {
|
||||
if (jsonObj.isextractable){
|
||||
allowedActions.push("downloadISO");
|
||||
}
|
||||
allowedActions.push("shareISO");
|
||||
}
|
||||
|
||||
// "Delete ISO"
|
||||
//if (((isUser() && jsonObj.ispublic == true && !(jsonObj.domainid == g_domainid && jsonObj.account == g_account)))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user