Revision 022e018a

View differences:

src/sunstone/public/js/plugins/clusters-tab.js
175 175
var datastore_row_hash      = {};
176 176

  
177 177
// Prepares the cluster creation dialog
178
function setupCreateClusterDialog(datatable_filter){
178
function setupCreateClusterDialog(){
179 179

  
180 180
    $create_cluster_dialog = $('div#create_cluster_dialog');
181 181
    var dialog = $create_cluster_dialog;
182 182

  
183 183
    dialog.html(create_cluster_tmpl);
184 184
    var height = Math.floor($(window).height()*0.8); //set height to a percentage of the window
185
    //dialog.dialog({
186
    //    autoOpen: false,
187
    //    modal: true,
188
    //    height: height,
189
    //    width: 'auto'
190
    //});
191
    dialog.addClass("reveal-modal large");
192 185

  
193
    //Enable tabs
194
    //$('#cluster_create_tabs',dialog).tabs({});
186
    dialog.addClass("reveal-modal large");
195 187

  
196 188
    //  ------- Create the dialog datatables ------------
197 189
    dataTable_cluster_hosts = $("#datatable_cluster_hosts", dialog).dataTable({
......
217 209
      dataTable_cluster_hosts.fnFilter( $(this).val() );
218 210
    })
219 211

  
220
    //preload it
221
    //dataTable_cluster_hosts.fnClearTable();
222

  
223
    //dataTable_cluster_hosts.fnFilter( datatable_filter, 3, true); // Only show no assigned resources
224
    //addElement([
225
    //    spinner,
226
    //    '','','','','','','','','','','',''],dataTable_cluster_hosts);
227

  
228 212
    dataTable_cluster_vnets = $("#datatable_cluster_vnets", dialog).dataTable({
229 213
        "sDom" : '<"H">t<"F"p>',
230 214
        "oColVis": {
......
248 232
      dataTable_cluster_vnets.fnFilter( $(this).val() );
249 233
    })
250 234

  
251
    //preload it
252
    //dataTable_cluster_vnets.fnClearTable();
253
    //dataTable_cluster_vnets.fnFilter( datatable_filter, 5, true); // Only show no assigned resources
254
    //addElement([
255
    //    spinner,
256
    //    '','','','','','','','','','','',''],dataTable_cluster_vnets);
257

  
258 235
    dataTable_cluster_datastores = $("#datatable_cluster_datastores", dialog).dataTable({
259 236
        "sDom" : '<"H">t<"F"p>',
260 237
        "oColVis": {
......
278 255
      dataTable_cluster_datastores.fnFilter( $(this).val() );
279 256
    })
280 257

  
281
    //preload it
282
    //dataTable_cluster_datastores.fnClearTable();
283
    //dataTable_cluster_datastores.fnFilter( datatable_filter, 5, true); // Only show no assigned resources
284
    //addElement([
285
    //    spinner,
286
    //    '','','','','','','','','','','',''],dataTable_cluster_datastores);
287

  
288 258
    //  ------- End of create the dialog datatables ------------
289 259

  
290 260
    // Add listener to row select action
......
500 470

  
501 471
// Open creation dialogs
502 472
function popUpCreateClusterDialog(){
473

  
474
    filter_expr = "-" ;
475

  
503 476
    if ($create_cluster_dialog)
504 477
    {
505 478
      $create_cluster_dialog.remove();
......
508 481

  
509 482
    reset_counters;
510 483

  
511
    setupCreateClusterDialog("-");
484
    setupCreateClusterDialog();
512 485

  
513 486
    // Activate create button
514 487
    $('#create_cluster_submit',$create_cluster_dialog).show();
......
520 493
    Sunstone.runAction("ClusterVN.list");
521 494
    Sunstone.runAction("ClusterDS.list");
522 495
    $create_cluster_dialog.reveal();
496

  
523 497
    return false;
524 498
}
525 499

  
......
545 519
    }
546 520

  
547 521
    // Get proper cluster_id
548
    var cluster_id   = ""+selected_nodes[0];
522
    cluster_id   = ""+selected_nodes[0];
549 523
    var cluster_name = "";
550 524

  
551 525
    var node  = $('tbody input.check_item:checked',dataTable_clusters);
552 526

  
553 527
    $.each(node,function(){
554 528
        cluster_name = $('td', $(this).closest("tr"))[2].innerHTML;
555

  
556 529
    });
557 530

  
558
    var filter_expr = "-|"+cluster_name;
531
    filter_expr = "-|"+cluster_name;
559 532

  
560
    setupCreateClusterDialog(filter_expr);
533
    setupCreateClusterDialog();
561 534

  
562 535
    Sunstone.runAction("ClusterHost.list");
563 536
    Sunstone.runAction("ClusterVN.list");
......
566 539

  
567 540
    $('#create_cluster_dialog').attr('title','Update Cluster');
568 541

  
569
    Sunstone.runAction("Cluster.show_to_update", cluster_id);
570

  
571 542
    return false;
572 543

  
573 544
}
......
610 581
  // Select hosts belonging to the cluster
611 582
  if (host_ids)
612 583
  {
584
    var rows = $("#datatable_cluster_hosts").dataTable().fnGetNodes();
585

  
613 586
    for (var i = 0; i < host_ids.length; i++)
614 587
    {
615
      var rows = $("#datatable_cluster_hosts").dataTable().fnGetNodes();
616

  
617 588
      for(var j=0;j<rows.length;j++){
618 589
        var current_row = $(rows[j]);
619 590
        var row_host_id = $(rows[j]).find("td:eq(0)").html();
......
623 594
        {
624 595
          if (row_host_id == host_ids[i])
625 596
          {
626
              rows[j].click();
627
              //selected_hosts_list[row_host_id]=1;
628
              //host_row_hash[row_host_id]=current_row;
629
              //current_row.children().each(function(){$(this).addClass('markrow');});
630
              //$('div#selected_hosts_div', dialog).append('<span id="tag_hosts_'+row_host_id+'"><span class="ui-icon ui-icon-close"></span>'+host_name+'</span>');
597
              current_row.click();
631 598
          }
632 599
        }
633 600
      }
......
636 603

  
637 604
  if (vnet_ids)
638 605
  {
606
    var rows = $("#datatable_cluster_vnets").dataTable().fnGetNodes();
639 607
    // Select vnets belonging to the cluster
640 608
    for (var i = 0; i < vnet_ids.length; i++)
641 609
    {
642
      var rows = $("#datatable_cluster_vnets").dataTable().fnGetNodes();
643

  
644 610
      for(var j=0;j<rows.length;j++){
645 611

  
646 612
        var current_row = $(rows[j]);
......
651 617
        {
652 618
          if (row_vnet_id == vnet_ids[i])
653 619
          {
654
              rows[j].click();
655
              //selected_vnets_list[row_vnet_id]=1;
656
              //vnet_row_hash[row_vnet_id]=current_row;
657
              //current_row.children().each(function(){$(this).addClass('markrow');});
658
              //$('div#selected_vnets_div', dialog).append('<span id="tag_vnets_'+row_vnet_id+'"><span class="ui-icon ui-icon-close"></span>'+vnet_name+'</span>');
620
              current_row.click();
659 621
          }
660 622
        }
661 623
      }
......
664 626

  
665 627
  if (ds_ids)
666 628
  {
629
    var rows = $("#datatable_cluster_datastores").dataTable().fnGetNodes();
667 630
    // Select datastores belonging to the cluster
668 631
    for (var i = 0; i < ds_ids.length; i++)
669 632
    {
670
      var rows = $("#datatable_cluster_datastores").dataTable().fnGetNodes();
671

  
672 633
      for(var j=0;j<rows.length;j++){
673 634

  
674 635
        var current_row      = $(rows[j]);
......
679 640
        {
680 641
          if (row_datastore_id == ds_ids[i])
681 642
          {
682
              rows[j].click();
683
              //selected_datastore_list[row_datastore_id]=1;
684
              //datastore_row_hash[row_datastore_id]=current_row;
685
              //current_row.children().each(function(){$(this).addClass('markrow');});
686
              //$('div#selected_datastores_div', dialog).append('<span id="tag_datastores_'+row_datastore_id+'"><span class="ui-icon ui-icon-close"></span>'+datastore_name+'</span>');
643
              current_row.click();
687 644
          }
688 645
        }
689 646
      }
......
764 721
    "ClusterHost.list" : {
765 722
        type:     "list",
766 723
        call:     OpenNebula.Host.list,
767
        callback: updateClusterHostsView,
724
        callback: function(request,host_list){
725
          updateClusterHostsView(request,host_list);
726
          dataTable_cluster_hosts.fnFilter( filter_expr, 3, true);
727
        },
768 728
        error:    onError
769 729
    },
770 730

  
......
809 769
    "ClusterVN.list" : {
810 770
        type: "list",
811 771
        call: OpenNebula.Network.list,
812
        callback: updateVNetworksView,
772
        callback: function(request,vnet_list){
773
          updateClusterVNetworksView(request,vnet_list);
774
          dataTable_cluster_vnets.fnFilter( filter_expr, 5, true);
775
        },
813 776
        error: onError
814 777
    },
815 778

  
......
822 785
}
823 786

  
824 787
//updates the list of virtual networks for Create dialog
825
function updateVNetworksView(request, network_list){
788
function updateClusterVNetworksView(request, network_list){
826 789
    var network_list_array = [];
827 790

  
828 791
    $.each(network_list,function(){
......
853 816
    "ClusterDS.list" : {
854 817
        type: "list",
855 818
        call: OpenNebula.Datastore.list,
856
        callback: updateDatastoresView,
819
        callback: function(request,ds_list){
820
          updateClusterDatastoresView(request,ds_list);
821
          dataTable_cluster_datastores.fnFilter( filter_expr, 5, true);
822
          Sunstone.runAction("Cluster.show_to_update", cluster_id);
823
        },      
857 824
        error: onError
858 825
    },
859 826

  
......
866 833
}
867 834

  
868 835
//updates the list of datastores for Create dialog
869
function updateDatastoresView(request, list){
836
function updateClusterDatastoresView(request, list){
870 837
    var list_array = [];
871 838

  
872 839
    $.each(list,function(){
873
        list_array.push( datastoreElementArray(this));
840
        if(this.DATASTORE.ID!=0)
841
          list_array.push( datastoreElementArray(this));
874 842
    });
875 843

  
876 844
    updateView(list_array,dataTable_cluster_datastores);
877
    updateDatastoreSelect();
878
    updateInfraDashboard("datastores",list);
879 845
}
880 846

  
881 847
//callback to update the list of datastores for info panel
......
1372 1338
        list_array.push(clusterElementArray(this));
1373 1339
    });
1374 1340

  
1375
    //Remove the menus as we recreate them again.
1376
    //removeClusterMenus();
1377
    //newClusterMenu(list);
1378

  
1379 1341
    updateView(list_array,dataTable_clusters);
1380 1342
    updateClusterSelect();
1381 1343
    //dependency with the infraestructure dashboard plugin
......
1482 1444
            } : ""
1483 1445
    });
1484 1446

  
1485
    //preload it
1486

  
1487
    //addElement([
1488
    //    spinner,
1489
    //    '','','','','','','','','','','',''],dataTable_cluster_hosts_panel);
1490

  
1491 1447
    // Virtual networks datatable
1492 1448

  
1493 1449
    dataTable_cluster_vnets_panel = $("#datatable_cluster_vnets_info_panel", dialog).dataTable({
......
1509 1465
    });
1510 1466

  
1511 1467

  
1512
    //preload it
1513
    //dataTable_cluster_vnets_panel.fnClearTable();
1514
    //addElement([
1515
    //    spinner,
1516
    //    '','','','','','','','','','','',''],dataTable_cluster_vnets_panel);
1517

  
1518 1468
    // Datastores datatable
1519 1469

  
1520 1470
    dataTable_cluster_datastores_panel = $("#datatable_cluster_datastores_info_panel", dialog).dataTable({
......
1536 1486
    });
1537 1487

  
1538 1488

  
1539
    //preload it
1540
    //dataTable_cluster_datastores_panel.fnClearTable();
1541
    //addElement([
1542
    //    spinner,
1543
    //    '','','','','','','','','','','',''],dataTable_cluster_datastores_panel);
1544

  
1545 1489
    // initialize datatables values
1546 1490
    Sunstone.runAction("ClusterHostInfo.list");
1547 1491
    Sunstone.runAction("ClusterVNInfo.list");
......
1797 1741
    return html_code;
1798 1742
};
1799 1743

  
1800
////Removes the clusters from the submenu
1801
//function removeClusterMenus(){
1802
//    var data = dataTable_clusters.fnGetData();
1803
//
1804
//    Sunstone.removeMainTab('cluster_tab_-',true);
1805
//
1806
//    for (var i=0; i < data.length; i++){
1807
//        var id = data[i][1];
1808
//        Sunstone.removeMainTab('cluster_tab_'+id,true);
1809
//    };
1810
//};
1811
//
1812
//// Creates new cluster submenus
1813
//// insert cluster none manually
1814
//function newClusterMenu(list){
1815
//    var cluster_none = {
1816
//        'CLUSTER' : {
1817
//            'NAME' : 'None',
1818
//            'ID' : '-',
1819
//            'DATASTORES' : [],
1820
//            'HOSTS' : [],
1821
//            'VNETS' : []
1822
//        }
1823
//    };
1824
//
1825
//    newClusterMenuElement(cluster_none);
1826
//
1827
//    for (var i=0; i < list.length; i++){
1828
//        newClusterMenuElement(list[i]);
1829
//    };
1830
//    $('div#menu li#li_clusters_tab span').removeClass('ui-icon-circle-minus');
1831
//    $('div#menu li#li_clusters_tab span').addClass('ui-icon-circle-plus');
1832
//};
1833
//
1834
//// Create new cluster menu
1835
//function newClusterMenuElement(element){
1836
//    var cluster = element.CLUSTER;
1837
//
1838
//    //trim long cluster names
1839
//    var menu_name = cluster.NAME.length > 10 ?
1840
//        cluster.NAME.substring(0,9)+'...' : cluster.NAME;
1841
//
1842
//    // Menu object
1843
//    var menu_cluster = {
1844
//        title: menu_name + ' (id ' + cluster.ID + ')',
1845
//        content: clusterTabContent(element),
1846
//        tabClass: 'subTab subsubTab',
1847
//        parentTab: 'clusters_tab'
1848
//
1849
//    };
1850
//
1851
//    // Add to sunstone
1852
//    Sunstone.addMainTab('cluster_tab_'+cluster.ID,menu_cluster,true);
1853
//};
1854

  
1855
// Basicly, we show the hosts/datastore/vnets tab, but before we set
1744
// Basically, we show the hosts/datastore/vnets tab, but before we set
1856 1745
// a filter on the cluster column, so it only shows the cluster we want.
1857 1746
function clusterResourceViewListeners(){
1858 1747
    //hack  the menu selection
......
1948 1837
      dataTable_clusters.fnFilter( $(this).val() );
1949 1838
    })
1950 1839

  
1951
    //preload it
1952
    //dataTable_clusters.fnClearTable();
1953
    //addElement([
1954
    //    spinner,
1955
    //    '','','','',''],dataTable_clusters);
1956 1840
    Sunstone.runAction("Cluster.list");
1957 1841

  
1958 1842
    dialogs_context.append('<div title=\"'+tr("Create cluster")+'\" id="create_cluster_dialog"></div>');
1959 1843

  
1960 1844
    setClusterAutorefresh();
1961

  
1962 1845
    clusterResourceViewListeners();
1963 1846

  
1964 1847
    initCheckAllBoxes(dataTable_clusters);

Also available in: Unified diff