This is an automated email from the ASF dual-hosted git repository. rohit pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/master by this push:
new f72b61e ui: Update ISO permissions (#4017)
f72b61e is described below
commit f72b61edb82592c5e17a4f73bac54cea7e8c3702
Author: Nicolas Vazquez <[email protected]>
AuthorDate: Sun Jun 7 23:05:28 2020 -0300
ui: Update ISO permissions (#4017)
Update ISO permissions
Co-Authored-By: Abhishek Kumar <[email protected]>
Co-authored-by: Abhishek Kumar <[email protected]>
---
ui/css/cloudstack3.css | 8 ++
ui/l10n/en.js | 1 +
ui/scripts/templates.js | 318 +++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 326 insertions(+), 1 deletion(-)
diff --git a/ui/css/cloudstack3.css b/ui/css/cloudstack3.css
index a2da335..98871c9 100644
--- a/ui/css/cloudstack3.css
+++ b/ui/css/cloudstack3.css
@@ -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;
}
diff --git a/ui/l10n/en.js b/ui/l10n/en.js
index cb967be..fa7d388 100644
--- a/ui/l10n/en.js
+++ b/ui/l10n/en.js
@@ -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",
diff --git a/ui/scripts/templates.js b/ui/scripts/templates.js
index 9216733..1516286 100644
--- a/ui/scripts/templates.js
+++ b/ui/scripts/templates.js
@@ -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,7 +4186,10 @@
) {
//do nothing
} else {
- allowedActions.push("downloadISO");
+ if (jsonObj.isextractable){
+ allowedActions.push("downloadISO");
+ }
+ allowedActions.push("shareISO");
}
// "Delete ISO"
