Example #1
0
 callback: function(){
   OpenNebula.Action.clear_cache("SERVICE");
   ProvisionFlowsList.show(0);
   var context = $("#provision_create_flow");
   $("#flow_name", context).val('');
   //$(".provision_selected_networks").html("");
   $(".provision-pricing-table", context).removeClass("selected");
 },
Example #2
0
File: list.js Project: lihaso/one
 error: function(request, response){
   if(response.error.http_status == 0){   // Failed due to cloning template taking too long
       OpenNebula.Action.clear_cache("VMTEMPLATE");
       update_provision_vm_info(vm_id, context);
       Notifier.notifyMessage(Locale.tr("VM cloning in the background. The Template will appear as soon as it is ready, and the VM unlocked."));
   } else {
       Notifier.onError(request, response);
   }
   button.removeAttr("disabled");
 }
Example #3
0
      callback: function(){
        OpenNebula.Action.clear_cache("VM");
        ProvisionVmsList.show(0);
        var context = $("#provision_create_vm");
        $("#vm_name", context).val('');
        $(".provision_selected_networks").html("");
        $(".provision-pricing-table", context).removeClass("selected");
        $(".alert-box-error", context).hide();

        $('#provision_vm_instantiate_templates_owner_filter').val('all').change();
        $('#provision_vm_instantiate_template_search').val('').trigger('input');
      },
Example #4
0
  function show_provision_create_vm() {
    OpenNebula.Action.clear_cache("VMTEMPLATE");

    ProvisionTemplatesList.updateDatatable(provision_vm_instantiate_templates_datatable);
    $('#provision_vm_instantiate_templates_owner_filter').val('all').change();
    $('#provision_vm_instantiate_template_search').val('').trigger('input');

    $(".provision_accordion_template .selected_template").hide();
    $(".provision_accordion_template .select_template").show();

    $("#provision_create_vm .provision_capacity_selector").html("");
    $("#provision_create_vm .provision_disk_selector").html("");
    $("#provision_create_vm .provision_network_selector").html("");
    $("#provision_create_vm .provision_custom_attributes_selector").html("")

    $("#provision_create_vm li:not(.is-active) a[href='#provision_dd_template']").trigger("click")

    $(".section_content").hide();
    $("#provision_create_vm").fadeIn();
  }
