← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4318: wip, correctly display messages as server goes up/down, allow user to re-login using ajax

 

------------------------------------------------------------
revno: 4318
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-08-16 16:47:08 +0200
message:
  wip, correctly display messages as server goes up/down, allow user to re-login using ajax
modified:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml
  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-dataentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml	2011-08-12 16:10:13 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml	2011-08-16 14:47:08 +0000
@@ -16,7 +16,7 @@
       <param name="menuTreeHeight">420</param>
       <param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/form.js,javascript/entry.js,javascript/history.js</param>
       <param name="stylesheets">style/dhis-web-dataentry.css</param>
-      <param name="offline">true</param>
+      <param name="offline">false</param>
     </action>
 
     <action name="getDataValues" class="org.hisp.dhis.de.action.GetDataValuesForDataSetAction">

=== 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:48:25 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js	2011-08-16 14:47:08 +0000
@@ -204,6 +204,20 @@
     return false;
 }
 
+function ajax_login() {
+    $("#login_button").bind("click", function() {
+        var username = prompt("Please enter username");
+        var password = prompt("Please enter password");
+
+        $.post("../dhis-web-commons-security/login.action", {
+            "j_username": username,
+            "j_password": password
+        }).success(function() {
+            alert("login attempt successful, TODO check if login was successful with checkAvailability");
+        })
+    })    
+}
+
 $(document).ready(function() {
     dhis2.availability.startAvailabilityCheck();
 
@@ -221,12 +235,10 @@
         } 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";
-                })
+                ajax_login();
             } else {
                 setHeaderMessage( "Successfully connected with server. Please <button id='login_button'>Login</button> " )
+                ajax_login();
             }
         }
     })