dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #40714
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20699: Made uploaded file downloadable in data entry. Note that a file will be processed in the backgrou...
------------------------------------------------------------
revno: 20699
committer: Halvdan Hoem Grelland <halvdanhg@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-10-14 13:46:39 +0200
message:
Made uploaded file downloadable in data entry. Note that a file will be processed in the background after upload, which might take a long time depending on the file store, and the link could therefore return a 409 instead of the file. Future improvement: poll the api/fileResources/<uid> endpoint for the StorageStatus and do not render link until it equals STORED.
modified:
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/form.js
dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/style/dhis-web-dataentry.css
--
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-14 10:45:24 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.fileresource.js 2015-10-14 11:46:39 +0000
@@ -23,7 +23,7 @@
var dataElementId = split.dataElementId;
var optionComboId = split.optionComboId;
- var orgUnitid = dhis2.de.currentOrganisationUnitId;
+ var orgUnitid = split.organisationUnitId;
var periodId = $( '#selectedPeriodId' ).val();
var formData = {
@@ -118,7 +118,14 @@
var onFileDataValueSavedSuccess = function( fileResource ) {
var name = fileResource.name, size = '(' + filesize( fileResource.contentLength ) + ')';
- $fileinfoName.text( name );
+ //$fileinfoName.text( name );
+
+ $('<a>', {
+ text: name,
+ title: name,
+ href: createDownloadLink()
+ } ).appendTo( $fileinfoName );
+
$fileinfoSize.text( size );
$fileinfo.show();
$progressBar.toggleClass( 'upload-progress-bar-complete' );
@@ -135,6 +142,10 @@
$progressInfo.text( percent + '%' );
};
+ var createDownloadLink = function() {
+ return "../api/dataValues/files?" + $.param( formData );
+ };
+
var disableField = function() {
$button.button( 'disable' );
$displayField.toggleClass( 'upload-field-disabled', true );
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2015-10-06 22:13:49 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2015-10-14 11:46:39 +0000
@@ -1679,6 +1679,15 @@
{
$( fieldId ).val( value.val );
+ var split = dhis2.de.splitFieldId( value.id );
+
+ var dvParams = {
+ 'de': split.dataElementId,
+ 'co': split.optionComboId,
+ 'ou': split.organisationUnitId,
+ 'pe': $( '#selectedPeriodId' ).val()
+ };
+
var $container = $( '.entryfileresource-container[name=' + value.id + '-val]' );
var name = "", size = "";
@@ -1693,7 +1702,14 @@
name = i18n_loading_file_info_failed;
}
- $container.find( '.upload-fileinfo-name' ).text( name );
+ var $filename = $container.find( '.upload-fileinfo-name' );
+
+ $( '<a>', {
+ text: name,
+ title: name,
+ href: "../api/dataValues/files?" + $.param( dvParams )
+ } ).appendTo( $filename );
+
$container.find( '.upload-fileinfo-size' ).text( size );
}
else
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/style/dhis-web-dataentry.css'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/style/dhis-web-dataentry.css 2015-10-02 23:47:42 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/style/dhis-web-dataentry.css 2015-10-14 11:46:39 +0000
@@ -321,7 +321,7 @@
{
padding: 5px;
position: absolute;
- max-width: 100%;
+ max-width: 95%;
z-index: 2;
}