Skip to content

Commit

Permalink
issue #1097 - add my ugly mess of columns back (helps debug nasty err…
Browse files Browse the repository at this point in the history
…ors). Remove old jqgrid
  • Loading branch information
davmlaw committed Jul 11, 2024
1 parent 4603fdc commit 25e2159
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 43 deletions.
2 changes: 2 additions & 0 deletions snpdb/views/datatable_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ class DatatableConfig(Generic[DC]):
download_csv_button_enabled = False
rich_columns: list[RichColumn] # columns for display
expand_client_renderer: Optional[str] = None # if provided, will expand rows and render content with this JavaScript method
scroll_x = False

def value_columns(self) -> list[str]:
column_names = list(itertools.chain(*[rc.value_columns for rc in self.rich_columns if rc.enabled]))
Expand Down Expand Up @@ -451,6 +452,7 @@ def json_definition(self) -> JsonObjType:
"searchBoxEnabled": config.search_box_enabled,
"downloadCsvButtonEnabled": config.download_csv_button_enabled,
"expandClientRenderer": config.expand_client_renderer,
"scrollX": config.scroll_x,
}
if config.default_sort_order_column:
data["order"] = [[config.column_index(config.default_sort_order_column), "asc" if config.default_sort_order_column.default_sort != SortOrder.DESC else "desc"]]
Expand Down
34 changes: 10 additions & 24 deletions upload/grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ def render_status(row: CellData):

@staticmethod
def render_duration(row: CellData):
if end_date := row["end_date"]:
delta = end_date - row["start_date"]
start_date = row["start_date"]
end_date = row["end_date"]
if start_date and end_date:
delta = end_date - start_date
return f"{delta.total_seconds():.2f}"
else:
return ""

def __init__(self, request: HttpRequest):
super().__init__(request)
self.scroll_x = True
self.expand_client_renderer = DatatableConfig._row_expand_ajax('upload_step_detail',
expected_height=120)
self.rich_columns = [
Expand All @@ -40,33 +43,16 @@ def __init__(self, request: HttpRequest):
RichColumn(key='name', orderable=True),
RichColumn(key='status', orderable=True, renderer=UploadStepColumns.render_status),
RichColumn(key='items_processed', css_class='num', orderable=True),
RichColumn(key='error_message', orderable=True),
RichColumn(key='input_filename', orderable=True),
RichColumn(key='output_filename', orderable=True),
RichColumn(key='start_date', client_renderer='TableFormat.timestampMilliseconds', orderable=True),
RichColumn(key='end_date', client_renderer='TableFormat.timestampMilliseconds', orderable=True),
RichColumn(name='duration', label="Duration Seconds", extra_columns=["start_date", "end_date"], renderer=UploadStepColumns.render_duration, css_class="num")
RichColumn(name='duration', label="Duration Seconds", extra_columns=["start_date", "end_date"],
renderer=UploadStepColumns.render_duration, css_class="num")
]


class UploadStepsGrid(JqGridUserRowConfig):
"""
This is Grid has been replaced with the above DataTable
But haven't completely converted over to Grid yet
"""
model = UploadStep
caption = 'Upload Steps'
fields = ['sort_order', 'id', 'name', 'status', 'items_to_process', 'items_processed', 'error_message', 'input_filename', 'output_filename', 'start_date', 'end_date', 'task_type', 'pipeline_stage', 'pipeline_stage_dependency', 'script', 'output_text', 'tool_version__name', 'tool_version__version', 'import_variant_table', 'celery_task']
colmodel_overrides = {'name': {'width': 300},
'tool__name': {'label': 'Tool'},
'tool__version': {'label': 'Tool Version'}}

def __init__(self, user, upload_pipeline_id):
super().__init__(user)
upload_pipeline = get_object_or_404(UploadPipeline, pk=upload_pipeline_id)
upload_pipeline.uploaded_file.check_can_view(user)
self.queryset = self.get_queryset(None).filter(upload_pipeline=upload_pipeline) # .exclude(status=ProcessingStatus.SKIPPED)
self.extra_config.update({'sortname': 'sort_order',
'sortorder': 'desc'})


