From 8c0afff95ae4c5a504fd8fc32e1b3f8c2bfebc8e Mon Sep 17 00:00:00 2001 From: Seamus Toth Date: Fri, 16 May 2025 12:25:02 +0100 Subject: [PATCH 1/5] Fix Prettier Lint Issues --- pkg/web/src/routes/+page.svelte | 8 ++++---- pkg/web/src/routes/admin/+page.svelte | 6 +++--- pkg/web/src/routes/login/+page.svelte | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/web/src/routes/+page.svelte b/pkg/web/src/routes/+page.svelte index c4738f2e..d8eb8651 100644 --- a/pkg/web/src/routes/+page.svelte +++ b/pkg/web/src/routes/+page.svelte @@ -100,7 +100,7 @@ }); async function ratePizza(stars) { - faro.api.pushEvent('Submit Pizza Rating', {pizza_id: pizza['pizza']['id'], stars: stars}); + faro.api.pushEvent('Submit Pizza Rating', { pizza_id: pizza['pizza']['id'], stars: stars }); const res = await fetch(`${PUBLIC_BACKEND_ENDPOINT}/api/ratings`, { method: 'POST', body: JSON.stringify({ @@ -120,7 +120,7 @@ } async function getPizza() { - faro.api.pushEvent('Get Pizza Recommendation', {restrictions: restrictions}); + faro.api.pushEvent('Get Pizza Recommendation', { restrictions: restrictions }); if (restrictions.minNumberOfToppings > restrictions.maxNumberOfToppings) { faro.api.pushError(new Error('Invalid Restrictions, Min > Max')); } @@ -147,13 +147,13 @@ }) ); } - if (pizza['pizza']['ingredients'].find(e => e.name === 'Pineapple')) { + if (pizza['pizza']['ingredients'].find((e) => e.name === 'Pineapple')) { faro.api.pushError(new Error('Bad Pizza Recommendation')); } } async function getTools() { - faro.api.pushEvent('Get Pizza Tools', {tools: tools}); + faro.api.pushEvent('Get Pizza Tools', { tools: tools }); const res = await fetch(`${PUBLIC_BACKEND_ENDPOINT}/api/tools`, { headers: { Authorization: 'Token ' + userToken diff --git a/pkg/web/src/routes/admin/+page.svelte b/pkg/web/src/routes/admin/+page.svelte index 9f22ac27..fa24f873 100644 --- a/pkg/web/src/routes/admin/+page.svelte +++ b/pkg/web/src/routes/admin/+page.svelte @@ -32,12 +32,12 @@ ); if (!res.ok) { loginError = 'Login failed: ' + res.statusText; - faro.api.pushEvent('Unsuccessful Admin Login', {username: username}); + faro.api.pushEvent('Unsuccessful Admin Login', { username: username }); faro.api.pushError(new Error('Admin Login Error: ' + res.statusText)); return; } - faro.api.pushEvent('Successful Admin Login', {username: username}); + faro.api.pushEvent('Successful Admin Login', { username: username }); adminLoggedIn = checkAdminLoggedIn(); } @@ -59,7 +59,7 @@ }) .then((res) => res.json()) .then((json) => { - faro.api.pushEvent('Update Recent Pizza Recommendations',); + faro.api.pushEvent('Update Recent Pizza Recommendations'); var newRec: string[] = []; json.pizzas.forEach((pizza: string) => { newRec.push(` diff --git a/pkg/web/src/routes/login/+page.svelte b/pkg/web/src/routes/login/+page.svelte index 88c88755..7d083587 100644 --- a/pkg/web/src/routes/login/+page.svelte +++ b/pkg/web/src/routes/login/+page.svelte @@ -56,12 +56,12 @@ }); if (!res.ok) { loginError = 'Login failed: ' + res.statusText; - faro.api.pushEvent('Unsuccessful Login', {username: username}); + faro.api.pushEvent('Unsuccessful Login', { username: username }); faro.api.pushError(new Error('Login Error: ' + res.statusText)); return; } - faro.api.pushEvent('Successful Login', {username: username}); + faro.api.pushEvent('Successful Login', { username: username }); qpUserLoggedIn = checkQPUserLoggedIn(); } From 17098d98ab2e266d36809f15edf99d117de051e4 Mon Sep 17 00:00:00 2001 From: Seamus Toth Date: Fri, 16 May 2025 13:32:25 +0100 Subject: [PATCH 2/5] Improve Faro Initialization, when not Configured --- pkg/web/src/hooks.client.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/web/src/hooks.client.ts b/pkg/web/src/hooks.client.ts index 0514016c..289ea894 100644 --- a/pkg/web/src/hooks.client.ts +++ b/pkg/web/src/hooks.client.ts @@ -6,13 +6,14 @@ function setupFaro() { fetch(`${PUBLIC_BACKEND_ENDPOINT}/api/config`) .then((data) => data.json()) .then((config) => { - const url = config.faro_url; + let url = config.faro_url; if (!url) { - console.warn('Grafana faro is not configured.'); - return; + console.warn('Grafana Faro is not configured.'); + url = `${PUBLIC_BACKEND_ENDPOINT}/faro` + } else { + console.log(`Initializing Grafana Faro to '${url}'`); } - console.log(`Initializing Grafana Faro to ${url}`); initializeFaro({ url, app: { From 5b7651c095e5605ebe7566ebf6ae6c6c556e7724 Mon Sep 17 00:00:00 2001 From: Seamus Toth Date: Fri, 16 May 2025 13:34:45 +0100 Subject: [PATCH 3/5] Fix Prettier --- pkg/web/src/hooks.client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/web/src/hooks.client.ts b/pkg/web/src/hooks.client.ts index 289ea894..34f50c68 100644 --- a/pkg/web/src/hooks.client.ts +++ b/pkg/web/src/hooks.client.ts @@ -9,7 +9,7 @@ function setupFaro() { let url = config.faro_url; if (!url) { console.warn('Grafana Faro is not configured.'); - url = `${PUBLIC_BACKEND_ENDPOINT}/faro` + url = `${PUBLIC_BACKEND_ENDPOINT}/faro`; } else { console.log(`Initializing Grafana Faro to '${url}'`); } From 3359bba81cd48e6048902d25013784c045c5c31d Mon Sep 17 00:00:00 2001 From: Seamus Toth Date: Fri, 16 May 2025 13:44:29 +0100 Subject: [PATCH 4/5] Tweak Logging --- pkg/web/src/hooks.client.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/web/src/hooks.client.ts b/pkg/web/src/hooks.client.ts index 34f50c68..f4eb6d6a 100644 --- a/pkg/web/src/hooks.client.ts +++ b/pkg/web/src/hooks.client.ts @@ -10,10 +10,9 @@ function setupFaro() { if (!url) { console.warn('Grafana Faro is not configured.'); url = `${PUBLIC_BACKEND_ENDPOINT}/faro`; - } else { - console.log(`Initializing Grafana Faro to '${url}'`); } + console.log(`Initializing Grafana Faro to '${url}'`); initializeFaro({ url, app: { From c1c25763437dbdd16c2fa2a4ef14c2a077c7f6e6 Mon Sep 17 00:00:00 2001 From: Seamus Toth Date: Fri, 16 May 2025 13:56:28 +0100 Subject: [PATCH 5/5] Improve Faro Initialization --- pkg/web/src/hooks.client.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/web/src/hooks.client.ts b/pkg/web/src/hooks.client.ts index f4eb6d6a..cd8759fa 100644 --- a/pkg/web/src/hooks.client.ts +++ b/pkg/web/src/hooks.client.ts @@ -6,10 +6,9 @@ function setupFaro() { fetch(`${PUBLIC_BACKEND_ENDPOINT}/api/config`) .then((data) => data.json()) .then((config) => { - let url = config.faro_url; + const url = config.faro_url; if (!url) { console.warn('Grafana Faro is not configured.'); - url = `${PUBLIC_BACKEND_ENDPOINT}/faro`; } console.log(`Initializing Grafana Faro to '${url}'`);