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] for file in filesList]
task = models.Task.create_from_images(files, project) 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) return Response({"id": task.id}, status=status.HTTP_201_CREATED)
else: else:
raise exceptions.ValidationError(detail="Cannot create task, input provided is not valid.") 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({ this.setState({
showTaskList: !this.state.showTaskList showTaskList: !this.state.showTaskList
}); });
console.log(this.props);
} }
closeUploadError(){ closeUploadError(){
@ -179,9 +180,6 @@ class ProjectListItem extends React.Component {
handleUpload(){ handleUpload(){
this.resetUploadState(); this.resetUploadState();
// Hide task list
// if (this.state.showTaskList) this.toggleTaskList();
} }
handleTaskSaved(taskInfo){ handleTaskSaved(taskInfo){

Wyświetl plik

@ -118,22 +118,7 @@ class TaskListItem extends React.Component {
return [pad(h), pad(m), pad(s)].join(':'); return [pad(h), pad(m), pad(s)].join(':');
} }
render() { genActionApiCall(action){
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) => {
return () => { return () => {
this.setState({actionButtonsDisabled: true}); 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){ 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")); // addActionButton("Restart", "btn-primary", "glyphicon glyphicon-play", genActionApiCall("cancel"));