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 all 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');
});

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', []),
})