From 51da9f4c7cb1952bac57c454e8edfdca3e02ab00 Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Thu, 22 Apr 2021 19:25:20 +0200 Subject: [PATCH] Prevent upload list from overflowing and add standalone copy text button --- assets/sass/app.scss | 2 +- assets/sass/layout.scss | 17 +++++++++++++++++ assets/ts/copyable_text.ts | 8 ++++++++ views/file-uploader.njk | 15 +++++---------- 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/assets/sass/app.scss b/assets/sass/app.scss index 0a709c7..65b166c 100644 --- a/assets/sass/app.scss +++ b/assets/sass/app.scss @@ -1,2 +1,2 @@ @import "layout"; -@import "fm"; \ No newline at end of file +@import "fm"; diff --git a/assets/sass/layout.scss b/assets/sass/layout.scss index e00af32..65f7b4a 100644 --- a/assets/sass/layout.scss +++ b/assets/sass/layout.scss @@ -928,6 +928,23 @@ td.actions { width: 100%; } +.table-col-grow-cell { + display: flex; + flex-direction: row; + + > * { + width: 0; + flex-grow: 1; + white-space: nowrap; + text-overflow: ellipsis; + } + + * { + overflow: hidden; + text-overflow: ellipsis; + } +} + .pagination { ul { display: flex; diff --git a/assets/ts/copyable_text.ts b/assets/ts/copyable_text.ts index 60d58ab..d5f079a 100644 --- a/assets/ts/copyable_text.ts +++ b/assets/ts/copyable_text.ts @@ -12,4 +12,12 @@ document.addEventListener('DOMContentLoaded', () => { }); } }); + + document.querySelectorAll('.copy-button[data-content]').forEach(el => { + el.addEventListener('click', () => { + navigator.clipboard.writeText(`${el.dataset.content}`) + .then(() => console.log('copy success')) + .catch(console.error); + }); + }); }); diff --git a/views/file-uploader.njk b/views/file-uploader.njk index d58a148..7e1b1d1 100644 --- a/views/file-uploader.njk +++ b/views/file-uploader.njk @@ -61,8 +61,7 @@ # - URL - Name + Name Size Expires at Actions @@ -73,19 +72,15 @@ {% for file in files %} {{ file.id }} - - - -
{{ file.real_name }}
+
{{ file.real_name }}
{{ (file.size / (1024 * 1024)).toFixed(2) }}MB {% if file.expires_at %}{{ file.expires_at.toISOString() }}{% else %}Never{% endif %} {% if file.shouldBeDeleted() %} Pending deletion {% else %} + +
{{ macros.csrf(getCsrfToken) }} @@ -95,7 +90,7 @@ {% else %} - You haven't uploaded any file yet. + You haven't uploaded any file yet. {% endfor %}