Skip to content

Commit

Permalink
Back link to task from annotation view (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsekachev authored and nmanovic committed Oct 25, 2018
1 parent dd6bdea commit ae77993
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 60 deletions.
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');
});

18 changes: 10 additions & 8 deletions cvat/apps/dashboard/templates/dashboard/task.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,35 @@
SPDX-License-Identifier: MIT
-->
<div class="dashboardTaskUI" id="dashboardTask_{{item.task_id}}">
<div class="dashboardTaskUI" id="dashboardTask_{{item.id}}">
<center class="dashboardTitleWrapper">
<label class="semiBold h1 dashboardTaskNameLabel selectable"> {{ item.name }} </label>
</center>
<center class="dashboardTitleWrapper">
<label class="regular dashboardStatusLabel"> {{ item.status }} </label>
</center>
<div class="dashboardTaskIntro" style='background-image: url("/get/task/{{item.task_id}}/frame/0")'> </div>
<div class="dashboardTaskIntro" style='background-image: url("/get/task/{{item.id}}/frame/0")'> </div>
<div class="dashboardButtonsUI">
<button class="dashboardDumpAnnotation semiBold dashboardButtonUI"> Dump Annotation </button>
<button class="dashboardUploadAnnotation semiBold dashboardButtonUI"> Upload Annotation </button>
<button class="dashboardUpdateTask semiBold dashboardButtonUI"> Update Task </button>
<button class="dashboardDeleteTask semiBold dashboardButtonUI"> Delete Task </button>
{%if item.has_bug_tracker %}
{%if item.bug_tracker %}
<button class="dashboardOpenTrackerButton semiBold dashboardButtonUI"> Open Bug Tracker </button>
<a class="dashboardBugTrackerLink" href='{{item.bug_tracker_link}}' style="display: none;"> </a>
<a class="dashboardBugTrackerLink" href='{{item.bug_tracker}}' style="display: none;"> </a>
{% endif %}
</div>
<div class="dashboardJobsUI">
<center class="dashboardTitleWrapper">
<label class="regular h1"> Jobs </label>
</center>
<table class="dashboardJobList regular">
{% for segment in item.segments %}
<tr>
<td> <a href="{{segment.url}}"> {{segment.url}} </a> </td>
</tr>
{% for segm in item.segment_set.all %}
{% for job in segm.job_set.all %}
<tr>
<td> <a href="{{base_url}}?id={{job.id}}"> {{base_url}}?id={{job.id}} </a> </td>
</tr>
{% endfor %}
{% endfor %}
</table>
</div>
Expand Down
66 changes: 14 additions & 52 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 @@ -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', []),
})

0 comments on commit ae77993

Please sign in to comment.