dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41063
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20892: Minor: don't poll if already stored
------------------------------------------------------------
revno: 20892
committer: Halvdan Hoem Grelland <halvdanhg@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-10-29 17:10:01 +0100
message:
Minor: don't poll if already stored
modified:
dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.fileresource.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/webapp/dhis-web-dataentry/javascript/entry.fileresource.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.fileresource.js 2015-10-19 14:07:54 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.fileresource.js 2015-10-29 16:10:01 +0000
@@ -124,6 +124,22 @@
$displayField.css( 'background-color', dhis2.de.cst.colorYellow );
resetAndHideProgress();
+ function onFileResourceConfirmedStored() {
+ $fileinfoName.text( '' );
+
+ $( '<a>', {
+ text: name,
+ title: name,
+ target: '_blank',
+ href: '../api/dataValues/files?' + $.param( formData )
+ } ).appendTo( $fileinfoName );
+
+ $displayField.css( 'background-color', dhis2.de.cst.colorGreen );
+
+ setButtonDelete();
+ $button.button( 'enable' );
+ }
+
function pollForFileResourceStored() {
$.ajax( {
url: '../api/fileResources/' + fileResource.id,
@@ -133,19 +149,7 @@
if ( data.storageStatus != 'STORED' ) {
setTimeout( pollForFileResourceStored, 4000 /* 4 sec polling time */ );
} else {
- $fileinfoName.text( '' );
-
- $( '<a>', {
- text: name,
- title: name,
- target: '_blank',
- href: '../api/dataValues/files?' + $.param( formData )
- } ).appendTo( $fileinfoName );
-
- $displayField.css( 'background-color', dhis2.de.cst.colorGreen );
-
- setButtonDelete();
- $button.button( 'enable' );
+ onFileResourceConfirmedStored();
}
} ).fail( function( jqXHR, textStatus, errorThrown ) {
// Really shouldn't happen...
@@ -153,7 +157,12 @@
throw 'Checking storage status of file failed: ' + errorThrown;
} );
}
- setTimeout( pollForFileResourceStored, 1500 );
+
+ if ( fileResource.storageStatus == 'STORED' ) {
+ onFileResourceConfirmedStored();
+ } else {
+ setTimeout( pollForFileResourceStored, 1500 );
+ }
};
var updateProgress = function( loaded, total ) {