Only show active assets in popups, verbose grass engine

pull/639/head
Piero Toffanin 2019-03-28 12:56:57 -04:00
rodzic a02b20ad73
commit b2fe78c07c
3 zmienionych plików z 42 dodań i 5 usunięć

Wyświetl plik

@ -86,6 +86,7 @@ class GrassContext:
f.write(tmpl.substitute(self.template_args))
# Execute it
logger.info("Executing grass script from {}: {} -c {} location --exec sh script.sh".format(self.get_cwd(), self.grass_binary, self.location))
p = subprocess.Popen([self.grass_binary, '-c', self.location, 'location', '--exec', 'sh', 'script.sh'],
cwd=self.get_cwd(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()

Wyświetl plik

@ -67,7 +67,6 @@ class Map extends React.Component {
loadImageryLayers(forceAddLayers = false){
const { tiles } = this.props,
assets = AssetDownloads.excludeSeparators(),
layerId = layer => {
const meta = layer[Symbol.for("meta")];
return meta.task.project + "_" + meta.task.id;
@ -132,10 +131,8 @@ class Map extends React.Component {
</div>
<div class="popup-opacity-slider">Opacity: <input id="layerOpacity" type="range" value="${layer.options.opacity}" min="0" max="1" step="0.01" /></div>
<div>Bounds: [${layer.options.bounds.toBBoxString().split(",").join(", ")}]</div>
<ul class="asset-links">
${assets.map(asset => {
return `<li><a href="${asset.downloadUrl(meta.task.project, meta.task.id)}">${asset.label}</a></li>`;
}).join("")}
<ul class="asset-links loading">
<li><i class="fa fa-spin fa-refresh fa-spin fa-fw"></i></li>
</ul>
<button
@ -278,6 +275,34 @@ https://a.tile.openstreetmap.org/{z}/{x}/{y}.png
break;
}
}
}).on('popupopen', e => {
// Load task assets links in popup
if (e.popup && e.popup._source && e.popup._content){
const infoWindow = e.popup._content;
const $assetLinks = $("ul.asset-links", infoWindow);
if ($assetLinks.length > 0 && $assetLinks.hasClass('loading')){
const {id, project} = (e.popup._source[Symbol.for("meta")] || {}).task;
$.getJSON(`/api/projects/${project}/tasks/${id}/`)
.done(res => {
const { available_assets } = res;
const assets = AssetDownloads.excludeSeparators();
const linksHtml = assets.filter(a => available_assets.indexOf(a.asset) !== -1)
.map(asset => {
return `<li><a href="${asset.downloadUrl(project, id)}">${asset.label}</a></li>`;
})
.join("");
$assetLinks.append($(linksHtml));
})
.fail(() => {
$assetLinks.append($("<li>Error: cannot load assets list. </li>"));
})
.always(() => {
$assetLinks.removeClass('loading');
});
}
}
});
});

Wyświetl plik

@ -8,6 +8,17 @@
}
.asset-links{
li:first-child{
display: none;
}
&.loading{
li{ display: none }
li:first-child{
display: block;
}
padding-left: 0;
list-style-type: none;
}
margin-top: 8px;
padding-left: 16px;