Download ui/web/src/components/FeedbackTab.svelte from localailb/assistant: direct link, hf CLI and curl.
- Browser
- Download file 10.3 kB
-
https://huggingface.co/spaces/localailb/assistant/resolve/main/ui/web/src/components/FeedbackTab.svelte
- Command line
-
hf download hf://spaces/localailb/assistant/ui/web/src/components/FeedbackTab.svelte
-
curl -L -o FeedbackTab.svelte https://huggingface.co/spaces/localailb/assistant/resolve/main/ui/web/src/components/FeedbackTab.svelte
10.3 kB
| <script> | |
| import { app, t } from "../lib/stores.svelte.js"; | |
| import { fetchDiagnostics, submitFeedback } from "../lib/api.js"; | |
| import "./FeedbackTab.css"; | |
| const TARGET_EMAIL = "aidgcreator@gmail.com"; | |
| let feedbackType = $state("feedback"); | |
| let subject = $state(""); | |
| let userEmail = $state(""); | |
| let message = $state(""); | |
| let includeDiag = $state(true); | |
| let diagText = $state(""); | |
| let recentLogs = $state(""); | |
| let loadingDiag = $state(false); | |
| let flash = $state(""); | |
| let flashErr = $state(false); | |
| let flashTimer = null; | |
| function showFlash(msg, isErr = false) { | |
| flash = msg; | |
| flashErr = isErr; | |
| if (flashTimer) clearTimeout(flashTimer); | |
| flashTimer = setTimeout(() => { | |
| flash = ""; | |
| }, 6000); | |
| } | |
| async function loadDiagnostics() { | |
| loadingDiag = true; | |
| try { | |
| const res = await fetchDiagnostics(app.lang); | |
| if (res?.ok) { | |
| diagText = res.diagnostics || ""; | |
| recentLogs = res.recent_logs || ""; | |
| } | |
| } catch { | |
| diagText = "App: LocalAiLab\nPlatform: Web/Desktop"; | |
| } finally { | |
| loadingDiag = false; | |
| } | |
| } | |
| // Load diagnostics once on mount or when language flips | |
| let loadedLang = ""; | |
| $effect(() => { | |
| if (app.lang !== loadedLang) { | |
| loadedLang = app.lang; | |
| loadDiagnostics(); | |
| } | |
| }); | |
| function clearForm() { | |
| subject = ""; | |
| message = ""; | |
| userEmail = ""; | |
| feedbackType = "feedback"; | |
| showFlash(t("status_feedback_cleared"), false); | |
| } | |
| async function copyEmailOnly() { | |
| try { | |
| await navigator.clipboard.writeText(TARGET_EMAIL); | |
| showFlash(t("status_email_copied"), false); | |
| } catch { | |
| showFlash(t("web_copy_fail"), true); | |
| } | |
| } | |
| async function copyFullReport() { | |
| if (!subject.trim() && !message.trim()) { | |
| showFlash(t("status_feedback_empty_msg"), true); | |
| return; | |
| } | |
| try { | |
| const res = await submitFeedback({ | |
| type: feedbackType, | |
| subject: subject.trim(), | |
| message: message.trim(), | |
| email: userEmail.trim(), | |
| include_diag: includeDiag, | |
| diagnostics: diagText, | |
| logs: recentLogs, | |
| lang: app.lang, | |
| }); | |
| if (res?.body) { | |
| await navigator.clipboard.writeText(res.body); | |
| showFlash(t("status_feedback_copied"), false); | |
| } | |
| } catch (err) { | |
| showFlash(err.message || t("web_copy_fail"), true); | |
| } | |
| } | |
| async function sendViaEmailClient() { | |
| if (!subject.trim() && !message.trim()) { | |
| showFlash(t("status_feedback_empty_msg"), true); | |
| return; | |
| } | |
| try { | |
| const res = await submitFeedback({ | |
| type: feedbackType, | |
| subject: subject.trim(), | |
| message: message.trim(), | |
| email: userEmail.trim(), | |
| include_diag: includeDiag, | |
| diagnostics: diagText, | |
| logs: recentLogs, | |
| lang: app.lang, | |
| }); | |
| if (res?.mailto_url) { | |
| showFlash(t("status_feedback_opening_mail"), false); | |
| window.location.href = res.mailto_url; | |
| } | |
| } catch (err) { | |
| showFlash(err.message || "Failed to launch mail client", true); | |
| } | |
| } | |
| async function sendViaGmailWeb() { | |
| if (!subject.trim() && !message.trim()) { | |
| showFlash(t("status_feedback_empty_msg"), true); | |
| return; | |
| } | |
| try { | |
| const res = await submitFeedback({ | |
| type: feedbackType, | |
| subject: subject.trim(), | |
| message: message.trim(), | |
| email: userEmail.trim(), | |
| include_diag: includeDiag, | |
| diagnostics: diagText, | |
| logs: recentLogs, | |
| lang: app.lang, | |
| }); | |
| if (res?.gmail_url) { | |
| showFlash(t("status_feedback_opening_gmail"), false); | |
| window.open(res.gmail_url, "_blank", "noopener,noreferrer"); | |
| } | |
| } catch (err) { | |
| showFlash(err.message || "Failed to open Gmail", true); | |
| } | |
| } | |
| </script> | |
| <div class="tab-scroll"> | |
| <div class="feedback-container"> | |
| <!-- Main Feedback Card --> | |
| <div class="card"> | |
| <div class="card-title">{t("sec_feedback_form")}</div> | |
| <!-- Recipient Chip --> | |
| <div class="feedback-target-chip" data-tooltip={t("label_feedback_recipient")}> | |
| <span>{t("label_feedback_recipient")}:</span> | |
| <span class="feedback-target-email">{TARGET_EMAIL}</span> | |
| <button | |
| type="button" | |
| class="btn btn-sm" | |
| onclick={copyEmailOnly} | |
| data-tooltip={t("info_copy_email")} | |
| > | |
| {t("btn_copy_email")} | |
| </button> | |
| </div> | |
| <!-- Feedback Type Selector --> | |
| <div> | |
| <label class="field-label" for="feedback-type-group">{t("label_feedback_type")}</label> | |
| <div class="feedback-type-group" id="feedback-type-group"> | |
| <button | |
| type="button" | |
| class="feedback-type-btn" | |
| class:active={feedbackType === "feedback"} | |
| onclick={() => { feedbackType = "feedback"; }} | |
| data-tooltip={t("fb_type_feedback")} | |
| > | |
| {t("fb_type_feedback")} | |
| </button> | |
| <button | |
| type="button" | |
| class="feedback-type-btn" | |
| class:active={feedbackType === "bug"} | |
| onclick={() => { feedbackType = "bug"; }} | |
| data-tooltip={t("fb_type_bug")} | |
| > | |
| {t("fb_type_bug")} | |
| </button> | |
| <button | |
| type="button" | |
| class="feedback-type-btn" | |
| class:active={feedbackType === "feature"} | |
| onclick={() => { feedbackType = "feature"; }} | |
| data-tooltip={t("fb_type_feature")} | |
| > | |
| {t("fb_type_feature")} | |
| </button> | |
| <button | |
| type="button" | |
| class="feedback-type-btn" | |
| class:active={feedbackType === "error"} | |
| onclick={() => { feedbackType = "error"; }} | |
| data-tooltip={t("fb_type_error")} | |
| > | |
| {t("fb_type_error")} | |
| </button> | |
| </div> | |
| </div> | |
| <!-- Subject / Title --> | |
| <label class="field" data-tooltip={t("label_feedback_subject")}> | |
| <span class="field-label">{t("label_feedback_subject")}</span> | |
| <input | |
| class="feedback-input" | |
| type="text" | |
| bind:value={subject} | |
| placeholder={t("placeholder_feedback_subject")} | |
| /> | |
| </label> | |
| <!-- User Email (Optional) --> | |
| <label class="field" data-tooltip={t("label_feedback_email")}> | |
| <span class="field-label">{t("label_feedback_email")}</span> | |
| <input | |
| class="feedback-input" | |
| type="email" | |
| bind:value={userEmail} | |
| placeholder={t("placeholder_feedback_email")} | |
| /> | |
| </label> | |
| <!-- Message Textarea --> | |
| <label class="field" data-tooltip={t("label_feedback_message")}> | |
| <span class="field-label">{t("label_feedback_message")}</span> | |
| <textarea | |
| class="feedback-textarea" | |
| bind:value={message} | |
| placeholder={t("placeholder_feedback_message")} | |
| ></textarea> | |
| </label> | |
| <!-- Include Diagnostics Checkbox --> | |
| <label class="chip" class:on={includeDiag} data-tooltip={t("info_feedback_diagnostics")}> | |
| <input type="checkbox" bind:checked={includeDiag} /> | |
| <span>{t("label_feedback_include_diag")}</span> | |
| </label> | |
| <!-- Collapsible Diagnostics Preview --> | |
| {#if includeDiag} | |
| <details class="feedback-diag-box"> | |
| <summary>{t("label_feedback_diag_preview")} ({loadingDiag ? "..." : "✓"})</summary> | |
| <pre class="feedback-diag-pre">{diagText}{recentLogs ? `\n\n--- Recent Logs ---\n${recentLogs}` : ""}</pre> | |
| </details> | |
| {/if} | |
| <!-- Action Buttons --> | |
| <div class="tool-row" style="flex-wrap: wrap; gap: 8px;"> | |
| <button | |
| type="button" | |
| class="btn btn-primary" | |
| onclick={sendViaEmailClient} | |
| data-tooltip={t("info_feedback_send_email")} | |
| > | |
| {t("btn_feedback_send_email")} | |
| </button> | |
| <button | |
| type="button" | |
| class="btn" | |
| onclick={sendViaGmailWeb} | |
| data-tooltip={t("info_feedback_send_gmail")} | |
| > | |
| {t("btn_feedback_send_gmail")} | |
| </button> | |
| <button | |
| type="button" | |
| class="btn" | |
| onclick={copyFullReport} | |
| data-tooltip={t("info_feedback_copy")} | |
| > | |
| {t("btn_feedback_copy")} | |
| </button> | |
| <button | |
| type="button" | |
| class="btn" | |
| onclick={clearForm} | |
| data-tooltip={t("info_feedback_clear")} | |
| > | |
| {t("btn_feedback_clear")} | |
| </button> | |
| </div> | |
| {#if flash} | |
| <div class="tool-flash" class:err={flashErr} role="status">{flash}</div> | |
| {/if} | |
| </div> | |
| <!-- Direct Developer Links Card --> | |
| <div class="card"> | |
| <div class="card-title">{t("sec_feedback_direct")}</div> | |
| <div class="feedback-contact-grid"> | |
| <div class="feedback-contact-card"> | |
| <div class="feedback-contact-info"> | |
| <span class="feedback-contact-label">{t("label_feedback_direct_email")}</span> | |
| <span class="feedback-contact-val">{TARGET_EMAIL}</span> | |
| </div> | |
| <button | |
| type="button" | |
| class="btn btn-sm" | |
| onclick={copyEmailOnly} | |
| data-tooltip={t("info_copy_email")} | |
| > | |
| 📋 | |
| </button> | |
| </div> | |
| <a | |
| class="feedback-contact-card" | |
| href="https://youtube.com/@localailabkh" | |
| target="_blank" | |
| rel="noopener" | |
| data-tooltip={t("web_youtube_tip")} | |
| > | |
| <div class="feedback-contact-info"> | |
| <span class="feedback-contact-label">YouTube</span> | |
| <span class="feedback-contact-val">@localailabkh</span> | |
| </div> | |
| <span>▶️</span> | |
| </a> | |
| <a | |
| class="feedback-contact-card" | |
| href="https://github.com/aidgcreator-prog/LocalAILab" | |
| target="_blank" | |
| rel="noopener" | |
| > | |
| <div class="feedback-contact-info"> | |
| <span class="feedback-contact-label">GitHub</span> | |
| <span class="feedback-contact-val">aidgcreator-prog/LocalAILab</span> | |
| </div> | |
| <span>🐙</span> | |
| </a> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |