kopia lustrzana https://github.com/OpenDroneMap/WebODM
Adding dialogs
rodzic
e9437ec8e1
commit
48acd62d63
Plik binarny nie jest wyświetlany.
|
@ -10,16 +10,16 @@ from app.plugins import logger
|
|||
|
||||
#from .platform_helper import get_all_extended_platforms
|
||||
|
||||
# def LoadButtonsView(plugin):
|
||||
# def view(request):
|
||||
def LoadButtonsView(plugin):
|
||||
def view(request):
|
||||
|
||||
# return render(
|
||||
# request,
|
||||
# plugin.template_path("load_buttons.js"),
|
||||
# {
|
||||
# "api_url": "/api" + plugin.public_url("").rstrip("/"),
|
||||
# },
|
||||
# content_type="text/javascript",
|
||||
# )
|
||||
return render(
|
||||
request,
|
||||
plugin.template_path("load_buttons.js"),
|
||||
{
|
||||
"api_url": "/api" + plugin.public_url("").rstrip("/"),
|
||||
},
|
||||
content_type="text/javascript",
|
||||
)
|
||||
|
||||
# return view
|
||||
return view
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from app.plugins import PluginBase, Menu, MountPoint, logger
|
||||
from coreplugins.dronedb.app_views import LoadButtonsView
|
||||
|
||||
from .api_views import ImportDatasetTaskView, CheckUrlTaskView
|
||||
#from .app_views import HomeView, LoadButtonsView
|
||||
|
@ -37,8 +38,8 @@ class Plugin(PluginBase):
|
|||
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("platforms/(?P<platform_name>[^/.]+)/verify", PlatformsVerifyTaskView.as_view()),
|
||||
MountPoint("platforms", PlatformsTaskView.as_view()),
|
||||
#MountPoint("platforms/(?P<platform_name>[^/.]+)/verify", PlatformsVerifyTaskView.as_view()),
|
||||
#MountPoint("platforms", PlatformsTaskView.as_view()),
|
||||
]
|
||||
|
||||
def HomeView(self):
|
||||
|
|
|
@ -3,12 +3,13 @@ import PropTypes from 'prop-types';
|
|||
|
||||
import ResizeModes from 'webodm/classes/ResizeModes';
|
||||
|
||||
import PlatformSelectButton from "./components/PlatformSelectButton";
|
||||
import PlatformDialog from "./components/PlatformDialog";
|
||||
import LibraryDialog from "./components/LibraryDialog";
|
||||
import ErrorDialog from "./components/ErrorDialog";
|
||||
import ConfigureNewTaskDialog from "./components/ConfigureNewTaskDialog";
|
||||
|
||||
import "./ImportView.scss";
|
||||
|
||||
export default class TaskView extends Component {
|
||||
static propTypes = {
|
||||
projectId: PropTypes.number.isRequired,
|
||||
|
@ -18,24 +19,27 @@ export default class TaskView extends Component {
|
|||
|
||||
state = {
|
||||
error: "",
|
||||
currentPlatform: null,
|
||||
selectedFolder: null,
|
||||
platforms: [],
|
||||
ddbUrl: "",
|
||||
selectedFolder: "",
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
$.getJSON(`${this.props.apiURL}/platforms/`)
|
||||
|
||||
// We should check if username and password were set in the DroneDB config
|
||||
|
||||
/*$.getJSON(`${this.props.apiURL}/platforms/`)
|
||||
.done(data => {
|
||||
this.setState({platforms: data.platforms});
|
||||
})
|
||||
.fail(() => {
|
||||
this.onErrorInDialog("Failed to find available platforms")
|
||||
})
|
||||
*/
|
||||
}
|
||||
|
||||
onSelectPlatform = platform => this.setState({ currentPlatform: platform });
|
||||
//onSelectPlatform = platform => this.setState({ currentPlatform: platform });
|
||||
onSelectFolder = folder => this.setState({ selectedFolder: folder });
|
||||
onHideDialog = () => this.setState({ currentPlatform: null, selectedFolder: null, taskId: null });
|
||||
onHideDialog = () => this.setState({ ddbUrl: null, taskId: null });
|
||||
|
||||
onSaveTask = taskInfo => {
|
||||
// Create task
|
||||
|
@ -47,8 +51,8 @@ export default class TaskView extends Component {
|
|||
partial: true
|
||||
};
|
||||
|
||||
if (taskInfo.resizeMode === ResizeModes.YES){
|
||||
formData.resize_to = taskInfo.resizeSize;
|
||||
if (taskInfo.resizeMode === ResizeModes.YES) {
|
||||
formData.resize_to = taskInfo.resizeSize;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
|
@ -61,7 +65,7 @@ export default class TaskView extends Component {
|
|||
$.ajax({
|
||||
url: `${this.props.apiURL}/projects/${this.props.projectId}/tasks/${task.id}/import`,
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({platform: this.state.currentPlatform.name, selectedFolderUrl: this.state.selectedFolder.url}),
|
||||
data: JSON.stringify({ddb_url: this.state.ddbUrl}),
|
||||
dataType: 'json',
|
||||
type: 'POST'
|
||||
}).done(() => {
|
||||
|
@ -82,33 +86,32 @@ export default class TaskView extends Component {
|
|||
|
||||
render() {
|
||||
const {
|
||||
currentPlatform,
|
||||
error,
|
||||
selectedFolder,
|
||||
platforms,
|
||||
ddbUrl,
|
||||
} = this.state;
|
||||
return (
|
||||
<Fragment>
|
||||
{error ?
|
||||
<ErrorDialog errorMessage={error} />
|
||||
: ""}
|
||||
<PlatformSelectButton
|
||||
platforms={platforms}
|
||||
onSelect={this.onSelectPlatform}
|
||||
/>
|
||||
{error ? <ErrorDialog errorMessage={error} /> : ""}
|
||||
<Button
|
||||
id={"dronedbButton"}
|
||||
bsStyle={"default"}
|
||||
bsSize={"small"}
|
||||
className={"platform-btn"}
|
||||
onClick={this.handleClick}>
|
||||
<i className={"fas fa-cloud"} />
|
||||
DroneDB
|
||||
</Button>
|
||||
{selectedFolder === null ?
|
||||
<Fragment>
|
||||
<PlatformDialog
|
||||
show={selectedFolder === null}
|
||||
platform={currentPlatform}
|
||||
apiURL={this.props.apiURL}
|
||||
onHide={this.onHideDialog}
|
||||
onSubmit={this.onSelectFolder}
|
||||
/>
|
||||
<LibraryDialog
|
||||
show={selectedFolder === null}
|
||||
platform={currentPlatform}
|
||||
apiURL={this.props.apiURL}
|
||||
apiURL={this.props.apiURL}
|
||||
onHide={this.onHideDialog}
|
||||
onSubmit={this.onSelectFolder}
|
||||
/>
|
||||
|
@ -116,8 +119,7 @@ export default class TaskView extends Component {
|
|||
:
|
||||
<ConfigureNewTaskDialog
|
||||
show={selectedFolder !== null}
|
||||
folder={selectedFolder}
|
||||
platform={currentPlatform}
|
||||
folder={selectedFolder}
|
||||
onHide={this.onHideDialog}
|
||||
onSaveTask={this.onSaveTask}
|
||||
/>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
.platform-btn {
|
||||
.fa-cloud-import {
|
||||
.fa-cloud {
|
||||
margin-right: 0.5em;
|
||||
}
|
||||
|
||||
|
@ -10,12 +10,4 @@
|
|||
.btn-sm {
|
||||
border-radius: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.platforms-dropdowns {
|
||||
display: inline-block;
|
||||
|
||||
.dropdown {
|
||||
float: none;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
import React, { PureComponent, Fragment } from "react";
|
||||
|
||||
import { DropdownButton, MenuItem } from "react-bootstrap";
|
||||
|
||||
import "./PlatformSelectButton.scss";
|
||||
|
||||
export default class PlatformSelectButton extends PureComponent {
|
||||
static defaultProps = {
|
||||
platforms: [],
|
||||
onSelect: () => {}
|
||||
};
|
||||
|
||||
handleClick = platform => () => this.props.onSelect(platform);
|
||||
|
||||
render() {
|
||||
const {
|
||||
platforms,
|
||||
onSelect,
|
||||
} = this.props;
|
||||
|
||||
const menuItems = platforms
|
||||
.map(platform => (
|
||||
<MenuItem
|
||||
key={platform.name}
|
||||
tag={"a"}
|
||||
onClick={this.handleClick(platform)}
|
||||
>
|
||||
<Fragment>
|
||||
{" "}
|
||||
{platform.name}
|
||||
</Fragment>
|
||||
</MenuItem>
|
||||
));
|
||||
|
||||
const title = (
|
||||
<Fragment>
|
||||
<i className={"fa fa-cloud-download-alt fa-cloud-import"} />
|
||||
Cloud Import
|
||||
</Fragment>
|
||||
|
||||
);
|
||||
|
||||
return (
|
||||
<DropdownButton
|
||||
id={"platformsDropdown"}
|
||||
bsStyle={"default"}
|
||||
bsSize={"small"}
|
||||
className={"platform-btn"}
|
||||
title={title}
|
||||
>
|
||||
{menuItems}
|
||||
</DropdownButton>
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
PluginsAPI.Dashboard.addNewTaskButton(
|
||||
["cloudimport/build/ImportView.js"],
|
||||
["dronedb/build/ImportView.js"],
|
||||
function(args, ImportView) {
|
||||
return React.createElement(ImportView, {
|
||||
onNewTaskAdded: args.onNewTaskAdded,
|
||||
|
@ -10,7 +10,7 @@ PluginsAPI.Dashboard.addNewTaskButton(
|
|||
);
|
||||
|
||||
PluginsAPI.Dashboard.addTaskActionButton(
|
||||
["cloudimport/build/TaskView.js", "cloudimport/build/TaskView.css"],
|
||||
["dronedb/build/TaskView.js", "dronedb/build/TaskView.css"],
|
||||
function(args, TaskView) {
|
||||
var reactElement;
|
||||
$.ajax({
|
||||
|
|
Ładowanie…
Reference in New Issue