You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by je...@apache.org on 2014/09/04 00:13:27 UTC

git commit: updated refs/heads/master to 801a986

Repository: cloudstack
Updated Branches:
  refs/heads/master 5811ebeee -> 801a98617


CLOUDSTACK-7483: UI > instance page, template page > hide "Original XS Version is 6.1+" field when OS Type is not Windows since property jsonObj.details.hypervisortoolsversion only applies to Windows.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/801a9861
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/801a9861
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/801a9861

Branch: refs/heads/master
Commit: 801a98617c4fbec46c9fab65a9f05608f5574991
Parents: 5811ebe
Author: Jessica Wang <je...@apache.org>
Authored: Wed Sep 3 15:11:50 2014 -0700
Committer: Jessica Wang <je...@apache.org>
Committed: Wed Sep 3 15:13:14 2014 -0700

----------------------------------------------------------------------
 ui/scripts/instances.js | 105 ++++++++++-------
 ui/scripts/templates.js | 265 +++++++++++++++++++++++++++----------------
 2 files changed, 232 insertions(+), 138 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/801a9861/ui/scripts/instances.js
----------------------------------------------------------------------
diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js
index 7205999..6870f5b 100644
--- a/ui/scripts/instances.js
+++ b/ui/scripts/instances.js
@@ -15,7 +15,7 @@
 // specific language governing permissions and limitations
 // under the License.
 (function($, cloudStack) {
-    var vmMigrationHostObjs;
+    var vmMigrationHostObjs, ostypeObjs;
 
     var vmSnapshotAction = function(args) {
         var action = {
@@ -1175,25 +1175,27 @@
                                 },
                                 osTypeId: {
                                     label: 'label.os.type',
-                                    select: function(args) {
-                                        $.ajax({
-                                            url: createURL("listOsTypes"),
-                                            dataType: "json",
-                                            async: true,
-                                            success: function(json) {
-                                                var ostypes = json.listostypesresponse.ostype;
-                                                var items = [];
-                                                $(ostypes).each(function() {
-                                                    items.push({
-                                                        id: this.id,
-                                                        description: this.description
-                                                    });
-                                                });
-                                                args.response.success({
-                                                    data: items
-                                                });
-                                            }
+                                    select: function(args) {                                   
+                                    	if (ostypeObjs == undefined) {                                     	
+	                                        $.ajax({
+	                                            url: createURL("listOsTypes"),
+	                                            dataType: "json",
+	                                            async: false,
+	                                            success: function(json) {	                                            	
+	                                            	ostypeObjs = json.listostypesresponse.ostype;	
+	                                            }
+	                                        });
+                                    	}                                    	
+                                    	var items = [];
+                                        $(ostypeObjs).each(function() {
+                                            items.push({
+                                                id: this.id,
+                                                description: this.description
+                                            });
                                         });
+                                        args.response.success({
+                                            data: items
+                                        });                                    	
                                     }
                                 },
                                 isPublic: {
@@ -1685,7 +1687,32 @@
                             }
                             
                             if ('instances' in args.context && args.context.instances[0].hypervisor != 'XenServer') {
-                          	  hiddenFields.push('xenserverToolsVersion61plus');
+                          	    hiddenFields.push('xenserverToolsVersion61plus');
+                            }
+                            
+                            if ('instances' in args.context && args.context.instances[0].guestosid != undefined) {                        
+                            	if (ostypeObjs == undefined) {
+	                            	$.ajax({
+	                                    url: createURL("listOsTypes"),
+	                                    dataType: "json",
+	                                    async: false,
+	                                    success: function(json) {	                                    	
+	                                    	ostypeObjs = json.listostypesresponse.ostype;		                                    	
+	                                    }
+	                                });
+                            	}                            	
+                            	if (ostypeObjs != undefined) {
+                            		var ostypeName;
+                            		for (var i = 0; i < ostypeObjs.length; i++) {
+                            			if (ostypeObjs[i].id == args.context.instances[0].guestosid) {                            				
+                            				ostypeName = ostypeObjs[i].description;
+                            				break;
+                            			}
+                            		}                            		
+                            		if (ostypeName == undefined || ostypeName.indexOf("win") == -1) {                            			
+                            			hiddenFields.push('xenserverToolsVersion61plus');
+                            		}                            		
+                            	}
                             }
                             
                             if (!args.context.instances[0].publicip) {
@@ -1743,24 +1770,26 @@
                             guestosid: {
                                 label: 'label.os.type',
                                 isEditable: true,
-                                select: function(args) {
-                                    $.ajax({
-                                        url: createURL("listOsTypes"),
-                                        dataType: "json",
-                                        async: true,
-                                        success: function(json) {
-                                            var ostypes = json.listostypesresponse.ostype;
-                                            var items = [];
-                                            $(ostypes).each(function() {
-                                                items.push({
-                                                    id: this.id,
-                                                    description: this.description
-                                                });
-                                            });
-                                            args.response.success({
-                                                data: items
-                                            });
-                                        }
+                                select: function(args) {                                
+                                    if (ostypeObjs == undefined) {                                	
+	                                	$.ajax({
+	                                        url: createURL("listOsTypes"),
+	                                        dataType: "json",
+	                                        async: false,
+	                                        success: function(json) {	                                       
+	                                        	ostypeObjs = json.listostypesresponse.ostype;	 
+	                                        }
+	                                    });
+                                    }                                    
+                                    var items = [];
+                                    $(ostypeObjs).each(function() {
+                                        items.push({
+                                            id: this.id,
+                                            description: this.description
+                                        });
+                                    });
+                                    args.response.success({
+                                        data: items
                                     });
                                 }
                             },

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/801a9861/ui/scripts/templates.js
----------------------------------------------------------------------
diff --git a/ui/scripts/templates.js b/ui/scripts/templates.js
index 3e048cc..cef6a2a 100644
--- a/ui/scripts/templates.js
+++ b/ui/scripts/templates.js
@@ -15,7 +15,8 @@
 // specific language governing permissions and limitations
 // under the License.
 (function(cloudStack, $) {
-
+	var ostypeObjs;
+	
     cloudStack.sections.templates = {
         title: 'label.menu.templates',
         id: 'templates',
@@ -407,17 +408,19 @@
                                     osTypeId: {
                                         label: 'label.os.type',
                                         docID: 'helpRegisterTemplateOSType',
-                                        select: function(args) {
-                                            $.ajax({
-                                                url: createURL("listOsTypes"),
-                                                dataType: "json",
-                                                async: true,
-                                                success: function(json) {
-                                                    var items = json.listostypesresponse.ostype;
-                                                    args.response.success({
-                                                        data: items
-                                                    });
-                                                }
+                                        select: function(args) {                                        	
+                                        	if (ostypeObjs == undefined) {
+	                                            $.ajax({
+	                                                url: createURL("listOsTypes"),
+	                                                dataType: "json",
+	                                                async: false,
+	                                                success: function(json) {	                                                	
+	                                                	ostypeObjs = json.listostypesresponse.ostype;	                                                    
+	                                                }
+	                                            });
+                                        	}                                        	
+                                        	args.response.success({
+                                                data: ostypeObjs
                                             });
                                         }
                                     },
@@ -624,6 +627,7 @@
                                             name: item.name,
                                             description: item.description,
                                             hypervisor: item.hypervisor,
+                                            ostypeid: item.ostypeid,
                                             zones: item.zonename,
                                             zoneids: [item.zoneid]
                                         });
@@ -844,7 +848,32 @@
                                     if ('templates' in args.context && args.context.templates[0].hypervisor != 'XenServer') {
                                         hiddenFields.push('xenserverToolsVersion61plus');
                                     }
-                                    
+                                                                      
+                                    if ('templates' in args.context && args.context.templates[0].ostypeid != undefined) {
+                                    	if (ostypeObjs == undefined) {
+        	                            	$.ajax({
+        	                                    url: createURL("listOsTypes"),
+        	                                    dataType: "json",
+        	                                    async: false,
+        	                                    success: function(json) {	                                    	
+        	                                    	ostypeObjs = json.listostypesresponse.ostype;		                                    	
+        	                                    }
+        	                                });
+                                    	}                            	
+                                    	if (ostypeObjs != undefined) {
+                                    		var ostypeName;
+                                    		for (var i = 0; i < ostypeObjs.length; i++) {
+                                    			if (ostypeObjs[i].id == args.context.templates[0].ostypeid) {                            				
+                                    				ostypeName = ostypeObjs[i].description;
+                                    				break;
+                                    			}
+                                    		}                            		
+                                    		if (ostypeName == undefined || ostypeName.indexOf("win") == -1) {                            			
+                                    			hiddenFields.push('xenserverToolsVersion61plus');
+                                    		}                            		
+                                    	}
+                                    }
+                                                                       
                                     return hiddenFields;
                                 },
 
@@ -935,23 +964,25 @@
                                         label: 'label.os.type',
                                         isEditable: true,
                                         select: function(args) {
-                                            $.ajax({
-                                                url: createURL("listOsTypes"),
-                                                dataType: "json",
-                                                async: true,
-                                                success: function(json) {
-                                                    var ostypes = json.listostypesresponse.ostype;
-                                                    var items = [];
-                                                    $(ostypes).each(function() {
-                                                        items.push({
-                                                            id: this.id,
-                                                            description: this.description
-                                                        });
-                                                    });
-                                                    args.response.success({
-                                                        data: items
-                                                    });
-                                                }
+                                        	if (ostypeObjs == undefined) {
+	                                            $.ajax({
+	                                                url: createURL("listOsTypes"),
+	                                                dataType: "json",
+	                                                async: false,
+	                                                success: function(json) {	                                                	
+	                                                	ostypeObjs = json.listostypesresponse.ostype;	                                                   
+	                                                }
+	                                            });
+                                        	}                                        	
+                                        	var items = [];
+                                            $(ostypeObjs).each(function() {
+                                                items.push({
+                                                    id: this.id,
+                                                    description: this.description
+                                                });
+                                            });
+                                            args.response.success({
+                                                data: items
                                             });
                                         }
                                     },
@@ -1190,6 +1221,31 @@
                                                 if ('templates' in args.context && args.context.templates[0].hypervisor != 'XenServer') {
                                                     hiddenFields.push('xenserverToolsVersion61plus');
                                                 }
+                                                                                               
+                                                if ('templates' in args.context && args.context.templates[0].ostypeid != undefined) {
+                                                	if (ostypeObjs == undefined) {
+                    	                            	$.ajax({
+                    	                                    url: createURL("listOsTypes"),
+                    	                                    dataType: "json",
+                    	                                    async: false,
+                    	                                    success: function(json) {	                                    	
+                    	                                    	ostypeObjs = json.listostypesresponse.ostype;		                                    	
+                    	                                    }
+                    	                                });
+                                                	}                            	
+                                                	if (ostypeObjs != undefined) {
+                                                		var ostypeName;
+                                                		for (var i = 0; i < ostypeObjs.length; i++) {
+                                                			if (ostypeObjs[i].id == args.context.templates[0].ostypeid) {                            				
+                                                				ostypeName = ostypeObjs[i].description;
+                                                				break;
+                                                			}
+                                                		}                            		
+                                                		if (ostypeName == undefined || ostypeName.indexOf("win") == -1) {                            			
+                                                			hiddenFields.push('xenserverToolsVersion61plus');
+                                                		}                            		
+                                                	}
+                                                }                                         
                                                 
                                                 return hiddenFields;
                                             },
@@ -1297,24 +1353,26 @@
                                                 ostypeid: {
                                                     label: 'label.os.type',
                                                     isEditable: true,
-                                                    select: function(args) {
-                                                        $.ajax({
-                                                            url: createURL("listOsTypes"),
-                                                            dataType: "json",
-                                                            async: true,
-                                                            success: function(json) {
-                                                                var ostypes = json.listostypesresponse.ostype;
-                                                                var items = [];
-                                                                $(ostypes).each(function() {
-                                                                    items.push({
-                                                                        id: this.id,
-                                                                        description: this.description
-                                                                    });
-                                                                });
-                                                                args.response.success({
-                                                                    data: items
-                                                                });
-                                                            }
+                                                    select: function(args) {                                                    
+                                                    	if (ostypeObjs == undefined) {      
+	                                                        $.ajax({
+	                                                            url: createURL("listOsTypes"),
+	                                                            dataType: "json",
+	                                                            async: false,
+	                                                            success: function(json) {
+	                                                            	ostypeObjs = json.listostypesresponse.ostype;	                                                                
+	                                                            }
+	                                                        });
+                                                    	}                                                    
+                                                    	var items = [];
+                                                        $(ostypeObjs).each(function() {
+                                                            items.push({
+                                                                id: this.id,
+                                                                description: this.description
+                                                            });
+                                                        });
+                                                        args.response.success({
+                                                            data: items
                                                         });
                                                     }
                                                 },
@@ -1510,24 +1568,26 @@
                                             required: true
                                         },
                                         select: function(args) {
-                                            $.ajax({
-                                                url: createURL("listOsTypes"),
-                                                dataType: "json",
-                                                async: true,
-                                                success: function(json) {
-                                                    var osTypeObjs = json.listostypesresponse.ostype;
-                                                    var items = [];
-                                                    //items.push({id: "", description: "None"}); //shouldn't have None option when bootable is checked
-                                                    $(osTypeObjs).each(function() {
-                                                        items.push({
-                                                            id: this.id,
-                                                            description: this.description
-                                                        });
-                                                    });
-                                                    args.response.success({
-                                                        data: items
-                                                    });
-                                                }
+                                        	if (ostypeObjs == undefined) {   
+	                                            $.ajax({
+	                                                url: createURL("listOsTypes"),
+	                                                dataType: "json",
+	                                                async: false,
+	                                                success: function(json) {
+	                                                    osTypeObjs = json.listostypesresponse.ostype;	                                                    
+	                                                }
+	                                            });
+                                        	}
+                                        	var items = [];
+                                            //items.push({id: "", description: "None"}); //shouldn't have None option when bootable is checked
+                                            $(osTypeObjs).each(function() {
+                                                items.push({
+                                                    id: this.id,
+                                                    description: this.description
+                                                });
+                                            });
+                                            args.response.success({
+                                                data: items
                                             });
                                         }
                                     },
@@ -1703,6 +1763,7 @@
                                             id: item.id,
                                             name: item.name,
                                             description: item.description,
+                                            ostypeid: item.ostypeid,
                                             zones: item.zonename,
                                             zoneids: [item.zoneid]
                                         });
@@ -1930,23 +1991,25 @@
                                         label: 'label.os.type',
                                         isEditable: true,
                                         select: function(args) {
-                                            $.ajax({
-                                                url: createURL("listOsTypes"),
-                                                dataType: "json",
-                                                async: true,
-                                                success: function(json) {
-                                                    var ostypes = json.listostypesresponse.ostype;
-                                                    var items = [];
-                                                    $(ostypes).each(function() {
-                                                        items.push({
-                                                            id: this.id,
-                                                            description: this.description
-                                                        });
-                                                    });
-                                                    args.response.success({
-                                                        data: items
-                                                    });
-                                                }
+                                        	if (ostypeObjs == undefined) {   
+	                                            $.ajax({
+	                                                url: createURL("listOsTypes"),
+	                                                dataType: "json",
+	                                                async: false,
+	                                                success: function(json) {
+	                                                	ostypeObjs = json.listostypesresponse.ostype;	                                                   
+	                                                }
+	                                            });
+                                        	}
+                                        	var items = [];
+                                            $(ostypeObjs).each(function() {
+                                                items.push({
+                                                    id: this.id,
+                                                    description: this.description
+                                                });
+                                            });
+                                            args.response.success({
+                                                data: items
                                             });
                                         }
                                     },
@@ -2222,24 +2285,26 @@
                                                     label: 'label.os.type',
                                                     isEditable: true,
                                                     select: function(args) {
-                                                        $.ajax({
-                                                            url: createURL("listOsTypes"),
-                                                            dataType: "json",
-                                                            async: true,
-                                                            success: function(json) {
-                                                                var ostypes = json.listostypesresponse.ostype;
-                                                                var items = [];
-                                                                $(ostypes).each(function() {
-                                                                    items.push({
-                                                                        id: this.id,
-                                                                        description: this.description
-                                                                    });
-                                                                });
-                                                                args.response.success({
-                                                                    data: items
-                                                                });
-                                                            }
+                                                    	if (ostypeObjs == undefined) {  
+	                                                        $.ajax({
+	                                                            url: createURL("listOsTypes"),
+	                                                            dataType: "json",
+	                                                            async: false,
+	                                                            success: function(json) {
+	                                                            	ostypeObjs = json.listostypesresponse.ostype;	                                                                
+	                                                            }
+	                                                        });
+                                                    	}
+                                                    	var items = [];
+                                                        $(ostypeObjs).each(function() {
+                                                            items.push({
+                                                                id: this.id,
+                                                                description: this.description
+                                                            });
                                                         });
+                                                        args.response.success({
+                                                            data: items
+                                                        });                                                    	
                                                     }
                                                 },