kopia lustrzana https://github.com/OpenDroneMap/NodeODM
Download of assets
rodzic
f157aba2d8
commit
23bdfe3103
9
index.js
9
index.js
|
@ -86,6 +86,15 @@ app.get('/task/:uuid/info', getTaskFromUuid, (req, res) => {
|
||||||
app.get('/task/:uuid/output', getTaskFromUuid, (req, res) => {
|
app.get('/task/:uuid/output', getTaskFromUuid, (req, res) => {
|
||||||
res.json(req.task.getOutput(req.query.line));
|
res.json(req.task.getOutput(req.query.line));
|
||||||
});
|
});
|
||||||
|
app.get('/task/:uuid/download/:asset', getTaskFromUuid, (req, res) => {
|
||||||
|
if (!req.params.asset || req.params.asset === "all"){
|
||||||
|
res.download(req.task.getAssetsArchivePath(), "all.zip", err => {
|
||||||
|
if (err) res.json({error: "Asset not ready"});
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
res.json({error: "Invalid asset"});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let uuidCheck = (req, res, next) => {
|
let uuidCheck = (req, res, next) => {
|
||||||
if (!req.body.uuid) res.json({error: "uuid param missing."});
|
if (!req.body.uuid) res.json({error: "uuid param missing."});
|
||||||
|
|
12
libs/Task.js
12
libs/Task.js
|
@ -62,6 +62,12 @@ module.exports = class Task{
|
||||||
return `data/${this.uuid}`;
|
return `data/${this.uuid}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the path of the archive where all assets
|
||||||
|
// outputted by this task are stored.
|
||||||
|
getAssetsArchivePath(){
|
||||||
|
return `${this.getProjectFolderPath()}/all.zip`;
|
||||||
|
}
|
||||||
|
|
||||||
// Deletes files and folders related to this task
|
// Deletes files and folders related to this task
|
||||||
cleanup(cb){
|
cleanup(cb){
|
||||||
rmdir(this.getProjectFolderPath(), cb);
|
rmdir(this.getProjectFolderPath(), cb);
|
||||||
|
@ -138,12 +144,10 @@ module.exports = class Task{
|
||||||
zip.addLocalFolder(`${this.getProjectFolderPath()}/odm_georeferencing`);
|
zip.addLocalFolder(`${this.getProjectFolderPath()}/odm_georeferencing`);
|
||||||
zip.addLocalFolder(`${this.getProjectFolderPath()}/odm_texturing`);
|
zip.addLocalFolder(`${this.getProjectFolderPath()}/odm_texturing`);
|
||||||
zip.addLocalFolder(`${this.getProjectFolderPath()}/odm_meshing`);
|
zip.addLocalFolder(`${this.getProjectFolderPath()}/odm_meshing`);
|
||||||
zip.writeZip(`${this.getProjectFolderPath()/all.zip}`);
|
zip.writeZip(this.getAssetsArchivePath());
|
||||||
|
|
||||||
this.setStatus(statusCodes.COMPLETED);
|
this.setStatus(statusCodes.COMPLETED);
|
||||||
finished();
|
finished();
|
||||||
|
|
||||||
// TODO: test, think about possibly doing this on the fly
|
|
||||||
// upon download request...
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function finished(){
|
function finished(){
|
||||||
|
|
|
@ -71,6 +71,10 @@
|
||||||
<span data-bind="css: 'statusIcon glyphicon ' + icon()"></span>
|
<span data-bind="css: 'statusIcon glyphicon ' + icon()"></span>
|
||||||
|
|
||||||
<div class="actionButtons">
|
<div class="actionButtons">
|
||||||
|
<button data-bind="click: download, visible: showDownload()" type="button" class="btn btn-primary btn-sm" >
|
||||||
|
<span class="glyphicon glyphicon-download-alt"></span> Download Results
|
||||||
|
</button>
|
||||||
|
|
||||||
<button data-bind="click: cancel, visible: showCancel()" type="button" class="btn btn-primary btn-sm" >
|
<button data-bind="click: cancel, visible: showCancel()" type="button" class="btn btn-primary btn-sm" >
|
||||||
<span class="glyphicon glyphicon-remove-circle"></span> Cancel
|
<span class="glyphicon glyphicon-remove-circle"></span> Cancel
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -109,7 +109,10 @@ $(function(){
|
||||||
return this.info().status &&
|
return this.info().status &&
|
||||||
(this.info().status.code === codes.FAILED || this.info().status.code === codes.COMPLETED || this.info().status.code === codes.CANCELED);
|
(this.info().status.code === codes.FAILED || this.info().status.code === codes.COMPLETED || this.info().status.code === codes.CANCELED);
|
||||||
}, this);
|
}, this);
|
||||||
|
this.showDownload = ko.pureComputed(function(){
|
||||||
|
return this.info().status &&
|
||||||
|
(this.info().status.code === codes.COMPLETED);
|
||||||
|
}, this);
|
||||||
this.startRefreshingInfo();
|
this.startRefreshingInfo();
|
||||||
}
|
}
|
||||||
Task.prototype.refreshInfo = function(){
|
Task.prototype.refreshInfo = function(){
|
||||||
|
@ -229,6 +232,9 @@ $(function(){
|
||||||
Task.prototype.restart = genApiCall("/task/restart", function(task){
|
Task.prototype.restart = genApiCall("/task/restart", function(task){
|
||||||
task.resetOutput();
|
task.resetOutput();
|
||||||
});
|
});
|
||||||
|
Task.prototype.download = function(){
|
||||||
|
location.href = "/task/" + this.uuid + "/download/all";
|
||||||
|
};
|
||||||
|
|
||||||
var taskList = new TaskList();
|
var taskList = new TaskList();
|
||||||
ko.applyBindings(taskList);
|
ko.applyBindings(taskList);
|
||||||
|
|
Ładowanie…
Reference in New Issue