dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13448
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4317: minor changes, gives user indication when server is offline/online WIP
------------------------------------------------------------
revno: 4317
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-08-16 15:48:25 +0200
message:
minor changes, gives user indication when server is offline/online WIP
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.availability.js
dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.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/commons.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js 2011-08-16 12:16:33 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js 2011-08-16 13:48:25 +0000
@@ -582,6 +582,26 @@
}
/**
+ * Is header message visible.
+ *
+ * @returns true if visible, false is hidden
+ */
+function isHeaderMessageVisible()
+{
+ return $( 'div#headerMessage' ).is(":visible");
+}
+
+/**
+ * Is header message hidden.
+ *
+ * @returns true if hidden, false is visible
+ */
+function isHeaderMessageHidden()
+{
+ return !isHeaderMessageVisible();
+}
+
+/**
* Slides down the info message div and sets the message as text.
*
* @param message the message.
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.availability.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.availability.js 2011-08-16 12:41:09 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.availability.js 2011-08-16 13:48:25 +0000
@@ -35,8 +35,10 @@
* Start availability check, will trigger dhis2.online / dhis2.offline events
* when availability changes.
*
- * @param onlineInterval How often to check for availability, default is 1000.
- * @param offlineInterval How often to check for availability, default is 1000.
+ * @param onlineInterval How often to check for availability when online,
+ * default is 10000.
+ * @param offlineInterval How often to check for availability when offline,
+ * default is 1000.
*/
dhis2.availability.startAvailabilityCheck = function( onlineInterval, offlineInterval )
{
@@ -79,7 +81,8 @@
} );
}
- _availableTimeoutHandler = setTimeout( _checkAvailability, onlineInterval );
+ // use 500ms for initial check
+ _availableTimeoutHandler = setTimeout( _checkAvailability, 500 );
}
/**
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js 2011-08-16 13:16:34 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js 2011-08-16 13:48:25 +0000
@@ -205,19 +205,38 @@
}
$(document).ready(function() {
+ dhis2.availability.startAvailabilityCheck();
+
$("#orgUnitTree").one("ouwtLoaded", function() {
saveDataValuesInLocalStorage();
});
- dhis2.availability.startAvailabilityCheck();
-
$(document).bind("dhis2.online", function(event, loggedIn) {
- console.log("dhis2 is online")
- console.log("loggedIn: " + loggedIn)
+ if(loggedIn) {
+ if(isHeaderMessageVisible()) {
+ updateHeaderMessage( "Successful connection with server." )
+ } else {
+ setHeaderMessage( "Successful connection with server." )
+ }
+ } else {
+ if(isHeaderMessageVisible()) {
+ updateHeaderMessage( "Successfully connected with server. Please <button id='login_button'>Login</button> " )
+ $("#login_button").bind("click", function() {
+ // TODO hack, please improve
+ window.location.href = "../dhis-web-commons/security/login.html";
+ })
+ } else {
+ setHeaderMessage( "Successfully connected with server. Please <button id='login_button'>Login</button> " )
+ }
+ }
})
$(document).bind("dhis2.offline", function() {
- console.log("dhis2 is offline")
+ if(isHeaderMessageVisible()) {
+ updateHeaderMessage( "Unable to contact server. Data will be stored locally." )
+ } else {
+ setHeaderMessage( "Unable to contact server. Data will be stored locally." )
+ }
})
})