kopia lustrzana https://github.com/OpenDroneMap/WebODM
Added go to dataset button
rodzic
1cd6f1fbdd
commit
5d71c09460
|
@ -1,4 +1,5 @@
|
|||
import importlib
|
||||
import json
|
||||
import requests
|
||||
import os
|
||||
from os import path
|
||||
|
@ -14,8 +15,6 @@ from worker.celery import app
|
|||
from rest_framework.response import Response
|
||||
from rest_framework import status
|
||||
|
||||
#from .platform_helper import get_all_platforms, get_platform_by_name
|
||||
|
||||
VALID_IMAGE_EXTENSIONS = ['.tiff', '.tif', '.png', '.jpeg', '.jpg']
|
||||
|
||||
def is_valid(file):
|
||||
|
@ -45,6 +44,9 @@ def get_ddb(request):
|
|||
|
||||
return DroneDB(registry_url, username, password, token, lambda token: update_token(request, token))
|
||||
|
||||
def to_web_protocol(registry_url):
|
||||
return registry_url.replace('ddb+unsafe://', 'http://').replace('ddb://', 'https://').rstrip('/')
|
||||
|
||||
class ImportDatasetTaskView(TaskView):
|
||||
def post(self, request, project_pk=None, pk=None):
|
||||
|
||||
|
@ -79,7 +81,7 @@ class ImportDatasetTaskView(TaskView):
|
|||
combined_id = "{}_{}".format(project_pk, pk)
|
||||
|
||||
datastore = get_current_plugin().get_global_data_store()
|
||||
datastore.set_string(combined_id, {'ddbUrl': ddb_url, 'token': ddb.token})
|
||||
datastore.set_json(combined_id, {"ddbUrl": ddb_url, "token": ddb.token, "ddbWebUrl": "{}/r/{}/{}/{}".format(to_web_protocol(registry_url), orgSlug, dsSlug, folder.rstrip('/'))})
|
||||
|
||||
# Start importing the files in the background
|
||||
serialized = {'token': ddb.token, 'files': files}
|
||||
|
@ -233,3 +235,22 @@ def import_files(task_id, carrier):
|
|||
task.processing_time = 0
|
||||
task.partial = False
|
||||
task.save()
|
||||
|
||||
class CheckUrlTaskView(TaskView):
|
||||
def get(self, request, project_pk=None, pk=None):
|
||||
|
||||
from app.plugins import logger
|
||||
|
||||
# Assert that task exists
|
||||
self.get_and_check_task(request, pk)
|
||||
|
||||
# Check if there is an imported url associated with the project and task
|
||||
combined_id = "{}_{}".format(project_pk, pk)
|
||||
data = get_current_plugin().get_global_data_store().get_json(combined_id, default = None)
|
||||
|
||||
logger.info(data)
|
||||
|
||||
if data == None or 'ddbWebUrl' not in data:
|
||||
return Response({'ddbWebUrl': None}, status=status.HTTP_200_OK)
|
||||
else:
|
||||
return Response({'ddbUrl': data['ddbWebUrl']}, status=status.HTTP_200_OK)
|
||||
|
|
|
@ -2,7 +2,7 @@ from app.plugins import PluginBase, Menu, MountPoint, logger
|
|||
from coreplugins.dronedb.app_views import LoadButtonsView
|
||||
from coreplugins.dronedb.ddb import DEFAULT_HUB_URL
|
||||
|
||||
from .api_views import FoldersTaskView, ImportDatasetTaskView, CheckCredentialsTaskView, OrganizationsTaskView, DatasetsTaskView, VerifyUrlTaskView, InfoTaskView
|
||||
from .api_views import CheckUrlTaskView, FoldersTaskView, ImportDatasetTaskView, CheckCredentialsTaskView, OrganizationsTaskView, DatasetsTaskView, VerifyUrlTaskView, InfoTaskView
|
||||
|
||||
from django.contrib import messages
|
||||
from django.shortcuts import render
|
||||
|
@ -33,6 +33,7 @@ class Plugin(PluginBase):
|
|||
def api_mount_points(self):
|
||||
return [
|
||||
MountPoint("projects/(?P<project_pk>[^/.]+)/tasks/(?P<pk>[^/.]+)/import", ImportDatasetTaskView.as_view()),
|
||||
MountPoint("projects/(?P<project_pk>[^/.]+)/tasks/(?P<pk>[^/.]+)/checkforurl", CheckUrlTaskView.as_view()),
|
||||
MountPoint("checkcredentials", CheckCredentialsTaskView.as_view()),
|
||||
MountPoint("organizations/(?P<org>[^/.]+)/datasets/(?P<ds>[^/.]+)/folders", FoldersTaskView.as_view()),
|
||||
MountPoint("organizations/(?P<org>[^/.]+)/datasets", DatasetsTaskView.as_view()),
|
||||
|
|
|
@ -6,18 +6,18 @@ import $ from "jquery"; // Fixes a AMD module definition error due to webpack
|
|||
|
||||
export default class TaskView extends Component {
|
||||
static propTypes = {
|
||||
folderUrl: PropTypes.string.isRequired,
|
||||
ddbUrl: PropTypes.string.isRequired,
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
folderUrl,
|
||||
ddbUrl,
|
||||
} = this.props;
|
||||
return (
|
||||
<Fragment>
|
||||
{folderUrl ?
|
||||
{ddbUrl ?
|
||||
<GoToFolderButton
|
||||
folderUrl={folderUrl}
|
||||
ddbUrl={ddbUrl}
|
||||
/>
|
||||
: ""}
|
||||
</Fragment>
|
||||
|
|
|
@ -6,10 +6,10 @@ import "./GoToFolderButton.scss";
|
|||
|
||||
export default class GoToFolderButton extends Component {
|
||||
static defaultProps = {
|
||||
folderUrl: null,
|
||||
ddbUrl: null,
|
||||
};
|
||||
|
||||
handleClick = () => window.open(this.props.folderUrl, '_blank');;
|
||||
handleClick = () => window.open(this.props.ddbUrl, '_blank');;
|
||||
|
||||
render() {
|
||||
return (
|
||||
|
@ -17,8 +17,8 @@ export default class GoToFolderButton extends Component {
|
|||
bsStyle={"primary"}
|
||||
bsSize={"small"}
|
||||
onClick={this.handleClick}>
|
||||
<i className={"fa fa-folder icon"} />
|
||||
Go To Import Folder
|
||||
<i className={"fas fa-database icon"} />
|
||||
Go To Dataset
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,11 @@ export default class SelectUrlDialog extends Component {
|
|||
constructor(props){
|
||||
super(props);
|
||||
|
||||
this.resetState();
|
||||
}
|
||||
|
||||
resetState() {
|
||||
|
||||
this.state = {
|
||||
error: "",
|
||||
organizations: [],
|
||||
|
@ -45,8 +50,6 @@ export default class SelectUrlDialog extends Component {
|
|||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Format bytes to readable string
|
||||
formatBytes(bytes, decimals=2) {
|
||||
if(bytes == 0) return '0 bytes';
|
||||
|
@ -58,6 +61,9 @@ export default class SelectUrlDialog extends Component {
|
|||
}
|
||||
|
||||
handleOnShow = () => {
|
||||
|
||||
this.resetState();
|
||||
|
||||
$.get(`${this.props.apiURL}/organizations`)
|
||||
.done(result => {
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ PluginsAPI.Dashboard.addNewTaskButton(
|
|||
}
|
||||
);
|
||||
|
||||
/*
|
||||
|
||||
PluginsAPI.Dashboard.addTaskActionButton(
|
||||
["dronedb/build/TaskView.js", "dronedb/build/TaskView.css"],
|
||||
function(args, TaskView) {
|
||||
|
@ -19,13 +19,13 @@ PluginsAPI.Dashboard.addTaskActionButton(
|
|||
dataType: 'json',
|
||||
async: false,
|
||||
success: function(data) {
|
||||
if (data.folder_url) {
|
||||
if (data.ddbUrl) {
|
||||
reactElement = React.createElement(TaskView, {
|
||||
folderUrl: data.folder_url,
|
||||
ddbUrl: data.ddbUrl,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
return reactElement;
|
||||
}
|
||||
);*/
|
||||
);
|
||||
|
|
Ładowanie…
Reference in New Issue