Example #5
0
  function setup_provision_templates_list(context, opts) {
    var provision_templates_datatable = $('.provision_templates_table', context).dataTable({
      "iDisplayLength": 8,
      "sDom" : '<"H">t<"F"lp>',
      "aLengthMenu": [[6, 12, 36, 72], [6, 12, 36, 72]],
      "aaSorting"  : [[0, "desc"]],
      "aoColumnDefs": [
          { "bVisible": false, "aTargets": ["all"]}
      ],
      "aoColumns": [
          { "mDataProp": "VMTEMPLATE.ID" },
          { "mDataProp": "VMTEMPLATE.NAME" },
          { "mDataProp": "VMTEMPLATE.TEMPLATE.SAVED_TEMPLATE_ID", "sDefaultContent" : "-"  },
          { "mDataProp": "VMTEMPLATE.UID" }
      ],
      "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('<div class="text-center">'+
            '<span class="fa-stack fa-5x" style="color: #dfdfdf">'+
              '<i class="fa fa-cloud fa-stack-2x"></i>'+
              '<i class="fa fa-info-circle fa-stack-1x fa-inverse"></i>'+
            '</span>'+
            '<br>'+
            '<br>'+
            '<span style="font-size: 18px; color: #999">'+
              Locale.tr("There are no saved templates available")+
              '<br>'+
              Locale.tr("Create a template by saving a running Virtual Machine")+
            '</span>'+
            '</div>');
        } else {
          $(".provision_templates_table", context).html('<ul class="provision_templates_ul large-block-grid-3 medium-block-grid-3 small-block-grid-1 text-center"></ul>');
        }
        return true;
      },
      "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
        var data = aData.VMTEMPLATE;
        var actions_html = "";
        if (Config.isTabActionEnabled("provision-tab", "Template.chmod")) {
          if (data.UID == config['user_id']) {

            if (data.PERMISSIONS.GROUP_U == "1") {
              actions_html += '<a class="provision_confirm_unshare_template_button left" title="'+ Locale.tr("Unshare")+'" style="color:#555" href="#"><i class="fa fa-fw fa-lg fa-ban only-on-hover"/></a>';
              actions_html += '<span style="font-size:12px; color: #777">' + Locale.tr("SHARED") + '</span>';
            } else {
              actions_html += '<a class="provision_confirm_chmod_template_button left" title="'+ Locale.tr("Share")+'" style="color:#555" href="#"><i class="fa fa-fw fa-lg fa-share-alt only-on-hover"/></a>';
            }
          }
        }

        if (Config.isTabActionEnabled("provision-tab", "Template.delete")) {
          actions_html += '<a class="provision_confirm_delete_template_button" title="'+ Locale.tr("Delete")+'"  style="color:#555" href="#"><i class="fa fa-fw fa-lg fa-trash-o right only-on-hover"/></a>';
        }

        $(".provision_templates_ul", context).append('<li>'+
            '<ul class="provision-pricing-table" opennebula_id="'+data.ID+'" saved_to_image_id="'+data.TEMPLATE.SAVED_TO_IMAGE_ID+'" datatable_index="'+iDisplayIndexFull+'">'+
              '<li class="provision-title text-left" title="'+data.NAME+'">'+
                data.NAME +
              '</li>'+
              '<li class="provision-bullet-item text-left" >'+
                '<i class="fa fa-fw fa-lg fa-laptop"/> '+
                'x'+data.TEMPLATE.CPU+' - '+
                ((data.TEMPLATE.MEMORY > 1000) ?
                  (Math.floor(data.TEMPLATE.MEMORY/1024)+'GB') :
                  (data.TEMPLATE.MEMORY+'MB'))+
                ' - '+
                get_provision_disk_image(data) +
              '</li>'+
              '<li class="provision-description text-left" style="padding-top:0px; padding-bottom: 5px">'+
                (data.TEMPLATE.DESCRIPTION || '')+
              '</li>'+
              '<li class="provision-bullet-item" style="padding-top:10px">'+
                actions_html+
              '</li>'+
              '<li class="provision-bullet-item-last text-left" >'+
                '<span class="">'+
                  '<i class="fa fa-fw fa-lg fa-user"/> '+
                  data.UNAME+
                '</span>'+
                '<span class="right">'+
                  Humanize.prettyTimeAgo(data.REGTIME)+
                '</span>'+
              '</li>'+
            '</ul>'+
          '</li>');

        return nRow;
      }
    });

    provision_templates_datatable.fnFilter("^(?!\-$)", 2, true, false);

    $('.provision_list_templates_search', context).on('input',function(){
      provision_templates_datatable.fnFilter( $(this).val() );
    })

    context.on("click", ".provision_templates_list_refresh_button", function(){
      OpenNebula.Action.clear_cache("VMTEMPLATE");
      $(".provision_confirm_delete_template_div", context).html("");
      update_provision_templates_datatable(provision_templates_datatable, 0);
      return false;
    });

    context.on("click", ".provision_templates_list_search_button", function(){
      $(".provision_list_templates_search", context).fadeIn();
    });

    $(".provision_list_templates_filter", context).on("change", ".resource_list_select", function(){
      if ($(this).val() != "-2"){
        provision_templates_datatable.fnFilter("^" + $(this).val() + "$", 3, true, false);
      } else {
        provision_templates_datatable.fnFilter("", 3);
      }
    })

    ResourceSelect.insert(
      ".provision_list_templates_filter",
      context,
      "User",
      (opts.filter_expression ? opts.filter_expression : "-2"),
      false,
      '<option value="-2">'+Locale.tr("ALL")+'</option>',
      null,
      null,
      true,
      true);

    context.on("click", ".provision_templates_list_filter_button", function(){
      $(".provision_list_templates_filter", context).fadeIn();
      return false;
    });

    if (Config.isTabActionEnabled("provision-tab", "Template.delete")) {
      context.on("click", ".provision_confirm_delete_template_button", function(){
        var ul_context = $(this).parents(".provision-pricing-table");
        var template_id = ul_context.attr("opennebula_id");
        var template_name = $(".provision-title", ul_context).text();

        $(".provision_confirm_delete_template_div", context).html(
          '<div data-alert class="alert-box secondary radius">'+
            '<div class="row">'+
            '<div class="large-9 columns">'+
              '<span style="font-size: 14px; line-height: 20px">'+
                Locale.tr("Handle with care! This action will inmediately destroy the template")+
                ' "' + template_name + '" ' +
                Locale.tr("and the image associated.") +
              '</span>'+
            '</div>'+
            '<div class="large-3 columns">'+
              '<a href"#" class="provision_delete_template_button alert button large-12 radius right" style="margin-right: 15px" template_id="'+template_id+'">'+Locale.tr("Delete")+'</a>'+
            '</div>'+
            '</div>'+
            '<a href="#" class="close">&times;</a>'+
          '</div>');
      });

      context.on("click", ".provision_delete_template_button", function(){

        var button = $(this);
        button.attr("disabled", "disabled");

        var template_id = $(this).attr("template_id");

        OpenNebula.Template.delete_from_provision({
          timeout: true,
          data : {
            id : template_id
          },
          success: function (){
            $(".provision_templates_list_refresh_button", context).trigger("click");
          },
          error: function (request,error_json, container) {
            Notifier.onError(request, error_json, container);
            $(".provision_templates_list_refresh_button", context).trigger("click");
          }
        })
      });
    }


    if (Config.isTabActionEnabled("provision-tab", "Template.chmod")) {
      context.on("click", ".provision_confirm_chmod_template_button", function(){
        var ul_context = $(this).parents(".provision-pricing-table");
        var template_id = ul_context.attr("opennebula_id");
        var template_name = $(".provision-title", ul_context).text();

        $(".provision_confirm_delete_template_div", context).html(
          '<div data-alert class="alert-box secondary radius">'+
            '<div class="row">'+
            '<div class="large-8 columns">'+
              '<span style="font-size: 14px; line-height: 20px">'+
                Locale.tr("The template")+
                ' "' + template_name + '" ' +
                Locale.tr("and the image associated will be shared and all the users will be able to instantiate new VMs using this template.") +
              '</span>'+
            '</div>'+
            '<div class="large-4 columns">'+
              '<a href"#" class="provision_chmod_template_button success button large-12 radius right" style="margin-right: 15px" template_id="'+template_id+'">'+Locale.tr("Share template")+'</a>'+
            '</div>'+
            '</div>'+
            '<a href="#" class="close">&times;</a>'+
          '</div>');
      });

      context.on("click", ".provision_chmod_template_button", function(){

        var button = $(this);
        button.attr("disabled", "disabled");

        var template_id = $(this).attr("template_id");

        OpenNebula.Template.chmod_from_provision({
          timeout: true,
          data : {
            id : template_id,
            extra_param: {'group_u': 1}
          },
          success: function (){
            $(".provision_templates_list_refresh_button", context).trigger("click");
          },
          error: Notifier.onError
        })
      });

      context.on("click", ".provision_confirm_unshare_template_button", function(){
        var ul_context = $(this).parents(".provision-pricing-table");
        var template_id = ul_context.attr("opennebula_id");
        var template_name = $(".provision-title", ul_context).first().text();

        $(".provision_confirm_delete_template_div", context).html(
          '<div data-alert class="alert-box secondary radius">'+
            '<div class="row">'+
            '<div class="large-8 columns">'+
              '<span style="font-size: 14px; line-height: 20px">'+
                Locale.tr("The template")+
                ' "' + template_name + '" ' +
                Locale.tr("and the image associated will be unshared and the users will not be able to instantiate new VMs using this template.") +
              '</span>'+
            '</div>'+
            '<div class="large-4 columns">'+
              '<a href"#" class="provision_unshare_template_button success button large-12 radius right" style="margin-right: 15px" template_id="'+template_id+'">'+Locale.tr("Unshare template")+'</a>'+
            '</div>'+
            '</div>'+
            '<a href="#" class="close">&times;</a>'+
          '</div>');
      });

      context.on("click", ".provision_unshare_template_button", function(){
        var button = $(this);
        button.attr("disabled", "disabled");

        var template_id = $(this).attr("template_id");

        OpenNebula.Template.chmod_from_provision({
          timeout: true,
          data : {
            id : template_id,
            extra_param: {'group_u': 0}
          },
          success: function (){
            $(".provision_templates_list_refresh_button", context).trigger("click");
          },
          error: Notifier.onError
        })
      });
    }

    OpenNebula.Action.clear_cache("VMTEMPLATE");
    update_provision_templates_datatable(provision_templates_datatable, 0);
    context.foundation();
  }
