From 0a6ef64c335c81ca17437d047d9cfcfb085f9b67 Mon Sep 17 00:00:00 2001 From: Andrew van Breda Date: Thu, 14 Nov 2019 11:59:43 +0000 Subject: [PATCH 1/5] Fix problem where linked lists no longer seem to work. 1. The query parameter was causing problems as the query has parameter names in it. So we ended up with something like &query=square_id= removed query= so we get something like &square_id= 2. Also I don't understand why the replacement for '%22val22%' was present, the new replacement seems to work and is based on this line from data_entry_helper inilinkedlists $query = $options['filterField'] . '="+$(this).val()+"'; --- js/indicia.functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/indicia.functions.js b/js/indicia.functions.js index 0e2f1d77..e4dafa59 100644 --- a/js/indicia.functions.js +++ b/js/indicia.functions.js @@ -464,7 +464,7 @@ if (typeof window.indiciaData === 'undefined') { var childSelect = $('#' + options.escapedId); var parentSelect = $(el); if (parentSelect.val()) { - $.getJSON(options.request + '&query=' + options.query.replace('%22val%22', parentSelect.val()), function onResponse(data) { + $.getJSON(options.request + '&' + options.query.replace('"+$(this).val()+"', parentSelect.val()), function onResponse(data) { childSelect.find('option').remove(); if (data.length > 0) { childSelect.removeClass('ui-state-disabled'); From 4da9c00b1ff32395fc2ddcf3de7ec78534020c4a Mon Sep 17 00:00:00 2001 From: John van Breda Date: Tue, 19 Nov 2019 14:07:32 +0000 Subject: [PATCH 2/5] Updates to ES download JS for aggregation support Now supports composite aggregation downloads. --- .../jquery.idc.esDownload.js | 112 +++++++++++------- 1 file changed, 68 insertions(+), 44 deletions(-) diff --git a/js/indicia.datacomponents/jquery.idc.esDownload.js b/js/indicia.datacomponents/jquery.idc.esDownload.js index 49fd0019..ff9d733c 100644 --- a/js/indicia.datacomponents/jquery.idc.esDownload.js +++ b/js/indicia.datacomponents/jquery.idc.esDownload.js @@ -72,8 +72,16 @@ * Response body from the ES proxy containing progress data. */ function updateProgress(el, response) { - $(el).find('.progress-text').text(response.done + ' of ' + response.total.value); - animateTo(el, response.done / response.total.value); + var done; + if (el.settings.aggregation === 'composite') { + // Can't get progress, but show something happening. + $(el).find('.progress-text').text(response.done + ' items'); + } else { + // ES V7 seems to overshoot, reporting whole rather than partial last page size. + done = Math.min(response.done, response.total); + $(el).find('.progress-text').text(done + ' of ' + response.total); + animateTo(el, done / response.total); + } } /** @@ -87,7 +95,8 @@ */ function getColumnSettings(el) { var data = {}; - if (el.settings.columnsTemplate) { + // Note, columnsTemplate can be blank. + if (typeof el.settings.columnsTemplate !== 'undefined') { data.columnsTemplate = el.settings.columnsTemplate; } if (el.settings.addColumns) { @@ -109,40 +118,51 @@ var date; var hours; var minutes; - var data = { - scroll_id: lastResponse.scroll_id - }; - if (lastResponse.done < lastResponse.total.value) { + var data = {}; + var description = ''; + var query = '&state=nextPage&uniq_id=' + lastResponse.uniq_id; + if (lastResponse.scroll_id) { + // Scrolls remember the search query so only need the scroll ID. + query += '&scroll_id=' + lastResponse.scroll_id; + } else if (el.settings.aggregation && el.settings.aggregation === 'composite') { + // Paging composite aggregations requires the full search query. + data = indiciaFns.getFormQueryData(indiciaData.esSourceObjects[el.settings.sourceId]); + // Inform the warehouse as composite paging behaviour different. The + // uniq_id allows the warehouse to relocate the last request's after_key. + query += '&aggregation_type=composite'; + } + if (lastResponse.state === 'nextPage') { $.extend(data, getColumnSettings(el)); - // Post to the ES proxy. Pass scroll_id parameter to request the next - // chunk of the dataset. + // Post to the ES proxy. Pass scroll_id (docs) or after_key (composite aggregations) + // parameter to request the next chunk of the dataset. $.ajax({ - url: indiciaData.esProxyAjaxUrl + '/download/' + indiciaData.nid, + url: indiciaData.esProxyAjaxUrl + '/download/' + indiciaData.nid + query, type: 'POST', dataType: 'json', data: data, success: function success(response) { - // Patch response from V6 to behave like V7. - if (indiciaData.esVersion === 6) { - response.total = { value: response.total, relation: 'eq' }; - } - response.done = Math.min(response.done, response.total.value); updateProgress(el, response); doPages(el, response); } }); } else { + // Finished. + $(el).find('.progress-text').text('Done'); date = new Date(); + // File available for 45 minutes. date.setTime(date.getTime() + (45 * 60 * 1000)); hours = '0' + date.getHours(); hours = hours.substr(hours.length - 2); minutes = '0' + date.getMinutes(); minutes = minutes.substr(minutes.length - 2); + description = 'File containing ' + lastResponse.done + + (el.settings.aggregation && el.settings.aggregation === 'composite' ? ' items. ' : ' occurrences. '); + $(el).find('.progress-circle-container').addClass('download-done'); $(el).find('.idc-download-files').append('
' + '' + - 'Download .zip file
' + - 'File containing ' + lastResponse.total.value + ' occurrences. Available until ' + hours + ':' + minutes + '
'); + 'Download .zip file
' + description + + 'Available until ' + hours + ':' + minutes + ''); $(el).find('.idc-download-files').fadeIn('med'); } } @@ -156,34 +176,33 @@ */ $(el).find('.do-download').click(function doDownload() { var data; - $.each(el.settings.source, function eachSource(sourceId) { - var source = indiciaData.esSourceObjects[sourceId]; - if (typeof source === 'undefined') { - indiciaFns.controlFail(el, 'Download source not found.'); - } - $(el).find('.progress-circle-container').removeClass('download-done'); - $(el).find('.progress-circle-container').show(); - done = false; - $(el).find('.circle').attr('style', 'stroke-dashoffset: 503px'); - $(el).find('.progress-text').text('Loading...'); - data = indiciaFns.getFormQueryData(source); - $.extend(data, getColumnSettings(el)); - // Post to the ES proxy. - $.ajax({ - url: indiciaData.esProxyAjaxUrl + '/download/' + indiciaData.nid, - type: 'POST', - dataType: 'json', - data: data, - success: function success(response) { - if (typeof response.code !== 'undefined' && response.code === 401) { - alert('Elasticsearch alias configuration user or secret incorrect in the form configuration.'); - $('.progress-circle-container').hide(); - } else { - updateProgress(el, response); - doPages(el, response); - } + var source = indiciaData.esSourceObjects[el.settings.sourceId]; + var query = '&state=initial'; + $(el).find('.progress-circle-container').removeClass('download-done'); + $(el).find('.progress-circle-container').show(); + done = false; + $(el).find('.circle').attr('style', 'stroke-dashoffset: 503px'); + $(el).find('.progress-text').text('Loading...'); + data = indiciaFns.getFormQueryData(source); + if (el.settings.aggregation && el.settings.aggregation === 'composite') { + query += '&aggregation_type=composite'; + } + $.extend(data, getColumnSettings(el)); + // Post to the ES proxy. + $.ajax({ + url: indiciaData.esProxyAjaxUrl + '/download/' + indiciaData.nid + query, + type: 'POST', + dataType: 'json', + data: data, + success: function success(response) { + if (typeof response.code !== 'undefined' && response.code === 401) { + alert('Elasticsearch alias configuration user or secret incorrect in the form configuration.'); + $('.progress-circle-container').hide(); + } else { + updateProgress(el, response); + doPages(el, response); } - }); + } }); }); } @@ -211,6 +230,11 @@ if (typeof options !== 'undefined') { $.extend(el.settings, options); } + // Only allow a single source for download, so simplify the sources. + $.each(el.settings.source, function eachSource(sourceId) { + el.settings.sourceId = sourceId; + return false; + }); initHandlers(el); }, From 60729f211ca10933da90a412bb9cdd1190c8d457 Mon Sep 17 00:00:00 2001 From: John van Breda Date: Wed, 20 Nov 2019 10:01:48 +0000 Subject: [PATCH 3/5] Missing full stop --- js/indicia.datacomponents/jquery.idc.esDownload.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/indicia.datacomponents/jquery.idc.esDownload.js b/js/indicia.datacomponents/jquery.idc.esDownload.js index ff9d733c..e53406b8 100644 --- a/js/indicia.datacomponents/jquery.idc.esDownload.js +++ b/js/indicia.datacomponents/jquery.idc.esDownload.js @@ -162,7 +162,7 @@ $(el).find('.idc-download-files').append('
' + '' + 'Download .zip file
' + description + - 'Available until ' + hours + ':' + minutes + '
'); + 'Available until ' + hours + ':' + minutes + '.'); $(el).find('.idc-download-files').fadeIn('med'); } } From 99549b251fd1fa87ceba6642526c84f8358b500d Mon Sep 17 00:00:00 2001 From: John van Breda Date: Wed, 27 Nov 2019 13:33:09 +0000 Subject: [PATCH 4/5] Switch tilecacheLayers param to flexible otherBaseLayerConfig Allows different classes of base layers to be added to the map. --- js/jquery.indiciaMapPanel.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/js/jquery.indiciaMapPanel.js b/js/jquery.indiciaMapPanel.js index 6e3fbb6b..4d83a4db 100644 --- a/js/jquery.indiciaMapPanel.js +++ b/js/jquery.indiciaMapPanel.js @@ -2673,11 +2673,19 @@ var destroyAllFeatures; div.georeferencer = new Georeferencer(div, _displayGeorefOutput); } - // Add any tile cache layers - var tcLayer; - $.each(this.settings.tilecacheLayers, function(i, item) { - tcLayer = new OpenLayers.Layer.TileCache(item.caption, item.servers, item.layerName, item.settings); - div.map.addLayer(tcLayer); + // Add any custom layers. + $.each(this.settings.otherBaseLayerConfig, function(i, item) { + var params = item.params; + var layer; + // Pad to max 4 params, just so the function call can be the same whatever. + while (params.length < 4) { + params.push(null); + } + layer = new OpenLayers.Layer[item.class](params[0], params[1], params[2], params[3]); + if (!layer.layerId) { + layer.layerId = 'custom-' + i; + } + div.map.addLayer(layer); }); // Iterate over the preset layers, adding them to the map From 137031a1b2c8b6d5c9495fc005f981ff69e86170 Mon Sep 17 00:00:00 2001 From: John van Breda Date: Thu, 28 Nov 2019 17:41:31 +0000 Subject: [PATCH 5/5] Fixes squashed columns in IE11 after verify last record. https://github.com/BiologicalRecordsCentre/iRecord/issues/554 --- js/indicia.datacomponents/jquery.idc.dataGrid.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/indicia.datacomponents/jquery.idc.dataGrid.js b/js/indicia.datacomponents/jquery.idc.dataGrid.js index 003637ac..b2cdb103 100644 --- a/js/indicia.datacomponents/jquery.idc.dataGrid.js +++ b/js/indicia.datacomponents/jquery.idc.dataGrid.js @@ -783,7 +783,9 @@ $(el).find('.col-' + idx).css('width', (100 * (maxCharsPerCol['col-' + idx] / maxCharsPerRow)) + '%'); }); // Space header if a scroll bar visible. - $(el).find('.scroll-spacer').css('width', (tbody[0].offsetWidth - tbody[0].clientWidth) + 'px'); + if (tbody.find('tr').length > 0) { + $(el).find('.scroll-spacer').css('width', (tbody[0].offsetWidth - tbody[0].clientWidth) + 'px'); + } } }