Added task list mockup

pull/39/head
Piero Toffanin 2016-10-25 10:47:49 -04:00
rodzic 621e9dbf09
commit 9581f563b7
9 zmienionych plików z 90 dodań i 53 usunięć

Wyświetl plik

@ -14,9 +14,9 @@ scheduler = None
def job(func):
def wrapper(*args,**kwargs):
if (kwargs.get('background', False)):
thread = (threading.Thread(target=func))
thread.start()
return thread
t = (threading.Thread(target=func))
t.start()
return t
else:
return func(*args, **kwargs)
return wrapper

Wyświetl plik

@ -1,7 +1,7 @@
import '../css/ProjectListItem.scss';
import React from 'react';
import update from 'react-addons-update';
import ProjectListItemPanel from './ProjectListItemPanel';
import TaskList from './TaskList';
import EditTaskPanel from './EditTaskPanel';
import UploadProgressBar from './UploadProgressBar';
import Dropzone from '../vendor/dropzone';
@ -13,12 +13,12 @@ class ProjectListItem extends React.Component {
super(props);
this.state = {
showPanel: false,
showTaskList: false,
updatingTask: false,
upload: this.getDefaultUploadState()
};
this.togglePanel = this.togglePanel.bind(this);
this.toggleTaskList = this.toggleTaskList.bind(this);
this.handleUpload = this.handleUpload.bind(this);
this.closeUploadError = this.closeUploadError.bind(this);
this.cancelUpload = this.cancelUpload.bind(this);
@ -145,10 +145,10 @@ class ProjectListItem extends React.Component {
dataType: 'json',
type: 'PATCH'
}).done(() => {
if (this.state.showPanel){
this.projectListItemPanel.refresh();
if (this.state.showTaskList){
this.taskList.refresh();
}else{
this.setState({showPanel: true});
this.setState({showTaskList: true});
}
}).fail(() => {
this.setUploadState({error: "Could not update task information. Plese try again."});
@ -163,9 +163,9 @@ class ProjectListItem extends React.Component {
}
}
togglePanel(){
toggleTaskList(){
this.setState({
showPanel: !this.state.showPanel
showTaskList: !this.state.showTaskList
});
}
@ -223,18 +223,26 @@ class ProjectListItem extends React.Component {
</ul>
</div>
<i style={{width: 14}} className={'fa ' + (this.state.showPanel ? 'fa-caret-down' : 'fa-caret-right')}>
</i> <a href="javascript:void(0);" onClick={this.togglePanel}>
<span className="project-name">
{this.props.data.name}
</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 className="row">
<div className="dropzone" ref={this.setRef("dropzone")}>
<div className="dz-default dz-message text-center">
</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}/> : ""}

Wyświetl plik

@ -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;

Wyświetl plik

@ -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;

Wyświetl plik

@ -1,8 +1,4 @@
#dashboard-app{
.project-list-item-panel{
min-height: 100px;
}
.row{
&.no-margin{
margin: 0;

Wyświetl plik

@ -1,6 +1,17 @@
.project-list-item{
min-height: 60px;
.project-name{
font-weight: bold;
}
.project-links{
font-size: 90%;
i{
margin-right: 4px;
}
}
.dz-preview{
display: none;
}

Wyświetl plik

@ -0,0 +1,5 @@
.task-list{
background-color: #ecf0f1;
padding: 10px;
min-height: 100px;
}

Wyświetl plik

@ -33,3 +33,11 @@ class ApiClient:
@check_client
def options(self):
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()

Wyświetl plik

@ -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)")
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):
return '{}:{}'.format(self.hostname, self.port)
@ -32,12 +26,13 @@ class ProcessingNode(models.Model):
: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:
self.api_version = info['version']
self.queue_count = info['taskQueueCount']
options = self.api_client.options()
options = api_client.options()
if options != None:
self.available_options = options
self.last_refreshed = timezone.now()
@ -46,12 +41,25 @@ class ProcessingNode(models.Model):
return True
return False
def api_client(self):
return ApiClient(self.hostname, self.port)
def get_available_options_json(self):
"""
:returns available options in JSON string format
"""
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
@receiver(signals.post_save, sender=ProcessingNode, dispatch_uid="update_processing_node_info")
def auto_update_node_info(sender, instance, created, **kwargs):