mirror of https://github.com/apache/cloudstack.git
bug 12273: Add project resource management
status 12273: resolved fixed
This commit is contained in:
parent
568db1fdb7
commit
8e075b38c3
|
|
@ -4,6 +4,76 @@
|
|||
return window.g_projectsInviteRequired;
|
||||
},
|
||||
|
||||
resourceManagement: {
|
||||
update: function(args) {
|
||||
var totalResources = 5;
|
||||
var updatedResources = 0;
|
||||
$.each(args.data, function(key, value) {
|
||||
$.ajax({
|
||||
url: createURL('updateResourceLimit'),
|
||||
data: {
|
||||
resourcetype: key,
|
||||
max: args.data[key]
|
||||
},
|
||||
success: function(json) {
|
||||
updatedResources++;
|
||||
if (updatedResources == totalResources) {
|
||||
args.response.success();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
dataProvider: function(args) {
|
||||
$.ajax({
|
||||
url: createURL('listResourceLimits'),
|
||||
success: function(json) {
|
||||
args.response.success({
|
||||
data: $.map(
|
||||
json.listresourcelimitsresponse.resourcelimit,
|
||||
function(resource) {
|
||||
var resourceMap = {
|
||||
0: {
|
||||
id: 'user_vm',
|
||||
label: 'Max. User VMs'
|
||||
},
|
||||
1: {
|
||||
id: 'public_ip',
|
||||
label: 'Max. Public IPs'
|
||||
},
|
||||
2: {
|
||||
id: 'volume',
|
||||
label: 'Max. Volumes'
|
||||
},
|
||||
3: {
|
||||
id: 'snapshot',
|
||||
label: 'Max. Snapshots'
|
||||
},
|
||||
4: {
|
||||
id: 'template',
|
||||
label: 'Max. Templates'
|
||||
},
|
||||
5: {
|
||||
id: 'project',
|
||||
label: 'Max. Projects'
|
||||
}
|
||||
};
|
||||
return {
|
||||
id: resourceMap[resource.resourcetype].id,
|
||||
label: resourceMap[resource.resourcetype].label,
|
||||
type: resource.resourcetype,
|
||||
value: resource.max
|
||||
};
|
||||
}
|
||||
)
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
dashboard: function(args) {
|
||||
var dataFns = {
|
||||
instances: function(data) {
|
||||
|
|
|
|||
|
|
@ -96,6 +96,69 @@
|
|||
return $('<div>').addClass('management-invite').data('tab-title', 'Invitations');
|
||||
};
|
||||
}
|
||||
|
||||
tabs.resources = function() {
|
||||
var $resources = $('<div>').addClass('resources').data('tab-title', 'Resources');
|
||||
var $form = $('<form>');
|
||||
var $submit = $('<input>').attr({
|
||||
type: 'submit'
|
||||
}).val('Apply');
|
||||
|
||||
cloudStack.projects.resourceManagement.dataProvider({
|
||||
response: {
|
||||
success: function(args) {
|
||||
$(args.data).each(function() {
|
||||
var resource = this;
|
||||
var $field = $('<div>').addClass('field');
|
||||
var $label = $('<label>').attr({
|
||||
for: resource.type
|
||||
}).html(resource.label);
|
||||
var $input = $('<input>').attr({
|
||||
type: 'text',
|
||||
name: resource.type,
|
||||
value: resource.value
|
||||
}).addClass('required');
|
||||
|
||||
$field.append($label, $input);
|
||||
$field.appendTo($form);
|
||||
});
|
||||
|
||||
$form.validate();
|
||||
$form.submit(function() {
|
||||
if (!$form.valid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var $loading = $('<div>').addClass('loading-overlay').appendTo($form);
|
||||
|
||||
cloudStack.projects.resourceManagement.update({
|
||||
data: cloudStack.serializeForm($form),
|
||||
response: {
|
||||
success: function(args) {
|
||||
$loading.remove();
|
||||
$('.notifications').notifications('add', {
|
||||
section: 'dashboard',
|
||||
desc: 'Updated project resources',
|
||||
interval: 1000,
|
||||
poll: function(args) {
|
||||
args.complete();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$submit.appendTo($form);
|
||||
$form.appendTo($resources);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return $resources;
|
||||
};
|
||||
}
|
||||
|
||||
var $tabs = $('<div>').addClass('tab-content').append($('<ul>'));
|
||||
|
|
|
|||
Loading…
Reference in New Issue