class UploadPipelineSkippedAnnotationGrid(JqGridUserRowConfig):
model = Variant
caption = 'Skipped Annotation'
Expand Down
20 changes: 5 additions & 15 deletions upload/templates/upload/view_upload_pipeline.html
Original file line number Diff line number Diff line change
Expand Up @@ -275,24 +275,14 @@ <h4>Accumulative Times</h4>
{% endfor %}
</table>
{% endif %}

{% if has_upload_steps %}
<h4>All Upload Steps</h4>
<table id="uploadstep-datatable" data-datatable-url="{% url 'upload_step_datatables' %}" data-datatable-data='uploadStepFilter'></table>
<div id='upload-steps-graph'></div>
{% endif %}
</div>

{% comment %}
<div class="container-table">
{% if has_upload_steps %}
<div id='upload-steps-graph'></div>
<div id="upload-steps-container">
{% load jqgrid_tags %}
{% jqgrid 'upload_step_grid' name='upload_step' search=True upload_pipeline_id=upload_pipeline.pk %}
</div>
{% endif %}
<div class="container-table">
<h4>All Upload Steps</h4>
<table id="uploadstep-datatable" data-datatable-url="{% url 'upload_step_datatables' %}" data-datatable-data='uploadStepFilter'></table>
<div id='upload-steps-graph'></div>
</div>
{% endcomment %}
{% endif %}

{% endblock %}
1 change: 0 additions & 1 deletion upload/tests/test_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def setUpTestData(cls):

# (url_name, url_kwargs, object to check appears in grid pk column or (grid column, object)
cls.PRIVATE_GRID_LIST_URLS = [
("upload_step_grid", upload_pipeline_kwargs, upload_step),
("upload_pipeline_modified_variants_grid", upload_pipeline_kwargs, None),
]

Expand Down
3 changes: 1 addition & 2 deletions upload/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from library.django_utils.jqgrid_view import JQGridView
from snpdb.views.datatable_view import DatabaseTableView
from upload.grids import UploadStepsGrid, UploadPipelineModifiedVariantsGrid, UploadPipelineSkippedAnnotationGrid, \
from upload.grids import UploadPipelineModifiedVariantsGrid, UploadPipelineSkippedAnnotationGrid, \
UploadStepColumns
from upload.views import views
from upload.views.views import view_upload_step_detail
Expand All @@ -15,7 +15,6 @@
perm_path('upload_retry_import/<int:upload_pipeline_id>', views.upload_retry_import, name='upload_retry_import'),
# Grids

perm_path('upload_pipeline/steps/grid/<int:upload_pipeline_id>/<slug:op>/', JQGridView.as_view(grid=UploadStepsGrid), name='upload_step_grid'),
perm_path('upload_pipeline/steps/datatables/', DatabaseTableView.as_view(column_class=UploadStepColumns), name='upload_step_datatables'),
perm_path('upload_pipeline/step/<int:upload_step_id>', view_upload_step_detail, name='upload_step_detail'),
perm_path('upload_pipeline/skipped_annotation/grid/<int:upload_pipeline_id>/<slug:op>/',
Expand Down
1 change: 0 additions & 1 deletion variantgrid/settings/env/shariantcommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@
"view_upload_pipeline": False,
"view_upload_pipeline_warnings_and_errors": False,
"upload_retry_import": False,
"upload_step_grid": False,
"upload_pipeline_modified_variants_grid": False,
"view_upload_stats_detail": False,
"accept_vcf_import_info_tag": False,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ let DataTableDefinition = (function() {
},
bFilter: defn.searchBoxEnabled,
bAutoWidth: false,
scrollX: defn.scrollX,
initComplete: function( settings, json ) {
$('th.toggle-link').removeClass('toggle-link');
}
Expand Down

0 comments on commit 25e2159

Please sign in to comment.