From 2b3e23f6cf7b194c10dabea8504ab0826adf7e0d Mon Sep 17 00:00:00 2001 From: Pranav Saxena Date: Fri, 15 Feb 2013 12:02:26 +0530 Subject: [PATCH 1/4] LDAP front end UI development --- ui/scripts/globalSettings.js | 98 ++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/ui/scripts/globalSettings.js b/ui/scripts/globalSettings.js index e65a00b290c..9ede3135aa4 100644 --- a/ui/scripts/globalSettings.js +++ b/ui/scripts/globalSettings.js @@ -14,6 +14,7 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. + (function(cloudStack) { cloudStack.sections['global-settings'] = { title: 'label.menu.global.settings', @@ -81,6 +82,103 @@ } } }, + + ldapConfiguration:{ + type:'select', + title:'LDAP Configuration', + listView:{ + id:'ldap', + label:'LDAP Configuration', + fields:{ + hostname: {label: 'Hostname'}, + queryfilter: {label: 'Query Filter'}, + searchbase: {label: 'Search Base'}, + port: {label: 'LDAP Port'}, + ssl: { + label: 'SSL' + + + } + + + }, + dataProvider:function(args){ + var data = {}; + listViewDataProvider(args, data); + $.ajax({ + url: createURL(''), + data: data, + success: function(json) { + // var items = json.listhypervisorcapabilitiesresponse.hypervisorCapabilities; + args.response.success({data:items}); + }, + error: function(data) { + args.response.error(parseXMLHttpResponse(data)); + } + }); + }, + + actions: { + add:{ + + label: 'Configure LDAP', + + messages: { + confirm: function(args) { + return 'Do you really want to configure LDAP ? '; + }, + notification: function(args) { + return 'LDAP configured'; + } + }, + + createForm: { + + title: 'Configure LDAP', + fields:{ + name:{label: 'Bind Username' , validation: {required:true} }, + password: {label: 'Bind Password', validation: {required: true },isPassword:true }, + hostname: {label:'Hostname' , validation:{required:true}}, + queryfilter: {label:'Query Filter' , validation: {required:true}}, + searchbase: {label:'SearchBase',validation:{required:true}}, + ssl: { + label:'SSL' , + isBoolean:true, + isChecked:false + // var $form = $(this).closest("form"); + + + }, + port: { label: 'Port' , defaultValue: '389' }, + truststore:{ label:'Trust Store' , isHidden:true }, + truststorepassword:{ label:'Trust Store Password' ,isHidden:true } + + } + + + }, + + + action:function(args) { + var $form = $(this).closest("form"); + if($form.find('.form-item [rel=port]').find('input[ type=checkbox]').is(":checked") ==true) { + $form.find('.form-item[rel=truststore]').attr("isHidden",false); + $form.find('.form-item[rel=truststorepassword]').attr("isHidden",false); + } + + + } + } + + } + + + + } + + + + }, hypervisorCapabilities: { type: 'select', title: 'label.hypervisor.capabilities', From ff9d62a8ed779597e1294937a79f2a47638215e1 Mon Sep 17 00:00:00 2001 From: Pranav Saxena Date: Fri, 15 Feb 2013 17:00:59 +0530 Subject: [PATCH 2/4] LDAP UI front end complete --- ui/scripts/globalSettings.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/ui/scripts/globalSettings.js b/ui/scripts/globalSettings.js index 9ede3135aa4..e9461490b27 100644 --- a/ui/scripts/globalSettings.js +++ b/ui/scripts/globalSettings.js @@ -150,8 +150,8 @@ }, port: { label: 'Port' , defaultValue: '389' }, - truststore:{ label:'Trust Store' , isHidden:true }, - truststorepassword:{ label:'Trust Store Password' ,isHidden:true } + truststore:{ label:'Trust Store' , isHidden:true , dependsOn:'ssl' }, + truststorepassword:{ label:'Trust Store Password' ,isHidden:true , dependsOn:'ssl'} } @@ -160,11 +160,6 @@ action:function(args) { - var $form = $(this).closest("form"); - if($form.find('.form-item [rel=port]').find('input[ type=checkbox]').is(":checked") ==true) { - $form.find('.form-item[rel=truststore]').attr("isHidden",false); - $form.find('.form-item[rel=truststorepassword]').attr("isHidden",false); - } } From d8537a4446b65c8f172e057976511f2750dffcb8 Mon Sep 17 00:00:00 2001 From: Pranav Saxena Date: Fri, 15 Feb 2013 21:12:22 +0530 Subject: [PATCH 3/4] Server side integration for LDAP Configuration --- ui/scripts/globalSettings.js | 45 +++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/ui/scripts/globalSettings.js b/ui/scripts/globalSettings.js index e9461490b27..5f7fb742b2d 100644 --- a/ui/scripts/globalSettings.js +++ b/ui/scripts/globalSettings.js @@ -106,10 +106,10 @@ var data = {}; listViewDataProvider(args, data); $.ajax({ - url: createURL(''), + url: createURL(''), //Need a list LDAP configuration API call which needs to be implemented data: data, success: function(json) { - // var items = json.listhypervisorcapabilitiesresponse.hypervisorCapabilities; + // var items = json.listldapconfigresponse; args.response.success({data:items}); }, error: function(data) { @@ -145,13 +145,11 @@ label:'SSL' , isBoolean:true, isChecked:false - // var $form = $(this).closest("form"); - }, port: { label: 'Port' , defaultValue: '389' }, - truststore:{ label:'Trust Store' , isHidden:true , dependsOn:'ssl' }, - truststorepassword:{ label:'Trust Store Password' ,isHidden:true , dependsOn:'ssl'} + truststore:{ label:'Trust Store' , isHidden:true , dependsOn:'ssl',validation:{required:true} }, + truststorepassword:{ label:'Trust Store Password' ,isHidden:true , dependsOn:'ssl', validation:{required:true}} } @@ -160,6 +158,41 @@ action:function(args) { + var array = []; + array.push("&binddn=" + todb(args.data.name)); + array.push("&bindpass=" + todb(args.data.password)); + array.push("&hostname=" + todb(args.data.hostname)); + array.push("&searchbase=" +todb(args.data.searchbase)); + array.push("&queryfilter=" +todb(args.data.queryfilter)); + array.push("&port=" +todb(args.data.port)); + + if(args.$form.find('.form-item[rel=ssl]').find('input[type=checkbox]').is(':Checked')== true) { + + array.push("&ssl=true"); + if(args.data.truststore != "") + array.push("&truststore=" +todb(args.data.truststore)); + + if(args.data.truststorepassword !="") + array.push("&truststorepass=" +todb(args.data.truststorepassword)); + + } + + else + array.push("&ssl=false"); + + $.ajax({ + url: createURL("ldapConfig" + array.join("")), + dataType: "json", + async: true, + success: function(json) { + var items = json.ldapconfigresponse; + args.response.success({ + data: items + }); + + } + + }); } From bff3d8ac9a0566addeb24d4c4c16ceab99b242b6 Mon Sep 17 00:00:00 2001 From: Pranav Saxena Date: Tue, 19 Feb 2013 16:40:47 +0530 Subject: [PATCH 4/4] LDAP-UI integration code --- ui/scripts/globalSettings.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ui/scripts/globalSettings.js b/ui/scripts/globalSettings.js index 5f7fb742b2d..598c9c542c8 100644 --- a/ui/scripts/globalSettings.js +++ b/ui/scripts/globalSettings.js @@ -97,19 +97,17 @@ ssl: { label: 'SSL' - } - }, dataProvider:function(args){ var data = {}; listViewDataProvider(args, data); $.ajax({ - url: createURL(''), //Need a list LDAP configuration API call which needs to be implemented + url: createURL('ldapConfig&listall=true'), //Need a list LDAP configuration API call which needs to be implemented data: data, success: function(json) { - // var items = json.listldapconfigresponse; + var items = json.ldapconfigresponse.ldapconfig; args.response.success({data:items}); }, error: function(data) { @@ -185,7 +183,7 @@ dataType: "json", async: true, success: function(json) { - var items = json.ldapconfigresponse; + var items = json.ldapconfigresponse.ldapconfig; args.response.success({ data: items });