kopia lustrzana https://github.com/OpenDroneMap/WebODM
Added task list mockup
rodzic
621e9dbf09
commit
9581f563b7
|
@ -14,9 +14,9 @@ scheduler = None
|
||||||
def job(func):
|
def job(func):
|
||||||
def wrapper(*args,**kwargs):
|
def wrapper(*args,**kwargs):
|
||||||
if (kwargs.get('background', False)):
|
if (kwargs.get('background', False)):
|
||||||
thread = (threading.Thread(target=func))
|
t = (threading.Thread(target=func))
|
||||||
thread.start()
|
t.start()
|
||||||
return thread
|
return t
|
||||||
else:
|
else:
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import '../css/ProjectListItem.scss';
|
import '../css/ProjectListItem.scss';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import update from 'react-addons-update';
|
import update from 'react-addons-update';
|
||||||
import ProjectListItemPanel from './ProjectListItemPanel';
|
import TaskList from './TaskList';
|
||||||
import EditTaskPanel from './EditTaskPanel';
|
import EditTaskPanel from './EditTaskPanel';
|
||||||
import UploadProgressBar from './UploadProgressBar';
|
import UploadProgressBar from './UploadProgressBar';
|
||||||
import Dropzone from '../vendor/dropzone';
|
import Dropzone from '../vendor/dropzone';
|
||||||
|
@ -13,12 +13,12 @@ class ProjectListItem extends React.Component {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
showPanel: false,
|
showTaskList: false,
|
||||||
updatingTask: false,
|
updatingTask: false,
|
||||||
upload: this.getDefaultUploadState()
|
upload: this.getDefaultUploadState()
|
||||||
};
|
};
|
||||||
|
|
||||||
this.togglePanel = this.togglePanel.bind(this);
|
this.toggleTaskList = this.toggleTaskList.bind(this);
|
||||||
this.handleUpload = this.handleUpload.bind(this);
|
this.handleUpload = this.handleUpload.bind(this);
|
||||||
this.closeUploadError = this.closeUploadError.bind(this);
|
this.closeUploadError = this.closeUploadError.bind(this);
|
||||||
this.cancelUpload = this.cancelUpload.bind(this);
|
this.cancelUpload = this.cancelUpload.bind(this);
|
||||||
|
@ -145,10 +145,10 @@ class ProjectListItem extends React.Component {
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
type: 'PATCH'
|
type: 'PATCH'
|
||||||
}).done(() => {
|
}).done(() => {
|
||||||
if (this.state.showPanel){
|
if (this.state.showTaskList){
|
||||||
this.projectListItemPanel.refresh();
|
this.taskList.refresh();
|
||||||
}else{
|
}else{
|
||||||
this.setState({showPanel: true});
|
this.setState({showTaskList: true});
|
||||||
}
|
}
|
||||||
}).fail(() => {
|
}).fail(() => {
|
||||||
this.setUploadState({error: "Could not update task information. Plese try again."});
|
this.setUploadState({error: "Could not update task information. Plese try again."});
|
||||||
|
@ -163,9 +163,9 @@ class ProjectListItem extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
togglePanel(){
|
toggleTaskList(){
|
||||||
this.setState({
|
this.setState({
|
||||||
showPanel: !this.state.showPanel
|
showTaskList: !this.state.showTaskList
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,10 +223,18 @@ class ProjectListItem extends React.Component {
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<i style={{width: 14}} className={'fa ' + (this.state.showPanel ? 'fa-caret-down' : 'fa-caret-right')}>
|
<span className="project-name">
|
||||||
</i> <a href="javascript:void(0);" onClick={this.togglePanel}>
|
|
||||||
{this.props.data.name}
|
{this.props.data.name}
|
||||||
</a>
|
</span>
|
||||||
|
<div className="project-description">
|
||||||
|
{this.props.data.description}
|
||||||
|
</div>
|
||||||
|
<div className="row project-links">
|
||||||
|
<i className='fa fa-tasks'>
|
||||||
|
</i> <a href="javascript:void(0);" onClick={this.toggleTaskList}>
|
||||||
|
{(this.state.showTaskList ? 'Hide' : 'Show')} Tasks
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="dropzone" ref={this.setRef("dropzone")}>
|
<div className="dropzone" ref={this.setRef("dropzone")}>
|
||||||
|
@ -234,7 +242,7 @@ class ProjectListItem extends React.Component {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{this.state.showPanel ? <ProjectListItemPanel ref={this.setRef("projectListItemPanel")}/> : ""}
|
{this.state.showTaskList ? <TaskList ref={this.setRef("taskList")}/> : ""}
|
||||||
|
|
||||||
{this.state.upload.showEditTask ? <UploadProgressBar {...this.state.upload}/> : ""}
|
{this.state.upload.showEditTask ? <UploadProgressBar {...this.state.upload}/> : ""}
|
||||||
|
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
|
|
||||||
class ProjectListItemPanel extends React.Component {
|
|
||||||
constructor(){
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount(){
|
|
||||||
console.log("DISPLAY");
|
|
||||||
}
|
|
||||||
|
|
||||||
refresh(){
|
|
||||||
console.log("REFRESH");
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
return (
|
|
||||||
<div className="project-list-item-panel">
|
|
||||||
TODO
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ProjectListItemPanel;
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
import React from 'react';
|
||||||
|
import '../css/TaskList.scss';
|
||||||
|
|
||||||
|
class TaskList extends React.Component {
|
||||||
|
constructor(){
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount(){
|
||||||
|
console.log("DISPLAY");
|
||||||
|
}
|
||||||
|
|
||||||
|
refresh(){
|
||||||
|
console.log("REFRESH");
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div className="task-list">
|
||||||
|
<span>Updating task list... <i className="fa fa-refresh fa-spin fa-fw"></i></span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TaskList;
|
|
@ -1,8 +1,4 @@
|
||||||
#dashboard-app{
|
#dashboard-app{
|
||||||
.project-list-item-panel{
|
|
||||||
min-height: 100px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.row{
|
.row{
|
||||||
&.no-margin{
|
&.no-margin{
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
.project-list-item{
|
.project-list-item{
|
||||||
min-height: 60px;
|
min-height: 60px;
|
||||||
|
|
||||||
|
.project-name{
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-links{
|
||||||
|
font-size: 90%;
|
||||||
|
i{
|
||||||
|
margin-right: 4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.dz-preview{
|
.dz-preview{
|
||||||
display: none;
|
display: none;
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
.task-list{
|
||||||
|
background-color: #ecf0f1;
|
||||||
|
padding: 10px;
|
||||||
|
min-height: 100px;
|
||||||
|
}
|
|
@ -32,4 +32,12 @@ class ApiClient:
|
||||||
|
|
||||||
@check_client
|
@check_client
|
||||||
def options(self):
|
def options(self):
|
||||||
return self.client.server.get_options().result()
|
return self.client.server.get_options().result()
|
||||||
|
|
||||||
|
@check_client
|
||||||
|
def new_task(self):
|
||||||
|
print(dir(self.client.task.post_task_new))
|
||||||
|
return self.client.task.post_task_new(images=[])
|
||||||
|
|
||||||
|
a = ApiClient("localhost", 3000)
|
||||||
|
a.new_task()
|
|
@ -16,12 +16,6 @@ class ProcessingNode(models.Model):
|
||||||
queue_count = models.PositiveIntegerField(default=0, help_text="Number of tasks currently being processed by this node (as reported by the node itself)")
|
queue_count = models.PositiveIntegerField(default=0, help_text="Number of tasks currently being processed by this node (as reported by the node itself)")
|
||||||
available_options = fields.JSONField(default=dict(), help_text="Description of the options that can be used for processing")
|
available_options = fields.JSONField(default=dict(), help_text="Description of the options that can be used for processing")
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super(ProcessingNode, self).__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
# Initialize api client
|
|
||||||
self.api_client = ApiClient(self.hostname, self.port)
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return '{}:{}'.format(self.hostname, self.port)
|
return '{}:{}'.format(self.hostname, self.port)
|
||||||
|
|
||||||
|
@ -32,12 +26,13 @@ class ProcessingNode(models.Model):
|
||||||
|
|
||||||
:returns: True if information could be updated, False otherwise
|
:returns: True if information could be updated, False otherwise
|
||||||
"""
|
"""
|
||||||
info = self.api_client.info()
|
api_client = self.api_client()
|
||||||
|
info = api_client.info()
|
||||||
if info != None:
|
if info != None:
|
||||||
self.api_version = info['version']
|
self.api_version = info['version']
|
||||||
self.queue_count = info['taskQueueCount']
|
self.queue_count = info['taskQueueCount']
|
||||||
|
|
||||||
options = self.api_client.options()
|
options = api_client.options()
|
||||||
if options != None:
|
if options != None:
|
||||||
self.available_options = options
|
self.available_options = options
|
||||||
self.last_refreshed = timezone.now()
|
self.last_refreshed = timezone.now()
|
||||||
|
@ -46,12 +41,25 @@ class ProcessingNode(models.Model):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def api_client(self):
|
||||||
|
return ApiClient(self.hostname, self.port)
|
||||||
|
|
||||||
def get_available_options_json(self):
|
def get_available_options_json(self):
|
||||||
"""
|
"""
|
||||||
:returns available options in JSON string format
|
:returns available options in JSON string format
|
||||||
"""
|
"""
|
||||||
return json.dumps(self.available_options)
|
return json.dumps(self.available_options)
|
||||||
|
|
||||||
|
def process_new_task(self):
|
||||||
|
"""
|
||||||
|
Sends a set of images (and optional GCP file) via the API
|
||||||
|
to start processing.
|
||||||
|
|
||||||
|
:returns UUID of the newly created task or ... ?
|
||||||
|
"""
|
||||||
|
api_client = self.api_client()
|
||||||
|
|
||||||
|
|
||||||
# First time a processing node is created, automatically try to update
|
# First time a processing node is created, automatically try to update
|
||||||
@receiver(signals.post_save, sender=ProcessingNode, dispatch_uid="update_processing_node_info")
|
@receiver(signals.post_save, sender=ProcessingNode, dispatch_uid="update_processing_node_info")
|
||||||
def auto_update_node_info(sender, instance, created, **kwargs):
|
def auto_update_node_info(sender, instance, created, **kwargs):
|
||||||
|
|
Ładowanie…
Reference in New Issue