Example #6
0
File: list.js Project: lihaso/one
 success: function(request, response){
   OpenNebula.Action.clear_cache("VMTEMPLATE");
   Notifier.notifyMessage(Locale.tr("VM Template") + ' ' + request.request.data[0][1].name + ' ' + Locale.tr("saved successfully"))
   update_provision_vm_info(vm_id, context);
   button.removeAttr("disabled");
 },
Example #7
0
File: list.js Project: lihaso/one
  function setup_provision_vms_list(context, opts) {
    var provision_vms_datatable = $('.provision_vms_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": "VM.ID" },
          { "mDataProp": "VM.NAME" },
          { "mDataProp": "VM.UID" }
      ],
      "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('<div class="text-center">'+
            '<span class="fa-stack fa-5x" style="color: #dfdfdf">'+
              '<i class="fa fa-cloud fa-stack-2x"></i>'+
              '<i class="fa fa-info-circle fa-stack-1x fa-inverse"></i>'+
            '</span>'+
            '<br>'+
            '<br>'+
            '<span style="font-size: 18px; color: #999">'+
              Locale.tr("There are no Virtual Machines")+
            '</span>'+
            '</div>');
        } else {
          $(".provision_vms_table", context).html('<ul class="provision_vms_ul large-block-grid-3 medium-block-grid-3 small-block-grid-1 text-center"></ul>');
        }

        return true;
      },
      "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
        var data = aData.VM;
        var state = get_provision_vm_state(data);

        $(".provision_vms_ul", context).append('<li>'+
            '<ul class="provision-pricing-table" opennebula_id="'+data.ID+'" datatable_index="'+iDisplayIndexFull+'">'+
              '<li class="provision-title text-left">'+
                '<a class="provision_info_vm_button" style="color:#555" href="#">'+
                '<span class="'+ state.color +'-color" title="'+state.str+'">'+
                  '<i class="fa fa-fw fa-square"/> '+
                '</span>'+
                data.NAME + '</a>'+
              '</li>'+
              '<li class="provision-bullet-item text-left" >'+
                '<i class="fa fa-fw fa-lg fa-laptop"/> '+
                'x'+data.TEMPLATE.CPU+' - '+
                ((data.TEMPLATE.MEMORY > 1000) ?
                  (Math.floor(data.TEMPLATE.MEMORY/1024)+'GB') :
                  (data.TEMPLATE.MEMORY+'MB'))+
                ' - '+
                get_provision_disk_image(data) +
              '</li>'+
              '<li class="provision-bullet-item text-left" >'+
                '<span class="">'+
                  get_provision_ips(data) +
                '</span>'+
              '</li>'+
              '<li class="provision-bullet-item-last text-left" >'+
                '<span class="">'+
                  '<i class="fa fa-fw fa-lg fa-user"/> '+
                  data.UNAME+
                '</span>'+
                '<span class="right">'+
                  Humanize.prettyTimeAgo(data.STIME)+
                '</span>'+
              '</li>'+
            '</ul>'+
          '</li>');

        return nRow;
      }
    });

    $('.provision_list_vms_search', context).on('input',function(){
      provision_vms_datatable.fnFilter( $(this).val() );
    })

    context.on("click", ".provision_vms_list_refresh_button", function(){
      OpenNebula.Action.clear_cache("VM");
      update_provision_vms_datatable(provision_vms_datatable, 0);
      return false;
    });

    $(".provision_list_vms_filter", context).on("change", ".resource_list_select", function(){
      if ($(this).val() != "-2"){
        provision_vms_datatable.fnFilter("^" + $(this).val() + "$", 2, true, false);
      } else {
        provision_vms_datatable.fnFilter("", 2);
      }
    })

    ResourceSelect.insert({
        context: $('.provision_list_vms_filter', context),
        resourceName: 'User',
        initValue: (opts.filter_expression ? opts.filter_expression : "-2"),
        extraOptions: '<option value="-2">' + Locale.tr("ALL") + '</option>',
        triggerChange: true,
        onlyName: true
      });

    context.on("click", ".provision_vms_list_filter_button", function(){
      $(".provision_list_vms_filter", context).fadeIn();
      return false;
    });

    OpenNebula.Action.clear_cache("VM");
    update_provision_vms_datatable(provision_vms_datatable, 0);

    $(document).foundation();
  }
