From 437401539f71c11cb10f010f902b572bc7af9bfe Mon Sep 17 00:00:00 2001
From: JW-CH <17313367+JW-CH@users.noreply.github.com>
Date: Fri, 20 Sep 2024 11:24:42 +0200
Subject: [PATCH 1/2] auto reload web, add progressbar, changes to docker
compose for auto reloading
---
docker/docker-compose.dev.yml | 1 +
immichFrame.Web/eslint.config.js | 13 ++-
immichFrame.Web/package.json | 5 +-
.../components/elements/imageOverlay.svelte | 14 +--
.../components/elements/progress-bar.svelte | 101 ++++++++++++++++++
.../components/elements/slideshow-bar.svelte | 55 ++++++++++
.../lib/components/home-page/home-page.svelte | 66 +++++++++++-
.../src/lib/stores/slideshow.store.ts | 48 +++++++++
immichFrame.Web/src/lib/utils.ts | 4 +
9 files changed, 292 insertions(+), 15 deletions(-)
create mode 100644 immichFrame.Web/src/lib/components/elements/progress-bar.svelte
create mode 100644 immichFrame.Web/src/lib/components/elements/slideshow-bar.svelte
create mode 100644 immichFrame.Web/src/lib/stores/slideshow.store.ts
diff --git a/docker/docker-compose.dev.yml b/docker/docker-compose.dev.yml
index 09d13d7..aa1147c 100644
--- a/docker/docker-compose.dev.yml
+++ b/docker/docker-compose.dev.yml
@@ -16,4 +16,5 @@ services:
- 5173:5173
volumes:
- ~/immichFrame_Config:/app/Config
+ - ../immichFrame.Web/src:/app/src
# - PATH/TO/CONFIG:/app/Config
diff --git a/immichFrame.Web/eslint.config.js b/immichFrame.Web/eslint.config.js
index 62dbd03..d10144b 100644
--- a/immichFrame.Web/eslint.config.js
+++ b/immichFrame.Web/eslint.config.js
@@ -3,6 +3,7 @@ import ts from 'typescript-eslint';
import svelte from 'eslint-plugin-svelte';
import prettier from 'eslint-config-prettier';
import globals from 'globals';
+import parser from 'svelte-eslint-parser';
/** @type {import('eslint').Linter.Config[]} */
export default [
@@ -22,12 +23,22 @@ export default [
{
files: ['**/*.svelte'],
languageOptions: {
+ parser: parser,
+ ecmaVersion: 5,
+ sourceType: 'script',
+
parserOptions: {
- parser: ts.parser
+ parser: '@typescript-eslint/parser'
}
}
},
{
ignores: ['build/', '.svelte-kit/', 'dist/']
+ },
+ {
+ files: ['*.ts'],
+ rules: {
+ 'no-undef': 'off'
+ }
}
];
diff --git a/immichFrame.Web/package.json b/immichFrame.Web/package.json
index 91efdb9..972431c 100644
--- a/immichFrame.Web/package.json
+++ b/immichFrame.Web/package.json
@@ -10,10 +10,7 @@
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --check . && eslint .",
"format": "prettier --write .",
- "api": "oazapfts https://localhost:7018/swagger/v1/swagger.json src/lib/immichFrameApi.ts",
- "dev-up": "docker compose -f ../docker/docker-compose.dev.yml up --remove-orphans || make dev-down",
- "dev-down": "docker compose -f ../docker/docker-compose.dev.yml down --remove-orphans",
- "dev-update": "docker compose -f ../docker/docker-compose.dev.yml up --build -V --remove-orphans"
+ "api": "oazapfts https://localhost:7018/swagger/v1/swagger.json src/lib/immichFrameApi.ts"
},
"devDependencies": {
"@sveltejs/adapter-auto": "^3.0.0",
diff --git a/immichFrame.Web/src/lib/components/elements/imageOverlay.svelte b/immichFrame.Web/src/lib/components/elements/imageOverlay.svelte
index 0835791..c7e8d0c 100644
--- a/immichFrame.Web/src/lib/components/elements/imageOverlay.svelte
+++ b/immichFrame.Web/src/lib/components/elements/imageOverlay.svelte
@@ -7,8 +7,6 @@
function clickNext() {
dispatch('next');
- dispatch('back');
- dispatch('settings');
}
function clickBack() {
dispatch('back');
@@ -23,23 +21,23 @@
-
-
@@ -62,8 +60,10 @@
justify-content: center; /* Centers the SVG horizontally */
align-items: center; /* Optionally, centers the SVG vertically as well */
/* background-color: rgba(75, 75, 75, 0.4); */
- color: wheat;
height: 100%;
width: 100%;
}
+ .frame-color {
+ color: wheat;
+ }
diff --git a/immichFrame.Web/src/lib/components/elements/progress-bar.svelte b/immichFrame.Web/src/lib/components/elements/progress-bar.svelte
new file mode 100644
index 0000000..3732626
--- /dev/null
+++ b/immichFrame.Web/src/lib/components/elements/progress-bar.svelte
@@ -0,0 +1,101 @@
+
+
+
+
+{#if !hidden}
+
+{/if}
+
+
diff --git a/immichFrame.Web/src/lib/components/elements/slideshow-bar.svelte b/immichFrame.Web/src/lib/components/elements/slideshow-bar.svelte
new file mode 100644
index 0000000..7f175fd
--- /dev/null
+++ b/immichFrame.Web/src/lib/components/elements/slideshow-bar.svelte
@@ -0,0 +1,55 @@
+
+
+
diff --git a/immichFrame.Web/src/lib/components/home-page/home-page.svelte b/immichFrame.Web/src/lib/components/home-page/home-page.svelte
index eaf2d62..44dc2c0 100644
--- a/immichFrame.Web/src/lib/components/home-page/home-page.svelte
+++ b/immichFrame.Web/src/lib/components/home-page/home-page.svelte
@@ -1,16 +1,27 @@
{#if imageData && assetData}
- loadImage()} />
+ {
+ progressBar.restart(true);
+ console.log('next load');
+ await loadImage();
+ }}
+ on:back={async () => {
+ progressBar.restart(true);
+ console.log('back load');
+ await loadImage();
+ }}
+ />
+
{:else}
LOADING ...
diff --git a/immichFrame.Web/src/lib/stores/slideshow.store.ts b/immichFrame.Web/src/lib/stores/slideshow.store.ts
new file mode 100644
index 0000000..dd330c1
--- /dev/null
+++ b/immichFrame.Web/src/lib/stores/slideshow.store.ts
@@ -0,0 +1,48 @@
+import { writable } from 'svelte/store';
+
+export enum SlideshowState {
+ PlaySlideshow = 'play-slideshow',
+ StopSlideshow = 'stop-slideshow',
+ None = 'none',
+}
+
+
+function createSlideshowStore() {
+ const restartState = writable(false);
+ const stopState = writable(false);
+
+ const slideshowState = writable(SlideshowState.None);
+
+ return {
+ restartProgress: {
+ subscribe: restartState.subscribe,
+ set: (value: boolean) => {
+
+ console.log('restartProgress value is: ')
+ console.log(value)
+ // Trigger an action whenever the restartProgress is set to true. Automatically
+ // reset the restart state after that
+ if (value) {
+ restartState.set(true);
+ restartState.set(false);
+ }
+ },
+ },
+ stopProgress: {
+ subscribe: stopState.subscribe,
+ set: (value: boolean) => {
+ console.log('stopProgress value is: ')
+ console.log(value)
+ // Trigger an action whenever the stopProgress is set to true. Automatically
+ // reset the stop state after that
+ if (value) {
+ stopState.set(true);
+ stopState.set(false);
+ }
+ },
+ },
+ slideshowState
+ };
+}
+
+export const slideshowStore = createSlideshowStore();
diff --git a/immichFrame.Web/src/lib/utils.ts b/immichFrame.Web/src/lib/utils.ts
index a76b2cc..6b3ff6e 100644
--- a/immichFrame.Web/src/lib/utils.ts
+++ b/immichFrame.Web/src/lib/utils.ts
@@ -1 +1,5 @@
export const decodeBase64 = (data: string) => Uint8Array.from(atob(data), (c) => c.charCodeAt(0));
+
+export const handlePromiseError = (promise: Promise): void => {
+ promise.catch((error) => console.error(`[utils.ts]:handlePromiseError ${error}`, error));
+};
From 617f04fddbc516398b6650bf5b6a9967b79c26f7 Mon Sep 17 00:00:00 2001
From: JW-CH <17313367+JW-CH@users.noreply.github.com>
Date: Fri, 20 Sep 2024 11:28:38 +0200
Subject: [PATCH 2/2] remove debug-logging, remove unused components,
progressbar restart on done
---
.../components/elements/slideshow-bar.svelte | 55 -------------------
.../lib/components/home-page/home-page.svelte | 10 +---
2 files changed, 3 insertions(+), 62 deletions(-)
delete mode 100644 immichFrame.Web/src/lib/components/elements/slideshow-bar.svelte
diff --git a/immichFrame.Web/src/lib/components/elements/slideshow-bar.svelte b/immichFrame.Web/src/lib/components/elements/slideshow-bar.svelte
deleted file mode 100644
index 7f175fd..0000000
--- a/immichFrame.Web/src/lib/components/elements/slideshow-bar.svelte
+++ /dev/null
@@ -1,55 +0,0 @@
-
-
-
diff --git a/immichFrame.Web/src/lib/components/home-page/home-page.svelte b/immichFrame.Web/src/lib/components/home-page/home-page.svelte
index 44dc2c0..f09e2ab 100644
--- a/immichFrame.Web/src/lib/components/home-page/home-page.svelte
+++ b/immichFrame.Web/src/lib/components/home-page/home-page.svelte
@@ -21,7 +21,6 @@
let unsubscribeStop: () => void;
async function loadImage() {
- console.log('loading image');
let assetRequest = await api.getAsset();
if (assetRequest.status != 200) {
@@ -52,7 +51,6 @@
}
});
- console.log('mount load');
await loadImage();
});
@@ -67,8 +65,8 @@
});
const handleDone = async () => {
- console.log('done load');
await loadImage();
+ progressBar.restart(true);
};
@@ -77,14 +75,12 @@
{
- progressBar.restart(true);
- console.log('next load');
await loadImage();
+ progressBar.restart(true);
}}
on:back={async () => {
- progressBar.restart(true);
- console.log('back load');
await loadImage();
+ progressBar.restart(true);
}}
/>