From ec792318e61422d8966e8b32a03f0bb30e282962 Mon Sep 17 00:00:00 2001 From: Amir Raminfar Date: Fri, 18 Apr 2025 13:52:53 -0700 Subject: [PATCH] feat: adds better disabled colors and loader while fetching big logs (#3816) --- assets/components/LogViewer/LogAnalytics.vue | 29 ++++++++++++++++++-- locales/da.yml | 2 +- locales/de.yml | 2 +- locales/en.yml | 2 +- locales/es.yml | 2 +- locales/fr.yml | 2 +- locales/it.yml | 2 +- locales/pl.yml | 2 +- locales/pr.yml | 2 +- locales/pt.yml | 2 +- locales/ru.yml | 2 +- locales/tr.yml | 2 +- locales/zh-tw.yml | 2 +- locales/zh.yml | 2 +- 14 files changed, 40 insertions(+), 15 deletions(-) diff --git a/assets/components/LogViewer/LogAnalytics.vue b/assets/components/LogViewer/LogAnalytics.vue index 5dc19879..0d8a02cf 100644 --- a/assets/components/LogViewer/LogAnalytics.vue +++ b/assets/components/LogViewer/LogAnalytics.vue @@ -12,11 +12,14 @@ v-model="query" class="textarea textarea-primary w-full font-mono text-lg" :class="{ 'textarea-error': error }" + :disabled="state !== 'ready'" >
{{ error }} {{ $t("analytics.creating_table") }} - {{ $t("analytics.downloading") }} + {{ + $t("analytics.downloading", { size: formatBytes(bytes, { decimals: 1 }) }) + }} {{ $t("analytics.evaluating_query") }} {{ $t("analytics.total_records", { count: results.numRows.toLocaleString() }) }} @@ -43,6 +46,7 @@ const debouncedQuery = debouncedRef(query, 500); const evaluating = ref(false); const pageLimit = 1000; const state = ref<"downloading" | "error" | "ready" | "initializing">("downloading"); +const bytes = ref(0); const url = withBase( `/api/hosts/${container.host}/containers/${container.id}/logs?stdout=1&stderr=1&everything&jsonOnly`, @@ -61,7 +65,28 @@ const empty = await conn.query>(`SELECT 1 LIMIT 0`); onMounted(async () => { try { state.value = "downloading"; - await db.registerFileBuffer("logs.json", new Uint8Array(await response.arrayBuffer())); + + const reader = response.body?.getReader(); + if (!reader) throw new Error("No reader available from stream"); + + const chunks: Uint8Array[] = []; + bytes.value = 0; + + while (true) { + const { done, value } = await reader.read(); + if (done) break; + chunks.push(value); + bytes.value += value.length; + } + + const arrayBuffer = new Uint8Array(bytes.value); + let position = 0; + for (const chunk of chunks) { + arrayBuffer.set(chunk, position); + position += chunk.length; + } + + await db.registerFileBuffer("logs.json", arrayBuffer); state.value = "initializing"; await conn.query( diff --git a/locales/da.yml b/locales/da.yml index c9113317..ccae4ee9 100644 --- a/locales/da.yml +++ b/locales/da.yml @@ -116,7 +116,7 @@ toasts: message: Log kopieret til clipboard analytics: creating_table: Opretter midlertidig tabel... - downloading: Henter containerlogfiler... + downloading: Henter containerlogfiler... ({size}) evaluating_query: Evaluerer forespørgsel... total_records: I alt {count} poster. showing_first: Viser de første {count}. diff --git a/locales/de.yml b/locales/de.yml index 162d20d0..5e50e2fc 100644 --- a/locales/de.yml +++ b/locales/de.yml @@ -116,7 +116,7 @@ toasts: message: Log in Zwischenablage kopiert analytics: creating_table: Temporäre Tabelle wird erstellt... - downloading: Container-Logs werden abgerufen... + downloading: Container-Logs werden abgerufen... ({size}) evaluating_query: Abfrage wird ausgewertet... total_records: Insgesamt {count} Datensätze. showing_first: Zeige die ersten {count}. diff --git a/locales/en.yml b/locales/en.yml index a411150c..923084e1 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -121,7 +121,7 @@ toasts: message: Log copied to clipboard analytics: creating_table: Creating temporary table... - downloading: Fetching containers logs... + downloading: Fetching container logs... ({size}) evaluating_query: Evaluating query... total_records: Total {count} records. showing_first: Showing first {count}. diff --git a/locales/es.yml b/locales/es.yml index ee78ebae..5acd3fb9 100644 --- a/locales/es.yml +++ b/locales/es.yml @@ -116,7 +116,7 @@ toasts: message: Registro copiado al portapapeles analytics: creating_table: Creando tabla temporal... - downloading: Obteniendo registros de contenedores... + downloading: Obteniendo registros de contenedores... ({size}) evaluating_query: Evaluando consulta... total_records: Total {count} registros. showing_first: Mostrando los primeros {count}. diff --git a/locales/fr.yml b/locales/fr.yml index 617dac1c..280802e1 100644 --- a/locales/fr.yml +++ b/locales/fr.yml @@ -116,7 +116,7 @@ toasts: message: Journal copié dans le presse-papiers analytics: creating_table: Création d'une table temporaire... - downloading: Récupération des journaux des conteneurs... + downloading: Récupération des journaux des conteneurs... ({size}) evaluating_query: Évaluation de la requête... total_records: Total de {count} enregistrements. showing_first: Affichage des {count} premiers. diff --git a/locales/it.yml b/locales/it.yml index 8361af6c..adab5017 100644 --- a/locales/it.yml +++ b/locales/it.yml @@ -116,7 +116,7 @@ toasts: message: Log copiato nella clipboard analytics: creating_table: Creazione tabella temporanea... - downloading: Recupero dei log dei container... + downloading: Recupero dei log dei container... ({size}) evaluating_query: Valutazione della query... total_records: Totale {count} record. showing_first: Mostrati i primi {count}. diff --git a/locales/pl.yml b/locales/pl.yml index 7c66708c..2bd06c12 100644 --- a/locales/pl.yml +++ b/locales/pl.yml @@ -116,7 +116,7 @@ toasts: message: Log skopiowany do schowka analytics: creating_table: Tworzenie tymczasowej tabeli... - downloading: Pobieranie logów kontenerów... + downloading: Pobieranie logów kontenerów... ({size}) evaluating_query: Przetwarzanie zapytania... total_records: Razem {count} rekordów. showing_first: Pokazywanie pierwszych {count}. diff --git a/locales/pr.yml b/locales/pr.yml index af0c0900..885948ca 100644 --- a/locales/pr.yml +++ b/locales/pr.yml @@ -112,7 +112,7 @@ settings: analytics: creating_table: A criar tabela temporária... - downloading: A obter registos dos contentores... + downloading: A obter registos dos contentores... ({size}) evaluating_query: A avaliar consulta... total_records: Total de {count} registos. showing_first: A mostrar os primeiros {count}. diff --git a/locales/pt.yml b/locales/pt.yml index 390b76c1..7cb2a43c 100644 --- a/locales/pt.yml +++ b/locales/pt.yml @@ -116,7 +116,7 @@ toasts: message: Log copiado para a área de transferência analytics: creating_table: Criando tabela temporária... - downloading: Buscando logs dos containers... + downloading: Buscando logs dos containers... ({size}) evaluating_query: Avaliando consulta... total_records: Total de {count} registros. showing_first: Mostrando os primeiros {count}. diff --git a/locales/ru.yml b/locales/ru.yml index 358efa4e..7d538c54 100644 --- a/locales/ru.yml +++ b/locales/ru.yml @@ -116,7 +116,7 @@ toasts: message: Log copied to clipboard analytics: creating_table: Создание временной таблицы... - downloading: Получение логов контейнеров... + downloading: Получение логов контейнеров... ({size}) evaluating_query: Выполнение запроса... total_records: Всего {count} записей. showing_first: Показаны первые {count}. diff --git a/locales/tr.yml b/locales/tr.yml index 1998e0ca..e2dbc6eb 100644 --- a/locales/tr.yml +++ b/locales/tr.yml @@ -109,7 +109,7 @@ toasts: message: Günlük panoya kopyalandı analytics: creating_table: Geçici tablo oluşturuluyor... - downloading: Konteyner günlükleri alınıyor... + downloading: Konteyner günlükleri alınıyor... ({size}) evaluating_query: Sorgu değerlendiriliyor... total_records: Toplam {count} kayıt. showing_first: İlk {count} gösteriliyor. diff --git a/locales/zh-tw.yml b/locales/zh-tw.yml index 2b0cae17..13586ca9 100644 --- a/locales/zh-tw.yml +++ b/locales/zh-tw.yml @@ -119,7 +119,7 @@ toasts: message: 日誌已複製到剪貼簿 analytics: creating_table: 正在建立臨時資料表... - downloading: 正在取得容器日誌... + downloading: 正在取得容器日誌... ({size}) evaluating_query: 正在評估查詢... total_records: 共計 {count} 筆記錄。 showing_first: 顯示前 {count} 筆。 diff --git a/locales/zh.yml b/locales/zh.yml index f77938c8..1ec4d5e2 100644 --- a/locales/zh.yml +++ b/locales/zh.yml @@ -116,7 +116,7 @@ toasts: message: 日志已复制到剪贴板 analytics: creating_table: 正在创建临时表... - downloading: 正在获取容器日志... + downloading: 正在获取容器日志... ({size}) evaluating_query: 正在评估查询... total_records: 总共 {count} 条记录。 showing_first: 显示前 {count} 条。