Example #8
0
 context.on("click", ".provision_flows_list_refresh_button", function(){
   OpenNebula.Action.clear_cache("SERVICE");
   update_provision_flows_datatable(provision_flows_datatable, 0);
   return false;
 });
Example #9
0
File: list.js Project: stdweird/one
  function setup_provision_flows_list(context, opts){
    //
    // List Flows
    //

    provision_flows_datatable = $('.provision_flows_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": "DOCUMENT.ID" },
          { "mDataProp": "DOCUMENT.NAME" },
          { "mDataProp": "DOCUMENT.UID" }
      ],
      "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('<div class="text-center">'+
            '<span class="fa-stack fa-5x">'+
              '<i class="fa fa-cloud fa-stack-2x"></i>'+
              '<i class="fa fa-info-circle fa-stack-1x fa-inverse"></i>'+
            '</span>'+
            '<br>'+
            '<br>'+
            '<span>'+
              Locale.tr("Looks like you don't have any Service. Click the button below to get started")+
            '</span>'+
            '<br>'+
            '<br>'+
            '<div class="row">'+
              '<div class="large-6 large-centered columns">'+
                '<a href"#" class="medium large-12 button radius provision_create_flow_button"">'+Locale.tr("Create a new Service")+'</a>'+
              '</div>'+
            '</div>'+
            '<br>'+
            '<br>'+
            '</div>');
        } else {
          $(".provision_flows_table", context).html('<div class="provision_flows_ul large-up-3 medium-up-3 small-up-1"></div>');
        }

        return true;
      },
      "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
        var data = aData.DOCUMENT;
        var body = data.TEMPLATE.BODY;
        var state = get_provision_flow_state(body);
        var start_time = get_provision_flow_start_time(body);

        var roles_li = "";
        if (body.roles) {
          $.each(body.roles, function(index, role) {
            var role_state = get_provision_flow_state(role);
            var rvms = {
              str : (role.nodes ? role.nodes.length : 0) + " / " + role.cardinality ,
              percentage : Math.floor((role.nodes ? role.nodes.length : 0) / role.cardinality)*100
            }

            roles_li +=
              '<li class="provision-bullet-item"">'+
                '<i class="fa fa-fw fa-lg fa-cube"/> '+
                role.name+
                '<span class="right">'+rvms.str+" VMs</span>"+
              '</li>';
          });
        }

        $(".provision_flows_ul", context).append('<div class="column">'+
            '<ul class="provision-pricing-table menu vertical" opennebula_id="'+data.ID+'" datatable_index="'+iDisplayIndexFull+'">'+
              '<li class="provision-title">'+
                '<a class="provision_info_flow_button" href="#">'+
                  '<span class="'+ state.color +'-color right" title="'+ state.str +'">'+
                    '<i class="fa fa-fw fa-lg fa-square"/>'+
                  '</span>'+
                  data.NAME +
                '</a>'+
              '</li>'+
              roles_li +
              '<li class="provision-bullet-item-last">'+
                '<span>'+
                  '<i class="fa fa-fw fa-lg fa-user"/> '+
                  data.UNAME+
                '</span>'+
                '<span class="right">'+
                  (start_time ? Humanize.prettyTimeAgo(start_time) : '-') +
                '</span>'+
              '</li>'+
            '</ul>'+
          '</div>');

        return nRow;
      }
    });

    $('.provision_list_flows_search', context).on('input',function(){
      provision_flows_datatable.fnFilter( $(this).val() );
    })

    context.on("click", ".provision_flows_list_refresh_button", function(){
      OpenNebula.Action.clear_cache("SERVICE");
      update_provision_flows_datatable(provision_flows_datatable, 0);
      return false;
    });

    context.on("click", ".provision_flows_list_search_button", function(){
      $(".provision_list_flows_search", context).fadeIn();
    });

    $(".provision_list_flows_filter", context).on("change", ".resource_list_select", function(){
      if ($(this).val() != "-2"){
        provision_flows_datatable.fnFilter("^" + $(this).val() + "$", 2, true, false);
      } else {
        provision_flows_datatable.fnFilter("", 2);
      }
    })

    ResourceSelect.insert({
        context: $('.provision_list_flows_filter', context),
        resourceName: 'User',
        initValue: (opts.filter_expression ? opts.filter_expression : "-2"),
        extraOptions: '<option value="-2">' + Locale.tr("ALL") + '</option>',
        triggerChange: true,
        onlyName: true
      });

    context.on("click", ".provision_flows_list_filter_button", function(){
      $(".provision_list_flows_filter", context).fadeIn();
      return false;
    });

    OpenNebula.Action.clear_cache("SERVICE");
    update_provision_flows_datatable(provision_flows_datatable, 0);

    //$(document).foundation();
  }
