mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 09:15:41 +00:00
66 lines
3.4 KiB
Python
66 lines
3.4 KiB
Python
from flask_table import Table, Col, DatetimeCol, LinkCol
|
|
|
|
|
|
class ResultTable(Table):
|
|
'''
|
|
Declares the Table showing results. Declaration is column by column.
|
|
'''
|
|
classes = ['highlight', 'responsive-table']
|
|
query = Col('Query', column_html_attrs={'class': 'query'},
|
|
th_html_attrs={'class': 'sort',
|
|
'data-sort': 'query'})
|
|
match_count = Col('Match count', column_html_attrs={'class':
|
|
'match-count'},
|
|
th_html_attrs={'class': 'sort',
|
|
'data-sort': 'match-count'})
|
|
corpus_name = Col('Corpus name', column_html_attrs={'class':
|
|
'corpus-name'},
|
|
th_html_attrs={'class': 'sort',
|
|
'data-sort': 'corpus-name'})
|
|
corpus_creation_date = DatetimeCol('Corpus creation date',
|
|
column_html_attrs={'class':
|
|
'corpus-creation- date'}, # noqa
|
|
th_html_attrs={'class': 'sort',
|
|
'data-sort':
|
|
'corpus-creation-date'},
|
|
datetime_format='dd/MM/yyyy, HH:mm:ss a') # noqa
|
|
corpus_analysis_date = DatetimeCol('Date of result creation',
|
|
column_html_attrs={'class':
|
|
'corpus-analysis-data'}, # noqa
|
|
th_html_attrs={'class': 'sort',
|
|
'data-sort':
|
|
'corpus-analysis-data'},
|
|
datetime_format='dd/MM/yyyy, HH:mm:ss a') # noqa
|
|
corpus_type = Col('Result Type',
|
|
column_html_attrs={'class':
|
|
'corpus-type'},
|
|
th_html_attrs={'class': 'sort',
|
|
'data-sort':
|
|
'corpus-type'})
|
|
details = LinkCol('Details', 'results.result_details',
|
|
url_kwargs=dict(result_id='id'),
|
|
anchor_attrs={'class': 'waves-effect waves-light btn-floating'}, # noqa
|
|
text_fallback='<i class="material-icons">info_outline</i>') # noqa
|
|
inspect = LinkCol('Inspect', 'results.result_inspect',
|
|
url_kwargs=dict(result_id='id'),
|
|
anchor_attrs={'class': 'waves-effect waves-light btn-floating'}, # noqa
|
|
text_fallback='<i class="material-icons">search</i>') # noqa
|
|
# TODO: Maybe somehow fix taht there are two columns fpr two action buttons
|
|
# Or maybe just get rid of flask tables?
|
|
|
|
|
|
class ResultItem(object):
|
|
'''
|
|
Describes one result item row.
|
|
'''
|
|
|
|
def __init__(self, query, match_count, corpus_name, corpus_creation_date,
|
|
corpus_analysis_date, corpus_type, id):
|
|
self.query = query
|
|
self.match_count = match_count
|
|
self.corpus_name = corpus_name
|
|
self.corpus_creation_date = corpus_creation_date
|
|
self.corpus_analysis_date = corpus_analysis_date
|
|
self.corpus_type = corpus_type
|
|
self.id = id
|