Added some changes proposed by @mojodna

pull/40/head
Piero Toffanin 2016-11-03 18:13:26 -04:00
rodzic 955c9af4a6
commit 31e46bbfb9
3 zmienionych plików z 30 dodań i 32 usunięć

Wyświetl plik

@ -111,7 +111,7 @@ class TaskViewSet(viewsets.ViewSet):
for file in filesList]
task = models.Task.create_from_images(files, project)
if not task is None:
if task is not None:
return Response({"id": task.id}, status=status.HTTP_201_CREATED)
else:
raise exceptions.ValidationError(detail="Cannot create task, input provided is not valid.")

Wyświetl plik

@ -167,6 +167,7 @@ class ProjectListItem extends React.Component {
this.setState({
showTaskList: !this.state.showTaskList
});
console.log(this.props);
}
closeUploadError(){
@ -179,9 +180,6 @@ class ProjectListItem extends React.Component {
handleUpload(){
this.resetUploadState();
// Hide task list
// if (this.state.showTaskList) this.toggleTaskList();
}
handleTaskSaved(taskInfo){

Wyświetl plik

@ -118,22 +118,7 @@ class TaskListItem extends React.Component {
return [pad(h), pad(m), pad(s)].join(':');
}
render() {
let name = this.state.task.name !== null ? this.state.task.name : `Task #${this.state.task.id}`;
let status = statusCodes.description(this.state.task.status);
if (status === "") status = "Uploading images";
if (this.state.task.pending_action !== null) status = pendingActions.description(this.state.task.pending_action);
let expanded = "";
if (this.state.expanded){
let actionButtons = [];
const addActionButton = (label, className, icon, onClick) => {
actionButtons.push({
className, icon, label, onClick
});
};
const genActionApiCall = (action) => {
genActionApiCall(action){
return () => {
this.setState({actionButtonsDisabled: true});
@ -158,11 +143,26 @@ class TaskListItem extends React.Component {
});
});
};
}
render() {
let name = this.state.task.name !== null ? this.state.task.name : `Task #${this.state.task.id}`;
let status = statusCodes.description(this.state.task.status);
if (status === "") status = "Uploading images";
if (this.state.task.pending_action !== null) status = pendingActions.description(this.state.task.pending_action);
let expanded = "";
if (this.state.expanded){
let actionButtons = [];
const addActionButton = (label, className, icon, onClick) => {
actionButtons.push({
className, icon, label, onClick
});
};
if ([statusCodes.QUEUED, statusCodes.RUNNING, null].indexOf(this.state.task.status) !== -1){
addActionButton("Cancel", "btn-primary", "glyphicon glyphicon-remove-circle", genActionApiCall("cancel"));
addActionButton("Cancel", "btn-primary", "glyphicon glyphicon-remove-circle", this.genActionApiCall("cancel"));
}
// addActionButton("Restart", "btn-primary", "glyphicon glyphicon-play", genActionApiCall("cancel"));