From d25284e3a47a9efe6c0a8877e8abeac098ced8af Mon Sep 17 00:00:00 2001 From: Djuri Baars Date: Sun, 19 Nov 2023 20:27:22 +0100 Subject: [PATCH] Lint and format all files --- .eslintrc.cjs | 3 + .github/workflows/workflow.yml | 14 +- .prettierignore | 2 +- README.md | 4 +- src/hooks.server.ts | 12 +- src/lib/i18n/index.ts | 20 +- src/lib/locales/en.json | 138 ++--- src/lib/locales/es.json | 138 ++--- src/lib/locales/nl.json | 136 ++--- src/lib/style/app.scss | 244 ++++----- src/routes/+layout.svelte | 26 +- src/routes/+layout.ts | 25 +- src/routes/+page.svelte | 61 ++- src/routes/Control.svelte | 190 ++++--- src/routes/Rendered.svelte | 40 +- src/routes/Settings.svelte | 221 +++++--- src/routes/Status.svelte | 240 +++++---- src/routes/api/+page.svelte | 43 +- static/swagger.json | 926 ++++++++++++++++----------------- static/swagger.yml | 66 +-- svelte.config.js | 20 +- vite.config.ts | 68 +-- 22 files changed, 1357 insertions(+), 1280 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index ebc1958..1105b14 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -18,6 +18,9 @@ module.exports = { es2017: true, node: true }, + rules: { + 'no-empty': ['error', { allowEmptyCatch: true }] + }, overrides: [ { files: ['*.svelte'], diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 0875a0b..c9512f5 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -3,7 +3,7 @@ name: BTClock WebUI CI on: [push] env: - PUBLIC_BASE_URL: "" + PUBLIC_BASE_URL: '' jobs: check-changes: @@ -12,13 +12,13 @@ jobs: all_changed_and_modified_files_count: ${{ steps.changed-files.outputs.all_changed_and_modified_files_count }} steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Get changed files count id: changed-files uses: tj-actions/changed-files@v40.1.1 with: - files_ignore: "doc/**,README.md,Dockerfile,.*" + files_ignore: 'doc/**,README.md,Dockerfile,.*' files_ignore_separator: ',' - name: Print changed files count run: > @@ -33,7 +33,7 @@ jobs: contents: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive - uses: actions/setup-node@v3 @@ -71,7 +71,7 @@ jobs: - name: Create tarball run: tar czf webui.tgz --strip-components=1 dist - name: Build LittleFS - run: /tmp/mklittlefs/mklittlefs -c build_gz -s 409600 littlefs.bin + run: /tmp/mklittlefs/mklittlefs -c build_gz -s 409600 littlefs.bin - name: Upload artifacts uses: actions/upload-artifact@v3 with: @@ -84,7 +84,7 @@ jobs: tag: ${{ steps.getBlockHeight.outputs.blockHeight }} commit: main name: release-${{ steps.getBlockHeight.outputs.blockHeight }} - artifacts: "littlefs.bin,webui.tgz" + artifacts: 'littlefs.bin,webui.tgz' allowUpdates: true removeArtifacts: true - makeLatest: true \ No newline at end of file + makeLatest: true diff --git a/.prettierignore b/.prettierignore index 297772e..96ca2e4 100644 --- a/.prettierignore +++ b/.prettierignore @@ -8,7 +8,7 @@ node_modules !.env.example dist/ build_gz - +dist/** # Ignore files for PNPM, NPM and YARN pnpm-lock.yaml diff --git a/README.md b/README.md index e93e964..805bfa1 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ To upload the firmware to the BTClock, you need to GZIP all the files. You can u Then you can make a `LittleFS.bin` with mklittlefs: ```bash -mklittlefs -c build_gz -s 409600 littlefs.bin +mklittlefs -c build_gz -s 409600 littlefs.bin ``` -You can preview the production build with `yarn preview`. \ No newline at end of file +You can preview the production build with `yarn preview`. diff --git a/src/hooks.server.ts b/src/hooks.server.ts index 2c6aa97..1f9b93e 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -1,10 +1,10 @@ -import type { Handle } from '@sveltejs/kit' -import { locale } from 'svelte-i18n' +import type { Handle } from '@sveltejs/kit'; +import { locale } from 'svelte-i18n'; export const handle: Handle = async ({ event, resolve }) => { - const lang = event.request.headers.get('accept-language')?.split(',')[0] + const lang = event.request.headers.get('accept-language')?.split(',')[0]; if (lang) { - locale.set(lang) + locale.set(lang); } - return resolve(event) -} \ No newline at end of file + return resolve(event); +}; diff --git a/src/lib/i18n/index.ts b/src/lib/i18n/index.ts index c920fcc..492de13 100644 --- a/src/lib/i18n/index.ts +++ b/src/lib/i18n/index.ts @@ -1,13 +1,17 @@ -import { browser } from '$app/environment' -import { init, register } from 'svelte-i18n' +import { browser } from '$app/environment'; +import { init, register } from 'svelte-i18n'; -const defaultLocale = 'en' +const defaultLocale = 'en'; -register('en', () => import('../locales/en.json')) -register('nl', () => import('../locales/nl.json')) -register('es', () => import('../locales/es.json')) +register('en', () => import('../locales/en.json')); +register('nl', () => import('../locales/nl.json')); +register('es', () => import('../locales/es.json')); init({ fallbackLocale: defaultLocale, - initialLocale: browser ? browser && localStorage.getItem('locale') ? localStorage.getItem('locale') : window.navigator.language : defaultLocale, -}) \ No newline at end of file + initialLocale: browser + ? browser && localStorage.getItem('locale') + ? localStorage.getItem('locale') + : window.navigator.language + : defaultLocale +}); diff --git a/src/lib/locales/en.json b/src/lib/locales/en.json index d634291..7521b3a 100644 --- a/src/lib/locales/en.json +++ b/src/lib/locales/en.json @@ -1,71 +1,71 @@ { - "section": { - "settings": { - "title": "Settings", - "textColor": "Text color", - "backgroundColor": "Background color", - "ledPowerOnTest": "LED power-on test", - "ledFlashOnBlock": "LED flash on new block", - "timePerScreen": "Time per screen", - "ledBrightness": "LED brightness", - "timezoneOffset": "Timezone offset", - "timeBetweenPriceUpdates": "Time between price updates", - "fullRefreshEvery": "Full refresh every", - "mempoolnstance": "Mempool Instance", - "hostnamePrefix": "Hostname prefix", - "StealFocusOnNewBlock": "Steal focus on new block", - "useBigCharsMcap": "Use big characters for market cap", - "otaUpdates": "OTA updates", - "enableMdns": "mDNS", - "fetchEuroPrice": "Fetch € price", - "shortAmountsWarning": "Short amounts might shorten lifespan.", - "tzOffsetHelpText": "A restart is required to apply TZ offset.", - "screens": "Screens" - }, - "control": { - "systemInfo": "System info", - "version": "Version", - "buildTime": "Build time", - "ledColor": "LED color", - "turnOff": "Turn off", - "setColor": "Set color", - "showText": "Show text", - "text": "Text", - "title": "Control", - "hostname": "Hostname" - }, - "status": { - "title": "Status", - "screenCycle": "Screen cycle", - "memoryFree": "Memory free", - "wsPriceConnection": "WS Price connection", - "wsMempoolConnection": "WS Mempool.space connection", - "fetchEuroNote": "If you use \"Fetch € price\" the WS Price connection will show ❌ since it uses another data source.", - "uptime": "Uptime" - } - }, - "colors": { - "black": "Black", - "white": "White" - }, - "time": { - "minutes": "minutes", - "seconds": "seconds" - }, - "restartRequired": "restart required", - "button": { - "save": "Save", - "reset": "Reset", - "restart": "Restart", - "forceFullRefresh": "Force full refresh" - }, - "timer": { - "running": "running", - "stopped": "stopped" - }, - "sections": { - "control": { - "keepSameColor": "Keep same color" - } - } + "section": { + "settings": { + "title": "Settings", + "textColor": "Text color", + "backgroundColor": "Background color", + "ledPowerOnTest": "LED power-on test", + "ledFlashOnBlock": "LED flash on new block", + "timePerScreen": "Time per screen", + "ledBrightness": "LED brightness", + "timezoneOffset": "Timezone offset", + "timeBetweenPriceUpdates": "Time between price updates", + "fullRefreshEvery": "Full refresh every", + "mempoolnstance": "Mempool Instance", + "hostnamePrefix": "Hostname prefix", + "StealFocusOnNewBlock": "Steal focus on new block", + "useBigCharsMcap": "Use big characters for market cap", + "otaUpdates": "OTA updates", + "enableMdns": "mDNS", + "fetchEuroPrice": "Fetch € price", + "shortAmountsWarning": "Short amounts might shorten lifespan.", + "tzOffsetHelpText": "A restart is required to apply TZ offset.", + "screens": "Screens" + }, + "control": { + "systemInfo": "System info", + "version": "Version", + "buildTime": "Build time", + "ledColor": "LED color", + "turnOff": "Turn off", + "setColor": "Set color", + "showText": "Show text", + "text": "Text", + "title": "Control", + "hostname": "Hostname" + }, + "status": { + "title": "Status", + "screenCycle": "Screen cycle", + "memoryFree": "Memory free", + "wsPriceConnection": "WS Price connection", + "wsMempoolConnection": "WS Mempool.space connection", + "fetchEuroNote": "If you use \"Fetch € price\" the WS Price connection will show ❌ since it uses another data source.", + "uptime": "Uptime" + } + }, + "colors": { + "black": "Black", + "white": "White" + }, + "time": { + "minutes": "minutes", + "seconds": "seconds" + }, + "restartRequired": "restart required", + "button": { + "save": "Save", + "reset": "Reset", + "restart": "Restart", + "forceFullRefresh": "Force full refresh" + }, + "timer": { + "running": "running", + "stopped": "stopped" + }, + "sections": { + "control": { + "keepSameColor": "Keep same color" + } + } } diff --git a/src/lib/locales/es.json b/src/lib/locales/es.json index 72dbcea..fb6e7bc 100644 --- a/src/lib/locales/es.json +++ b/src/lib/locales/es.json @@ -1,71 +1,71 @@ { - "section": { - "settings": { - "title": "Configuración", - "textColor": "Color de texto", - "backgroundColor": "Color de fondo", - "ledBrightness": "Brillo LED", - "screens": "Pantallas", - "shortAmountsWarning": "Cantidades pequeñas pueden acortar la vida útil.", - "fullRefreshEvery": "Actualización completa cada", - "timePerScreen": "Tiempo por pantalla", - "tzOffsetHelpText": "Es necesario reiniciar para aplicar la compensación.", - "timezoneOffset": "Compensación de zona horaria", - "StealFocusOnNewBlock": "Presta atención al nuevo bloque", - "ledFlashOnBlock": "El LED parpadea con un bloque nuevo", - "useBigCharsMcap": "Utilice caracteres grandes para la market cap", - "fetchEuroPrice": "Obtener precio en €", - "timeBetweenPriceUpdates": "Tiempo entre actualizaciones de precios", - "ledPowerOnTest": "Prueba de encendido del LED", - "enableMdns": "mDNS", - "hostnamePrefix": "Prefijo de nombre de host", - "mempoolnstance": "Instancia de Mempool", - "otaUpdates": "Actualización por aire" - }, - "control": { - "turnOff": "Apagar", - "setColor": "Establecer el color", - "version": "Versión", - "ledColor": "color del LED", - "systemInfo": "Info del sistema", - "showText": "Mostrar texto", - "text": "Texto", - "title": "Control", - "buildTime": "Tiempo de compilación", - "hostname": "Nombre del host" - }, - "status": { - "memoryFree": "Memoria RAM libre", - "wsPriceConnection": "Conexión WebSocket Precio", - "wsMempoolConnection": "Conexión WebSocket Mempool.space", - "screenCycle": "Ciclo de pantalla", - "uptime": "Tiempo de funcionamiento", - "fetchEuroNote": "Si utiliza \"Obtener precio en €\", la conexión de Precio WS mostrará ❌ ya que utiliza otra fuente de datos.", - "title": "Estado" - } - }, - "button": { - "save": "Guardar", - "reset": "Restaurar", - "restart": "Reiniciar", - "forceFullRefresh": "Forzar refresco" - }, - "colors": { - "black": "Negro", - "white": "Blanco" - }, - "restartRequired": "reinicio requerido", - "time": { - "minutes": "minutos", - "seconds": "segundos" - }, - "timer": { - "running": "funcionando", - "stopped": "detenido" - }, - "sections": { - "control": { - "keepSameColor": "Mantén el mismo color" - } - } + "section": { + "settings": { + "title": "Configuración", + "textColor": "Color de texto", + "backgroundColor": "Color de fondo", + "ledBrightness": "Brillo LED", + "screens": "Pantallas", + "shortAmountsWarning": "Cantidades pequeñas pueden acortar la vida útil.", + "fullRefreshEvery": "Actualización completa cada", + "timePerScreen": "Tiempo por pantalla", + "tzOffsetHelpText": "Es necesario reiniciar para aplicar la compensación.", + "timezoneOffset": "Compensación de zona horaria", + "StealFocusOnNewBlock": "Presta atención al nuevo bloque", + "ledFlashOnBlock": "El LED parpadea con un bloque nuevo", + "useBigCharsMcap": "Utilice caracteres grandes para la market cap", + "fetchEuroPrice": "Obtener precio en €", + "timeBetweenPriceUpdates": "Tiempo entre actualizaciones de precios", + "ledPowerOnTest": "Prueba de encendido del LED", + "enableMdns": "mDNS", + "hostnamePrefix": "Prefijo de nombre de host", + "mempoolnstance": "Instancia de Mempool", + "otaUpdates": "Actualización por aire" + }, + "control": { + "turnOff": "Apagar", + "setColor": "Establecer el color", + "version": "Versión", + "ledColor": "color del LED", + "systemInfo": "Info del sistema", + "showText": "Mostrar texto", + "text": "Texto", + "title": "Control", + "buildTime": "Tiempo de compilación", + "hostname": "Nombre del host" + }, + "status": { + "memoryFree": "Memoria RAM libre", + "wsPriceConnection": "Conexión WebSocket Precio", + "wsMempoolConnection": "Conexión WebSocket Mempool.space", + "screenCycle": "Ciclo de pantalla", + "uptime": "Tiempo de funcionamiento", + "fetchEuroNote": "Si utiliza \"Obtener precio en €\", la conexión de Precio WS mostrará ❌ ya que utiliza otra fuente de datos.", + "title": "Estado" + } + }, + "button": { + "save": "Guardar", + "reset": "Restaurar", + "restart": "Reiniciar", + "forceFullRefresh": "Forzar refresco" + }, + "colors": { + "black": "Negro", + "white": "Blanco" + }, + "restartRequired": "reinicio requerido", + "time": { + "minutes": "minutos", + "seconds": "segundos" + }, + "timer": { + "running": "funcionando", + "stopped": "detenido" + }, + "sections": { + "control": { + "keepSameColor": "Mantén el mismo color" + } + } } diff --git a/src/lib/locales/nl.json b/src/lib/locales/nl.json index 24c2396..77e4ad6 100644 --- a/src/lib/locales/nl.json +++ b/src/lib/locales/nl.json @@ -1,70 +1,70 @@ { - "section": { - "settings": { - "title": "Instellingen", - "textColor": "Tekstkleur", - "backgroundColor": "Achtergrondkleur", - "timeBetweenPriceUpdates": "Tijd tussen prijs updates", - "timezoneOffset": "Tijdzone afwijking", - "ledBrightness": "LED helderheid", - "timePerScreen": "Tijd per scherm", - "fullRefreshEvery": "Volledig verversen elke", - "shortAmountsWarning": "Lage waardes verkorten levensduur", - "tzOffsetHelpText": "Herstart nodig voor toepassen afwijking.", - "enableMdns": "mDNS", - "ledPowerOnTest": "LED test bij aanzetten", - "StealFocusOnNewBlock": "Pak aandacht bij nieuw blok", - "ledFlashOnBlock": "Knipper led bij nieuw blok", - "useBigCharsMcap": "Gebruik grote tekens bij market cap", - "fetchEuroPrice": "Toon € prijs", - "screens": "Schermen", - "hostnamePrefix": "Hostnaam voorvoegsel", - "mempoolnstance": "Mempool instantie", - "otaUpdates": "OTA updates" - }, - "control": { - "systemInfo": "Systeeminformatie", - "version": "Versie", - "buildTime": "Bouwtijd", - "setColor": "Kleur instellen", - "turnOff": "Uitzetten", - "ledColor": "LED kleur", - "showText": "Toon tekst", - "text": "Tekst", - "title": "Besturing" - }, - "status": { - "title": "Status", - "memoryFree": "Geheugen vrij", - "screenCycle": "Scherm cyclus", - "wsPriceConnection": "WS Prijs verbinding", - "wsMempoolConnection": "WS Mempool.space verbinding", - "fetchEuroNote": "Wanneer je \"Toon € prijs\" aanzet, zal de prijsverbinding als ❌ verbroken getoond worden vanwege het gebruik van een andere bron.", - "uptime": "Uptime" - } - }, - "colors": { - "black": "Zwart", - "white": "Wit" - }, - "time": { - "minutes": "minuten", - "seconds": "seconden" - }, - "restartRequired": "herstart nodig", - "button": { - "save": "Opslaan", - "reset": "Herstel", - "restart": "Herstart", - "forceFullRefresh": "Forceer scherm verversen" - }, - "timer": { - "running": "actief", - "stopped": "gestopt" - }, - "sections": { - "control": { - "keepSameColor": "Behoud zelfde kleur" - } - } + "section": { + "settings": { + "title": "Instellingen", + "textColor": "Tekstkleur", + "backgroundColor": "Achtergrondkleur", + "timeBetweenPriceUpdates": "Tijd tussen prijs updates", + "timezoneOffset": "Tijdzone afwijking", + "ledBrightness": "LED helderheid", + "timePerScreen": "Tijd per scherm", + "fullRefreshEvery": "Volledig verversen elke", + "shortAmountsWarning": "Lage waardes verkorten levensduur", + "tzOffsetHelpText": "Herstart nodig voor toepassen afwijking.", + "enableMdns": "mDNS", + "ledPowerOnTest": "LED test bij aanzetten", + "StealFocusOnNewBlock": "Pak aandacht bij nieuw blok", + "ledFlashOnBlock": "Knipper led bij nieuw blok", + "useBigCharsMcap": "Gebruik grote tekens bij market cap", + "fetchEuroPrice": "Toon € prijs", + "screens": "Schermen", + "hostnamePrefix": "Hostnaam voorvoegsel", + "mempoolnstance": "Mempool instantie", + "otaUpdates": "OTA updates" + }, + "control": { + "systemInfo": "Systeeminformatie", + "version": "Versie", + "buildTime": "Bouwtijd", + "setColor": "Kleur instellen", + "turnOff": "Uitzetten", + "ledColor": "LED kleur", + "showText": "Toon tekst", + "text": "Tekst", + "title": "Besturing" + }, + "status": { + "title": "Status", + "memoryFree": "Geheugen vrij", + "screenCycle": "Scherm cyclus", + "wsPriceConnection": "WS Prijs verbinding", + "wsMempoolConnection": "WS Mempool.space verbinding", + "fetchEuroNote": "Wanneer je \"Toon € prijs\" aanzet, zal de prijsverbinding als ❌ verbroken getoond worden vanwege het gebruik van een andere bron.", + "uptime": "Uptime" + } + }, + "colors": { + "black": "Zwart", + "white": "Wit" + }, + "time": { + "minutes": "minuten", + "seconds": "seconden" + }, + "restartRequired": "herstart nodig", + "button": { + "save": "Opslaan", + "reset": "Herstel", + "restart": "Herstart", + "forceFullRefresh": "Forceer scherm verversen" + }, + "timer": { + "running": "actief", + "stopped": "gestopt" + }, + "sections": { + "control": { + "keepSameColor": "Behoud zelfde kleur" + } + } } diff --git a/src/lib/style/app.scss b/src/lib/style/app.scss index 4b489b7..5adf8b8 100644 --- a/src/lib/style/app.scss +++ b/src/lib/style/app.scss @@ -1,193 +1,197 @@ -@import "../node_modules/bootstrap/scss/functions"; -@import "../node_modules/bootstrap/scss/variables"; -@import "../node_modules/bootstrap/scss/variables-dark"; +@import '../node_modules/bootstrap/scss/functions'; +@import '../node_modules/bootstrap/scss/variables'; +@import '../node_modules/bootstrap/scss/variables-dark'; //@import "@fontsource/antonio/latin-400.css"; -@import "@fontsource/ubuntu/latin-400.css"; -@import "@fontsource/oswald/latin-400.css"; +@import '@fontsource/ubuntu/latin-400.css'; +@import '@fontsource/oswald/latin-400.css'; $form-range-track-bg: #fff; $color-mode-type: media-query; -$font-family-base: "Ubuntu"; +$font-family-base: 'Ubuntu'; $font-size-base: 0.9rem; //$font-size-sm: $font-size-base * .875 !default; //$form-label-font-size: $font-size-base * .575 !default; //$input-btn-font-size-sm: 0.4rem; //$form-label-font-size: 0.4rem; -$input-font-size-sm: $font-size-base * .875; +$input-font-size-sm: $font-size-base * 0.875; // $border-radius: .675rem; -@import "../node_modules/bootstrap/scss/mixins"; -@import "../node_modules/bootstrap/scss/maps"; -@import "../node_modules/bootstrap/scss/utilities"; +@import '../node_modules/bootstrap/scss/mixins'; +@import '../node_modules/bootstrap/scss/maps'; +@import '../node_modules/bootstrap/scss/utilities'; -@import "../node_modules/bootstrap/scss/root"; -@import "../node_modules/bootstrap/scss/reboot"; -@import "../node_modules/bootstrap/scss/type"; -@import "../node_modules/bootstrap/scss/containers"; -@import "../node_modules/bootstrap/scss/grid"; -@import "../node_modules/bootstrap/scss/forms"; -@import "../node_modules/bootstrap/scss/buttons"; -@import "../node_modules/bootstrap/scss/button-group"; -@import "../node_modules/bootstrap/scss/pagination"; +@import '../node_modules/bootstrap/scss/root'; +@import '../node_modules/bootstrap/scss/reboot'; +@import '../node_modules/bootstrap/scss/type'; +@import '../node_modules/bootstrap/scss/containers'; +@import '../node_modules/bootstrap/scss/grid'; +@import '../node_modules/bootstrap/scss/forms'; +@import '../node_modules/bootstrap/scss/buttons'; +@import '../node_modules/bootstrap/scss/button-group'; +@import '../node_modules/bootstrap/scss/pagination'; -@import "../node_modules/bootstrap/scss/dropdown"; +@import '../node_modules/bootstrap/scss/dropdown'; -@import "../node_modules/bootstrap/scss/navbar"; -@import "../node_modules/bootstrap/scss/nav"; -@import "../node_modules/bootstrap/scss/card"; -@import "../node_modules/bootstrap/scss/progress"; +@import '../node_modules/bootstrap/scss/navbar'; +@import '../node_modules/bootstrap/scss/nav'; +@import '../node_modules/bootstrap/scss/card'; +@import '../node_modules/bootstrap/scss/progress'; -@import "../node_modules/bootstrap/scss/helpers"; -@import "../node_modules/bootstrap/scss/utilities/api"; +@import '../node_modules/bootstrap/scss/helpers'; +@import '../node_modules/bootstrap/scss/utilities/api'; @include media-breakpoint-down(xl) { - html { - font-size: 85%; - } + html { + font-size: 85%; + } - button.btn, - input[type="button"].btn, - input[type="submit"].btn, - input[type="reset"].btn { - @include button-size($btn-padding-y-sm, $btn-padding-x-sm, $font-size-sm, $btn-border-radius-sm); - } + button.btn, + input[type='button'].btn, + input[type='submit'].btn, + input[type='reset'].btn { + @include button-size( + $btn-padding-y-sm, + $btn-padding-x-sm, + $font-size-sm, + $btn-border-radius-sm + ); + } } @include media-breakpoint-down(lg) { - html { - font-size: 75%; - } + html { + font-size: 75%; + } } - nav { - margin-bottom: 15px; + margin-bottom: 15px; } .splitText div:first-child::after { - display: block; - content: ''; - margin-top: 0px; - border-bottom: 2px solid; - margin-bottom: 3px; + display: block; + content: ''; + margin-top: 0px; + border-bottom: 2px solid; + margin-bottom: 3px; } #btcclock-wrapper { - margin: 0 auto; + margin: 0 auto; } .btclock { - border: 1px solid darkgray; - background: #000; - border-radius: 5px; - padding: 10px; - max-width: 700px; - margin: 0 auto; - display: flex; - flex-direction: row; - flex-wrap: nowrap; - justify-content: space-between; - align-items: center; - align-content: stretch; - font-family: 'Oswald', sans-serif; + border: 1px solid darkgray; + background: #000; + border-radius: 5px; + padding: 10px; + max-width: 700px; + margin: 0 auto; + display: flex; + flex-direction: row; + flex-wrap: nowrap; + justify-content: space-between; + align-items: center; + align-content: stretch; + font-family: 'Oswald', sans-serif; - >div { - padding: 5px; - } + > div { + padding: 5px; + } - .digit, - .splitText, - .mediumText { - border: 2px solid gold; - border-radius: 8px; + .digit, + .splitText, + .mediumText { + border: 2px solid gold; + border-radius: 8px; - @include media-breakpoint-up(sm) { - min-width: 10px; - } + @include media-breakpoint-up(sm) { + min-width: 10px; + } - @include media-breakpoint-up(xxl) { - min-width: 70px; - } + @include media-breakpoint-up(xxl) { + min-width: 70px; + } - text-align: center; - color: #fff; - } + text-align: center; + color: #fff; + } } -.darkMode .btclock>div { - color: #fff; - border-color: #fff; +.darkMode .btclock > div { + color: #fff; + border-color: #fff; } -.lightMode .btclock>div { - background: #fff; +.lightMode .btclock > div { + background: #fff; } -.lightMode .btclock>div { - color: #000; +.lightMode .btclock > div { + color: #000; } -.darkMode .btclock>div { - background: #000; +.darkMode .btclock > div { + background: #000; } .splitText { - @include media-breakpoint-up(sm) { - font-size: 1.0rem; - padding-top: 8px !important; - padding-bottom: 9px !important; - } - @include media-breakpoint-up(xxl) { - font-size: 1.8rem; - padding-top: 19px !important; - padding-bottom: 20px !important; - } + @include media-breakpoint-up(sm) { + font-size: 1rem; + padding-top: 8px !important; + padding-bottom: 9px !important; + } + @include media-breakpoint-up(xxl) { + font-size: 1.8rem; + padding-top: 19px !important; + padding-bottom: 20px !important; + } - text-align: center; + text-align: center; } .mediumText { - font-size: 3rem; - padding-left: 5px; - padding-right: 5px; - padding-top: 20px !important; - padding-bottom: 20px !important; + font-size: 3rem; + padding-left: 5px; + padding-right: 5px; + padding-top: 20px !important; + padding-bottom: 20px !important; } .digit { - font-size: 5rem; - @include media-breakpoint-up(sm) { - font-size: 2.5rem; - } - @include media-breakpoint-up(xxl) { - font-size: 5rem; - } - padding-left: 10px; - padding-right: 10px; + font-size: 5rem; + @include media-breakpoint-up(sm) { + font-size: 2.5rem; + } + @include media-breakpoint-up(xxl) { + font-size: 5rem; + } + padding-left: 10px; + padding-right: 10px; } .digit-blank { - content: "abc"; + content: 'abc'; } #customText { - text-transform: uppercase; + text-transform: uppercase; } .system_info { - padding: 0; + padding: 0; - li { - list-style: none; - } + li { + list-style: none; + } } .card-title { - margin-bottom: 0; + margin-bottom: 0; } .navbar-brand { - font-style: italic; - font-weight: 600; -} \ No newline at end of file + font-style: italic; + font-weight: 600; +} diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index b7f1a34..9160c21 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -1,21 +1,19 @@ @@ -65,7 +64,7 @@ - + diff --git a/src/routes/Control.svelte b/src/routes/Control.svelte index 23b13c3..6bdd1cb 100644 --- a/src/routes/Control.svelte +++ b/src/routes/Control.svelte @@ -1,82 +1,78 @@ @@ -87,48 +83,72 @@ onDestroy(firstLedDataSubscription);
- + - + - - +

LEDs

-
+ - + {#if ledStatus} - {#each ledStatus as led, i } - - - - {/each} + {#each ledStatus as led, i} + + + + {/each} {/if} - + - - + +

-

{ $_('section.control.systemInfo') }

+

{$_('section.control.systemInfo')}

- - + +
diff --git a/src/routes/Rendered.svelte b/src/routes/Rendered.svelte index 0003cbf..c763d4a 100644 --- a/src/routes/Rendered.svelte +++ b/src/routes/Rendered.svelte @@ -1,25 +1,25 @@
-
- {#each status.data as char} - {#if isSplitText(char)} -
- {#each char.split("/") as part} -
{part}
- {/each} -
- {:else if char.length === 0 || char === " "} -
  
- {:else} -
{char}
- {/if} - {/each} -
-
\ No newline at end of file +
+ {#each status.data as char} + {#if isSplitText(char)} +
+ {#each char.split('/') as part} +
{part}
+ {/each} +
+ {:else if char.length === 0 || char === ' '} +
  
+ {:else} +
{char}
+ {/if} + {/each} +
+ diff --git a/src/routes/Settings.svelte b/src/routes/Settings.svelte index 994548a..3ee8f67 100644 --- a/src/routes/Settings.svelte +++ b/src/routes/Settings.svelte @@ -1,46 +1,41 @@ @@ -51,7 +46,9 @@
- + - - + + - + - - + + - + - { $_('time.minutes') } + {$_('time.minutes')} - + - { $_('time.minutes') } + {$_('time.minutes')} - + - { $_('time.seconds') } + {$_('time.seconds')} - { $_('section.settings.shortAmountsWarning') } + {$_('section.settings.shortAmountsWarning')} - + - { $_('time.minutes') } + {$_('time.minutes')} - { $_('section.settings.tzOffsetHelpText') } + {$_('section.settings.tzOffsetHelpText')} - + - - + + - + > - - + + - + > + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - -

{ $_('section.settings.screens') }

- {#if $settings.screens} - {#each $settings.screens as s} - - - - {/each} - {/if} -
- - + +

{$_('section.settings.screens')}

+ {#if $settings.screens} + {#each $settings.screens as s} + + + + {/each} + {/if} +
+ +
diff --git a/src/routes/Status.svelte b/src/routes/Status.svelte index 3195ad8..aea9255 100644 --- a/src/routes/Status.svelte +++ b/src/routes/Status.svelte @@ -1,65 +1,71 @@ @@ -68,64 +74,86 @@ {$_('section.status.title', { default: 'Status' })} - {#if $settings.screens} -
- - {#each $settings.screens as s} - - {/each} - -
-
- {#if $status.data} -
- -
- { $_('section.status.screenCycle') }: {#if $status.timerRunning}⏵ { $_('timer.running') }{:else}⏸ { $_('timer.stopped') }{/if} - {/if} - {/if} -
- - {#if $status.leds} - {#each $status.leds as led} - - - - {/each} - {/if} - -
- { memoryFreePercent }% -
-
{ $_('section.status.memoryFree') }
-
{ Math.round($status.espFreeHeap / 1024) } / { Math.round($status.espHeapSize / 1024) } KiB
-
-
- { $_('section.status.uptime') }: {toUptimeString($status.espUptime)} -
-

- { $_('section.status.wsPriceConnection') }: - - {#if $status.connectionStatus && $status.connectionStatus.price} - ✅ - {:else} - ❌ - {/if} - - - - { $_('section.status.wsMempoolConnection') }: - - {#if $status.connectionStatus && $status.connectionStatus.blocks} - ✅ - {:else} - ❌ - {/if} -
- {#if $settings.fetchEurPrice} - { $_('section.status.fetchEuroNote') } - {/if} -

-
- - + {#if $settings.screens} +
+ + {#each $settings.screens as s} + + {/each} + +
+
+ {#if $status.data} +
+ +
+ {$_('section.status.screenCycle')}: + {#if $status.timerRunning}⏵ {$_('timer.running')}{:else}⏸ {$_( + 'timer.stopped' + )}{/if} + {/if} + {/if} +
+ + {#if $status.leds} + {#each $status.leds as led} + + + + {/each} + {/if} + +
+ {memoryFreePercent}% +
+
{$_('section.status.memoryFree')}
+
+ {Math.round($status.espFreeHeap / 1024)} / {Math.round($status.espHeapSize / 1024)} KiB +
+
+
+ {$_('section.status.uptime')}: {toUptimestring($status.espUptime)} +
+

+ {$_('section.status.wsPriceConnection')}: + + {#if $status.connectionStatus && $status.connectionStatus.price} + ✅ + {:else} + ❌ + {/if} + + - + {$_('section.status.wsMempoolConnection')}: + + {#if $status.connectionStatus && $status.connectionStatus.blocks} + ✅ + {:else} + ❌ + {/if} +
+ {#if $settings.fetchEurPrice} + {$_('section.status.fetchEuroNote')} + {/if} +

+ + diff --git a/src/routes/api/+page.svelte b/src/routes/api/+page.svelte index cb11cd6..70ef4b3 100644 --- a/src/routes/api/+page.svelte +++ b/src/routes/api/+page.svelte @@ -1,36 +1,31 @@ @@ -54,11 +49,9 @@ crossorigin="anonymous" referrerpolicy="no-referrer" /> - -
+
- diff --git a/static/swagger.json b/static/swagger.json index a1ef68a..76b6918 100644 --- a/static/swagger.json +++ b/static/swagger.json @@ -1,480 +1,448 @@ { - "openapi": "3.0.3", - "info": { - "title": "BTClock API", - "version": "3.0", - "description": "BTClock V3 API" - }, - "servers": [ - { - "url": "/api/" - } - ], - "paths": { - "/status": { - "get": { - "tags": [ - "system" - ], - "summary": "Get current status", - "responses": { - "200": { - "description": "successful operation" - } - } - } - }, - "/system_status": { - "get": { - "tags": [ - "system" - ], - "summary": "Get system status", - "responses": { - "200": { - "description": "successful operation" - } - } - } - }, - "/settings": { - "get": { - "tags": [ - "system" - ], - "summary": "Get current settings", - "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json": { - "schema": { - "$ref": null - } - } - } - } - } - }, - "post": { - "tags": [ - "system" - ], - "summary": "Save current settings", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Settings" - } - } - } - }, - "responses": { - "200": { - "description": "successful operation" - } - } - }, - "patch": { - "tags": [ - "system" - ], - "summary": "Save current settings", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Settings" - } - } - } - }, - "responses": { - "200": { - "description": "successful operation" - } - } - } - }, - "/action/pause": { - "get": { - "tags": [ - "timer" - ], - "summary": "Pause screen rotation", - "responses": { - "200": { - "description": "successful operation" - } - } - } - }, - "/action/timer_restart": { - "get": { - "tags": [ - "timer" - ], - "summary": "Restart screen rotation", - "responses": { - "200": { - "description": "successful operation" - } - } - } - }, - "/show/screen/{id}": { - "get": { - "tags": [ - "screens" - ], - "summary": "Set screen to show", - "parameters": [ - { - "in": "path", - "name": "id", - "schema": { - "type": "integer", - "default": 1 - }, - "required": true, - "description": "ID of screen to show" - } - ], - "responses": { - "200": { - "description": "successful operation" - } - } - } - }, - "/show/text/{text}": { - "get": { - "tags": [ - "screens" - ], - "summary": "Set text to show", - "parameters": [ - { - "in": "path", - "name": "text", - "schema": { - "type": "string", - "default": "text" - }, - "required": true, - "description": "Text to show" - } - ], - "responses": { - "200": { - "description": "successful operation" - } - } - } - }, - "/show/custom": { - "post": { - "tags": [ - "screens" - ], - "summary": "Set text to show (advanced)", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CustomText" - } - } - } - }, - "responses": { - "200": { - "description": "successful operation" - } - } - } - }, - "/full_refresh": { - "get": { - "tags": [ - "system" - ], - "summary": "Force full refresh of all displays", - "responses": { - "200": { - "description": "successful operation" - } - } - } - }, - "/lights": { - "get": { - "tags": [ - "lights" - ], - "summary": "Get LEDs status", - "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ArrayOfLeds" - } - } - } - } - } - }, - "patch": { - "tags": [ - "lights" - ], - "summary": "Set individual LEDs", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ArrayOfLedsInput" - } - } - } - }, - "responses": { - "200": { - "description": "succesful operation" - }, - "400": { - "description": "invalid colors or wrong amount of LEDs" - } - } - } - }, - "/lights/{color}": { - "get": { - "tags": [ - "lights" - ], - "summary": "Turn on LEDs with specific color", - "parameters": [ - { - "in": "path", - "name": "color", - "schema": { - "type": "string", - "default": "FFCC00" - }, - "required": true, - "description": "Color in RGB hex" - } - ], - "responses": { - "200": { - "description": "successful operation" - } - } - } - }, - "/lights/off": { - "get": { - "tags": [ - "lights" - ], - "summary": "Turn LEDs off", - "responses": { - "200": { - "description": "successful operation" - } - } - } - }, - "/restart": { - "get": { - "tags": [ - "system" - ], - "summary": "Restart BTClock", - "responses": { - "200": { - "description": "successful operation" - } - } - } - } - }, - "components": { - "schemas": { - "RgbColorValues": { - "type": "object", - "properties": { - "red": { - "type": "integer", - "minimum": 0, - "maximum": 255, - "example": 255 - }, - "green": { - "type": "integer", - "minimum": 0, - "maximum": 255, - "example": 204 - }, - "blue": { - "type": "integer", - "minimum": 0, - "maximum": 255, - "example": 0 - } - } - }, - "RgbColorHex": { - "type": "object", - "properties": { - "hex": { - "type": "string", - "pattern": "^#(?:[0-9a-fA-F]{3}){1,2}$", - "example": "#FFCC00" - } - } - }, - "RgbColorValueAndHex": { - "allOf": [ - { - "$ref": "#/components/schemas/RgbColorValues" - }, - { - "$ref": "#/components/schemas/RgbColorHex" - } - ] - }, - "RgbColorValueOrHex": { - "oneOf": [ - { - "$ref": "#/components/schemas/RgbColorValues" - }, - { - "$ref": "#/components/schemas/RgbColorHex" - } - ] - }, - "ArrayOfLeds": { - "type": "array", - "items": { - "$ref": "#/components/schemas/RgbColorValueAndHex" - } - }, - "ArrayOfLedsInput": { - "type": "array", - "items": { - "$ref": "#/components/schemas/RgbColorValueOrHex" - } - }, - "Settings": { - "type": "object", - "properties": { - "fetchEurPrice": { - "type": "boolean", - "description": "Fetch EUR price instead of USD" - }, - "fgColor": { - "type": "string", - "default": 16777215, - "description": "ePaper foreground (text) color" - }, - "bgColor": { - "type": "string", - "default": 0, - "description": "ePaper background color" - }, - "ledTestOnPower": { - "type": "boolean", - "default": true, - "description": "Do LED test on power-on" - }, - "ledFlashOnUpd": { - "type": "boolean", - "default": false, - "description": "Flash LEDs on new block" - }, - "mdnsEnabled": { - "type": "boolean", - "default": true, - "description": "Enable mDNS" - }, - "otaEnabled": { - "type": "boolean", - "default": true, - "description": "Enable over-the-air updates" - }, - "stealFocus": { - "type": "boolean", - "default": false, - "description": "Steal focus on new block" - }, - "mcapBigChar": { - "type": "boolean", - "default": false, - "description": "Use big characters for market cap screen" - }, - "mempoolInstance": { - "type": "string", - "default": "mempool.space", - "description": "Mempool.space instance to connect to" - }, - "ledBrightness": { - "type": "integer", - "default": 128, - "description": "Brightness of LEDs" - }, - "fullRefreshMin": { - "type": "integer", - "default": 60, - "description": "Full refresh time of ePaper displays in minutes" - }, - "screen[0]": { - "type": "boolean" - }, - "screen[1]": { - "type": "boolean" - }, - "screen[2]": { - "type": "boolean" - }, - "screen[3]": { - "type": "boolean" - }, - "screen[4]": { - "type": "boolean" - }, - "screen[5]": { - "type": "boolean" - }, - "tzOffset": { - "type": "integer", - "default": 60, - "description": "Timezone offset in minutes" - }, - "minSecPriceUpd": { - "type": "integer", - "default": 30, - "description": "Minimum time between price updates in seconds" - }, - "timePerScreen": { - "type": "integer", - "default": 30, - "description": "Time between screens when rotating in minutes" - } - } - }, - "CustomText": { - "type": "array", - "items": { - "type": "string" - }, - "minItems": 7, - "maxItems": 7 - } - } - } -} \ No newline at end of file + "openapi": "3.0.3", + "info": { + "title": "BTClock API", + "version": "3.0", + "description": "BTClock V3 API" + }, + "servers": [ + { + "url": "/api/" + } + ], + "paths": { + "/status": { + "get": { + "tags": ["system"], + "summary": "Get current status", + "responses": { + "200": { + "description": "successful operation" + } + } + } + }, + "/system_status": { + "get": { + "tags": ["system"], + "summary": "Get system status", + "responses": { + "200": { + "description": "successful operation" + } + } + } + }, + "/settings": { + "get": { + "tags": ["system"], + "summary": "Get current settings", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": null + } + } + } + } + } + }, + "post": { + "tags": ["system"], + "summary": "Save current settings", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Settings" + } + } + } + }, + "responses": { + "200": { + "description": "successful operation" + } + } + }, + "patch": { + "tags": ["system"], + "summary": "Save current settings", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Settings" + } + } + } + }, + "responses": { + "200": { + "description": "successful operation" + } + } + } + }, + "/action/pause": { + "get": { + "tags": ["timer"], + "summary": "Pause screen rotation", + "responses": { + "200": { + "description": "successful operation" + } + } + } + }, + "/action/timer_restart": { + "get": { + "tags": ["timer"], + "summary": "Restart screen rotation", + "responses": { + "200": { + "description": "successful operation" + } + } + } + }, + "/show/screen/{id}": { + "get": { + "tags": ["screens"], + "summary": "Set screen to show", + "parameters": [ + { + "in": "path", + "name": "id", + "schema": { + "type": "integer", + "default": 1 + }, + "required": true, + "description": "ID of screen to show" + } + ], + "responses": { + "200": { + "description": "successful operation" + } + } + } + }, + "/show/text/{text}": { + "get": { + "tags": ["screens"], + "summary": "Set text to show", + "parameters": [ + { + "in": "path", + "name": "text", + "schema": { + "type": "string", + "default": "text" + }, + "required": true, + "description": "Text to show" + } + ], + "responses": { + "200": { + "description": "successful operation" + } + } + } + }, + "/show/custom": { + "post": { + "tags": ["screens"], + "summary": "Set text to show (advanced)", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CustomText" + } + } + } + }, + "responses": { + "200": { + "description": "successful operation" + } + } + } + }, + "/full_refresh": { + "get": { + "tags": ["system"], + "summary": "Force full refresh of all displays", + "responses": { + "200": { + "description": "successful operation" + } + } + } + }, + "/lights": { + "get": { + "tags": ["lights"], + "summary": "Get LEDs status", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ArrayOfLeds" + } + } + } + } + } + }, + "patch": { + "tags": ["lights"], + "summary": "Set individual LEDs", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ArrayOfLedsInput" + } + } + } + }, + "responses": { + "200": { + "description": "succesful operation" + }, + "400": { + "description": "invalid colors or wrong amount of LEDs" + } + } + } + }, + "/lights/{color}": { + "get": { + "tags": ["lights"], + "summary": "Turn on LEDs with specific color", + "parameters": [ + { + "in": "path", + "name": "color", + "schema": { + "type": "string", + "default": "FFCC00" + }, + "required": true, + "description": "Color in RGB hex" + } + ], + "responses": { + "200": { + "description": "successful operation" + } + } + } + }, + "/lights/off": { + "get": { + "tags": ["lights"], + "summary": "Turn LEDs off", + "responses": { + "200": { + "description": "successful operation" + } + } + } + }, + "/restart": { + "get": { + "tags": ["system"], + "summary": "Restart BTClock", + "responses": { + "200": { + "description": "successful operation" + } + } + } + } + }, + "components": { + "schemas": { + "RgbColorValues": { + "type": "object", + "properties": { + "red": { + "type": "integer", + "minimum": 0, + "maximum": 255, + "example": 255 + }, + "green": { + "type": "integer", + "minimum": 0, + "maximum": 255, + "example": 204 + }, + "blue": { + "type": "integer", + "minimum": 0, + "maximum": 255, + "example": 0 + } + } + }, + "RgbColorHex": { + "type": "object", + "properties": { + "hex": { + "type": "string", + "pattern": "^#(?:[0-9a-fA-F]{3}){1,2}$", + "example": "#FFCC00" + } + } + }, + "RgbColorValueAndHex": { + "allOf": [ + { + "$ref": "#/components/schemas/RgbColorValues" + }, + { + "$ref": "#/components/schemas/RgbColorHex" + } + ] + }, + "RgbColorValueOrHex": { + "oneOf": [ + { + "$ref": "#/components/schemas/RgbColorValues" + }, + { + "$ref": "#/components/schemas/RgbColorHex" + } + ] + }, + "ArrayOfLeds": { + "type": "array", + "items": { + "$ref": "#/components/schemas/RgbColorValueAndHex" + } + }, + "ArrayOfLedsInput": { + "type": "array", + "items": { + "$ref": "#/components/schemas/RgbColorValueOrHex" + } + }, + "Settings": { + "type": "object", + "properties": { + "fetchEurPrice": { + "type": "boolean", + "description": "Fetch EUR price instead of USD" + }, + "fgColor": { + "type": "string", + "default": 16777215, + "description": "ePaper foreground (text) color" + }, + "bgColor": { + "type": "string", + "default": 0, + "description": "ePaper background color" + }, + "ledTestOnPower": { + "type": "boolean", + "default": true, + "description": "Do LED test on power-on" + }, + "ledFlashOnUpd": { + "type": "boolean", + "default": false, + "description": "Flash LEDs on new block" + }, + "mdnsEnabled": { + "type": "boolean", + "default": true, + "description": "Enable mDNS" + }, + "otaEnabled": { + "type": "boolean", + "default": true, + "description": "Enable over-the-air updates" + }, + "stealFocus": { + "type": "boolean", + "default": false, + "description": "Steal focus on new block" + }, + "mcapBigChar": { + "type": "boolean", + "default": false, + "description": "Use big characters for market cap screen" + }, + "mempoolInstance": { + "type": "string", + "default": "mempool.space", + "description": "Mempool.space instance to connect to" + }, + "ledBrightness": { + "type": "integer", + "default": 128, + "description": "Brightness of LEDs" + }, + "fullRefreshMin": { + "type": "integer", + "default": 60, + "description": "Full refresh time of ePaper displays in minutes" + }, + "screen[0]": { + "type": "boolean" + }, + "screen[1]": { + "type": "boolean" + }, + "screen[2]": { + "type": "boolean" + }, + "screen[3]": { + "type": "boolean" + }, + "screen[4]": { + "type": "boolean" + }, + "screen[5]": { + "type": "boolean" + }, + "tzOffset": { + "type": "integer", + "default": 60, + "description": "Timezone offset in minutes" + }, + "minSecPriceUpd": { + "type": "integer", + "default": 30, + "description": "Minimum time between price updates in seconds" + }, + "timePerScreen": { + "type": "integer", + "default": 30, + "description": "Time between screens when rotating in minutes" + } + } + }, + "CustomText": { + "type": "array", + "items": { + "type": "string" + }, + "minItems": 7, + "maxItems": 7 + } + } + } +} diff --git a/static/swagger.yml b/static/swagger.yml index c07a798..a2aa028 100644 --- a/static/swagger.yml +++ b/static/swagger.yml @@ -31,7 +31,7 @@ paths: '200': description: successful operation content: - application/json: + application/json: schema: $ref: #/components/schemas/ArrayOfLeds post: @@ -140,7 +140,7 @@ paths: schema: $ref: '#/components/schemas/ArrayOfLeds' patch: - tags: + tags: - lights summary: Set individual LEDs requestBody: @@ -149,9 +149,9 @@ paths: schema: $ref: '#/components/schemas/ArrayOfLedsInput' responses: - "200": + '200': description: succesful operation - "400": + '400': description: invalid colors or wrong amount of LEDs /lights/{color}: get: @@ -188,38 +188,38 @@ paths: components: schemas: RgbColorValues: - type: object - properties: - red: - type: integer - minimum: 0 - maximum: 255 - example: 255 - green: - type: integer - minimum: 0 - maximum: 255 - example: 204 - blue: - type: integer - minimum: 0 - maximum: 255 - example: 0 + type: object + properties: + red: + type: integer + minimum: 0 + maximum: 255 + example: 255 + green: + type: integer + minimum: 0 + maximum: 255 + example: 204 + blue: + type: integer + minimum: 0 + maximum: 255 + example: 0 RgbColorHex: - type: object - properties: - hex: - type: string - pattern: ^#(?:[0-9a-fA-F]{3}){1,2}$ - example: "#FFCC00" + type: object + properties: + hex: + type: string + pattern: ^#(?:[0-9a-fA-F]{3}){1,2}$ + example: '#FFCC00' RgbColorValueAndHex: - allOf: - - $ref: '#/components/schemas/RgbColorValues' - - $ref: '#/components/schemas/RgbColorHex' + allOf: + - $ref: '#/components/schemas/RgbColorValues' + - $ref: '#/components/schemas/RgbColorHex' RgbColorValueOrHex: - oneOf: - - $ref: '#/components/schemas/RgbColorValues' - - $ref: '#/components/schemas/RgbColorHex' + oneOf: + - $ref: '#/components/schemas/RgbColorValues' + - $ref: '#/components/schemas/RgbColorHex' ArrayOfLeds: type: array items: diff --git a/svelte.config.js b/svelte.config.js index 468ccd1..59a7734 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -5,16 +5,14 @@ import { vitePreprocess } from '@sveltejs/kit/vite'; const config = { // Consult https://kit.svelte.dev/docs/integrations#preprocessors // for more information about preprocessors - preprocess: vitePreprocess({ - - }), -build: { - rollupOptions: { - output: { - assetFilenames: '[hash]' + preprocess: vitePreprocess({}), + build: { + rollupOptions: { + output: { + assetFilenames: '[hash]' + } } - } -}, + }, kit: { // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list. // If your environment is not supported or you settled on a specific environment, switch out the adapter. @@ -24,11 +22,11 @@ build: { // these options are set automatically — see below pages: 'dist', assets: 'dist', - fallback: "bundle.html", + fallback: 'bundle.html', precompress: false, strict: true }), - appDir: "build", + appDir: 'build' // inlineStyleThreshold: 9999999999 } }; diff --git a/vite.config.ts b/vite.config.ts index ea53800..7458b5d 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,61 +1,71 @@ import { sveltekit } from '@sveltejs/kit/vite'; import { defineConfig } from 'vite'; -import * as fs from 'fs' -import * as path from 'path' +import * as fs from 'fs'; +import * as path from 'path'; const doRewrap = ({ cssClass }) => { try { if (fs.existsSync(path.resolve(__dirname, 'dist/bundle.js'))) { - return + return; } - } catch(e) {} - console.log("\nStart re-wrapping...") - fs.readFile(path.resolve(__dirname, 'dist/bundle.html'), 'utf8', function(err, data){ + } catch (e) {} + console.log('\nStart re-wrapping...'); + fs.readFile(path.resolve(__dirname, 'dist/bundle.html'), 'utf8', function (err, data) { if (!data) { - console.log(`[Error]: No bundle.html generated, check svelte.config.js -> config.kit.adapter -> fallback: "bundle.html"`) - return + console.log( + `[Error]: No bundle.html generated, check svelte.config.js -> config.kit.adapter -> fallback: "bundle.html"` + ); + return; } - let matchData = data.match(/(?<=]*>)([\s\S]*?)(?=<\/script>)/gm) + const matchData = data.match(/(?<=]*>)([\s\S]*?)(?=<\/script>)/gm); if (matchData) { - let cleanData = matchData[0].trim() - .replace(`document.querySelector('[data-sveltekit-hydrate="45h"]').parentNode`, `document.querySelector(".${cssClass}")`) + const cleanData = matchData[0] + .trim() + .replace( + `document.querySelector('[data-sveltekit-hydrate="45h"]').parentNode`, + `document.querySelector(".${cssClass}")` + ); fs.writeFile(path.resolve(__dirname, 'dist/bundle.js'), cleanData, (err) => { - if (err) - console.log(err) + if (err) console.log(err); else { try { - fs.rename(path.resolve(__dirname,'dist/index.page'), path.resolve(__dirname, 'dist/index.html'), (err) => { }) - } catch (e) { } + fs.rename( + path.resolve(__dirname, 'dist/index.page'), + path.resolve(__dirname, 'dist/index.html'), + () => {} + ); + } catch (e) {} try { - fs.unlinkSync(path.resolve(__dirname, 'dist/bundle.html')) - } catch (e) { } - console.log("Finished: bundle.js + index.html have been regenerated.\n") + fs.unlinkSync(path.resolve(__dirname, 'dist/bundle.html')); + } catch (e) {} + console.log('Finished: bundle.js + index.html have been regenerated.\n'); } - }) - } else - console.log(`[Error]: No proper