Example #10
0
 $(document).on("click", ".provision_flows_list_button", function(){
   OpenNebula.Action.clear_cache("SERVICE");
   ProvisionFlowsList.show(0);
 });
Example #11
0
 $(document).on("click", ".provision_templates_list_button", function(){
   OpenNebula.Action.clear_cache("VMTEMPLATE");
   ProvisionTemplatesList.show(0);
 });
Example #12
0
 $(document).on("click", ".provision_vms_list_button", function(){
   OpenNebula.Action.clear_cache("VM");
   ProvisionVmsList.show(0);
 });
Example #13
0
 $(document).on("click", ".provision_dashboard_button", function(){
   OpenNebula.Action.clear_cache("VM");
   show_provision_dashboard();
 });
Example #14
0
  function setup_provision_templates_list(context, opts) {
    var provision_templates_datatable = $('.provision_templates_table', context).dataTable({
      "iDisplayLength": 8,
      "sDom" : '<"H">t<"F"lp>',
      "aLengthMenu": [[6, 12, 36, 72], [6, 12, 36, 72]],
      "aaSorting"  : [[0, "desc"]],
      "aoColumnDefs": [
          { "bVisible": false, "aTargets": ["all"]}
      ],
      "aoColumns": [
          { "mDataProp": "VMTEMPLATE.ID" },
          { "mDataProp": "VMTEMPLATE.NAME" },
          { "mDataProp": "VMTEMPLATE.UID" }
      ],
      "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('<div class="text-center">'+
            '<span class="fa-stack fa-5x">'+
              '<i class="fa fa-cloud fa-stack-2x"></i>'+
              '<i class="fa fa-info-circle fa-stack-1x fa-inverse"></i>'+
            '</span>'+
            '<br>'+
            '<br>'+
            '<span>'+
              Locale.tr("There are no templates available")+
              '<br>'+
              Locale.tr("Create a template by saving a running Virtual Machine")+
            '</span>'+
            '</div>');
        } else {
          $(".provision_templates_table", context).html('<div class="provision_templates_ul large-up-3 medium-up-3 small-up-1"></div>');
        }
        return true;
      },
      "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
        var data = aData.VMTEMPLATE;
        var actions_html = "";
        if (Config.isTabActionEnabled("provision-tab", "Template.chmod")) {
          if (data.UID == config['user_id']) {

            if (data.PERMISSIONS.GROUP_U == "1") {
              actions_html += '<a class="provision_confirm_unshare_template_button left" title="'+ Locale.tr("Unshare")+'" href="#"><i class="fa fa-fw fa-lg fa-ban only-on-hover"/></a>';
              actions_html += '<span>' + Locale.tr("SHARED") + '</span>';
            } else {
              actions_html += '<a class="provision_confirm_chmod_template_button left" title="'+ Locale.tr("Share")+'" href="#"><i class="fa fa-fw fa-lg fa-share-alt only-on-hover"/></a>';
            }
          }
        }

        if (Config.isTabActionEnabled("provision-tab", "Template.delete")) {
          actions_html += '<a class="provision_confirm_delete_template_button" title="'+ Locale.tr("Delete")+'"  href="#"><i class="fa fa-fw fa-lg fa-trash-o only-on-hover"/></a>';
        }

        var cpu_txt = "";
        var mem_txt = "";

        if(data.TEMPLATE.CPU){
          cpu_txt = 'x'+TemplateUtils.htmlEncode(data.TEMPLATE.CPU);
        }

        if(data.TEMPLATE.MEMORY){
          if (data.TEMPLATE.MEMORY > 1000){
            mem_txt = Math.floor(data.TEMPLATE.MEMORY/1024)+'GB';
          } else {
            mem_txt = TemplateUtils.htmlEncode(data.TEMPLATE.MEMORY)+'MB';
          }
        }

        $(".provision_templates_ul", context).append('<div class="column">'+
            '<ul class="provision-pricing-table menu vertical" opennebula_id="'+data.ID+'" datatable_index="'+iDisplayIndexFull+'">'+
              '<li class="provision-title" title="'+data.NAME+'">'+
                '<span class="without-link">' +
                  TemplateUtils.htmlEncode(data.NAME) +
                '</span>' +
              '</li>'+
              '<li class="provision-bullet-item">'+
                (TemplateUtils.htmlEncode(data.TEMPLATE.DESCRIPTION) || '')+
              '</li>'+
              '<li class="provision-bullet-item" >'+
                '<i class="fa fa-fw fa-lg fa-laptop"/> '+
                cpu_txt+' - '+
                mem_txt+' - '+
                get_provision_disk_image(data) +
              '</li>'+
              '<li class="provision-bullet-item text-right">'+
                actions_html+
              '</li>'+
              '<li class="provision-bullet-item-last" >'+
                '<span class="">'+
                  '<i class="fa fa-fw fa-lg fa-user"/> '+
                  TemplateUtils.htmlEncode(data.UNAME)+
                '</span>'+
                '<span class="right">'+
                  Humanize.prettyTimeAgo(data.REGTIME)+
                '</span>'+
              '</li>'+
            '</ul>'+
          '</div>');

        return nRow;
      }
    });

    $('.provision_list_templates_search', context).on('input',function(){
      provision_templates_datatable.fnFilter( $(this).val() );
    })

    context.on("click", ".provision_templates_list_refresh_button", function(){
      OpenNebula.Action.clear_cache("VMTEMPLATE");
      $(".provision_confirm_delete_template_div", context).html("");
      update_provision_templates_datatable(provision_templates_datatable, 0);
      return false;
    });

    context.on("click", ".provision_templates_list_search_button", function(){
      $(".provision_list_templates_search", context).fadeIn();
    });

    $(".provision_list_templates_filter", context).on("change", ".resource_list_select", function(){
      if ($(this).val() != "-2"){
        provision_templates_datatable.fnFilter("^" + $(this).val() + "$", 2, true, false);
      } else {
        provision_templates_datatable.fnFilter("", 2);
      }
    })

    ResourceSelect.insert({
        context: $('.provision_list_templates_filter', context),
        resourceName: 'User',
        initValue: (opts.filter_expression ? opts.filter_expression : "-2"),
        extraOptions: '<option value="-2">' + Locale.tr("ALL") + '</option>',
        triggerChange: true,
        onlyName: true
      });

    context.on("click", ".provision_templates_list_filter_button", function(){
      $(".provision_list_templates_filter", context).fadeIn();
      return false;
    });

    if (Config.isTabActionEnabled("provision-tab", "Template.delete")) {
      context.on("click", ".provision_confirm_delete_template_button", function(){
        var ul_context = $(this).parents(".provision-pricing-table");
        var template_id = ul_context.attr("opennebula_id");
        var template_name = $(".provision-title", ul_context).text();

        $(".provision_confirm_delete_template_div", context).html(
          '<div data-closable class="callout large secondary">'+
            '<div class="row">'+
            '<div class="large-12 columns">'+
              '<p>'+
                Locale.tr("Handle with care! This action will immediately destroy the template")+
                ' "' + template_name + '" ' +
                Locale.tr("and the image associated.") +
              '</p>'+
            '</div>'+
            '<div class="large-12 columns">'+
              '<button href"#" class="provision_delete_template_button alert button right" template_id="'+template_id+'">'+Locale.tr("Delete")+'</button>'+
            '</div>'+
            '</div>'+
            '<button class="close-button" aria-label="Dismiss alert" type="button" data-close>' +
              '<span aria-hidden="true">&times;</span>' +
            '</button>' +
          '</div>');
      });

      context.on("click", ".provision_delete_template_button", function(){

        var button = $(this);
        button.attr("disabled", "disabled");

        var template_id = $(this).attr("template_id");

        OpenNebula.Template.delete_recursive({
          timeout: true,
          data : {
            id : template_id
          },
          success: function (){
            $(".provision_templates_list_refresh_button", context).trigger("click");
          },
          error: function (request,error_json, container) {
            Notifier.onError(request, error_json, container);
            $(".provision_templates_list_refresh_button", context).trigger("click");
          }
        })
      });
    }


    if (Config.isTabActionEnabled("provision-tab", "Template.chmod")) {
      context.on("click", ".provision_confirm_chmod_template_button", function(){
        var ul_context = $(this).parents(".provision-pricing-table");
        var template_id = ul_context.attr("opennebula_id");
        var template_name = $(".provision-title", ul_context).text();

        $(".provision_confirm_delete_template_div", context).html(
          '<div data-closable class="callout large secondary">'+
            '<div class="row">'+
              '<div class="large-12 columns">'+
                '<p>'+
                  Locale.tr("The template")+
                  ' "' + template_name + '" ' +
                  Locale.tr("and the image associated will be shared and all the users will be able to instantiate new VMs using this template.") +
                '</p>'+
              '</div>'+
              '<div class="large-12 columns">'+
                '<button href"#" class="provision_chmod_template_button success button right" template_id="'+template_id+'">'+Locale.tr("Share template")+'</button>'+
              '</div>'+
            '</div>'+
            '<button class="close-button" aria-label="Dismiss alert" type="button" data-close>' +
              '<span aria-hidden="true">&times;</span>' +
            '</button>' +
          '</div>');
      });

      context.on("click", ".provision_chmod_template_button", function(){

        var button = $(this);
        button.attr("disabled", "disabled");

        var template_id = $(this).attr("template_id");

        OpenNebula.Template.chmod({
          timeout: true,
          data : {
            id : template_id,
            extra_param: {
              'group_u': 1,
              'recursive' : true
            }
          },
          success: function (){
            $(".provision_templates_list_refresh_button", context).trigger("click");
          },
          error: Notifier.onError
        })
      });

      context.on("click", ".provision_confirm_unshare_template_button", function(){
        var ul_context = $(this).parents(".provision-pricing-table");
        var template_id = ul_context.attr("opennebula_id");
        var template_name = $(".provision-title", ul_context).first().text();

        $(".provision_confirm_delete_template_div", context).html(
          '<div data-closable class="callout large secondary">'+
            '<div class="row">'+
              '<div class="large-12 columns">'+
                '<p>'+
                  Locale.tr("The template")+
                  ' "' + template_name + '" ' +
                  Locale.tr("and the image associated will be unshared and the users will not be able to instantiate new VMs using this template.") +
                '</p>'+
              '</div>'+
              '<div class="large-12 columns">'+
                '<button href"#" class="provision_unshare_template_button success button right" template_id="'+template_id+'">'+Locale.tr("Unshare template")+'</button>'+
              '</div>'+
            '</div>'+
            '<button class="close-button" aria-label="Dismiss alert" type="button" data-close>' +
              '<span aria-hidden="true">&times;</span>' +
            '</button>' +
          '</div>');
      });

      context.on("click", ".provision_unshare_template_button", function(){
        var button = $(this);
        button.attr("disabled", "disabled");

        var template_id = $(this).attr("template_id");

        OpenNebula.Template.chmod({
          timeout: true,
          data : {
            id : template_id,
            extra_param: {
              'group_u': 0,
              'recursive' : true
            }
          },
          success: function (){
            $(".provision_templates_list_refresh_button", context).trigger("click");
          },
          error: Notifier.onError
        })
      });
    }

    OpenNebula.Action.clear_cache("VMTEMPLATE");
    update_provision_templates_datatable(provision_templates_datatable, 0);
    // context.foundation();
  }
