chg: [chat explorer] show files tags

This commit is contained in:
terrtia 2025-01-29 14:20:21 +01:00
parent 16bd61a559
commit 18dbd0002f
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0
3 changed files with 25 additions and 5 deletions

View file

@ -193,14 +193,14 @@ class Message(AbstractObject):
for it in self.get_correlation_iter('file-name', '', file_name, 'item'):
if file_name not in files:
files[file_name] = []
files[file_name].append(it[1:])
files[file_name].append({'obj': it[1:], 'tags': self.get_obj_tags('item', '', it[1:])})
s_files.add(it[1:])
nb_files += 1
if nb_files < self.get_nb_files():
files['undefined'] = []
for f in self.get_correlation('item').get('item'):
if f[1:] not in s_files:
files['undefined'].append(f[1:])
files['undefined'].append({'obj': f[1:], 'tags': self.get_obj_tags('item', '', f[1:])})
return files
def get_reactions(self):

View file

@ -109,6 +109,12 @@ class AbstractObject(ABC):
tags = list(tags)
return tags
def get_obj_tags(self, obj_type, subtype, obj_id, r_list=False):
tags = Tag.get_object_tags(obj_type, obj_id, subtype)
if r_list:
tags = list(tags)
return tags
def add_tag(self, tag):
Tag.add_object_tag(tag, self.type, self.id, subtype=self.get_subtype(r_str=True))

View file

@ -134,15 +134,29 @@
{% if message['files'][file_name] | length > 1 %}
<div class="flex-shrink-1 bg-white border-primary text-secondary rounded py-2 px-3 ml-4 mb-3" style="overflow-x: auto">
<i class="far fa-file fa-3x"></i> {{ file_name }}
{% for item in message['files'][file_name] %}
{% for obj in message['files'][file_name] %}
<br>
<a href="{{ url_for('objects_item.showItem') }}?id={{ item }}"><i class="far fa-file"></i> {{ loop.index }}</a>
<a href="{{ url_for('objects_item.showItem') }}?id={{ obj['obj'] }}"><i class="far fa-file"></i> {{ loop.index }}</a>
{% if obj['tags'] %}
<div>
{% for tag in obj['tags'] %}
<span class="badge badge-{{ bootstrap_label[loop.index0 % 5] }}">{{ tag }}</span>
{% endfor %}
</div>
{% endif %}
{% endfor %}
</div>
{% else %}
<a href="{{ url_for('objects_item.showItem') }}?id={{ message['files'][file_name][0] }}">
<a href="{{ url_for('objects_item.showItem') }}?id={{ message['files'][file_name][0]['obj'] }}">
<div class="flex-shrink-1 bg-white border-primary text-primary rounded py-2 px-3 ml-4 mb-3" style="overflow-x: auto">
<i class="far fa-file fa-3x"></i> {{ file_name }}
{% if message['files'][file_name][0]['tags'] %}
<div>
{% for tag in message['files'][file_name][0]['tags'] %}
<span class="badge badge-{{ bootstrap_label[loop.index0 % 5] }}">{{ tag }}</span>
{% endfor %}
</div>
{% endif %}
</div>
</a>
{% endif %}