← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17654: Dashboard, cache fix

 

------------------------------------------------------------
revno: 17654
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-12-04 10:42:25 +0200
message:
  Dashboard, cache fix
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.util.js
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js


--
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-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.util.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.util.js	2014-10-10 07:10:36 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.util.js	2014-12-04 08:42:25 +0000
@@ -176,6 +176,16 @@
 };
 
 /**
+ * Returns a query parameter string where _ is the parameter and the time stamp
+ * in milliseconds is the value, intended to force fresh non-cached responses
+ * from server.
+ */
+dhis2.util.cacheBust = function()
+{
+	return "_=" + new Date().getTime();
+}
+
+/**
  * adds ':containsNC' to filtering.
  * $(sel).find(':containsNC(key)').doSomething();
  */

=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js	2014-09-14 22:37:13 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js	2014-12-04 08:42:25 +0000
@@ -49,7 +49,7 @@
 	$( "#searchField" ).focus();
 	$( "#searchField" ).keyup( dhis2.db.search );
 	
-	$.getJSON( "../api/me/user-account.json", function( json ) {
+	$.getJSON( "../api/me/user-account.json?" + dhis2.util.cacheBust(), function( json ) {
 		dhis2.db.currentKey = "dhis2.dashboard.current." + json.username;
 		dhis2.db.renderDashboardListLoadFirst();
 	} );
@@ -329,7 +329,7 @@
 	
 	$l.empty();
 	
-	$.getJSON( "../api/dashboards.json?paging=false&links=false", function( data )
+	$.getJSON( "../api/dashboards.json?paging=false&links=false&" + dhis2.util.cacheBust(), function( data )
 	{
 		if ( undefined !== data.dashboards )
 		{
@@ -385,7 +385,7 @@
 	
 	$( "#dashboard-" + dhis2.db.current() ).addClass( "currentDashboard" );
 	
-	$.getJSON( "../api/dashboards/" + id + '/?fields=:all,dashboardItems[:all]', function( data )
+	$.getJSON( "../api/dashboards/" + id + "/?fields=:all,dashboardItems[:all]&" + dhis2.util.cacheBust(), function( data )
 	{
         $d = $( "#contentList" ).empty();