CLOUDSTACK-4831: allow create network by domain admin
(cherry picked from commit 46e4cfd3c3c79e3bc3ec4a49c4ebae6c32240db3)


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

Branch: refs/heads/master
Commit: 57036e379bf5675e97e33eff7c074cf1744a2f3d
Parents: 5109498
Author: Wei Zhou <w.z...@leaseweb.com>
Authored: Wed Oct 30 15:12:32 2013 +0100
Committer: Wei Zhou <w.z...@leaseweb.com>
Committed: Thu Oct 31 11:37:18 2013 +0100

----------------------------------------------------------------------
 ui/scripts/network.js | 55 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/57036e37/ui/scripts/network.js
----------------------------------------------------------------------
diff --git a/ui/scripts/network.js b/ui/scripts/network.js
index 12e5389..fabbe1c 100755
--- a/ui/scripts/network.js
+++ b/ui/scripts/network.js
@@ -536,6 +536,48 @@
                                     },
                                     networkDomain: {
                                         label: 'label.network.domain'
+                                    },
+                                    domain: {
+                                        label: 'label.domain',
+                                        select: function(args) {
+                                            var items = [];
+                                            $.ajax({
+                                                url: 
createURL("listDomains&listAll=true"),
+                                                dataType: "json",
+                                                async: false,
+                                                success: function(json) {
+                                                    var items = [];
+                                                    items.push({
+                                                        id: "",
+                                                        description: ""
+                                                    });
+                                                    var domainObjs = 
json.listdomainsresponse.domain;
+                                                    
$(domainObjs).each(function() {
+                                                        items.push({
+                                                            id: this.id,
+                                                            description: 
this.path
+                                                        });
+                                                    });
+                                                    args.response.success({
+                                                        data: items
+                                                    });
+                                                }
+                                            });
+                                            args.$select.change(function() {
+                                                var $form = 
$(this).closest('form');
+                                                if ($(this).val() == "") {
+                                                    
$form.find('.form-item[rel=account]').hide();
+                                                } else {
+                                                    
$form.find('.form-item[rel=account]').css('display', 'inline-block');
+                                                }
+                                            });
+                                        },
+                                    },
+                                    account: {
+                                        label: 'label.account',
+                                        validation: {
+                                            required: true
+                                        },
                                     }
                                 }
                             },
@@ -575,6 +617,19 @@
                                     });
                                 }
 
+                                if 
(args.$form.find('.form-item[rel=domain]').css("display") != "none") {
+                                    if (args.data.domain != null && 
args.data.domain.length > 0) {
+                                        $.extend(dataObj, {
+                                            domainid: args.data.domain
+                                        });
+                                    }
+                                    if (args.data.account != null && 
args.data.account.length > 0) {
+                                        $.extend(dataObj, {
+                                            account: args.data.account
+                                        });
+                                    }
+                                }
+
                                 $.ajax({
                                     url: createURL('createNetwork'),
                                     data: dataObj,

Reply via email to