Example #15
0
 $("#provision_create_template_refresh_button").click(function(){
   OpenNebula.Action.clear_cache("VMTEMPLATE");
   ProvisionTemplatesList.updateDatatable(provision_vm_instantiate_templates_datatable);
 });
Example #16
0
 context.on("click", ".provision_templates_list_refresh_button", function(){
   OpenNebula.Action.clear_cache("VMTEMPLATE");
   $(".provision_confirm_delete_template_div", context).html("");
   update_provision_templates_datatable(provision_templates_datatable, 0);
   return false;
 });
Example #17
0
 success: function(request, response){
   OpenNebula.Action.clear_cache("VMTEMPLATE");
   Notifier.notifyMessage(Locale.tr("VM Template") + ' ' + template_name + ' ' + Locale.tr("saved successfully"))
 },
Example #18
0
  function setup_provision_flows_list(context, opts){
    //
    // List Flows
    //

    provision_flows_datatable = $(".provision_flows_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": "DOCUMENT.ID" },
          { "mDataProp": "DOCUMENT.NAME" },
          { "mDataProp": "DOCUMENT.UID" }
      ],
      "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("<div class=\"text-center\">"+
            "<span class=\"fa-stack fa-5x\">"+
              "<i class=\"fas fa-cloud fa-stack-2x\"></i>"+
              "<i class=\"fas fa-info-circle fa-stack-1x fa-inverse\"></i>"+
            "</span>"+
            "<br>"+
            "<br>"+
            "<span>"+
              Locale.tr("There are no Services")+
            "</span>"+
            "<br>"+
            "<br>"+
            "</div>");
        } else {
          $(".provision_flows_table", context).html("<div class=\"provision_flows_ul large-up-3 medium-up-3 small-up-1\"></div>");
        }

        return true;
      },
      "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
        var data = aData.DOCUMENT;
        var body = data.TEMPLATE.BODY;
        var state = get_provision_flow_state(body);
        var start_time = get_provision_flow_start_time(body);

        var roles_li = "";
        if (body.roles) {
          $.each(body.roles, function(index, role) {
            var role_state = get_provision_flow_state(role);
            var rvms = {
              str : (role.nodes ? role.nodes.length : 0) + " / " + role.cardinality ,
              percentage : Math.floor((role.nodes ? role.nodes.length : 0) / role.cardinality)*100
            };

            roles_li +=
              "<li class=\"provision-bullet-item\"\">"+
                "<i class=\"fas fa-fw fa-lg fa-cube\"/> "+
                TemplateUtils.htmlEncode(role.name)+
                "<span class=\"right\">"+TemplateUtils.htmlEncode(rvms.str)+" VMs</span>"+
              "</li>";
          });
        }

        $(".provision_flows_ul", context).append("<div class=\"column\">"+
            "<ul class=\"provision-pricing-table menu vertical\" opennebula_id=\""+data.ID+"\" datatable_index=\""+iDisplayIndexFull+"\">"+
              "<li class=\"provision-title\">"+
                "<a class=\"provision_info_flow_button\" href=\"#\">"+
                  "<span class=\""+ state.color +"-color right\" title=\""+ state.str +"\">"+
                    "<i class=\"fas fa-square\"/>"+
                  "</span>"+
                  TemplateUtils.htmlEncode(data.NAME) +
                "</a>"+
              "</li>"+
              roles_li +
              "<li class=\"provision-bullet-item-last\">"+
                "<span>"+
                  "<i class=\"fas fa-fw fa-lg fa-user\"/> "+
                  TemplateUtils.htmlEncode(data.UNAME)+
                "</span>"+
                "<span class=\"right\">"+
                  (start_time ? Humanize.prettyTimeAgo(start_time) : "-") +
                "</span>"+
              "</li>"+
            "</ul>"+
          "</div>");

        return nRow;
      }
    });

    $(".provision_list_flows_search", context).on("input",function(){
      provision_flows_datatable.fnFilter( $(this).val() );
    });

    context.on("click", ".provision_flows_list_refresh_button", function(){
      OpenNebula.Action.clear_cache("SERVICE");
      update_provision_flows_datatable(provision_flows_datatable, 0);
      return false;
    });

    context.on("click", ".provision_flows_list_search_button", function(){
      $(".provision_list_flows_search", context).fadeIn();
    });

    $(".provision_list_flows_filter", context).on("change", ".resource_list_select", function(){
      if ($(this).val() != "-2"){
        provision_flows_datatable.fnFilter("^" + $(this).val() + "$", 2, true, false);
      } else {
        provision_flows_datatable.fnFilter("", 2);
      }
    });

    ResourceSelect.insert({
        context: $(".provision_list_flows_filter", context),
        resourceName: "User",
        initValue: (opts.filter_expression ? opts.filter_expression : "-2"),
        extraOptions: "<option value=\"-2\">" + Locale.tr("ALL") + "</option>",
        triggerChange: true,
        onlyName: true
      });

    context.on("click", ".provision_flows_list_filter_button", function(){
      $(".provision_list_flows_filter", context).fadeIn();
      return false;
    });

    OpenNebula.Action.clear_cache("SERVICE");
    update_provision_flows_datatable(provision_flows_datatable, 0);

    //$(document).foundation();
  }
