diff --git a/ui/index.jsp b/ui/index.jsp
index a645c04fade..1b3332b9117 100644
--- a/ui/index.jsp
+++ b/ui/index.jsp
@@ -1414,8 +1414,8 @@
-
+
diff --git a/ui/scripts/cloudStack.js b/ui/scripts/cloudStack.js
index 0101722f63e..7790a837717 100644
--- a/ui/scripts/cloudStack.js
+++ b/ui/scripts/cloudStack.js
@@ -4,13 +4,13 @@
sectionPreFilter: function(args) {
if(isAdmin()) {
- return ["dashboard", "instances", "storage", "network", "templates", "accounts", "domains", "events", "system", "global-settings", "configuration"];
+ return ["dashboard", "instances", "storage", "network", "templates", "accounts", "domains", "events", "system", "global-settings", "configuration", "projects"];
}
else if(isDomainAdmin()) {
- return ["dashboard", "instances", "storage", "network", "templates", "accounts", "domains", "events"];
+ return ["dashboard", "instances", "storage", "network", "templates", "accounts", "domains", "events", "projects"];
}
else { //normal user
- return ["dashboard", "instances", "storage", "network", "templates", "events"];
+ return ["dashboard", "instances", "storage", "network", "templates", "events", "projects"];
}
},
sections: {
@@ -28,7 +28,8 @@
events: {},
system: {},
'global-settings': {},
- configuration: {}
+ configuration: {},
+ projects: {}
}
});
diff --git a/ui/scripts/projects.js b/ui/scripts/projects.js
index 0e8b24e87b6..c52c9ab9019 100644
--- a/ui/scripts/projects.js
+++ b/ui/scripts/projects.js
@@ -29,17 +29,6 @@
noSelect: true,
fields: {
'username': { edit: true, label: 'Account' },
- 'role': {
- label: 'Role',
- select: function(args) {
- args.response.success({
- data: [
- { name: 'User', description: 'User' },
- { name: 'Admin', description: 'Admin' }
- ]
- });
- }
- },
'add-user': { addButton: true, label: '' }
},
add: {
@@ -61,16 +50,21 @@
notification: {
label: 'Added user to project',
poll: pollAsyncJobResult
- }
+ }
});
}
});
}
},
actionPreFilter: function(args) {
- if (cloudStack.context.projects &&
- cloudStack.context.projects[0] &&
- !cloudStack.context.projects[0].isNew) {
+ var rowAccount = args.context.multiRule[0].account;
+ var userAccount = cloudStack.context.users[0].account;
+ var projectOwner = cloudStack.context.projects[0].account;
+ var isExistingProject = cloudStack.context.projects &&
+ cloudStack.context.projects[0] &&
+ !cloudStack.context.projects[0].isNew;
+
+ if (isExistingProject) {
return args.context.actions;
}
@@ -80,27 +74,51 @@
destroy: {
label: 'Remove user from project',
action: function(args) {
- setTimeout(function() {
- args.response.success({
- notification: {
- label: 'Removed user from project',
- poll: testData.notifications.testPoll
- }
- });
- }, 500);
+ $.ajax({
+ url: createURL('deleteAccountFromProject'),
+ data: {
+ projectId: cloudStack.context.projects[0].id,
+ account: args.context.multiRule[0].username
+ },
+ dataType: 'json',
+ async: true,
+ success: function(data) {
+ args.response.success({
+ _custom: {
+ jobId: data.deleteaccountfromprojectresponse.jobid
+ },
+ notification: {
+ label: 'Removed user from project',
+ poll: pollAsyncJobResult
+ }
+ });
+ }
+ });
}
},
makeOwner: {
label: 'Make user project owner',
action: function(args) {
- setTimeout(function() {
- args.response.success({
- notification: {
- label: 'Assigned new owner to project',
- poll: testData.notifications.testPoll
- }
- });
+ $.ajax({
+ url: createURL('updateProject'),
+ data: {
+ id: cloudStack.context.projects[0].id,
+ account: args.context.multiRule[0].username
+ },
+ dataType: 'json',
+ async: true,
+ success: function(data) {
+ args.response.success({
+ _custom: {
+ jobId: data.updateprojectresponse.jobid
+ },
+ notification: {
+ label: 'Assigned new project owner',
+ poll: pollAsyncJobResult
+ }
+ });
+ }
});
}
}
@@ -111,7 +129,6 @@
$.ajax({
url: createURL('listProjectAccounts'),
data: {
- role: 'Admin, User',
projectId: cloudStack.context.projects[0].id
},
dataType: 'json',
@@ -121,8 +138,8 @@
data: $.map(data.listprojectaccountsresponse.projectaccount, function(elem) {
return {
id: elem.accountid,
- username: elem.account,
- role: elem.role
+ username: elem.role == 'Owner' ?
+ elem.account + ' (owner)' : elem.account
};
})
});
@@ -144,7 +161,10 @@
async: true,
success: function(data) {
args.response.success({
- data: $.map(data.listprojectsresponse.project, function(elem) {
+ data: $.map(
+ data.listprojectsresponse.project ?
+ data.listprojectsresponse.project : [],
+ function(elem) {
return $.extend(elem, {
displayText: elem.displaytext
});
@@ -154,4 +174,88 @@
});
}
};
+
+ cloudStack.sections.projects = {
+ title: 'Projects',
+ id: 'projects',
+ listView: {
+ fields: {
+ name: { label: 'Project Name' },
+ displaytext: { label: 'Display Text' },
+ domain: { label: 'Domain' },
+ account: { label: 'Owner' }
+ },
+
+ dataProvider: function(args) {
+ $.ajax({
+ url: createURL('listProjects'),
+ dataType: 'json',
+ async: true,
+ success: function(data) {
+ args.response.success({
+ data: data.listprojectsresponse.project
+ });
+ }
+ });
+ },
+
+ actions: {
+ add: {
+ label: 'New Project',
+ action: {
+ custom: function(args) {
+
+ }
+ },
+
+ messages: {
+ confirm: function(args) {
+ return 'Are you sure you want to remove ' + args.name + '?';
+ },
+ notification: function(args) {
+ return 'Removed project';
+ }
+ },
+
+ notification: {
+ poll: testData.notifications.testPoll
+ }
+ },
+
+ destroy: {
+ label: 'Remove project',
+ action: function(args) {
+ $.ajax({
+ url: createURL('deleteProject'),
+ data: {
+ id: args.data.id
+ },
+ dataType: 'json',
+ async: true,
+ success: function(data) {
+ args.response.success({
+ _custom: {
+ jobId: data.deleteprojectresponse.jobid
+ }
+ });
+ }
+ });
+ },
+
+ messages: {
+ confirm: function(args) {
+ return 'Are you sure you want to remove ' + args.name + '?';
+ },
+ notification: function(args) {
+ return 'Removed project';
+ }
+ },
+
+ notification: {
+ poll: pollAsyncJobResult
+ }
+ }
+ }
+ }
+ };
} (cloudStack, testData));
\ No newline at end of file
diff --git a/ui/scripts/ui/multiEdit.js b/ui/scripts/ui/multiEdit.js
index 49d4438d198..b33d8723e23 100644
--- a/ui/scripts/ui/multiEdit.js
+++ b/ui/scripts/ui/multiEdit.js
@@ -98,6 +98,7 @@
// Action filter
var allowedActions = options.preFilter ? options.preFilter({
context: $.extend(true, {}, options.context, {
+ multiRule: [data],
actions: $.map(actions, function(value, key) { return key; })
})
}) : null;