Skip to content

Commit

Permalink
fix: [chats] fix templates, chat subtype
Browse files Browse the repository at this point in the history
  • Loading branch information
Terrtia committed Mar 5, 2024
1 parent 87dc619 commit 38d71e9
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 26 deletions.
16 changes: 8 additions & 8 deletions var/www/blueprints/chats_explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def chats_explorer_networks():
networks = chats_viewer.get_chat_service_instances_by_protocol(protocol)
if len(networks) == 1:
instance_uuid = list(networks.values())[0]
return redirect(url_for('chats_explorer.chats_explorer_instance', uuid=instance_uuid))
return redirect(url_for('chats_explorer.chats_explorer_instance', subtype=instance_uuid))
else:
return render_template('chats_networks.html', protocol=protocol, networks=networks)

Expand All @@ -67,7 +67,7 @@ def chats_explorer_networks():
@login_required
@login_read_only
def chats_explorer_instance():
intance_uuid = request.args.get('uuid')
intance_uuid = request.args.get('subtype')
chat_instance = chats_viewer.api_get_chat_service_instance(intance_uuid)
if chat_instance[1] != 200:
return create_json_response(chat_instance[0], chat_instance[1])
Expand All @@ -80,7 +80,7 @@ def chats_explorer_instance():
@login_read_only
def chats_explorer_chat():
chat_id = request.args.get('id')
instance_uuid = request.args.get('uuid')
instance_uuid = request.args.get('subtype')
target = request.args.get('target')
if target == "Don't Translate":
target = None
Expand Down Expand Up @@ -125,7 +125,7 @@ def chats_explorer_messages_stats_week_all():
@login_read_only
def objects_subchannel_messages():
subchannel_id = request.args.get('id')
instance_uuid = request.args.get('uuid')
instance_uuid = request.args.get('subtype')
target = request.args.get('target')
if target == "Don't Translate":
target = None
Expand All @@ -144,7 +144,7 @@ def objects_subchannel_messages():
@login_read_only
def objects_thread_messages():
thread_id = request.args.get('id')
instance_uuid = request.args.get('uuid')
instance_uuid = request.args.get('subtype')
target = request.args.get('target')
if target == "Don't Translate":
target = None
Expand Down Expand Up @@ -178,7 +178,7 @@ def chats_explorer_chat_participants():
@login_read_only
def chats_explorer_chat_download():
chat_id = request.args.get('id')
chat_subtype = request.args.get('uuid')
chat_subtype = request.args.get('subtype')
chat = chats_viewer.api_chat_messages(chat_subtype, chat_id)
if chat[1] != 200:
if chat[1] == 404:
Expand All @@ -193,7 +193,7 @@ def chats_explorer_chat_download():
@login_read_only
def objects_subchannel_messages_download():
subchannel_id = request.args.get('id')
instance_uuid = request.args.get('uuid')
instance_uuid = request.args.get('subtype')
subchannel = chats_viewer.api_subchannel_messages(instance_uuid, subchannel_id)
if subchannel[1] != 200:
return create_json_response(subchannel[0], subchannel[1])
Expand All @@ -206,7 +206,7 @@ def objects_subchannel_messages_download():
@login_read_only
def objects_thread_messages_download():
thread_id = request.args.get('id')
instance_uuid = request.args.get('uuid')
instance_uuid = request.args.get('subtype')
thread = chats_viewer.api_thread_messages(instance_uuid, thread_id)
if thread[1] != 200:
return create_json_response(thread[0], thread[1])
Expand Down
8 changes: 4 additions & 4 deletions var/www/templates/chats_explorer/SubChannelMessages.html
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ <h3 class="text-secondary">{% if subchannel['chat']['name'] %}{{ subchannel['cha
{% for thread in subchannel['threads'] %}
<tr>
<td>
<a href="{{ url_for('chats_explorer.objects_thread_messages')}}?uuid={{ thread['subtype'] }}&id={{ thread['id'] }}">{{ thread['name'] }} <i class="far fa-comment"></i> {{ thread['nb_messages'] }} Messages</a>
<a href="{{ url_for('chats_explorer.objects_thread_messages')}}?subtype={{ thread['subtype'] }}&id={{ thread['id'] }}">{{ thread['name'] }} <i class="far fa-comment"></i> {{ thread['nb_messages'] }} Messages</a>
</td>
<td>{{ thread["created_at"] }}</td>
<td>
Expand Down Expand Up @@ -198,15 +198,15 @@ <h5 class="mx-5 text-secondary">This week:</h5>
<span class="mt-3">
{% include 'objects/image/block_blur_img_slider.html' %}
</span>
{% with translate_url=url_for('chats_explorer.objects_subchannel_messages', uuid=subchannel['subtype']), obj_id=subchannel['id'], pagination=subchannel['pagination'] %}
{% with translate_url=url_for('chats_explorer.objects_subchannel_messages', subtype=subchannel['subtype']), obj_id=subchannel['id'], pagination=subchannel['pagination'] %}
{% include 'chats_explorer/block_translation.html' %}
{% endwith %}
{% with obj_subtype=subchannel['subtype'], obj_id=subchannel['id'], url_endpoint=url_for("chats_explorer.objects_subchannel_messages"), nb=subchannel['pagination']['nb'] %}
{% set date_from=subchannel['first_seen'] %}
{% set date_to=subchannel['last_seen'] %}
{% include 'block_obj_time_search.html' %}
{% endwith %}
{% with endpoint_url=url_for('chats_explorer.objects_subchannel_messages', uuid=subchannel['subtype']), pagination=subchannel['pagination'] %}
{% with endpoint_url=url_for('chats_explorer.objects_subchannel_messages', subtype=subchannel['subtype']), pagination=subchannel['pagination'] %}
{% set endpoint_url = endpoint_url + "&id=" + subchannel['id'] + "&nb=" + subchannel['pagination']['nb'] | string %}
{% if translation_target %}
{% set endpoint_url = endpoint_url + "&target=" + translation_target %}
Expand Down Expand Up @@ -238,7 +238,7 @@ <h5 class="mx-5 text-secondary">This week:</h5>
</div>
</div>

{% with endpoint_url=url_for('chats_explorer.objects_subchannel_messages', uuid=subchannel['subtype']), pagination=subchannel['pagination'] %}
{% with endpoint_url=url_for('chats_explorer.objects_subchannel_messages', subtype=subchannel['subtype']), pagination=subchannel['pagination'] %}
{% set endpoint_url = endpoint_url + "&id=" + subchannel['id'] + "&nb=" + subchannel['pagination']['nb'] | string %}
{% if translation_target %}
{% set endpoint_url = endpoint_url + "&target=" + translation_target %}
Expand Down
6 changes: 3 additions & 3 deletions var/www/templates/chats_explorer/ThreadMessages.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@
<span class="mt-3">
{% include 'objects/image/block_blur_img_slider.html' %}
</span>
{% with translate_url=url_for('chats_explorer.objects_thread_messages', uuid=meta['subtype']), obj_id=meta['id'], pagination=meta['pagination'] %}
{% with translate_url=url_for('chats_explorer.objects_thread_messages', subtype=meta['subtype']), obj_id=meta['id'], pagination=meta['pagination'] %}
{% include 'chats_explorer/block_translation.html' %}
{% endwith %}
{% with obj_subtype=meta['subtype'], obj_id=meta['id'], url_endpoint=url_for("chats_explorer.objects_thread_messages"), nb=meta['pagination']['nb'] %}
{% set date_from=meta['first_seen'] %}
{% set date_to=meta['last_seen'] %}
{% include 'block_obj_time_search.html' %}
{% endwith %}
{% with endpoint_url=url_for('chats_explorer.objects_thread_messages', uuid=meta['subtype']), pagination=meta['pagination'] %}
{% with endpoint_url=url_for('chats_explorer.objects_thread_messages', subtype=meta['subtype']), pagination=meta['pagination'] %}
{% set endpoint_url = endpoint_url + "&id=" + meta['id'] + "&nb=" + meta['pagination']['nb'] | string %}
{% if translation_target %}
{% set endpoint_url = endpoint_url + "&target=" + translation_target %}
Expand Down Expand Up @@ -178,7 +178,7 @@
</div>
</div>

{% with endpoint_url=url_for('chats_explorer.objects_thread_messages', uuid=meta['subtype']), pagination=meta['pagination'] %}
{% with endpoint_url=url_for('chats_explorer.objects_thread_messages', subtype=meta['subtype']), pagination=meta['pagination'] %}
{% set endpoint_url = endpoint_url + "&id=" + meta['id'] + "&nb=" + meta['pagination']['nb'] | string %}
{% if translation_target %}
{% set endpoint_url = endpoint_url + "&target=" + translation_target %}
Expand Down
2 changes: 1 addition & 1 deletion var/www/templates/chats_explorer/block_message.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
{% if message['thread'] %}
<hr class="mb-1">
<div class="my-2 text-center">
<a href="{{ url_for('chats_explorer.objects_thread_messages')}}?uuid={{ message['thread']['subtype'] }}&id={{ message['thread']['id'] }}"><i class="far fa-comment"></i> {{ message['thread']['nb'] }} Messages</a>
<a href="{{ url_for('chats_explorer.objects_thread_messages')}}?subtype={{ message['thread']['subtype'] }}&id={{ message['thread']['id'] }}"><i class="far fa-comment"></i> {{ message['thread']['nb'] }} Messages</a>
</div>
{% endif %}
{% for tag in message['tags'] %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ <h5 class="card-title">Filter by Time :</h5>
<script>

function filter_by_time() {
let parameter = "?uuid={{ obj_subtype }}&id={{ obj_id }}";
let parameter = "?subtype={{ obj_subtype }}&id={{ obj_id }}";
//let date_from = $('#date-range-from-input').val();
//let date_to = $('#date-range-to-input').val();
let nb_messages = $('#nb_messages').val();
Expand Down
2 changes: 1 addition & 1 deletion var/www/templates/chats_explorer/chat_instance.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ <h4 class="text-secondary">{{ chat_instance["protocol"] }} :</h4>
class="rounded-circle mr-1" alt="{{ chat['id'] }}" width="40" height="40">
</td>
<td><b>{{ chat['name'] }}</b></td>
<td><a href="{{ url_for('chats_explorer.chats_explorer_chat') }}?uuid={{ chat_instance['uuid'] }}&id={{ chat['id'] }}">{{ chat['id'] }}</a></td>
<td><a href="{{ url_for('chats_explorer.chats_explorer_chat') }}?subtype={{ chat_instance['uuid'] }}&id={{ chat['id'] }}">{{ chat['id'] }}</a></td>
<td>{{ chat['created_at'] }}</td>
<td>
{% if chat['first_seen'] %}
Expand Down
14 changes: 7 additions & 7 deletions var/www/templates/chats_explorer/chat_viewer.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@ <h4 class="text-secondary">{% if chat['username'] %}{{ chat["username"]["id"] }}
<span class="badge badge-{{ bootstrap_label[loop.index0 % 5] }}">{{ tag }} <span class="badge badge-light">{{ chat['tags_messages'][tag] }}</span></span>
{% endfor %}

{% with translate_url=url_for('chats_explorer.chats_explorer_chat', uuid=chat['subtype']), obj_id=chat['id'], pagination=chat['pagination'] %}
{% include 'chats_explorer/block_translation.html' %}
{% endwith %}

{% if chat['subchannels'] %}
<h4 class="mt-2">Sub-Channels:</h4>
<table id="tablesubchannels" class="table">
Expand All @@ -146,7 +142,7 @@ <h4 class="mt-2">Sub-Channels:</h4>
<div class="text-secondary">{{ meta['translation_name'] }}</div>
{% endif %}
</td>
<td><a href="{{ url_for('chats_explorer.objects_subchannel_messages') }}?uuid={{ meta['subtype'] }}&id={{ meta['id'] }}">{{ meta['id'] }}</a></td>
<td><a href="{{ url_for('chats_explorer.objects_subchannel_messages') }}?subtype={{ meta['subtype'] }}&id={{ meta['id'] }}">{{ meta['id'] }}</a></td>
<td>{{ meta['created_at'] }}</td>
<td>
{% if meta['first_seen'] %}
Expand Down Expand Up @@ -174,6 +170,10 @@ <h5 class="mx-5 text-secondary">This week:</h5>
<div id="heatmapweekhour"></div>
{% endif %}

{% with translate_url=url_for('chats_explorer.chats_explorer_chat', subtype=chat['subtype']), obj_id=chat['id'], pagination=chat['pagination'] %}
{% include 'chats_explorer/block_translation.html' %}
{% endwith %}

{% if chat['messages'] %}

<span class="mt-3">
Expand All @@ -185,7 +185,7 @@ <h5 class="mx-5 text-secondary">This week:</h5>
{% set date_to=chat['last_seen'] %}
{% include 'block_obj_time_search.html' %}
{% endwith %}
{% with endpoint_url=url_for('chats_explorer.chats_explorer_chat', uuid=chat['subtype']), pagination=chat['pagination'] %}
{% with endpoint_url=url_for('chats_explorer.chats_explorer_chat', subtype=chat['subtype']), pagination=chat['pagination'] %}
{% set endpoint_url = endpoint_url + "&id=" + chat['id'] + "&nb=" + chat['pagination']['nb'] | string %}
{% if translation_target %}
{% set endpoint_url = endpoint_url + "&target=" + translation_target %}
Expand Down Expand Up @@ -217,7 +217,7 @@ <h5 class="mx-5 text-secondary">This week:</h5>
</div>
</div>

{% with endpoint_url=url_for('chats_explorer.chats_explorer_chat', uuid=chat['subtype']), pagination=chat['pagination'] %}
{% with endpoint_url=url_for('chats_explorer.chats_explorer_chat', subtype=chat['subtype']), pagination=chat['pagination'] %}
{% set endpoint_url = endpoint_url + "&id=" + chat['id'] + "&nb=" + chat['pagination']['nb'] | string %}
{% if translation_target %}
{% set endpoint_url = endpoint_url + "&target=" + translation_target %}
Expand Down
2 changes: 1 addition & 1 deletion var/www/templates/chats_explorer/chats_networks.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ <h3>{{ network }}:</h3>

{% for instance_uuid in networks[network] %}
<li class="list-group-item">
<a class="nav-link" href="{{url_for('chats_explorer.chats_explorer_instance')}}?uuid={{ instance_uuid }}">
<a class="nav-link" href="{{url_for('chats_explorer.chats_explorer_instance')}}?subtype={{ instance_uuid }}">
<span>{{ instance_uuid }}</span>
</a>
</li>
Expand Down

0 comments on commit 38d71e9

Please sign in to comment.