Example #19
0
  function setup_provision_vms_list(context, opts) {
    var provision_vms_datatable = $(".provision_vms_table", context).dataTable({
      "iDisplayLength": 6,
      "bAutoWidth": false,
      "sDom" : "<\"H\">t<\"F\"lp>",
      "aLengthMenu": [[6, 12, 36, 72], [6, 12, 36, 72]],
      "aaSorting"  : [[0, "desc"]],
      "aoColumnDefs": [
          { "bVisible": false, "aTargets": ["all"]},
          { "sType": "num", "aTargets": [0]}
      ],
      "aoColumns": [
          { "mDataProp": "VM.ID" },
          { "mDataProp": "VM.NAME" },
          { "mDataProp": "VM.UID" }
      ],
      "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("<div class=\"text-center\">"+
            "<span class=\"fa-stack fa-5x\">"+
              "<i class=\"fas fa-cloud fa-stack-2x\"></i>"+
              "<i class=\"fas fa-info-circle fa-stack-1x fa-inverse\"></i>"+
            "</span>"+
            "<br>"+
            "<br>"+
            "<span>"+
              Locale.tr("There are no Virtual Machines")+
            "</span>"+
            "</div>");
        } else {
          $(".provision_vms_table", context).html("<div class=\"provision_vms_ul large-up-3 medium-up-3 small-up-1\"></div>");
        }

        return true;
      },
      "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
        var data = aData.VM;

        if(data == undefined){
          return nRow;
        }

        var state = get_provision_vm_state(data);

        var monitoring = "";
        if(data.MONITORING.GUEST_IP){
          monitoring = "<li class=\"provision-bullet-item\"><span class=\"\"><i class=\"fas fa-fw fa-lg fa-server\"/>" + data.MONITORING.GUEST_IP + "</span></li>";
        }

        $(".provision_vms_ul", context).append("<div class=\"column\">"+
            "<ul class=\"provision-pricing-table menu vertical\" opennebula_id=\""+data.ID+"\" datatable_index=\""+iDisplayIndexFull+"\">"+
              "<li class=\"provision-title\">"+
                "<a class=\"provision_info_vm_button\">"+
                "<span class=\""+ state.color +"-color right\" title=\""+state.str+"\">"+
                  "<i class=\"fas fa-square\"/>"+
                "</span>"+
                data.NAME + "</a>"+
              "</li>"+
              "<li class=\"provision-bullet-item\" >"+
                "<i class=\"fas fa-fw fa-lg fa-laptop\"/> "+
                "x"+data.TEMPLATE.CPU+" - "+
                ((data.TEMPLATE.MEMORY > 1000) ?
                  (Math.floor(data.TEMPLATE.MEMORY/1024)+"GB") :
                  (TemplateUtils.htmlEncode(data.TEMPLATE.MEMORY)+"MB"))+
                " - "+
                get_provision_disk_image(data) +
              "</li>"+
              "<li class=\"provision-bullet-item\" >"+
                "<span class=\"\">"+
                  get_provision_ips(data) +
                "</span>"+
              "</li>"+ monitoring +
              "<li class=\"provision-bullet-item-last\" >"+
                "<span class=\"\">"+
                  "<i class=\"fas fa-fw fa-lg fa-user\"/> "+
                  data.UNAME+
                "</span>"+
                "<span class=\"right\">"+
                  Humanize.prettyTimeAgo(data.STIME)+
                "</span>"+
              "</li>"+
            "</ul>"+
          "</div>");

        return nRow;
      }
    });

    $(".provision_list_vms_search", context).on("input",function(){
      provision_vms_datatable.fnFilter( $(this).val() );
    });

    context.on("click", ".provision_vms_list_refresh_button", function(){
      OpenNebula.Action.clear_cache("VM");
      update_provision_vms_datatable(provision_vms_datatable, 0);
      return false;
    });

    $(".provision_list_vms_filter", context).on("change", ".resource_list_select", function(){
      if ($(this).val() != "-2"){
        provision_vms_datatable.fnFilter("^" + $(this).val() + "$", 2, true, false);
      } else {
        provision_vms_datatable.fnFilter("", 2);
      }
    });

    ResourceSelect.insert({
        context: $(".provision_list_vms_filter", context),
        resourceName: "User",
        initValue: (opts.filter_expression ? opts.filter_expression : "-2"),
        extraOptions: "<option value=\"-2\">" + Locale.tr("ALL") + "</option>",
        triggerChange: true,
        onlyName: true
      });

    context.on("click", ".provision_vms_list_filter_button", function(){
      $(".provision_list_vms_filter", context).fadeIn();
      return false;
    });

    OpenNebula.Action.clear_cache("VM");
    update_provision_vms_datatable(provision_vms_datatable, 0);

    // $(document).foundation();
  }
Example #20
0
 success: function(request, response){
   OpenNebula.Action.clear_cache("SERVICE");
   $(".provision_refresh_info", context).trigger("click");
 },
Example #21
0
        $("#provision_create_flow_template_refresh_button").click(function(){
          OpenNebula.Action.clear_cache("SERVICE_TEMPLATE");
          update_provision_flow_templates_datatable(provision_flow_templates_datatable);

        });