From e506764bbd81f87fa36ecb39b5cff7a77dd1ccf6 Mon Sep 17 00:00:00 2001 From: thiloho <123883702+thiloho@users.noreply.github.com> Date: Sun, 15 Sep 2024 17:54:54 +0200 Subject: [PATCH 1/7] Update navigation loading and NGINX try_file --- nix/dev-vm.nix | 4 ++-- nix/module.nix | 10 ++++------ web-app/src/routes/+layout.svelte | 13 ++----------- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/nix/dev-vm.nix b/nix/dev-vm.nix index 48bacd4..33518f4 100644 --- a/nix/dev-vm.nix +++ b/nix/dev-vm.nix @@ -68,9 +68,9 @@ ]; locations = { "/" = { - root = "/var/www/archtika-websites/"; + root = "/var/www/archtika-websites"; index = "index.html"; - tryFiles = "$uri $uri/ $uri.html $uri/index.html index.html =404"; + tryFiles = "$uri $uri/ $uri.html =404"; extraConfig = '' autoindex on; ''; diff --git a/nix/module.nix b/nix/module.nix index 123a60e..8ca01aa 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -158,16 +158,14 @@ in proxyPass = "http://localhost:${toString cfg.webAppPort}"; }; "/previews/" = { - alias = "/var/www/archtika-websites/previews/"; + root = "/var/www/archtika-websites/previews"; index = "index.html"; - tryFiles = "$uri $uri/ $uri.html $uri/index.html index.html =404"; + tryFiles = "$uri $uri/ $uri.html =404" }; "/api/" = { proxyPass = "http://localhost:${toString cfg.apiPort}/"; extraConfig = '' default_type application/json; - proxy_hide_header Content-Location; - add_header Content-Location /api/$upstream_http_content_location; proxy_set_header Connection ""; proxy_http_version 1.1; ''; @@ -179,9 +177,9 @@ in forceSSL = true; locations = { "/" = { - alias = "/var/www/archtika-websites/$subdomain/"; + root = "/var/www/archtika-websites/$subdomain"; index = "index.html"; - tryFiles = "$uri $uri/ $uri.html $uri/index.html index.html =404"; + tryFiles = "$uri $uri/ $uri.html =404"; }; }; }; diff --git a/web-app/src/routes/+layout.svelte b/web-app/src/routes/+layout.svelte index 866a528..4843fcc 100644 --- a/web-app/src/routes/+layout.svelte +++ b/web-app/src/routes/+layout.svelte @@ -3,20 +3,11 @@ import { page } from "$app/stores"; import type { LayoutServerData } from "./$types"; import type { Snippet } from "svelte"; - import { beforeNavigate, afterNavigate } from "$app/navigation"; + import { navigating } from "$app/stores"; import LoadingSpinner from "$lib/components/LoadingSpinner.svelte"; const { data, children }: { data: LayoutServerData; children: Snippet } = $props(); - let loading = $state(false); - - beforeNavigate(() => { - loading = true; - }); - afterNavigate(() => { - loading = false; - }); - const isProjectRoute = $derived($page.url.pathname.startsWith("/website") && !$page.error); const routeName = $derived( $page.url.pathname === "/" @@ -25,7 +16,7 @@ ); -{#if loading} +{#if $navigating} {/if} From fd3312239e398e720cac385c7d3da5a7a13a1957 Mon Sep 17 00:00:00 2001 From: thiloho <123883702+thiloho@users.noreply.github.com> Date: Sun, 15 Sep 2024 18:18:10 +0200 Subject: [PATCH 2/7] Trigger actions From d4984fba8810833c7cf5f4bd4205a48f799cf569 Mon Sep 17 00:00:00 2001 From: thiloho <123883702+thiloho@users.noreply.github.com> Date: Sun, 15 Sep 2024 21:37:32 +0200 Subject: [PATCH 3/7] Add pagination for logs route --- .../website/[websiteId]/logs/+page.server.ts | 4 +- .../website/[websiteId]/logs/+page.svelte | 109 +++++++++++++++++- web-app/src/routes/+layout.svelte | 2 +- 3 files changed, 110 insertions(+), 5 deletions(-) diff --git a/web-app/src/routes/(authenticated)/website/[websiteId]/logs/+page.server.ts b/web-app/src/routes/(authenticated)/website/[websiteId]/logs/+page.server.ts index a89f5db..533b4c0 100644 --- a/web-app/src/routes/(authenticated)/website/[websiteId]/logs/+page.server.ts +++ b/web-app/src/routes/(authenticated)/website/[websiteId]/logs/+page.server.ts @@ -6,6 +6,8 @@ export const load: PageServerLoad = async ({ parent, fetch, params, cookies, url const userFilter = url.searchParams.get("logs_filter_user"); const resourceFilter = url.searchParams.get("logs_filter_resource"); const operationFilter = url.searchParams.get("logs_filter_operation"); + const currentPage = Number.parseInt(url.searchParams.get("logs_results_page") ?? "1"); + const resultOffset = currentPage === 1 ? 0 : currentPage * 50; const searchParams = new URLSearchParams(); @@ -23,7 +25,7 @@ export const load: PageServerLoad = async ({ parent, fetch, params, cookies, url searchParams.append("operation", `eq.${operationFilter.toUpperCase()}`); } - const constructedFetchUrl = `${baseFetchUrl}&${searchParams.toString()}`; + const constructedFetchUrl = `${baseFetchUrl}&${searchParams.toString()}&limit=50&offset=${resultOffset}`; const changeLogData = await fetch(constructedFetchUrl, { method: "GET", diff --git a/web-app/src/routes/(authenticated)/website/[websiteId]/logs/+page.svelte b/web-app/src/routes/(authenticated)/website/[websiteId]/logs/+page.svelte index 8cda235..b52db73 100644 --- a/web-app/src/routes/(authenticated)/website/[websiteId]/logs/+page.svelte +++ b/web-app/src/routes/(authenticated)/website/[websiteId]/logs/+page.svelte @@ -42,6 +42,8 @@ const { user, change_log, media, ...restTables } = tables; resources = restTables; } + + let logsSection: HTMLElement; -
+

Logs

- {data.resultChangeLogCount} - results + {data.resultChangeLogCount.toLocaleString("en", { useGrouping: true })} + result(s)

@@ -111,6 +113,7 @@ > +
@@ -155,6 +158,106 @@ {/each} + {#snippet commonFilterInputs()} + + + + {/snippet} +
+ + diff --git a/web-app/src/routes/+layout.svelte b/web-app/src/routes/+layout.svelte index 4843fcc..75a5ce9 100644 --- a/web-app/src/routes/+layout.svelte +++ b/web-app/src/routes/+layout.svelte @@ -16,7 +16,7 @@ ); -{#if $navigating} +{#if $navigating && ["link", "goto"].includes($navigating.type)} {/if} From 4c22ae3f61ec779296a6147476fcba966c07c644 Mon Sep 17 00:00:00 2001 From: thiloho <123883702+thiloho@users.noreply.github.com> Date: Sun, 15 Sep 2024 21:48:28 +0200 Subject: [PATCH 4/7] Add missing semicolon --- nix/module.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/module.nix b/nix/module.nix index 8ca01aa..21fb878 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -160,7 +160,7 @@ in "/previews/" = { root = "/var/www/archtika-websites/previews"; index = "index.html"; - tryFiles = "$uri $uri/ $uri.html =404" + tryFiles = "$uri $uri/ $uri.html =404"; }; "/api/" = { proxyPass = "http://localhost:${toString cfg.apiPort}/"; From d509a65f1cd0e5ae3f5221cbd4dc912ba41556e3 Mon Sep 17 00:00:00 2001 From: thiloho <123883702+thiloho@users.noreply.github.com> Date: Sun, 15 Sep 2024 21:58:29 +0200 Subject: [PATCH 5/7] Update module --- nix/module.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/module.nix b/nix/module.nix index 21fb878..b934d60 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -158,7 +158,7 @@ in proxyPass = "http://localhost:${toString cfg.webAppPort}"; }; "/previews/" = { - root = "/var/www/archtika-websites/previews"; + root = "/var/www/archtika-websites/previews/"; index = "index.html"; tryFiles = "$uri $uri/ $uri.html =404"; }; From 6acfc69def45da763ccade62d92e19489a40239b Mon Sep 17 00:00:00 2001 From: thiloho <123883702+thiloho@users.noreply.github.com> Date: Sun, 15 Sep 2024 22:25:38 +0200 Subject: [PATCH 6/7] Update module --- nix/module.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/module.nix b/nix/module.nix index b934d60..d939861 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -158,7 +158,7 @@ in proxyPass = "http://localhost:${toString cfg.webAppPort}"; }; "/previews/" = { - root = "/var/www/archtika-websites/previews/"; + alias = "/var/www/archtika-websites/previews/"; index = "index.html"; tryFiles = "$uri $uri/ $uri.html =404"; }; From 107c6c340daf95ea119eeaa8c2e8c5d800aa8a73 Mon Sep 17 00:00:00 2001 From: thiloho <123883702+thiloho@users.noreply.github.com> Date: Sun, 15 Sep 2024 22:37:50 +0200 Subject: [PATCH 7/7] Update deploy action --- .github/workflows/deploy.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 07be266..9b0cfe5 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -31,8 +31,9 @@ jobs: - name: Deploy to demo server run: | nix run nixpkgs#nixos-rebuild -- switch \ - --flake .#${{ github.ref_name == 'devel' && 'qs' || 'prod' }} \ + --flake github:archtika/archtika/${{ github.ref_name }}#${{ github.ref_name == 'devel' && 'qs' || 'prod' }} \ --fast \ + --refresh \ --build-host ${{ env.SERVER_USER }}@${{ github.ref_name == 'devel' && env.QS_SERVER_IP || env.PROD_SERVER_IP }} \ --target-host ${{ env.SERVER_USER }}@${{ github.ref_name == 'devel' && env.QS_SERVER_IP || env.PROD_SERVER_IP }} \ --use-remote-sudo