Skip to content

Commit fc57aa2

Browse files
bodom0015lmarini
andauthored
Improve error-handling for geospatial previewer (#141)
* Improve error-handling for geospatial previewer * Update CHANGELOG * Squelch debug output from fetching metadata * Fixed typo * Removed unnecessary javascript console.log for metadata. Co-authored-by: Luigi Marini <[email protected]> Co-authored-by: Luigi Marini <[email protected]>
1 parent eb16223 commit fc57aa2

File tree

4 files changed

+20
-21
lines changed

4 files changed

+20
-21
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
78
## Unreleased
89

910
### Added
1011
- Added support for Amplitude clickstream tracking. See Admin -> Customize to configure Amplitude apikey.
1112
- Ability to submit multiple selected files within a dataset to an extractor.
1213

14+
### Fixed
15+
- GeospatialViewer preview tab should no longer show if it does not contain any rendered data.
16+
1317
## 1.12.2 - 2020-11-19
1418

1519
### Changed

app/views/file.scala.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@
185185
aria-haspopup="true" aria-expanded="true">
186186
<span class="glyphicon glyphicon-hdd"></span> <span class="caret"></span>
187187
</button>
188-
<ul class="dropdown-menu" arialanelledby="dropdown_space_list">
188+
<ul class="dropdown-menu" aria-labelledby="dropdown_space_list">
189189
@spaces.map{ s =>
190190
<li><a href="@routes.Spaces.getSpace(s.id)" title="s.name"><span class="glyphicon glyphicon-hdd"></span> @Html(ellipsize(s.name, 18))</a></li>
191191
}

app/views/metadatald/addMetadata.scala.html

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -434,14 +434,6 @@ <h5 class="pull-left">Add metadata</h5>
434434
var field_id = context.val();
435435
var field_type = context.data("type");
436436
var space_id = context.attr("space_id");
437-
console.log('Metadata field (' + field_label + '):', {
438-
'Context': context,
439-
'Label: ': field_label,
440-
'Field Description: ': field_description,
441-
'Field ID: ': field_id,
442-
'Field Type: ': field_type,
443-
'Space ID: ': space_id
444-
});
445437
// Create the template and HTML content.
446438
var template_map =
447439
{"string": "add_metadata_string",

public/javascripts/previewers/geospatial/geospatial.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66

77
console.log("geospatial data previewer for " + initialID);
88

9+
var hideTab = function() {
10+
var tabHeader = $(`a[href^="${initialTab}"]`);
11+
tabHeader.hide();
12+
};
13+
914
var defaultOpacity = 0.8;
1015
// retrieve the metadata
1116
var metadataApiUrl = jsRoutes.api.Files.getTechnicalMetadataJSON(initialID).url;
@@ -18,14 +23,10 @@
1823
request
1924
.done(function(data) {
2025

21-
// if there are no tehcnical metadata or no wms metadata
26+
// if there are no technical metadata or no wms metadata
2227
// then return
23-
if (data == null)
24-
return;
25-
if (data == undefined)
26-
return;
27-
if (data.length == 0)
28-
return;
28+
if (data == null || data == undefined || data.length == 0)
29+
return hideTab();
2930

3031
// search the metadata index which contains geospatial metadata
3132
var geoMetadataIndex = -1;
@@ -41,7 +42,7 @@
4142

4243
// if it couldn't find the index, return
4344
if (geoMetadataIndex == -1)
44-
return;
45+
return hideTab();
4546

4647
console.log("Updating tab " + initialTab);
4748

@@ -60,7 +61,7 @@
6061
// add layer opacity control
6162
$(initialTab).append(
6263
"<div id='layer-opacity-control'><label>Layer Opacity: </label><input id='opacity' type='range' min='0' max='1' value='"+defaultOpacity+"' step='0.01' style='width:200px;' /></div>");
63-
64+
6465
// drawing the map
6566
console.log("ol3js loaded");
6667

@@ -111,7 +112,7 @@
111112
wmsLayer.setOpacity($(this).val());
112113
});
113114

114-
115+
115116
// create map object
116117
var map = new ol.Map({
117118
target : 'map'
@@ -135,16 +136,18 @@
135136

136137
// zoom into the layer extent
137138
map.setView(view);
138-
139+
139140
// fix for MMDB-1617
140141
// force to redraw the map
141-
// TODO the dom selector needs to select the current selector instead of this selection
142+
// TODO the dom selector needs to select the current selector instead of this selection
142143
$('a[data-toggle="tab"]').on(
143144
'shown.bs.tab', function(e) {
144145
map.updateSize()
145146
});
146147
});
147148

149+
}).fail(function() {
150+
hideTab();
148151
});
149152

150153
}(jQuery, Configuration));

0 commit comments

Comments
 (0)