diff --git a/cvat/apps/dashboard/__init__.py b/cvat/apps/dashboard/__init__.py index d8e62e54b35..da270801d9c 100644 --- a/cvat/apps/dashboard/__init__.py +++ b/cvat/apps/dashboard/__init__.py @@ -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'] diff --git a/cvat/apps/dashboard/static/dashboard/js/enginePlugin.js b/cvat/apps/dashboard/static/dashboard/js/enginePlugin.js new file mode 100644 index 00000000000..4c95fa66bff --- /dev/null +++ b/cvat/apps/dashboard/static/dashboard/js/enginePlugin.js @@ -0,0 +1,15 @@ +/* + * Copyright (C) 2018 Intel Corporation + * + * SPDX-License-Identifier: MIT + */ + +"use strict"; + +window.addEventListener('DOMContentLoaded', () => { + $(``).on('click', () => { + let win = window.open(`${window.location.origin }/dashboard/?jid=${window.cvat.job.id}`, '_blank'); + win.focus(); + }).prependTo('#engineMenuButtons'); +}); + diff --git a/cvat/apps/dashboard/templates/dashboard/task.html b/cvat/apps/dashboard/templates/dashboard/task.html index 46f10255cc7..da017006b59 100644 --- a/cvat/apps/dashboard/templates/dashboard/task.html +++ b/cvat/apps/dashboard/templates/dashboard/task.html @@ -3,22 +3,22 @@ SPDX-License-Identifier: MIT --> -
+
-
+
- {%if item.has_bug_tracker %} + {%if item.bug_tracker %} - + {% endif %}
@@ -26,10 +26,12 @@ - {% for segment in item.segments %} - - - + {% for segm in item.segment_set.all %} + {% for job in segm.job_set.all %} + + + + {% endfor %} {% endfor %}
{{segment.url}}
{{base_url}}?id={{job.id}}
diff --git a/cvat/apps/dashboard/views.py b/cvat/apps/dashboard/views.py index 37e2d3d5ac0..ea695ce0cb6 100644 --- a/cvat/apps/dashboard/views.py +++ b/cvat/apps/dashboard/views.py @@ -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 @@ -56,63 +56,25 @@ def JsTreeView(request): json_dumps_params=dict(ensure_ascii=False)) -def MainTaskInfo(task, dst_dict): - dst_dict["status"] = task.status - dst_dict["num_of_segments"] = task.segment_set.count() - dst_dict["mode"] = task.mode.capitalize() - dst_dict["name"] = task.name - dst_dict["task_id"] = task.id - dst_dict["created_date"] = task.created_date - dst_dict["updated_date"] = task.updated_date - dst_dict["bug_tracker_link"] = task.bug_tracker - dst_dict["has_bug_tracker"] = len(task.bug_tracker) > 0 - dst_dict["owner"] = 'undefined' - dst_dict["id"] = task.id - dst_dict["segments"] = [] - -def DetailTaskInfo(request, task, dst_dict): - scheme = request.scheme - host = request.get_host() - dst_dict['segments'] = [] - - for segment in task.segment_set.all(): - for job in segment.job_set.all(): - segment_url = "{0}://{1}/?id={2}".format(scheme, host, job.id) - dst_dict["segments"].append({ - 'id': job.id, - 'start': segment.start_frame, - 'stop': segment.stop_frame, - 'url': segment_url - }) - - db_labels = task.label_set.prefetch_related('attributespec_set').all() - attributes = {} - for db_label in db_labels: - attributes[db_label.id] = {} - for db_attrspec in db_label.attributespec_set.all(): - attributes[db_label.id][db_attrspec.id] = db_attrspec.text - - dst_dict['labels'] = attributes - @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)) - - data = [] - for task in tasks_query_set: - task_info = {} - MainTaskInfo(task, task_info) - DetailTaskInfo(request, task, task_info) - data.append(task_info) + 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 + 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__job_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)) return render(request, 'dashboard/dashboard.html', { - 'data': data, + 'data': task_list, 'max_upload_size': settings.LOCAL_LOAD_MAX_FILES_SIZE, 'max_upload_count': settings.LOCAL_LOAD_MAX_FILES_COUNT, + 'base_url': "{0}://{1}/".format(request.scheme, request.get_host()), 'share_path': os.getenv('CVAT_SHARE_URL', default=r'${cvat_root}/share'), - 'js_3rdparty': JS_3RDPARTY.get('dashboard', []) + 'js_3rdparty': JS_3RDPARTY.get('dashboard', []), })