dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #26266
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13014: support for setting google analytics UA key, script is included on login pages, and pages that us...
------------------------------------------------------------
revno: 13014
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-11-25 10:51:18 +0100
message:
support for setting google analytics UA key, script is included on login pages, and pages that uses main.vm or layout.vm (mobile).
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login.vm
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login_mobile.vm
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.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/systemGeneralSettings.vm
dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/layout.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-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java 2013-10-16 16:00:05 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java 2013-11-25 09:51:18 +0000
@@ -80,6 +80,7 @@
final String KEY_CONFIGURATION = "keyConfig";
final String KEY_ACCOUNT_RECOVERY = "keyAccountRecovery";
final String KEY_LAST_MONITORING_RUN = "keyLastMonitoringRun";
+ final String KEY_GOOGLE_ANALYTICS_UA = "googleAnalyticsUA";
final String DEFAULT_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASK_STRATEGY = "lastMonth";
final String DEFAULT_FLAG = "dhis2";
@@ -130,4 +131,6 @@
boolean accountRecoveryEnabled();
boolean emailEnabled();
+
+ String googleAnalyticsUA();
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java 2013-10-01 16:44:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java 2013-11-25 09:51:18 +0000
@@ -28,14 +28,14 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.apache.commons.lang.StringUtils;
+import org.springframework.transaction.annotation.Transactional;
+
import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import org.apache.commons.lang.StringUtils;
-import org.springframework.transaction.annotation.Transactional;
-
/**
* @author Stian Strandli
* @author Lars Helge Overland
@@ -137,7 +137,7 @@
{
return StringUtils.trimToNull( (String) getSystemSetting( KEY_EMAIL_HOST_NAME ) );
}
-
+
public int getEmailPort()
{
return (Integer) getSystemSetting( KEY_EMAIL_PORT, DEFAULT_EMAIL_PORT );
@@ -152,19 +152,24 @@
{
return StringUtils.trimToNull( (String) getSystemSetting( KEY_EMAIL_USERNAME ) );
}
-
+
public boolean getEmailTls()
{
return (Boolean) getSystemSetting( KEY_EMAIL_TLS, true );
}
-
+
public boolean accountRecoveryEnabled()
{
return (Boolean) getSystemSetting( KEY_ACCOUNT_RECOVERY, false );
}
-
+
public boolean emailEnabled()
{
return getEmailHostName() != null;
}
+
+ public String googleAnalyticsUA()
+ {
+ return StringUtils.trimToNull( (String) getSystemSetting( KEY_GOOGLE_ANALYTICS_UA ) );
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login.vm 2013-11-04 22:45:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login.vm 2013-11-25 09:51:18 +0000
@@ -26,7 +26,7 @@
</div>
#if ( $keyConfig.selfRegistrationAllowed() )
<div id="accountArea">
- <a id="createAccountButton" class="greenButtonLink" href="account.action">Create an account</a>
+ <a id="createAccountButton" class="greenButtonLink" href="account.action">Create an account</a>
</div>
#end
<div id="loginField">
@@ -56,7 +56,7 @@
<div id="loginMessage">Wrong username or password</div>
#end
#if ( $keyApplicationNotification )
- <div id="notificationArea">$!{keyApplicationNotification}</div>
+ <div id="notificationArea">$!{keyApplicationNotification}</div>
#end
</div>
<div id="footerArea">
@@ -67,10 +67,25 @@
<select id="localeSelect" onchange="login.localeChanged()" style="margin-left: 30px">
<option value="">[ Change language ]</option>
#foreach( $locale in $availableLocales )
- <option value="${locale.language}">${locale.displayName}</option>
- #end
+ <option value="${locale.language}">${locale.displayName}</option>
+ #end
</select>
</div>
+
+ #* Seems we can't access macros.vm from login.vm/login_mobile.vm so we include the full script here *#
+ #if( $googleAnalyticsUA && $googleAnalyticsUA != '' )
+ <script type="text/javascript">
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', '$encoder.jsEncode($googleAnalyticsUA)']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+ </script>
+ #end
</body>
</html>
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login_mobile.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login_mobile.vm 2013-06-23 18:19:54 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login_mobile.vm 2013-11-25 09:51:18 +0000
@@ -51,5 +51,20 @@
</div>
</div>
+#* Seems we can't access macros.vm from login.vm/login_mobile.vm so we include the full script here *#
+#if( $googleAnalyticsUA && $googleAnalyticsUA != '' )
+<script type="text/javascript">
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', '$encoder.jsEncode($googleAnalyticsUA)']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+</script>
+#end
+
</body>
</html>
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm 2013-09-29 19:31:42 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm 2013-11-25 09:51:18 +0000
@@ -387,3 +387,21 @@
#end
</div>
#end
+
+#macro( googleAnalyticsUA )
+
+#if( $googleAnalyticsUA && $googleAnalyticsUA != '' )
+<script type="text/javascript">
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', '$encoder.jsEncode($googleAnalyticsUA)']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+</script>
+#end
+
+#end
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm 2013-11-17 20:31:46 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm 2013-11-25 09:51:18 +0000
@@ -164,5 +164,7 @@
<div id="rightBarContents"/>
</div>
+ #googleAnalyticsUA()
+
</body>
</html>
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java 2013-09-30 10:39:35 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java 2013-11-25 09:51:18 +0000
@@ -28,19 +28,17 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.interceptor.Interceptor;
+import org.hisp.dhis.configuration.ConfigurationService;
+import org.hisp.dhis.setting.SystemSettingManager;
+
import java.util.HashMap;
import java.util.Map;
-import org.hisp.dhis.configuration.ConfigurationService;
-import org.hisp.dhis.setting.SystemSettingManager;
-
-import com.opensymphony.xwork2.ActionInvocation;
-import com.opensymphony.xwork2.interceptor.Interceptor;
-
+import static org.apache.commons.lang.StringUtils.defaultIfEmpty;
+import static org.hisp.dhis.appmanager.AppManager.KEY_APP_BASE_URL;
import static org.hisp.dhis.setting.SystemSettingManager.*;
-import static org.hisp.dhis.appmanager.AppManager.KEY_APP_BASE_URL;
-
-import static org.apache.commons.lang.StringUtils.defaultIfEmpty;
/**
* @author Lars Helge Overland
@@ -58,7 +56,7 @@
{
this.systemSettingManager = systemSettingManager;
}
-
+
private ConfigurationService configurationService;
public void setConfigurationService( ConfigurationService configurationService )
@@ -71,7 +69,7 @@
// -------------------------------------------------------------------------
public void destroy()
- {
+ {
}
public void init()
@@ -82,7 +80,7 @@
throws Exception
{
Map<String, Object> map = new HashMap<String, Object>();
-
+
map.put( KEY_CACHE_STRATEGY, systemSettingManager.getSystemSetting( KEY_CACHE_STRATEGY, DEFAULT_CACHE_STRATEGY ) );
map.put( KEY_APPLICATION_TITLE, systemSettingManager.getSystemSetting( KEY_APPLICATION_TITLE, DEFAULT_APPLICATION_TITLE ) );
map.put( KEY_APPLICATION_INTRO, systemSettingManager.getSystemSetting( KEY_APPLICATION_INTRO ) );
@@ -98,11 +96,12 @@
map.put( KEY_ACCOUNT_RECOVERY, systemSettingManager.getSystemSetting( KEY_ACCOUNT_RECOVERY, false ) );
map.put( KEY_CONFIGURATION, configurationService.getConfiguration() );
map.put( KEY_APP_BASE_URL, systemSettingManager.getSystemSetting( KEY_APP_BASE_URL ) );
-
+ map.put( KEY_GOOGLE_ANALYTICS_UA, systemSettingManager.getSystemSetting( KEY_GOOGLE_ANALYTICS_UA, "" ) );
+
map.put( SYSPROP_PORTAL, defaultIfEmpty( System.getProperty( SYSPROP_PORTAL ), String.valueOf( false ) ) );
-
+
invocation.getStack().push( map );
-
+
return invocation.invoke();
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java 2013-09-30 19:54:38 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java 2013-11-25 09:51:18 +0000
@@ -154,6 +154,13 @@
this.phoneNumberAreaCode = phoneNumberAreaCode;
}
+ private String googleAnalyticsUA;
+
+ public void setGoogleAnalyticsUA( String googleAnalyticsUA )
+ {
+ this.googleAnalyticsUA = googleAnalyticsUA;
+ }
+
private boolean multiOrganisationUnitForms;
public void setMultiOrganisationUnitForms( boolean multiOrganisationUnitForms )
@@ -186,6 +193,7 @@
systemSettingManager.saveSystemSetting( KEY_FACTOR_OF_DEVIATION, factorDeviation );
systemSettingManager.saveSystemSetting( KEY_PHONE_NUMBER_AREA_CODE, phoneNumberAreaCode );
systemSettingManager.saveSystemSetting( KEY_MULTI_ORGANISATION_UNIT_FORMS, multiOrganisationUnitForms );
+ systemSettingManager.saveSystemSetting( KEY_GOOGLE_ANALYTICS_UA, googleAnalyticsUA );
Configuration configuration = configurationService.getConfiguration();
=== 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 2013-06-17 17:39:32 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties 2013-11-25 09:51:18 +0000
@@ -47,8 +47,8 @@
cache_for_two_weeks=Cache for two weeks
max_levels_to_offline=Maximum offline organisation unit levels
phone_number_area_code = Phone number area code
+google_analytics_ua_key=Google Analytics (Universal Analytics) Key
application_introduction=Application introduction
-do_not_allow_self_registration=Do not allow self registration
access_settings=Access settings
do_not_allow_self_registration=Do not allow self registration
self_registration_account_user_role=Self registration account user role
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemGeneralSettings.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemGeneralSettings.vm 2013-09-30 10:39:35 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemGeneralSettings.vm 2013-11-25 09:51:18 +0000
@@ -1,23 +1,24 @@
<script>
- jQuery(document).ready(function() {
- jQuery("input[type=button]").click(function() {
- jQuery.postUTF8( 'setSystemGeneralSettings.action', {
- cacheStrategy: getFieldValue( 'cacheStrategy' ),
- infrastructuralDataElements: getFieldValue( 'infrastructuralDataElements' ),
- infrastructuralPeriodType: getFieldValue( 'infrastructuralPeriodType' ),
- feedbackRecipients: getFieldValue( 'feedbackRecipients' ),
- offlineOrganisationUnitLevel: getFieldValue( 'offlineOrganisationUnitLevel' ),
- omitIndicatorsZeroNumeratorDataMart: jQuery( '#omitIndicatorsZeroNumeratorDataMart' ).is( ':checked' ),
- factorDeviation: getFieldValue( 'factorDeviation' ),
- phoneNumberAreaCode: getFieldValue( 'phoneNumberAreaCode' ),
- multiOrganisationUnitForms: jQuery( '#multiOrganisationUnitForms' ).is( ':checked' )
- }, function( json ) {
- if ( json.response == "success" ) {
- setHeaderDelayMessage( json.message );
- }
- });
- });
- });
+ jQuery(document).ready(function() {
+ jQuery("input[type=button]").click(function() {
+ jQuery.postUTF8('setSystemGeneralSettings.action', {
+ cacheStrategy: getFieldValue('cacheStrategy'),
+ infrastructuralDataElements: getFieldValue('infrastructuralDataElements'),
+ infrastructuralPeriodType: getFieldValue('infrastructuralPeriodType'),
+ feedbackRecipients: getFieldValue('feedbackRecipients'),
+ offlineOrganisationUnitLevel: getFieldValue('offlineOrganisationUnitLevel'),
+ omitIndicatorsZeroNumeratorDataMart: jQuery('#omitIndicatorsZeroNumeratorDataMart').is(':checked'),
+ factorDeviation: getFieldValue('factorDeviation'),
+ phoneNumberAreaCode: getFieldValue('phoneNumberAreaCode'),
+ googleAnalyticsUA: getFieldValue('googleAnalyticsUA'),
+ multiOrganisationUnitForms: jQuery('#multiOrganisationUnitForms').is(':checked')
+ }, function( json ) {
+ if( json.response == "success" ) {
+ setHeaderDelayMessage(json.message);
+ }
+ });
+ });
+ });
</script>
<h3>$i18n.getString( "general_settings" ) #openHelp( "systemGeneralSettings" )</h3>
@@ -87,6 +88,12 @@
<input type="text" id="phoneNumberAreaCode" name="phoneNumberAreaCode" value="$!phoneNumberAreaCode"/>
</div>
+<div class="settingLabel">$i18n.getString( "google_analytics_ua_key" )</div>
+
+<div class="setting">
+ <input type="text" id="googleAnalyticsUA" name="googleAnalyticsUA" value="$!googleAnalyticsUA"/>
+</div>
+
<div class="setting">
<input type="checkbox" id="multiOrganisationUnitForms" name="multiOrganisationUnitForms" #if( $multiOrganisationUnitForms )checked="checked"#end>
<label for="multiOrganisationUnitForms">$i18n.getString( "multi_organisation_unit_forms" )</label>
=== modified file 'dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/layout.vm'
--- dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/layout.vm 2013-08-21 11:44:03 +0000
+++ dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/layout.vm 2013-11-25 09:51:18 +0000
@@ -30,5 +30,7 @@
#parse( $page )
#end
+#googleAnalyticsUA()
+
</body>
</html>