Sort ordering

sorting-paging
dgtlmoon 2 years ago
parent 1f250aa868
commit 982291e63c

@ -83,6 +83,13 @@ class model(dict):
return False
@property
def label(self):
# Used for sorting
if self['title']:
return self['title']
return self['url']
@property
def last_changed(self):
# last_changed will be the newest snapshot, but when we have just one snapshot, it should be 0

@ -529,3 +529,13 @@ class ChangeDetectionStore:
def update_3(self):
# see https://github.com/dgtlmoon/changedetection.io/pull/835
return
# `last_changed` not needed, we pull that information from the history.txt index
def update_4(self):
for uuid, watch in self.data['watching'].items():
try:
# Remove it from the struct
del(watch['last_changed'])
except:
continue
return

@ -32,22 +32,25 @@
{% endfor %}
</div>
{% set sort_order = request.args.get('order', 'desc') == 'desc' %}
{% set sort_attribute = request.args.get('sort', 'last_changed') %}
<div id="watch-table-wrapper">
<table class="pure-table pure-table-striped watch-table">
<thead>
<tr>
<th>#</th>
<th></th>
<th></th>
<th>Last Checked</th>
<th>Last Changed</th>
{% set link_order = "asc" if sort_order else "desc" %}
<th><a href="{{url_for('index', sort='label', order=link_order)}}">Website</a></th>
<th><a href="{{url_for('index', sort='last_checked', order=link_order)}}">Last Checked</a></th>
<th><a href="{{url_for('index', sort='last_changed', order=link_order)}}">Last Changed</a></th>
<th></th>
</tr>
</thead>
<tbody>
{% for watch in watches|sort(attribute='last_changed', reverse=True) %}
{% for watch in watches|sort(attribute=sort_attribute, reverse=sort_order) %}
<tr id="{{ watch.uuid }}"
class="{{ loop.cycle('pure-table-odd', 'pure-table-even') }}
{% if watch.last_error is defined and watch.last_error != False %}error{% endif %}

Loading…
Cancel
Save