see all emojis in a pack from the admin panel

This commit is contained in:
mst 2024-11-26 15:00:52 +03:00
parent 95f2f4e1a9
commit 0af8ce7648
2 changed files with 23 additions and 5 deletions

17
app.py
View file

@ -575,10 +575,23 @@ def uploadEmojiPack():
def getEmojis(): def getEmojis():
return func.listEmojis() return func.listEmojis()
@api_bp.route('/get_emoji_packs/', methods=['GET']) @api_bp.route('/hyper/get_emoji_packs/', methods=['GET'])
@loginRequired @loginRequired
def getEmojiPacks(): def getEmojiPacks():
return func.listEmojiPacks() index = int(request.args.get('index', ''))
packs = func.listEmojiPacks()
pack = packs[index]
rel_path = pack['relative_path']
emojis = pack['emojis']
html = ''
for emoji in emojis:
html += f"""
<div class="mb-2">
<img src="/{ rel_path }/{ emoji['file_name'] }" width="28" height="28" class="emoji" title=":{ emoji['name'] }:">
<span>{ emoji['name'] }</span>
</div>
"""
return html
# -- delete routes -- # -- delete routes --

View file

@ -1,6 +1,6 @@
<tr id="pack-{{pack.name}}" class="emoji-pack-row"> <tr id="pack-{{pack.name}}" class="emoji-pack-row">
<td><img src="/{{ pack.preview_image }}" width="28" height="28" class="emoji"></td> <td><img src="/{{ pack.preview_image }}" width="28" height="28" class="emoji"></td>
<td>{{ pack.name }}</td> <td><a data-bs-toggle="collapse" href="#pack-collapse-{{pack.name}}" class="text-decoration-none" title="Click to see all emojis in this pack">{{ pack.name }} <i class="bi bi-chevron-down small ms-1"></i></a></td>
{% if json_pack %} {% if json_pack %}
<td>{{ pack.website }}</td> <td>{{ pack.website }}</td>
<td>{{ formatRelativeTime(pack.exportedAt) }}</td> <td>{{ formatRelativeTime(pack.exportedAt) }}</td>
@ -8,7 +8,12 @@
<td><code>{{ pack.relative_path }}</code></td> <td><code>{{ pack.relative_path }}</code></td>
<td> <td>
<div id="actions"> <div id="actions">
<button class="btn btn-sm btn-outline-danger" hx-target="#pack-{{pack.name}}" hx-delete="{{ url_for('api.deleteEmojiPack', pack_name=pack.name) }}">Delete</button> <button class="btn btn-sm btn-outline-danger" hx-target="#pack-{{pack.name}}" hx-delete="{{ url_for('api.deleteEmojiPack', pack_name=pack.name) }}"><i class="bi bi-trash me-1"></i> Delete</button>
</div> </div>
</td> </td>
</tr> </tr>
<tr class="collapse" id="pack-collapse-{{pack.name}}" data-dontshowtoast hx-get="{{ url_for('api.getEmojiPacks', index=index) }}" hx-trigger="intersect" hx-target="#{{ pack.name }}-td">
<td class="border-0"></td>
<td class="border-0" id="{{ pack.name }}-td">
</td>
</tr>