mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
Implement projects server calls
This commit is contained in:
parent
fe04fab57e
commit
7dfaf2bb39
@ -1414,7 +1414,7 @@
|
||||
<script src="scripts/sharedFunctions.js" type="text/javascript"></script>
|
||||
<script src="scripts/ui-custom/login.js" type="text/javascript"></script>
|
||||
<script src="scripts/ui-custom/projects.js" type="text/javascript"></script>
|
||||
<script src="scripts-test/projects.js" type="text/javascript"></script>
|
||||
<script src="scripts/projects.js" type="text/javascript"></script>
|
||||
<script src="scripts/cloudStack.js" type="text/javascript"></script>
|
||||
<script src="scripts/dashboard.js" type="text/javascript"></script>
|
||||
<script src="scripts/ui-custom/instanceWizard.js" type="text/javascript"></script>
|
||||
|
||||
@ -2,14 +2,28 @@
|
||||
cloudStack.projects = {
|
||||
add: function(args) {
|
||||
setTimeout(function() {
|
||||
args.response.success({
|
||||
$.ajax({
|
||||
url: createURL('createProject'),
|
||||
data: {
|
||||
account: args.context.users[0].account,
|
||||
domainId: args.context.users[0].domainid,
|
||||
name: args.data['project-name'],
|
||||
displayText: args.data['project-display-text'],
|
||||
users: []
|
||||
displayText: args.data['project-display-text']
|
||||
},
|
||||
dataType: 'json',
|
||||
async: true,
|
||||
success: function(data) {
|
||||
args.response.success({
|
||||
data: {
|
||||
id: data.createprojectresponse.id,
|
||||
name: args.data['project-name'],
|
||||
displayText: args.data['project-display-text'],
|
||||
users: []
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}, 1000);
|
||||
}, 100);
|
||||
},
|
||||
addUserForm: {
|
||||
noSelect: true,
|
||||
@ -20,8 +34,8 @@
|
||||
select: function(args) {
|
||||
args.response.success({
|
||||
data: [
|
||||
{ name: 'user', description: 'User' },
|
||||
{ name: 'admin', description: 'Admin' }
|
||||
{ name: 'User', description: 'User' },
|
||||
{ name: 'Admin', description: 'Admin' }
|
||||
]
|
||||
});
|
||||
}
|
||||
@ -31,15 +45,26 @@
|
||||
add: {
|
||||
label: 'Invite',
|
||||
action: function(args) {
|
||||
setTimeout(function() {
|
||||
cloudStack.context.projects[0].users.push(args.data);
|
||||
args.response.success({
|
||||
notification: {
|
||||
label: 'Added user to project',
|
||||
poll: testData.notifications.testPoll
|
||||
}
|
||||
});
|
||||
}, 100);
|
||||
$.ajax({
|
||||
url: createURL('addAccountToProject'),
|
||||
data: {
|
||||
projectId: cloudStack.context.projects[0].id,
|
||||
account: args.data.username
|
||||
},
|
||||
dataType: 'json',
|
||||
async: true,
|
||||
success: function(data) {
|
||||
args.response.success({
|
||||
_custom: {
|
||||
jobId: data.addaccounttoprojectresponse.jobid
|
||||
},
|
||||
notification: {
|
||||
label: 'Added user to project',
|
||||
poll: pollAsyncJobResult
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
actionPreFilter: function(args) {
|
||||
@ -83,25 +108,50 @@
|
||||
|
||||
// Project users data provider
|
||||
dataProvider: function(args) {
|
||||
var data = cloudStack.context.projects ?
|
||||
cloudStack.context.projects[0].users : [];
|
||||
|
||||
setTimeout(function() {
|
||||
args.response.success({
|
||||
data: data
|
||||
});
|
||||
}, 100);
|
||||
$.ajax({
|
||||
url: createURL('listProjectAccounts'),
|
||||
data: {
|
||||
role: 'Admin, User',
|
||||
projectId: cloudStack.context.projects[0].id
|
||||
},
|
||||
dataType: 'json',
|
||||
async: true,
|
||||
success: function(data) {
|
||||
args.response.success({
|
||||
data: $.map(data.listprojectaccountsresponse.projectaccount, function(elem) {
|
||||
return {
|
||||
id: elem.accountid,
|
||||
username: elem.account,
|
||||
role: elem.role
|
||||
};
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// Project listing data provider
|
||||
dataProvider: function(args) {
|
||||
var user = args.context.users[0];
|
||||
setTimeout(function() {
|
||||
args.response.success({
|
||||
data: user.username == 'bfederle' ? [] : testData.data.projects
|
||||
});
|
||||
}, 200);
|
||||
|
||||
$.ajax({
|
||||
url: createURL('listProjects'),
|
||||
data: {
|
||||
accountId: user.userid
|
||||
},
|
||||
dataType: 'json',
|
||||
async: true,
|
||||
success: function(data) {
|
||||
args.response.success({
|
||||
data: $.map(data.listprojectsresponse.project, function(elem) {
|
||||
return $.extend(elem, {
|
||||
displayText: elem.displaytext
|
||||
});
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
} (cloudStack, testData));
|
||||
Loading…
x
Reference in New Issue
Block a user