dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #35017
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17975: simple UI for adding/removing CORS whitelist domains
------------------------------------------------------------
revno: 17975
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-01-14 17:06:04 +0700
message:
simple UI for adding/removing CORS whitelist domains
modified:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetRemoteAccessSettingsAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetRemoteAccessSettingsAction.java
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/systemRemoteAccessSettings.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/java/org/hisp/dhis/settings/action/system/GetRemoteAccessSettingsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetRemoteAccessSettingsAction.java 2015-01-14 03:56:35 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetRemoteAccessSettingsAction.java 2015-01-14 10:06:04 +0000
@@ -29,6 +29,11 @@
*/
import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.setting.SystemSettingManager;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.ArrayList;
+import java.util.List;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -36,10 +41,20 @@
public class GetRemoteAccessSettingsAction
implements Action
{
+ @Autowired
+ private SystemSettingManager systemSettingManager;
+
// -------------------------------------------------------------------------
// Input & Output
// -------------------------------------------------------------------------
+ private List<String> whitelist = new ArrayList<>();
+
+ public List<String> getWhitelist()
+ {
+ return whitelist;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -47,6 +62,8 @@
@Override
public String execute()
{
+ whitelist = systemSettingManager.getCorsWhitelist();
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetRemoteAccessSettingsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetRemoteAccessSettingsAction.java 2015-01-14 03:56:35 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetRemoteAccessSettingsAction.java 2015-01-14 10:06:04 +0000
@@ -30,6 +30,12 @@
import com.opensymphony.xwork2.Action;
import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.setting.SystemSettingManager;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -37,6 +43,9 @@
public class SetRemoteAccessSettingsAction
implements Action
{
+ @Autowired
+ private SystemSettingManager systemSettingManager;
+
// -------------------------------------------------------------------------
// Input & Output
// -------------------------------------------------------------------------
@@ -55,6 +64,13 @@
this.i18n = i18n;
}
+ private List<String> whitelist = new ArrayList<>();
+
+ public void setWhitelist( List<String> whitelist )
+ {
+ this.whitelist = whitelist;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -64,6 +80,8 @@
{
message = i18n.getString( "settings_updated" );
+ systemSettingManager.saveSystemSetting( SystemSettingManager.KEY_CORS_WHITELIST, (Serializable) whitelist );
+
return SUCCESS;
}
}
=== 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-01-14 03:56:35 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties 2015-01-14 10:06:04 +0000
@@ -126,4 +126,5 @@
acceptance_required_before_approval=Acceptance required before approval
system_notifications_email_address=System notifications email address
default_analysis_relative_period=Default relative period for analysis
-infrastructural_indicators=Infrastructural indicators
\ No newline at end of file
+infrastructural_indicators=Infrastructural indicators
+cors_whitelist=CORS Whitelist
\ 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/systemRemoteAccessSettings.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemRemoteAccessSettings.vm 2015-01-14 03:56:35 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemRemoteAccessSettings.vm 2015-01-14 10:06:04 +0000
@@ -1,5 +1,48 @@
+<script type="text/javascript">
+ $(document).ready(function() {
+ $("input[type=button]").click(function() {
+ $('#whitelist').children().attr('selected', true);
+
+ $.ajax({
+ url: 'setSystemRemoteAccessSettings.action',
+ type: 'POST',
+ data: $('#whitelist').serialize()
+ }).done(function( res ) {
+ if( res.response == "success" ) {
+ setHeaderDelayMessage(res.message);
+ }
+ });
+ });
+
+ $('#add-domain').on('click', function( e ) {
+ var domainText = $('#domain').val();
+
+ if( domainText && domainText.length > 0 ) {
+ $('<option/>').attr('value', domainText).text(domainText).appendTo('#whitelist');
+ }
+ });
+
+ $('#del-domain').on('click', function( e ) {
+ $("#whitelist option:selected").remove();
+ });
+ });
+</script>
<h3>$i18n.getString( "remote_access_settings" )</h3>
+<div class="settingLabel">$i18n.getString( "cors_whitelist" )</div>
+
+<div class="setting">
+ <input type="text" id="domain" name="domain">
+ <button id="add-domain"><span class="fa fa-plus"></button>
+ <button id="del-domain" style=""><span class="fa fa-minus"></button>
+
+ <br/>
+ <select id="whitelist" name="whitelist" multiple="multiple">
+ #foreach( $domain in $whitelist )
+ <option value="$domain">$domain</option>
+ #end
+ </select>
+</div>
<div class="setting"><input type="button" value="$i18n.getString( 'save' )" style="width:10em"/></div>