0001-Feature-684-Reorganized-code-regarding-the-wizards.patch

Hector Sanjuan, 06/15/2011 06:01 PM

Download (9.67 KB)

View differences:

src/sunstone/public/js/plugins/templates-tab.js
503 503
              </div>\
504 504
              </fieldset>\
505 505
              </div>\
506
                          <!-- submit -->\
507
                         <fieldset>\
508
                          <div class="form_buttons">\
509
                                <button class="button" id="create_template_form_easy" value="OpenNebula.Template.create">\
510
                                Create\
511
                                </button>\
512
                                <button class="button" id="reset_template_form" type="reset" value="reset">Reset</button>\
513
                          </div>\
514
                        </fieldset>\
515
                </form>\
506
              <!-- submit -->\
507
           <fieldset>\
508
             <div class="form_buttons">\
509
               <button class="button" id="create_template_form_easy" value="OpenNebula.Template.create">\
510
                  Create\
511
               </button>\
512
               <button class="button" id="reset_template_form" type="reset" value="reset">Reset</button>\
513
             </div>\
514
           </fieldset>\
515
        </form>\
516 516
        </div><!--easy mode -->\
517 517
        <div id="manual">\
518 518
                <form>\
......
895 895
        // ui.tab     // anchor element of the selected (clicked) tab
896 896
        // ui.panel   // element, that contains the selected/clicked tab contents
897 897
        // ui.index   // zero-based index of the selected (clicked) tab
898

  
899
        //disable all items
900
        $(items).attr("disabled","disabled");
901
        //hide all mandatory icons
902
        $('.vm_param .man_icon').css("display","none");
903

  
904
        //empty selects
905
        $('div#os_boot_opts select#BOOT').empty();
906
        $('div#disks select#TYPE').empty();
907
        $('div#disks select#BUS').empty();
908

  
909
        //hide options about boot method
910
        $('div#kernel_bootloader',section_os_boot).show();
911
        $('.kernel, .bootloader', $('div#os_boot_opts')).hide();
912
        $('div#os_boot_opts select#BOOT').parent().hide();
913
        //unselect boot method
914
        $('select#boot_method option').removeAttr("selected");
915

  
916
        //hide non common sections
917
        $(section_inputs).hide();
918
        $(section_graphics).hide();
919

  
920
        //Repopulate images select
921
        $('div.vm_section#disks select#IMAGE_ID').html(images_select);
922
        //Repopulate network select
923
        $('div.vm_section#networks select#NETWORK_ID').html(vnetworks_select);
