Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backlink to task #156

Merged
merged 5 commits into from
Oct 25, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cvat/apps/dashboard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
#
# SPDX-License-Identifier: MIT

from cvat.settings.base import JS_3RDPARTY

JS_3RDPARTY['engine'] = JS_3RDPARTY.get('engine', []) + ['dashboard/js/enginePlugin.js']
15 changes: 15 additions & 0 deletions cvat/apps/dashboard/static/dashboard/js/enginePlugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright (C) 2018 Intel Corporation
*
* SPDX-License-Identifier: MIT
*/

"use strict";

window.addEventListener('DOMContentLoaded', () => {
$(`<button class="menuButton semiBold h2"> Open Task </button>`).on('click', () => {
let win = window.open(`${window.location.origin }/dashboard/?jid=${window.cvat.job.id}`, '_blank');
win.focus();
}).prependTo('#engineMenuButtons');
});

2 changes: 1 addition & 1 deletion cvat/apps/dashboard/templates/dashboard/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</table>
</center>

{% autopaginate data %}
{% autopaginate data tasks_per_page %}
<div style="float: left; width: 100%">
{% for item in data %}
{% include "dashboard/task.html" %}
Expand Down
37 changes: 27 additions & 10 deletions cvat/apps/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from django.contrib.auth.decorators import permission_required
from cvat.apps.authentication.decorators import login_required

from cvat.apps.engine.models import Task as TaskModel
from cvat.apps.engine.models import Task as TaskModel, Job as JobModel
from cvat.settings.base import JS_3RDPARTY

import os
Expand Down Expand Up @@ -97,22 +97,39 @@ def DetailTaskInfo(request, task, dst_dict):
@login_required
@permission_required('engine.view_task', raise_exception=True)
def DashboardView(request):
filter_name = request.GET['search'] if 'search' in request.GET else None
tasks_query_set = list(TaskModel.objects.prefetch_related('segment_set').order_by('-created_date').all())
if filter_name is not None:
tasks_query_set = list(filter(lambda x: filter_name.lower() in x.name.lower(), tasks_query_set))
query_name = request.GET['search'] if 'search' in request.GET else None
query_job = int(request.GET['jid']) if 'jid' in request.GET and request.GET['jid'].isdigit() else None
query_page = None
elements_per_page = 20
task_list = None

if query_job is not None and JobModel.objects.filter(pk = query_job).exists():
task_list = [JobModel.objects.select_related('segment__task').get(pk = query_job).segment.task]
else:
task_list = list(TaskModel.objects.prefetch_related('segment_set').order_by('-created_date').all())
if query_name is not None:
task_list = list(filter(lambda x: query_name.lower() in x.name.lower(), task_list))
query_page = int(request.GET['page']) if 'page' in request.GET and request.GET['page'].isdigit() else None

if query_page is not None:
start, stop = (query_page - 1) * elements_per_page, query_page * elements_per_page - 1 # 0, 19; 20, 39, 40, 59 etc
task_list = [ None if idx < start or idx > stop else task for idx, task in enumerate(task_list) ]
bsekachev marked this conversation as resolved.
Show resolved Hide resolved

data = []
for task in tasks_query_set:
task_info = {}
MainTaskInfo(task, task_info)
DetailTaskInfo(request, task, task_info)
data.append(task_info)
for task in task_list:
if task is not None:
task_info = {}
MainTaskInfo(task, task_info)
bsekachev marked this conversation as resolved.
Show resolved Hide resolved
DetailTaskInfo(request, task, task_info)
data.append(task_info)
else:
data.append(None)
bsekachev marked this conversation as resolved.
Show resolved Hide resolved

return render(request, 'dashboard/dashboard.html', {
'data': data,
'max_upload_size': settings.LOCAL_LOAD_MAX_FILES_SIZE,
'max_upload_count': settings.LOCAL_LOAD_MAX_FILES_COUNT,
'tasks_per_page': elements_per_page,
'share_path': os.getenv('CVAT_SHARE_URL', default=r'${cvat_root}/share'),
'js_3rdparty': JS_3RDPARTY.get('dashboard', [])
})