dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #19775
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8764: Impl restore user interface
------------------------------------------------------------
revno: 8764
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-10-30 10:18:35 +0300
message:
Impl restore user interface
added:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/recovery.js
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/restore.js
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/recovery.vm
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/restore.vm
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/useraccount/action/IsRestoreTokenValidAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties
--
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
=== added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/recovery.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/recovery.js 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/recovery.js 2012-10-30 07:18:35 +0000
@@ -0,0 +1,26 @@
+
+function recoverAccount()
+{
+ var username = $.trim( $( "#username" ).val() );
+
+ if ( username.length == 0 )
+ {
+ return false;
+ }
+
+ $.ajax( {
+ url: "../../api/account/recovery",
+ data: {
+ username: username
+ },
+ type: "post",
+ success: function( data ) {
+ $( "#recoveryForm" ).hide();
+ $( "#recoverySuccessMessage" ).fadeIn();
+ },
+ error: function( data ) {
+ $( "#recoveryForm" ).hide();
+ $( "#recoveryErrorMessage" ).fadeIn();
+ }
+ } );
+}
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/restore.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/restore.js 2012-10-30 06:50:49 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/restore.js 2012-10-30 07:18:35 +0000
@@ -1,26 +1,51 @@
-
-function recoverAccount()
+var validationRules = {
+ rules: {
+ code: {
+ required: true
+ },
+ password: {
+ required: true,
+ rangelength: [ 8, 80 ],
+ password: true
+ },
+ retypePassword: {
+ required: true,
+ equalTo: "#password",
+ }
+ }
+};
+
+$( document ).ready( function() {
+
+ $( "#restoreForm" ).validate( {
+ rules: validationRules.rules,
+ submitHandler: restoreSubmitHandler,
+ errorPlacement: function( error, element ) {
+ element.parent( "td" ).append( "<br>" ).append( error );
+ }
+ } );
+} );
+
+function restoreSubmitHandler()
{
- var username = $.trim( $( "#username" ).val() );
-
- if ( username.length == 0 )
- {
- return false;
- }
-
+ $( "#submitButton" ).attr( "disabled", "disabled" );
+
$.ajax( {
- url: "../../api/account/recovery",
+ url: "../../api/account/restore",
data: {
- username: username
+ username: $( "#username" ).val(),
+ token: $( "#token" ).val(),
+ code: $( "#code" ).val(),
+ password: $( "#password" ).val()
},
type: "post",
success: function( data ) {
- $( "#recoveryForm" ).hide();
- $( "#recoverySuccessMessage" ).fadeIn();
+ $( "#restoreForm" ).hide();
+ $( "#restoreSuccessMessage" ).fadeIn();
},
- error: function( data ) {
- $( "#recoveryForm" ).hide();
- $( "#recoveryErrorMessage" ).fadeIn();
+ error: function( jqXHR, textStatus, errorThrown ) {
+ $( "#submitButton" ).removeAttr( "disabled" );
+ $( "#restoreErrorMessage" ).fadeIn();
}
- } );
-}
+ } );
+}
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/recovery.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/recovery.vm 2012-10-30 06:50:49 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/recovery.vm 2012-10-30 07:18:35 +0000
@@ -3,7 +3,7 @@
<head>
<title>DHIS 2</title>
<script type="text/javascript" src="../javascripts/jQuery/jquery.min.js"></script>
- <script type="text/javascript" src="../javascripts/useraccount/restore.js"></script>
+ <script type="text/javascript" src="../javascripts/useraccount/recovery.js"></script>
<link type="text/css" rel="stylesheet" href="../css/account.css">
</head>
<body>
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/restore.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/restore.vm 2012-10-29 20:17:23 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/restore.vm 2012-10-30 07:18:35 +0000
@@ -5,7 +5,7 @@
<script type="text/javascript" src="../javascripts/jQuery/jquery.min.js"></script>
<script type="text/javascript" src="../javascripts/jQuery/jquery.validate.js"></script>
<script type="text/javascript" src="../javascripts/jQuery/jquery.validate.ext.js"></script>
- <script type="text/javascript" src="../javascripts/useraccount/account.js"></script>
+ <script type="text/javascript" src="../javascripts/useraccount/restore.js"></script>
<script type="text/javascript" src="../i18nJavaScript.action"></script>
<link type="text/css" rel="stylesheet" href="../css/account.css">
</head>
@@ -21,11 +21,14 @@
<h3>$i18n.getString( "restore_account" )</h3>
-<form id="accountForm">
-
-<table>
+<form id="restoreForm">
+
+<input type="hidden" id="username" value="${username}">
+<input type="hidden" id="token" value="${token}">
+
+<table style="margin-bottom:20px">
<tr>
- <td><label for="code">$i18n.getString( "code" )</label></td>
+ <td style="width:140px"><label for="code">$i18n.getString( "code_from_email" )</label></td>
<td><input type="text" id="code" name="code" autocomplete="off"></td>
</tr>
<tr>
@@ -44,6 +47,14 @@
</form>
+<div id="restoreSuccessMessage" style="display:none">
+You account was successfully restored. Go to the <a href="login.action">login page and log in</a>
+with your new password.
+</div>
+
+<div id="restoreErrorMessage" style="display:none">
+Sorry, your account could not be restored. The code might be invalid or expired. Try again or
+go to the <a href="login.action">login page</a> and request a new restore email.
</div>
</div>
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/useraccount/action/IsRestoreTokenValidAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/useraccount/action/IsRestoreTokenValidAction.java 2012-10-29 20:17:23 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/useraccount/action/IsRestoreTokenValidAction.java 2012-10-30 07:18:35 +0000
@@ -46,7 +46,12 @@
// -------------------------------------------------------------------------
private String username;
-
+
+ public String getUsername()
+ {
+ return username;
+ }
+
public void setUsername( String username )
{
this.username = username;
@@ -54,6 +59,11 @@
private String token;
+ public String getToken()
+ {
+ return token;
+ }
+
public void setToken( String token )
{
this.token = token;
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties 2012-10-29 20:17:23 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties 2012-10-30 07:18:35 +0000
@@ -132,6 +132,7 @@
restore_account=Restore account
account_recovery=Account recovery
recover=Recover
+code_from_email=Code from email
#-- PeriodTypes ----------------------------------------------------------------#