924

  
925

  
898 926
        switch(ui.index){
899 927
        case 0:
900 928
            enable_kvm();
......
935 963
        //~ $enabled.parent('.vm_param').show();
936 964
    //~ }
937 965

  
938
    //Using kvm wizard. Updates mandatory tag, optional tags, disable
939
    //XEN-only (and others) items, enables KVM items
966
    //Using kvm wizard.
940 967
    var enable_kvm = function(){
941 968
        man_class="kvm";
942 969
        opt_class="kvm_opt";
943
        $(xen_items).attr("disabled","disabled");
944
        $(vmware_items).attr("disabled","disabled");
945 970
        $(kvm_items).removeAttr("disabled");
946
        $('.vm_param .man_icon').css("display","none");
947 971
        $('.kvm .man_icon').css("display","inline-block");
948 972

  
949

  
950 973
        //KVM particularities:
951
        // * Add no_type option for disks
952
        // * Add driver default option for boot and select it - hide some fields
974
        // * Add custom disk types
975
        // * Add custom boot options
976
        // * Add custom bus options
977
        // * Show boot options
953 978
        // * Set the raw type to kvm
954
        // * Show the inputs section
979
        // * Show the inputs and graphics section
955 980

  
956 981
        var type_opts =
957 982
            '<option id="no_type" value="" selected="selected">None</option>\
......
971 996
            <option value="network">network</option>';
972 997

  
973 998
        $('div#os_boot_opts select#BOOT').html(boot_opts);
974

  
975

  
976
        $('div#kernel_bootloader',section_os_boot).show();
977
        $('select#boot_method option').removeAttr("selected");
999
        $('div#os_boot_opts select#BOOT').parent().show();
978 1000
        $('select#boot_method option#no_boot').html("Driver default");
979
        $('select#boot_method option').removeAttr("selected");
980
        $('.kernel, .bootloader', $('div#os_boot_opts')).hide();
981 1001

  
982 1002
        var bus_opts =
983 1003
                '<option value="ide">IDE</option>\
......
986 1006

  
987 1007
        $('div#disks select#BUS').html(bus_opts);
988 1008

  
989

  
990 1009
        $('input#TYPE', section_raw).val("kvm");
991 1010

  
992 1011
        $(section_inputs).show();
993 1012
        $(section_graphics).show();
994

  
995

  
996 1013
    };
997 1014

  
998
    // Using XEN wizard. Update mandatory and optional classes, disable
999
    // KVM-only (and other) items, enable XEN fields...
1015
    // Using XEN wizard.
1000 1016
    var enable_xen = function(){
1001 1017
        man_class="xen";
1002 1018
        opt_class="xen_opt";
1003
        $(kvm_items).attr("disabled","disabled");
1004
        $(vmware_items).attr("disabled","disabled");
1005 1019
        $(xen_items).removeAttr("disabled");
1006
        $('.vm_param .man_icon').css("display","none");
1007 1020
        $('.xen .man_icon').css("display","inline-block");
1008 1021

  
1009

  
1010 1022
        // XEN particularities:
1011
        // * Remove no_type option from disks
1023
        // * Add custom disk types
1012 1024
        // * Remove driver default boot method
1025
        // * Add custom bus types
1013 1026
        // * Set the raw section to XEN
1014
        // * Hide the inputs section
1027
        // * Show the graphics section
1015 1028

  
1016 1029
        var type_opts =
1017 1030
            '<option value="disk">Disk</option>\
......
1023 1036

  
1024 1037
        $('div#disks select#TYPE').html(type_opts);
1025 1038

  
1026
        $('div#os_boot_opts select#BOOT').empty();
1027

  
1028
        $('div#kernel_bootloader',section_os_boot).show();
1029
        $('select#boot_method option:selected').removeAttr("selected");
1030 1039
        $('select#boot_method option#no_boot').html("Please choose");
1031
        $('.kernel, .bootloader', $('div#os_boot_opts')).hide();
1032 1040

  
1033 1041
        var bus_opts =
1034 1042
                '<option value="ide">IDE</option>\
......
1037 1045
        $('div#disks select#BUS').html(bus_opts);
1038 1046

  
1039 1047
        $('input#TYPE', section_raw).val("xen");
1040
        $(section_inputs).hide(); //not present for xen
1041 1048
        $(section_graphics).show();
1042

  
1043 1049
    };
1044 1050

  
1051
    //VMWare wizard
1045 1052
    var enable_vmware = function() {
1046 1053
        man_class="vmware";
1047 1054
        opt_class="vmware_opt";
1048
        $(xen_items).attr("disabled","disabled");
1049
        $(kvm_items).attr("disabled","disabled");
1050 1055
        $(vmware_items).removeAttr("disabled");
1051
        $('.vm_param .man_icon').css("display","none");
1052 1056
        $('.vmware .man_icon').css("display","inline-block");
1053 1057

  
1054 1058
        //VMWARE particularities
1055
        // * Add no_type option for disks
1056
        // * Set the raw type to kvm
1057
        // * Hide the inputs and graphics section
1058
        // * Hide boot method
1059
        // * Add custom disk types
1060
        // * Hide boot method field
1061
        // * Add custom bus types
1062
        // * Set the raw type to vmware
1063

  
1059 1064
        var type_opts =
1060 1065
            '<option value="file" selected="selected">File</option>\
1061 1066
             <option value="cdrom">CD-ROM</option>\
1062 1067
             <option value="block">Block</option>';
1063 1068

  
1064
        $('div#os_boot_opts select#BOOT').empty();
1065

  
1066
        $('div#disks select#BOOT').empty();
1069
        $('div#disks select#TYPE').html(type_opts);
1067 1070

  
1068
        $('select#boot_method option').removeAttr("selected");
1069
        $('select#boot_method option#no_boot').html("Driver default");
1070
        $('select#boot_method option').removeAttr("selected");
1071
        $('.kernel, .bootloader', $('div#os_boot_opts')).hide();
1071
        $('div#kernel_bootloader',section_os_boot).hide();
1072 1072

  
1073 1073
        var bus_opts =
1074 1074
                '<option value="ide">IDE</option>\
......
1076 1076

  
1077 1077
        $('div#disks select#BUS').html(bus_opts);
1078 1078

  
1079

  
1080 1079
        $('input#TYPE', section_raw).val("vmware");
1081

  
1082
        $(section_inputs).hide();
1083
        $(section_graphics).hide();
1084

  
1085
        $('div#kernel_bootloader',section_os_boot).hide();
1086
        $('.kernel, .bootloader', $('div#os_boot_opts')).hide();
1087 1080
    }
1088 1081

  
1089 1082
    //This function checks that all mandatory items within a section
......
1668 1661

  
1669 1662
    // Enhace buttons
1670 1663
    $('#create_template_dialog button').button();
1671
    // Setup tips200
1664

  
1665
    // Re-Setup tips
1672 1666
    setupTips($('#create_template_dialog'));
1673 1667

  
1674 1668
    //Enable different icon for folded/unfolded categories
......
1704 1698
    var opt_class=".kvm_opt";
1705 1699
    var man_class=".kvm";
1706 1700

  
1707
    enable_kvm(); //enable all kvm options
1701
    vmTabChange(0,{index : 0}); //enable kvm
1708 1702

  
1709 1703
    //Fold/unfold all sections button
1710 1704
    $('#fold_unfold_vm_params').toggle(
......
1899 1893
    initCheckAllBoxes(dataTable_templates);
1900 1894
    tableCheckboxesListener(dataTable_templates);
1901 1895
    templateInfoListener();
1902

  
1903 1896
})
1904
-