← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19520: support redirectUris in add/edit oauth2 client UI

 

------------------------------------------------------------
revno: 19520
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-06-25 16:01:17 +0700
message:
  support redirectUris in add/edit oauth2 client UI
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/javascripts/oauth2Clients.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/oAuth2client.vm


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties	2015-06-25 07:57:12 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties	2015-06-25 09:01:17 +0000
@@ -137,4 +137,5 @@
 name=Name
 client_id=Client ID
 client_secret=Client Secret
-grant_types=Grant Types
\ No newline at end of file
+grant_types=Grant Types
+redirect_uris=Redirect URIs
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/javascripts/oauth2Clients.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/javascripts/oauth2Clients.js	2015-06-25 07:57:12 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/javascripts/oauth2Clients.js	2015-06-25 09:01:17 +0000
@@ -37,6 +37,10 @@
     if( o.grantTypes.indexOf('authorization_code') != -1 ) {
       $('#gtAuthorizationCode').attr('checked', true);
     }
+
+    o.redirectUris.forEach(function(el) {
+      $('<option/>').attr('value', el).text(el).appendTo('#redirectUris');
+    });
   },
   toJson: function() {
     var o = {};
@@ -59,6 +63,10 @@
       o.grantTypes.push("authorization_code");
     }
 
+    $("#redirectUris").children().each(function(idx, el) {
+      o.redirectUris.push($(el).val());
+    });
+
     return o;
   },
   getUuid: function() {

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/oAuth2client.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/oAuth2client.vm	2015-06-25 07:57:12 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/oAuth2client.vm	2015-06-25 09:01:17 +0000
@@ -26,6 +26,7 @@
 
     $('#clientForm').submit(function(e) {
       var o = OAuth2Service.toJson();
+      console.log(o);
 
       OAuth2Service.save(o, "$!id").then(function() {
         location.href = "systemOAuth2Clients.action";
@@ -33,6 +34,18 @@
 
       e.preventDefault();
     })
+
+    $('#addRedirectUri').on('click', function() {
+      var redirectUri = $('#redirectUri').val();
+
+      if( redirectUri && redirectUri.length > 0 ) {
+        $('<option/>').attr('value', redirectUri).text(redirectUri).appendTo('#redirectUris');
+      }
+    });
+
+    $('#removeRedirectUri').on('click', function() {
+      $('#redirectUris option:selected').remove();
+    });
   });
 </script>
 
@@ -67,6 +80,20 @@
         <input type="checkbox" id="gtAuthorizationCode" name="gtAuthorizationCode">Authorization Code<br/>
       </td>
     </tr>
+    <tr>
+      <td><label for="name">$i18n.getString( "redirect_uris" )</label></td>
+      <td>
+        <input id="redirectUri" type="text" value="https://";>
+        <button type="button" id="addRedirectUri" style="height: 22px;"><i class="fa fa-plus"></i> Add</button>
+        <button type="button" id="removeRedirectUri" style="height: 22px;"><i class="fa fa-minus"></i> Remove</button>
+      </td>
+    </tr>
+    <tr>
+      <td></td>
+      <td>
+        <select id="redirectUris" multiple></select>
+      </td>
+    </tr>
   </table>
 
   #if( $id )