dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #38220
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19516: UI for OAuth2 clients, wip
------------------------------------------------------------
revno: 19516
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-06-25 10:36:52 +0700
message:
UI for OAuth2 clients, wip
added:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetOAuth2ClientsAction.java
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/systemOAuth2Clients.vm
modified:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/META-INF/dhis/beans.xml
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/struts.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/index.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/settingsMenu.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
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetOAuth2ClientsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetOAuth2ClientsAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetOAuth2ClientsAction.java 2015-06-25 03:36:52 +0000
@@ -0,0 +1,73 @@
+package org.hisp.dhis.settings.action.system;
+
+/*
+ * Copyright (c) 2004-2015, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.oauth2.OAuth2Client;
+import org.hisp.dhis.oauth2.OAuth2ClientService;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class GetOAuth2ClientsAction implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ @Autowired
+ private OAuth2ClientService clientService;
+
+ // -------------------------------------------------------------------------
+ // Input & Output
+ // -------------------------------------------------------------------------
+
+ private List<OAuth2Client> clients;
+
+ public List<OAuth2Client> getClients()
+ {
+ return clients;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ @Override
+ public String execute() throws Exception
+ {
+ clients = new ArrayList<>( clientService.getOAuth2Clients() );
+
+ return SUCCESS;
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/META-INF/dhis/beans.xml 2015-03-31 15:57:18 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/META-INF/dhis/beans.xml 2015-06-25 03:36:52 +0000
@@ -55,11 +55,11 @@
<bean id="org.hisp.dhis.settings.action.system.GetSMTPSettingsAction"
class="org.hisp.dhis.settings.action.system.GetSMTPSettingsAction"
- scope="prototype"/>
+ scope="prototype" />
<bean id="org.hisp.dhis.settings.action.system.SetSMTPSettingsAction"
class="org.hisp.dhis.settings.action.system.SetSMTPSettingsAction"
- scope="prototype"/>
+ scope="prototype" />
<bean id="org.hisp.dhis.settings.action.system.GetAccessSettingsAction"
class="org.hisp.dhis.settings.action.system.GetAccessSettingsAction"
@@ -112,17 +112,21 @@
scope="prototype">
<property name="dataApprovalLevelService" ref="org.hisp.dhis.dataapproval.DataApprovalLevelService" />
</bean>
-
+
<!-- Configuration -->
-
+
<bean id="org.hisp.dhis.settings.action.system.GetSynchronizationSettingsAction"
class="org.hisp.dhis.settings.action.system.GetSynchronizationSettingsAction"
scope="prototype">
</bean>
-
- <bean id="org.hisp.dhis.settings.action.system.SetSynchronizationSettingsAction"
+
+ <bean id="org.hisp.dhis.settings.action.system.SetSynchronizationSettingsAction"
class="org.hisp.dhis.settings.action.system.SetSynchronizationSettingsAction"
scope="prototype">
</bean>
-
+
+ <!-- OAuth2 -->
+ <bean id="org.hisp.dhis.settings.action.system.GetOAuth2ClientsAction"
+ class="org.hisp.dhis.settings.action.system.GetOAuth2ClientsAction" />
+
</beans>
=== 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-09 12:52:15 +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 03:36:52 +0000
@@ -21,6 +21,7 @@
intro_access_settings=Configure access to the system, like which user role should be used for user self registration.
intro_data_synchronization = Configure remote server URL and authentication for automatic synchronization of data.
intro_calendar_settings=Configure the system calendar and date format. The system supports a wide range of calendars.
+intro_oauth2_clients=Configure which clients are allowed to access this system using OAuth2.
general_settings=General Settings
appearance_settings=Appearance Settings
email_settings=Email Settings
@@ -107,6 +108,7 @@
custom_login_page_logo=Custom login page logo
custom_top_menu_logo=Custom top menu logo
synchronization=Synchronization
+oauth2_clients=OAuth2 Clients
remote_server_url=Remote server URL
remote_server_username=Remote server username
remote_server_password=Remote server password
@@ -127,4 +129,6 @@
cors_whitelist=CORS whitelist
require_authority_to_add_to_view_object_lists=Require authority to add to view object lists
for_example=For example
-allow_assigning_object_to_related_objects_during_add_or_update=Allow assigning object to related objects during add or update
\ No newline at end of file
+allow_assigning_object_to_related_objects_during_add_or_update=Allow assigning object to related objects during add or update
+delete_oauth2_client=Are you sure you want to remove this OAuth2 client?
+oauth2_client_management=OAuth2 Management
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/struts.xml 2015-03-31 15:57:18 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/struts.xml 2015-06-25 03:36:52 +0000
@@ -22,7 +22,7 @@
<param name="menu">/dhis-web-maintenance-settings/settingsMenu.vm</param>
<param name="requiredAuthorities">F_SYSTEM_SETTING</param>
</action>
-
+
<action name="setSystemCalendarSettings" class="org.hisp.dhis.settings.action.system.SetCalendarSettingsAction">
<result name="success" type="velocity-json">
/dhis-web-commons/ajax/jsonResponseSuccess.vm
@@ -161,22 +161,30 @@
<result name="error" type="velocity-json">../dhis-web-commons/ajax/jsonResponseError.vm</result>
<param name="onExceptionReturn">plainTextError</param>
</action>
-
+
<!-- Synchronization -->
- <action name="systemSynchronizationSettings" class="org.hisp.dhis.settings.action.system.GetSynchronizationSettingsAction">
+ <action name="systemSynchronizationSettings" class="org.hisp.dhis.settings.action.system.GetSynchronizationSettingsAction">
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-maintenance-settings/systemSynchronizationSettings.vm</param>
<param name="menu">/dhis-web-maintenance-settings/settingsMenu.vm</param>
<param name="javascripts">javascripts/systemSynchronizationSettings.js</param>
<param name="requiredAuthorities">F_SYSTEM_SETTING</param>
- </action>
-
+ </action>
+
<action name="setConfiguration" class="org.hisp.dhis.settings.action.system.SetSynchronizationSettingsAction">
<result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
<result name="error" type="velocity-json">../dhis-web-commons/ajax/jsonResponseError.vm</result>
<param name="onExceptionReturn">plainTextError</param>
</action>
-
+
+ <!-- OAuth2 -->
+ <action name="systemOAuth2Clients" class="org.hisp.dhis.settings.action.system.GetOAuth2ClientsAction">
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="page">/dhis-web-maintenance-settings/systemOAuth2Clients.vm</param>
+ <param name="menu">/dhis-web-maintenance-settings/settingsMenu.vm</param>
+ <param name="requiredAuthorities">F_OAUTH2_CLIENT_MANAGE</param>
+ </action>
+
</package>
</struts>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/index.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/index.vm 2015-03-31 15:57:18 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/index.vm 2015-06-25 03:36:52 +0000
@@ -8,4 +8,8 @@
#introListImgItem( "systemApprovalSettings.action" "approval_settings" "systemsettings" )
#introListImgItem( "systemCalendarSettings.action" "calendar_settings" "systemsettings" )
#introListImgItem( "systemSynchronizationSettings.action" "data_synchronization" "systemsettings" )
+
+ #if( $security.hasAnyAuthority( "F_OAUTH2_CLIENT_MANAGE", "ALL" ) )
+ #introListImgItem( "systemOAuth2Clients.action" "oauth2_clients" "systemsettings" )
+ #end
</ul>
=== added 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 1970-01-01 00:00:00 +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 03:36:52 +0000
@@ -0,0 +1,7 @@
+function updateO2Client(context) {
+ console.log(context);
+}
+
+function deleteO2Client(context) {
+ console.log(context);
+}
\ 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/settingsMenu.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/settingsMenu.vm 2015-03-31 15:57:18 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/settingsMenu.vm 2015-06-25 03:36:52 +0000
@@ -7,4 +7,9 @@
<li><a href="systemApprovalSettings.action">$i18n.getString( "approval" ) </a></li>
<li><a href="systemCalendarSettings.action">$i18n.getString( "calendar" ) </a></li>
<li><a href="systemSynchronizationSettings.action">$i18n.getString( "synchronization" ) </a></li>
+
+ #if( $security.hasAnyAuthority( "F_OAUTH2_CLIENT_MANAGE", "ALL" ) )
+ <li><a href="systemOAuth2Clients.action">$i18n.getString( "oauth2_clients" ) </a></li>
+ #end
+
</ul>
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemOAuth2Clients.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemOAuth2Clients.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemOAuth2Clients.vm 2015-06-25 03:36:52 +0000
@@ -0,0 +1,47 @@
+<script src="javascripts/oauth2Clients.js"></script>
+<script type="text/javascript">
+ jQuery(document).ready(function() {
+ tableSorter('listTable');
+
+ dhis2.contextmenu.makeContextMenu({
+ menuId: 'contextMenu',
+ menuItemActiveClass: 'contextMenuItemActive'
+ });
+ });
+
+ var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "delete_oauth2_client" ) , "'" )';
+</script>
+
+<h3>$i18n.getString( "oauth2_client_management" )</h3>
+
+<div id="contextMenu" class="contextMenu" style="width: 240px;">
+ <ul id="contextMenuItems" class="contextMenuItems">
+ <li><a data-target-fn="updateO2Client"><i class="fa fa-edit"></i> $i18n.getString( "edit" )</a></li>
+ <li><a data-target-fn="deleteO2Client"><i class="fa fa-trash-o"></i> $i18n.getString( "remove" )</a></li>
+ </ul>
+</div>
+
+<table class="mainPageTable">
+ <tr>
+ <td style="vertical-align:top">
+ <table class="listTable" id="listTable">
+ <col/>
+ <thead>
+ <tr>
+ <th>$i18n.getString( "name" )</th>
+ </tr>
+ </thead>
+ <tbody id="list">
+ #foreach( $client in $clients )
+ <tr id="tr${client.id}" data-id="$!client.id" data-uid="$!client.uid" data-type="OAuth2Client" data-name="$encoder.htmlEncode( $!client.displayName )">
+ <td>$encoder.htmlEncode( $!client.displayName )</td>
+ </tr>
+ #end
+ </tbody>
+
+ </table>
+ <p></p>
+
+ </td>
+ </tr>
+</table>