diff --git a/src/sunstone/public/app/tabs/provision-tab/users/list.js b/src/sunstone/public/app/tabs/provision-tab/users/list.js
new file mode 100644
index 0000000000..babaa2fc21
--- /dev/null
+++ b/src/sunstone/public/app/tabs/provision-tab/users/list.js
@@ -0,0 +1,760 @@
+define(function(require) {
+ var OpenNebula = require('opennebula');
+ var Locale = require('utils/locale');
+ var Config = require('sunstone-config');
+ var Notifier = require('utils/notifier');
+ var QuotaWidgets = require('utils/quotas/quota-widgets');
+ var QuotaLimits = require('utils/quotas/quota-limits');
+ var QuotaDefaults = require('utils/quotas/quota-defaults');
+ var Accounting = require('utils/accounting');
+ var Showback = require('utils/showback');
+
+ var ProvisionQuotaWidget = require('./quota-widget');
+ var ProvisionVmsList = require('tabs/provision-tab/vms/list');
+
+ var TemplateProvisionQuotaWidget = require('hbs!./quota-widget/html');
+ var TemplateUsersList = require('hbs!./list');
+
+ var _accordionId = 0;
+
+ return {
+ 'generate': generate_provision_users_list,
+ 'show': show_provision_user_list
+ };
+
+ function show_provision_user_list(timeout) {
+ $(".section_content").hide();
+ $(".provision_users_list_section").fadeIn();
+
+ $("dd:not(.active) .provision_back", $(".provision_users_list_section")).trigger("click");
+ $(".provision_users_list_refresh_button", $(".provision_users_list_section")).trigger("click");
+ }
+
+ function generate_provision_users_list(context, opts) {
+ context.off();
+ context.html(html(opts));
+ setup_provision_users_list(context);
+ setup_provision_user_info(context);
+ }
+
+ function html(opts_arg) {
+ _accordionId += 1;
+ return TemplateUsersList({'accordionId': _accordionId});
+ }
+
+ function update_provision_users_datatable(datatable, timeout) {
+ datatable.html('
' +
+ '' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ '' +
+ ' ' +
+ '
');
+
+ setTimeout(function() {
+ OpenNebula.User.list({
+ timeout: true,
+ success: function (request, item_list, quotas_list) {
+ datatable.fnClearTable(true);
+ if (item_list.length == 0) {
+ datatable.html('
' +
+ '' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ '' +
+ Locale.tr("The list of users is empty") +
+ ' ' +
+ '
');
+ } else {
+ provision_quotas_list = quotas_list;
+ datatable.fnAddData(item_list);
+ }
+ },
+ error: Notifier.onError
+ })
+ }, timeout);
+ }
+
+ function setup_provision_users_list(context) {
+ var provision_users_datatable = $('.provision_users_table', context).dataTable({
+ "iDisplayLength": 6,
+ "sDom" : '<"H">t<"F"lp>',
+ "aLengthMenu": [[6, 12, 36, 72], [6, 12, 36, 72]],
+ "aaSorting" : [[0, "desc"]],
+ "aoColumnDefs": [
+ {"bVisible": false, "aTargets": ["all"]}
+ ],
+ "aoColumns": [
+ {"mDataProp": "USER.ID"},
+ {"mDataProp": "USER.NAME"}
+ ],
+ "fnPreDrawCallback": function (oSettings) {
+ // create a thumbs container if it doesn't exist. put it in the dataTables_scrollbody div
+ if (this.$('tr', {"filter": "applied"}).length == 0) {
+ this.html('
' +
+ '' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ '' +
+ Locale.tr("The list of users is empty") +
+ ' ' +
+ '
');
+ } else {
+ $(".provision_users_table", context).html('
');
+ }
+
+ return true;
+ },
+ "fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
+ var data = aData.USER;
+ //var state = get_provision_vm_state(data);
+ var vms = "";
+ var memory = "";
+ var cpu = "";
+
+ // Inject the VM user quota. This info is returned separately in the
+ // pool info call, but the userElementArray expects it inside the USER,
+ // as it is returned by the individual info call
+ var q = provision_quotas_list[data.ID];
+
+ var quotas_html;
+
+ if (q != undefined) {
+ var quota = q.QUOTAS;
+
+ if ($.isEmptyObject(quota.VM_QUOTA)) {
+ var limit = (data.ID != 0 ? QuotaLimits.QUOTA_LIMIT_DEFAULT : QuotaLimits.QUOTA_LIMIT_UNLIMITED);
+
+ quota.VM_QUOTA = {
+ VM: {
+ VMS : limit,
+ VMS_USED : 0,
+ CPU : limit,
+ CPU_USED : 0,
+ MEMORY : limit,
+ MEMORY_USED : 0
+ }
+ }
+ }
+
+ if (!$.isEmptyObject(quota.VM_QUOTA)) {
+ var default_user_quotas = QuotaDefaults.getDefaultUserQuotas();
+
+ quotas = QuotaWidgets.quotaFloatInfo(
+ quota.VM_QUOTA.VM.VMS_USED,
+ quota.VM_QUOTA.VM.VMS,
+ default_user_quotas.VM_QUOTA.VM.VMS,
+ true);
+
+ quotas_html = "";
+ quotas_html += '
' +
+ Locale.tr("VMs") +
+ '' + quotas.str + " " +
+ ' ' +
+ '
' +
+ '' +
+ ' ' +
+ '
' +
+ ' ';
+
+ quotas = QuotaWidgets.quotaFloatInfo(
+ quota.VM_QUOTA.VM.CPU_USED,
+ quota.VM_QUOTA.VM.CPU,
+ default_user_quotas.VM_QUOTA.VM.CPU,
+ true);
+
+ quotas_html += '
' +
+ Locale.tr("CPU") +
+ '' + quotas.str + " " +
+ ' ' +
+ '
' +
+ '' +
+ ' ' +
+ '
' +
+ ' ';
+
+ quotas = QuotaWidgets.quotaMBInfo(
+ quota.VM_QUOTA.VM.MEMORY_USED,
+ quota.VM_QUOTA.VM.MEMORY,
+ default_user_quotas.VM_QUOTA.VM.MEMORY,
+ true);
+
+ quotas_html += '
' +
+ Locale.tr("Memory") +
+ '' + quotas.str + " " +
+ ' ' +
+ '
' +
+ '' +
+ ' ' +
+ '
' +
+ ' ';
+ } else {
+ quotas = QuotaWidgets.quotaFloatInfo(0, 0, null, true);
+
+ quotas_html = "";
+ quotas_html += '
' +
+ Locale.tr("VMs") +
+ '' + quotas.str + " " +
+ ' ' +
+ '
' +
+ '' +
+ ' ' +
+ '
' +
+ ' ';
+
+ quotas = QuotaWidgets.quotaFloatInfo(0, 0, null, true);
+
+ quotas_html += '
' +
+ Locale.tr("CPU") +
+ '' + quotas.str + " " +
+ ' ' +
+ '
' +
+ '' +
+ ' ' +
+ '
' +
+ ' ';
+
+ quotas = QuotaWidgets.quotaMBInfo(0, 0, null, true);
+
+ quotas_html += '
' +
+ Locale.tr("Memory") +
+ '' + quotas.str + " " +
+ ' ' +
+ '
' +
+ '' +
+ ' ' +
+ '
' +
+ ' ';
+ }
+ }
+
+ $(".provision_users_ul", context).append('
' +
+ '' +
+ ' ');
+
+ return nRow;
+ }
+ });
+
+ $('.provision_list_users_search', context).keyup(function() {
+ provision_users_datatable.fnFilter($(this).val());
+ })
+
+ $('.provision_list_users_search', context).change(function() {
+ provision_users_datatable.fnFilter($(this).val());
+ })
+
+ context.on("click", ".provision_users_list_refresh_button", function() {
+ OpenNebula.Action.clear_cache("USER");
+ update_provision_users_datatable(provision_users_datatable, 0);
+ return false;
+ });
+
+ $(document).foundation();
+ }
+
+
+ function setup_provision_user_info(context) {
+ function update_provision_vdc_user_info(user_id, context) {
+ $(".provision_info_vdc_user_name", context).text("");
+ $(".provision_vdc_info_container", context).html("");
+ $(".provision_info_vdc_user", context).hide();
+ $(".provision_info_vdc_user_loading", context).fadeIn();
+
+ OpenNebula.User.show({
+ data : {
+ id: user_id
+ },
+ error: Notifier.onError,
+ success: function(request, response){
+ var data = response.USER
+
+ $(".provision_vdc_user_confirm_action",context).html("");
+ $(".provision_info_vdc_user_acct",context).html("");
+
+ $(".provision_info_vdc_user", context).attr("opennebula_id", data.ID);
+ $(".provision_info_vdc_user", context).attr("uname", data.NAME);
+ $(".provision_info_vdc_user", context).attr("quotas", JSON.stringify(data.VM_QUOTA));
+ $(".provision_info_vdc_user_name", context).text(data.NAME);
+
+ $(".provision-pricing-table_user_info", context).html("");
+
+ QuotaWidgets.initEmptyQuotas(data);
+
+ if (!$.isEmptyObject(data.VM_QUOTA)){
+ var default_user_quotas = QuotaDefaults.default_quotas(data.DEFAULT_USER_QUOTAS);
+ quotas = QuotaWidgets.quotaFloatInfo(
+ data.VM_QUOTA.VM.VMS_USED,
+ data.VM_QUOTA.VM.VMS,
+ default_user_quotas.VM_QUOTA.VM.VMS,
+ true);
+
+ $(".provision-pricing-table_user_info", context).append('
'+
+ Locale.tr("Running VMs")+
+ ''+quotas.str+" "+
+ ' '+
+ '
'+
+ ''+
+ ' '+
+ '
'+
+ ' ');
+
+ quotas = QuotaWidgets.quotaFloatInfo(
+ data.VM_QUOTA.VM.CPU_USED,
+ data.VM_QUOTA.VM.CPU,
+ default_user_quotas.VM_QUOTA.VM.CPU,
+ true);
+
+ $(".provision-pricing-table_user_info", context).append('
'+
+ Locale.tr("CPU")+
+ ''+quotas.str+" "+
+ ' '+
+ '
'+
+ ''+
+ ' '+
+ '
'+
+ ' ');
+
+ quotas = QuotaWidgets.quotaMBInfo(
+ data.VM_QUOTA.VM.MEMORY_USED,
+ data.VM_QUOTA.VM.MEMORY,
+ default_user_quotas.VM_QUOTA.VM.MEMORY,
+ true);
+
+ $(".provision-pricing-table_user_info", context).append('
'+
+ Locale.tr("Memory")+
+ ''+quotas.str+" "+
+ ' '+
+ '
'+
+ ''+
+ ' '+
+ '
'+
+ ' ');
+ } else {
+ quotas = QuotaWidgets.quotaFloatInfo(0, 0, null, true);
+
+ $(".provision-pricing-table_user_info", context).append('
'+
+ Locale.tr("Running VMs")+
+ ''+quotas.str+" "+
+ ' '+
+ '
'+
+ ''+
+ ' '+
+ '
'+
+ ' ');
+
+ quotas = QuotaWidgets.quotaFloatInfo(0, 0, null, true);
+
+ $(".provision-pricing-table_user_info", context).append('
'+
+ Locale.tr("CPU")+
+ ''+quotas.str+" "+
+ ' '+
+ '
'+
+ ''+
+ ' '+
+ '
'+
+ ' ');
+
+ quotas = QuotaWidgets.quotaMBInfo(0, 0, null, true);
+
+ $(".provision-pricing-table_user_info", context).append('
'+
+ Locale.tr("Memory")+
+ ''+quotas.str+" "+
+ ' '+
+ '
'+
+ ''+
+ ' '+
+ '
'+
+ ' ');
+ }
+
+ $(".provision-pricing-table_user_info", context).append(
+ '
'+
+ ' '+
+ ' '+
+ '
'+
+ ''+
+ ' '+
+ ' '+
+ ''+
+ ' '+
+ ' '+
+ ''+
+ ' '+
+ ' '+
+ ''+
+ ' '+
+ ' '+
+ (Config.isFeatureEnabled("showback") ? ''+
+ ' '+
+ ' ' : '') +
+ ' '+
+ '
'+
+ ' ')
+
+ var start_time = Math.floor(new Date().getTime() / 1000);
+ // ms to s
+
+ // 604800 = 7 days = 7*24*60*60
+ start_time = start_time - 604800;
+
+ // today
+ var end_time = -1;
+
+ var options = {
+ "start_time": start_time,
+ "end_time": end_time,
+ "userfilter": user_id
+ }
+
+ var no_table = true;
+
+ OpenNebula.VM.accounting({
+ success: function(req, response){
+ Accounting.fillAccounting($(".dashboard_vm_accounting", context), req, response, no_table);
+ },
+ error: Notifier.onError,
+ data: options
+ });
+
+ $(".provision_info_vdc_user", context).show();
+ $(".provision_info_vdc_user_loading", context).hide();
+
+ $(document).foundation();
+ //$("#provision_info_vdc_quotas").html(quotas_html);
+ }
+ })
+ }
+ //
+ // Info User
+ //
+
+ $(".provision_list_users", context).on("click", ".provision_info_user_button", function(){
+ $("a.provision_show_user_accordion", context).trigger("click");
+ // TODO loading
+
+ var user_id = $(this).parents(".provision-pricing-table").attr("opennebula_id")
+ update_provision_vdc_user_info(user_id, context);
+ })
+
+ context.on("click", ".provision_vdc_user_info_show_vms", function(){
+ $(".provision_vdc_info_container", context).html('
'+
+ ''+
+ ' '+
+ ' '+
+ ' '+
+ ' '+
+ ' '+
+ ''+
+ ' '+
+ '
');
+
+ ProvisionVmsList.generate(
+ $(".provision_vdc_info_container", context),
+ {
+ title: $(".provision_info_vdc_user", context).attr("uname") + ' ' + Locale.tr("VMs"),
+ active: true,
+ refresh: true,
+ create: false,
+ filter: false,
+ filter_expression: $(".provision_info_vdc_user", context).attr("opennebula_id")
+ });
+ })
+
+ context.on("click", ".provision_vdc_user_info_show_templates", function(){
+ $(".provision_vdc_info_container", context).html('
'+
+ ''+
+ ' '+
+ ' '+
+ ' '+
+ ' '+
+ ' '+
+ ''+
+ ' '+
+ '
');
+
+ generate_provision_templates_list(
+ $(".provision_vdc_info_container", context),
+ {
+ title: $(".provision_info_vdc_user", context).attr("uname") + ' ' + Locale.tr("Templates"),
+ active: true,
+ refresh: true,
+ create: false,
+ filter: false,
+ filter_expression: $(".provision_info_vdc_user", context).attr("opennebula_id")
+ });
+ })
+
+ context.on("click", ".provision_vdc_user_info_show_flows", function(){
+ $(".provision_vdc_info_container", context).html('
'+
+ ''+
+ ' '+
+ ' '+
+ ' '+
+ ' '+
+ ' '+
+ ''+
+ ' '+
+ '
');
+
+ generate_provision_flows_list(
+ $(".provision_vdc_info_container", context),
+ {
+ title: $(".provision_info_vdc_user", context).attr("uname") + ' ' + Locale.tr("Services"),
+ active: true,
+ refresh: true,
+ create: false,
+ filter: false,
+ filter_expression: $(".provision_info_vdc_user", context).attr("opennebula_id")
+ });
+ })
+
+
+ context.on("click", ".provision_vdc_user_info_show_acct", function(){
+ $(".provision_vdc_info_container", context).html("");
+
+ $(".provision_vdc_info_container", context).html(Accounting.html());
+ Accounting.setup(
+ $(".provision_vdc_info_container", context),
+ { fixed_user: $(".provision_info_vdc_user", context).attr("opennebula_id"),
+ init_group_by: "vm" });
+
+ $(".provision_vdc_info_container", context).prepend(
+ '')
+ })
+
+ if (Config.isFeatureEnabled("showback")) {
+ context.on("click", ".provision_vdc_user_info_show_showback", function(){
+ $(".provision_vdc_info_container", context).html("");
+
+ $(".provision_vdc_info_container", context).html(Showback.html());
+ Showback.setup(
+ $(".provision_vdc_info_container", context),
+ { fixed_user: $(".provision_info_vdc_user", context).attr("opennebula_id"),
+ fixed_group: "" });
+
+ $(".provision_vdc_info_container", context).prepend(
+ '')
+ })
+ };
+
+ context.on("click", ".provision_vdc_user_delete_confirm_button", function(){
+ $(".provision_vdc_user_confirm_action", context).html(
+ '
'+
+ '
'+
+ '
'+
+ ''+
+ Locale.tr("Be careful, this action will inmediately remove the User from OpenNebula")+
+ ' '+
+ '
'+
+ '
'+
+ '
'+
+ '
'+
+ '
× '+
+ '
');
+ });
+
+ context.on("click", ".provision_vdc_user_password_confirm_button", function(){
+ $(".provision_vdc_user_confirm_action", context).html(
+ '
'+
+ '
'+
+ '
'+
+ '
'+
+ ' '+
+ ' '+
+ '
'+
+ '
'+
+ '
'+
+ '
'+
+ ''+Locale.tr("Update Password")+' '+
+ '
'+
+ '
'+
+ '
× '+
+ '
');
+
+ context.on("click", ".provision_vdc_user_change_password_button", function(){
+ var button = $(this);
+ button.attr("disabled", "disabled");
+ var user_id = $(".provision_info_vdc_user", context).attr("opennebula_id");
+ var pw = $('.provision_vdc_user_new_password', context).val();
+ var confirm_password = $('.provision_vdc_user_new_confirm_password', context).val();
+
+ if (!pw.length){
+ Notifier.notifyError(Locale.tr("Fill in a new password"));
+ return false;
+ }
+
+ if (pw !== confirm_password){
+ Notifier.notifyError(Locale.tr("Passwords do not match"));
+ return false;
+ }
+
+ OpenNebula.User.passwd({
+ data : {
+ id: user_id,
+ extra_param: pw
+ },
+ success: function(request, response){
+ update_provision_vdc_user_info(user_id, context);
+ button.removeAttr("disabled");
+ },
+ error: function(request, response){
+ Notifier.onError(request, response);
+ button.removeAttr("disabled");
+ }
+ })
+ return false;
+ });
+ });
+
+
+
+ context.on("click", ".provision_vdc_user_quota_confirm_button", function(){
+ $(".provision_vdc_user_confirm_action", context).html(
+ '
'+
+ TemplateProvisionQuotaWidget() +
+ '
'+
+ '
'+
+ '
'+
+ '
× '+
+ '
');
+
+ ProvisionQuotaWidget.setup(context);
+
+ $(document).foundation();
+
+ var quotas_str = $(".provision_info_vdc_user", context).attr("quotas");
+ if (quotas_str) {
+ var quotas = JSON.parse(quotas_str);
+
+ var vms_limit = QuotaLimits.QUOTA_LIMIT_DEFAULT;
+ var cpu_limit = QuotaLimits.QUOTA_LIMIT_DEFAULT;
+ var mem_limit = QuotaLimits.QUOTA_LIMIT_DEFAULT;
+
+ if ( quotas.VM != undefined ){
+ vms_limit = quotas.VM.VMS;
+ cpu_limit = quotas.VM.CPU;
+ mem_limit = quotas.VM.MEMORY;
+
+ if(mem_limit != QuotaLimits.QUOTA_LIMIT_UNLIMITED &&
+ mem_limit != QuotaLimits.QUOTA_LIMIT_DEFAULT){
+
+ mem_limit = quotas.VM.MEMORY/1024;
+ }
+ }
+
+ var fill_limits = function(limit, select, input){
+ switch(limit){
+ case QuotaLimits.QUOTA_LIMIT_DEFAULT:
+ select.val('default').change();
+ input.val('').change();
+ break;
+
+ case QuotaLimits.QUOTA_LIMIT_UNLIMITED:
+ select.val('unlimited').change();
+ input.val('').change();
+ break;
+
+ default:
+ select.val('edit').change();
+ input.val(limit).change();
+ }
+ }
+
+ fill_limits(
+ vms_limit,
+ $("div.provision_rvms_quota select.provision_quota_select", context),
+ $(".provision_rvms_quota_input", context) );
+
+ fill_limits(
+ cpu_limit,
+ $("div.provision_cpu_quota select.provision_quota_select", context),
+ $(".provision_cpu_quota_input", context) );
+
+ fill_limits(
+ mem_limit,
+ $("div.provision_memory_quota select.provision_quota_select", context),
+ $(".provision_memory_quota_tmp_input", context) );
+ }
+ });
+
+ context.on("click", ".provision_delete_button", function(){
+ var button = $(this);
+ button.attr("disabled", "disabled");
+ var user_id = $(".provision_info_vdc_user", context).attr("opennebula_id");
+ OpenNebula.User.del({
+ data : {
+ id: user_id
+ },
+ success: function(request, response){
+ $(".provision_back", context).click();
+ $(".provision_users_list_refresh_button", context).click();
+ button.removeAttr("disabled");
+ },
+ error: function(request, response){
+ Notifier.onError(request, response);
+ button.removeAttr("disabled");
+ }
+ })
+ });
+
+ context.on("click", ".provision_update_quota_button", function(){
+ var button = $(this);
+ button.attr("disabled", "disabled");
+ var user_id = $(".provision_info_vdc_user", context).attr("opennebula_id");
+
+ quota_json = ProvisionQuotaWidget.retrieve(context);
+
+ OpenNebula.User.set_quota({
+ data : {
+ id: user_id,
+ extra_param: quota_json
+ },
+ success: function(request, response){
+ update_provision_vdc_user_info(user_id, context);
+ button.removeAttr("disabled");
+ },
+ error: function(request, response){
+ Notifier.onError(request, response);
+ button.removeAttr("disabled");
+ }
+ })
+ });
+
+ context.on("click", ".provision_refresh_info", function(){
+ var user_id = $(".provision_info_vdc_user", context).attr("opennebula_id");
+ update_provision_vdc_user_info(user_id, context);
+ return false;
+ });
+ }
+});
diff --git a/src/sunstone/public/app/tabs/provision-tab/users/quota-widget.js b/src/sunstone/public/app/tabs/provision-tab/users/quota-widget.js
new file mode 100644
index 0000000000..8311874373
--- /dev/null
+++ b/src/sunstone/public/app/tabs/provision-tab/users/quota-widget.js
@@ -0,0 +1,136 @@
+define(function(require) {
+ var QuotaLimits = require('utils/quotas/quota-limits');
+
+ return {
+ 'setup': setup_provision_quota_widget,
+ 'reset': reset_provision_quota_widget,
+ 'retrieve': retrieve_provision_quota_widget
+ }
+
+ function setup_provision_quota_widget(context){
+ // Mode selector, for the 3 sliders
+ $("select.provision_quota_select", context).on('change', function(){
+ var row = $(this).closest(".row");
+
+ switch($(this).val()) {
+ case "edit":
+ $("div.provision_quota_edit", row).show();
+ $("div.provision_quota_default", row).hide();
+ $("div.provision_quota_unlimited", row).hide();
+
+ $("input", row).change();
+
+ break;
+
+ case "default":
+ $("div.provision_quota_edit", row).hide();
+ $("div.provision_quota_default", row).show();
+ $("div.provision_quota_unlimited", row).hide();
+
+ break;
+
+ case "unlimited":
+ $("div.provision_quota_edit", row).hide();
+ $("div.provision_quota_default", row).hide();
+ $("div.provision_quota_unlimited", row).show();
+
+ break;
+ }
+
+ return false;
+ });
+
+ var provision_rvms_quota_input = $(".provision_rvms_quota_input", context);
+
+ $( ".provision_rvms_quota_slider", context).on('change', function(){
+ provision_rvms_quota_input.val($(this).attr('data-slider'))
+ });
+
+ provision_rvms_quota_input.change(function() {
+ $( ".provision_rvms_quota_slider", context).foundation(
+ 'slider', 'set_value', this.value);
+ });
+
+ var provision_cpu_quota_input = $(".provision_cpu_quota_input", context);
+
+ $( ".provision_cpu_quota_slider", context).on('change', function(){
+ provision_cpu_quota_input.val($(this).attr('data-slider'))
+ });
+
+ provision_cpu_quota_input.change(function() {
+ $( ".provision_cpu_quota_slider", context).foundation(
+ 'slider', 'set_value', this.value);
+ });
+
+ var provision_memory_quota_input = $(".provision_memory_quota_input", context);
+ var provision_memory_quota_tmp_input = $(".provision_memory_quota_tmp_input", context);
+
+ var update_final_memory_input = function() {
+ var value = provision_memory_quota_tmp_input.val();
+ if (value > 0) {
+ provision_memory_quota_input.val( Math.floor(value * 1024) );
+ } else {
+ provision_memory_quota_input.val(value);
+ }
+ }
+
+ $( ".provision_memory_quota_slider", context).on('change', function(){
+ provision_memory_quota_tmp_input.val($(this).attr('data-slider'));
+ update_final_memory_input();
+ });
+
+ provision_memory_quota_tmp_input.change(function() {
+ update_final_memory_input();
+ $( ".provision_memory_quota_slider", context).foundation(
+ 'slider', 'set_value', this.value);
+ });
+
+ $(".provision_rvms_quota_input", context).val('').change();
+ $(".provision_memory_quota_input", context).val('').change();
+ $(".provision_memory_quota_tmp_input", context).val('').change();
+ $(".provision_cpu_quota_input", context).val('').change();
+ }
+
+ function reset_provision_quota_widget(context){
+ $("select.provision_quota_select", context).val('edit').change();
+
+ $(".provision_rvms_quota_input", context).val('').change();
+ $(".provision_memory_quota_input", context).val('').change();
+ $(".provision_memory_quota_tmp_input", context).val('').change();
+ $(".provision_cpu_quota_input", context).val('').change();
+ }
+
+ function retrieve_provision_quota_widget(context){
+ var retrieve_quota = function(select, input){
+ switch(select.val()) {
+ case "edit":
+ return input.val();
+ case "default":
+ return QuotaLimits.QUOTA_LIMIT_DEFAULT;
+ case "unlimited":
+ return QuotaLimits.QUOTA_LIMIT_UNLIMITED;
+ }
+ }
+
+ var vms_limit = retrieve_quota(
+ $(".provision_rvms_quota select.provision_quota_select", context),
+ $(".provision_rvms_quota_input", context));
+
+ var cpu_limit = retrieve_quota(
+ $(".provision_cpu_quota select.provision_quota_select", context),
+ $(".provision_cpu_quota_input", context));
+
+ var mem_limit = retrieve_quota(
+ $(".provision_memory_quota select.provision_quota_select", context),
+ $(".provision_memory_quota_input", context));
+
+ return {
+ "VM" : {
+ "VOLATILE_SIZE": QuotaLimits.QUOTA_LIMIT_DEFAULT,
+ "VMS": vms_limit,
+ "MEMORY": mem_limit,
+ "CPU": cpu_limit
+ }
+ };
+ }
+});
diff --git a/src/sunstone/public/app/tabs/provision-tab/users/quota-widget/html.hbs b/src/sunstone/public/app/tabs/provision-tab/users/quota-widget/html.hbs
new file mode 100644
index 0000000000..3e11ccaa63
--- /dev/null
+++ b/src/sunstone/public/app/tabs/provision-tab/users/quota-widget/html.hbs
@@ -0,0 +1,114 @@
+
+
+
+
+ {{tr "Manual"}}
+ {{tr "Unlimited"}}
+ {{tr "Default"}}
+
+
+
+
+ {{tr "Unlimited. Group quotas will still apply"}}
+
+
+
+ {{tr "Use the default system quotas set by the cloud adminstrator"}}
+
+
+
+
+
+
+
+ {{tr "Manual"}}
+ {{tr "Unlimited"}}
+ {{tr "Default"}}
+
+
+
+
+ {{tr "Unlimited. Group quotas will still apply"}}
+
+
+
+ {{tr "Use the default system quotas set by the cloud adminstrator"}}
+
+
+
+
+
+
+
+
+
+
+ {{tr "Manual"}}
+ {{tr "Unlimited"}}
+ {{tr "Default"}}
+
+
+
+
+ {{tr "Unlimited. Group quotas will still apply"}}
+
+
+
+ {{tr "Use the default system quotas set by the cloud adminstrator"}}
+
+
+
\ No newline at end of file