diff --git a/web/.eslintrc.cjs b/web/.eslintrc.cjs index 3ccf435f02..91d1ce3f77 100644 --- a/web/.eslintrc.cjs +++ b/web/.eslintrc.cjs @@ -16,5 +16,8 @@ module.exports = { browser: true, es2017: true, node: true + }, + globals: { + NodeJS: true } }; diff --git a/web/src/api/utils.ts b/web/src/api/utils.ts index 5d7cfc4e70..73f4d7213b 100644 --- a/web/src/api/utils.ts +++ b/web/src/api/utils.ts @@ -1,5 +1,4 @@ -import { AssetCountByTimeGroupResponseDto } from '@api'; -let _basePath = '/api'; +const _basePath = '/api'; export function getFileUrl(aid: string, did: string, isThumb?: boolean, isWeb?: boolean) { const urlObj = new URL(`${window.location.origin}${_basePath}/asset/file`); diff --git a/web/src/lib/components/album-page/album-card.svelte b/web/src/lib/components/album-page/album-card.svelte index 62c7624591..36fd52a268 100644 --- a/web/src/lib/components/album-page/album-card.svelte +++ b/web/src/lib/components/album-page/album-card.svelte @@ -15,12 +15,11 @@ import { AlbumResponseDto, api, ThumbnailFormat } from '@api'; import { createEventDispatcher, onMount } from 'svelte'; import DotsVertical from 'svelte-material-icons/DotsVertical.svelte'; - import { fly } from 'svelte/transition'; import CircleIconButton from '../shared-components/circle-icon-button.svelte'; export let album: AlbumResponseDto; - let imageData: string = `/api/asset/thumbnail/${album.albumThumbnailAssetId}?format=${ThumbnailFormat.Webp}`; + let imageData = `/api/asset/thumbnail/${album.albumThumbnailAssetId}?format=${ThumbnailFormat.Webp}`; const dispatchClick = createEventDispatcher(); const dispatchShowContextMenu = createEventDispatcher(); @@ -29,7 +28,7 @@ return; } - const { data } = await api.assetApi.getAssetThumbnail(thubmnailId!, ThumbnailFormat.Jpeg, { + const { data } = await api.assetApi.getAssetThumbnail(thubmnailId, ThumbnailFormat.Jpeg, { responseType: 'blob' }); diff --git a/web/src/lib/components/album-page/album-viewer.svelte b/web/src/lib/components/album-page/album-viewer.svelte index 75f69436b7..caef56f017 100644 --- a/web/src/lib/components/album-page/album-viewer.svelte +++ b/web/src/lib/components/album-page/album-viewer.svelte @@ -11,7 +11,6 @@ import CircleAvatar from '../shared-components/circle-avatar.svelte'; import ImmichThumbnail from '../shared-components/immich-thumbnail.svelte'; import AssetSelection from './asset-selection.svelte'; - import _ from 'lodash-es'; import UserSelectionModal from './user-selection-modal.svelte'; import ShareInfoModal from './share-info-modal.svelte'; import CircleIconButton from '../shared-components/circle-icon-button.svelte'; @@ -53,8 +52,7 @@ let currentViewAssetIndex = 0; let viewWidth: number; - let thumbnailSize: number = 300; - let border = ''; + let thumbnailSize = 300; let backUrl = '/albums'; let currentAlbumName = ''; let currentUser: UserResponseDto; diff --git a/web/src/lib/components/asset-viewer/asser-viewer-nav-bar.svelte b/web/src/lib/components/asset-viewer/asser-viewer-nav-bar.svelte index 4ba542d4ef..09730a0587 100644 --- a/web/src/lib/components/asset-viewer/asser-viewer-nav-bar.svelte +++ b/web/src/lib/components/asset-viewer/asser-viewer-nav-bar.svelte @@ -2,9 +2,7 @@ import { createEventDispatcher } from 'svelte'; import ArrowLeft from 'svelte-material-icons/ArrowLeft.svelte'; - import DotsVertical from 'svelte-material-icons/DotsVertical.svelte'; import CloudDownloadOutline from 'svelte-material-icons/CloudDownloadOutline.svelte'; - import TrashCanOutline from 'svelte-material-icons/TrashCanOutline.svelte'; import InformationOutline from 'svelte-material-icons/InformationOutline.svelte'; import CircleIconButton from '../shared-components/circle-icon-button.svelte'; const dispatch = createEventDispatcher(); diff --git a/web/src/lib/components/asset-viewer/asset-viewer.svelte b/web/src/lib/components/asset-viewer/asset-viewer.svelte index 18d7876d1b..5d7264cc37 100644 --- a/web/src/lib/components/asset-viewer/asset-viewer.svelte +++ b/web/src/lib/components/asset-viewer/asset-viewer.svelte @@ -29,12 +29,14 @@ let isShowDetail = false; let appearsInAlbums: AlbumResponseDto[] = []; + const onKeyboardPress = (keyInfo: KeyboardEvent) => handleKeyboardPress(keyInfo.key); + onMount(() => { - document.addEventListener('keydown', (keyInfo) => handleKeyboardPress(keyInfo.key)); + document.addEventListener('keydown', onKeyboardPress); }); onDestroy(() => { - document.removeEventListener('keydown', (e) => {}); + document.removeEventListener('keydown', onKeyboardPress); }); const handleKeyboardPress = (key: string) => { diff --git a/web/src/lib/components/asset-viewer/detail-panel.svelte b/web/src/lib/components/asset-viewer/detail-panel.svelte index 26c98dbb10..47debc6b32 100644 --- a/web/src/lib/components/asset-viewer/detail-panel.svelte +++ b/web/src/lib/components/asset-viewer/detail-panel.svelte @@ -9,10 +9,14 @@ import { browser } from '$app/env'; import { AssetResponseDto, AlbumResponseDto } from '@api'; + type Leaflet = typeof import('leaflet'); + type LeafletMap = import('leaflet').Map; + type LeafletMarker = import('leaflet').Marker; + // Map Property - let map: any; - let leaflet: any; - let marker: any; + let map: LeafletMap; + let leaflet: Leaflet; + let marker: LeafletMarker; export let asset: AssetResponseDto; $: if (asset.exifInfo?.latitude != null && asset.exifInfo?.longitude != null) { @@ -31,7 +35,6 @@ async function drawMap(lat: number, lon: number) { if (!leaflet) { - // @ts-ignore leaflet = await import('leaflet'); } diff --git a/web/src/lib/components/asset-viewer/intersection-observer.svelte b/web/src/lib/components/asset-viewer/intersection-observer.svelte index c0cf19964b..f08a244db1 100644 --- a/web/src/lib/components/asset-viewer/intersection-observer.svelte +++ b/web/src/lib/components/asset-viewer/intersection-observer.svelte @@ -10,7 +10,7 @@ export let root: HTMLElement | null = null; let intersecting = false; - let container: any; + let container: HTMLDivElement; const dispatch = createEventDispatcher(); onMount(() => { diff --git a/web/src/lib/components/asset-viewer/photo-viewer.svelte b/web/src/lib/components/asset-viewer/photo-viewer.svelte index 9297b8e8c7..42535cb14b 100644 --- a/web/src/lib/components/asset-viewer/photo-viewer.svelte +++ b/web/src/lib/components/asset-viewer/photo-viewer.svelte @@ -33,7 +33,9 @@ const assetData = URL.createObjectURL(data); return assetData; - } catch (e) {} + } catch { + // Do nothing + } }; diff --git a/web/src/lib/components/asset-viewer/video-viewer.svelte b/web/src/lib/components/asset-viewer/video-viewer.svelte index 4e38a17c62..4243040718 100644 --- a/web/src/lib/components/asset-viewer/video-viewer.svelte +++ b/web/src/lib/components/asset-viewer/video-viewer.svelte @@ -1,7 +1,7 @@ diff --git a/web/src/lib/components/shared-components/circle-avatar.svelte b/web/src/lib/components/shared-components/circle-avatar.svelte index a5980921c6..ee26386475 100644 --- a/web/src/lib/components/shared-components/circle-avatar.svelte +++ b/web/src/lib/components/shared-components/circle-avatar.svelte @@ -5,7 +5,7 @@ export let user: UserResponseDto; // Avatar Size In Pixel - export let size: number = 48; + export let size = 48; const dispatch = createEventDispatcher(); diff --git a/web/src/lib/components/shared-components/circle-icon-button.svelte b/web/src/lib/components/shared-components/circle-icon-button.svelte index a92f9acdd7..615a4a011e 100644 --- a/web/src/lib/components/shared-components/circle-icon-button.svelte +++ b/web/src/lib/components/shared-components/circle-icon-button.svelte @@ -4,10 +4,12 @@ */ import { createEventDispatcher } from 'svelte'; + // TODO: why any here? + // eslint-disable-next-line @typescript-eslint/no-explicit-any export let logo: any; - export let backgroundColor: string = 'transparent'; - export let hoverColor: string = '#e2e7e9'; - export let logoColor: string = '#5f6368'; + export let backgroundColor = 'transparent'; + export let hoverColor = '#e2e7e9'; + export let logoColor = '#5f6368'; export let size = '24'; export let title = ''; let iconButton: HTMLButtonElement; diff --git a/web/src/lib/components/shared-components/context-menu/context-menu.svelte b/web/src/lib/components/shared-components/context-menu/context-menu.svelte index 03fcd91fb3..6233f78e50 100644 --- a/web/src/lib/components/shared-components/context-menu/context-menu.svelte +++ b/web/src/lib/components/shared-components/context-menu/context-menu.svelte @@ -6,15 +6,13 @@ /** * x coordiante of the context menu. - * @type {number} */ - export let x: number = 0; + export let x = 0; /** * x coordiante of the context menu. - * @type {number} */ - export let y: number = 0; + export let y = 0; const dispatch = createEventDispatcher(); diff --git a/web/src/lib/components/shared-components/control-app-bar.svelte b/web/src/lib/components/shared-components/control-app-bar.svelte index 13e4083923..449a115c04 100644 --- a/web/src/lib/components/shared-components/control-app-bar.svelte +++ b/web/src/lib/components/shared-components/control-app-bar.svelte @@ -12,21 +12,23 @@ const dispatch = createEventDispatcher(); + const onScroll = () => { + if (window.pageYOffset > 80) { + appBarBorder = 'border border-gray-200 bg-gray-50'; + } else { + appBarBorder = 'bg-immich-bg border border-transparent'; + } + }; + onMount(() => { if (browser) { - document.addEventListener('scroll', (e) => { - if (window.pageYOffset > 80) { - appBarBorder = 'border border-gray-200 bg-gray-50'; - } else { - appBarBorder = 'bg-immich-bg border border-transparent'; - } - }); + document.addEventListener('scroll', onScroll); } }); onDestroy(() => { if (browser) { - document.removeEventListener('scroll', (e) => {}); + document.removeEventListener('scroll', onScroll); } }); diff --git a/web/src/lib/components/shared-components/immich-thumbnail.svelte b/web/src/lib/components/shared-components/immich-thumbnail.svelte index 3d280fc4d5..1140caa37a 100644 --- a/web/src/lib/components/shared-components/immich-thumbnail.svelte +++ b/web/src/lib/components/shared-components/immich-thumbnail.svelte @@ -6,7 +6,7 @@ import PlayCircleOutline from 'svelte-material-icons/PlayCircleOutline.svelte'; import PauseCircleOutline from 'svelte-material-icons/PauseCircleOutline.svelte'; import LoadingSpinner from './loading-spinner.svelte'; - import { api, AssetResponseDto, AssetTypeEnum, getFileUrl, ThumbnailFormat } from '@api'; + import { AssetResponseDto, AssetTypeEnum, getFileUrl, ThumbnailFormat } from '@api'; const dispatch = createEventDispatcher(); @@ -14,14 +14,14 @@ export let groupIndex = 0; export let thumbnailSize: number | undefined = undefined; export let format: ThumbnailFormat = ThumbnailFormat.Webp; - export let selected: boolean = false; - export let disabled: boolean = false; + export let selected = false; + export let disabled = false; let imageData: string; - let mouseOver: boolean = false; + let mouseOver = false; $: dispatch('mouse-event', { isMouseOver: mouseOver, selectedGroupIndex: groupIndex }); - let mouseOverIcon: boolean = false; + let mouseOverIcon = false; let videoPlayerNode: HTMLVideoElement; let isThumbnailVideoPlaying = false; let calculateVideoDurationIntervalHandler: NodeJS.Timer; diff --git a/web/src/lib/components/shared-components/navigation-bar.svelte b/web/src/lib/components/shared-components/navigation-bar.svelte index 3e7c109814..70cabe5ff1 100644 --- a/web/src/lib/components/shared-components/navigation-bar.svelte +++ b/web/src/lib/components/shared-components/navigation-bar.svelte @@ -2,7 +2,7 @@ import { goto } from '$app/navigation'; import { page } from '$app/stores'; import { createEventDispatcher, onMount } from 'svelte'; - import { fade, fly, slide } from 'svelte/transition'; + import { fade, fly } from 'svelte/transition'; import TrayArrowUp from 'svelte-material-icons/TrayArrowUp.svelte'; import { clickOutside } from '../../utils/click-outside'; import { api, UserResponseDto } from '@api'; diff --git a/web/src/lib/components/shared-components/portal/portal.svelte b/web/src/lib/components/shared-components/portal/portal.svelte index b3d3ece6f7..c18b318d9e 100644 --- a/web/src/lib/components/shared-components/portal/portal.svelte +++ b/web/src/lib/components/shared-components/portal/portal.svelte @@ -3,13 +3,10 @@ /** * Usage:
or
- * - * @param {HTMLElement} el - * @param {HTMLElement|string} target DOM Element or CSS Selector */ - export function portal(el: any, target: any = 'body') { + export function portal(el: HTMLElement, target: HTMLElement | string = 'body') { let targetEl; - async function update(newTarget: any) { + async function update(newTarget: HTMLElement | string) { target = newTarget; if (typeof target === 'string') { targetEl = document.querySelector(target); diff --git a/web/src/lib/components/shared-components/scrollbar/scrollbar.svelte b/web/src/lib/components/shared-components/scrollbar/scrollbar.svelte index 9a2172faf4..19f974bd18 100644 --- a/web/src/lib/components/shared-components/scrollbar/scrollbar.svelte +++ b/web/src/lib/components/shared-components/scrollbar/scrollbar.svelte @@ -3,14 +3,14 @@ import { SegmentScrollbarLayout } from './segment-scrollbar-layout'; export let scrollTop = 0; - export let viewportWidth = 0; + // export let viewportWidth = 0; export let scrollbarHeight = 0; let timelineHeight = 0; let segmentScrollbarLayout: SegmentScrollbarLayout[] = []; let isHover = false; let hoveredDate: Date; - let currentMouseYLocation: number = 0; + let currentMouseYLocation = 0; let scrollbarPosition = 0; $: { @@ -34,30 +34,28 @@ onMount(() => { // segmentScrollbarLayout = getLayoutDistance(); - - return () => {}; }); - const getSegmentHeight = (groupCount: number) => { - // if (segmentData.groups.length > 0) { - // const percentage = (groupCount * 100) / segmentData.totalAssets; - // return Math.round((percentage * scrollbarHeight) / 100); - // } else { - // return 0; - // } - }; + // const getSegmentHeight = (groupCount: number) => { + // if (segmentData.groups.length > 0) { + // const percentage = (groupCount * 100) / segmentData.totalAssets; + // return Math.round((percentage * scrollbarHeight) / 100); + // } else { + // return 0; + // } + // }; - const getLayoutDistance = () => { - // let result: SegmentScrollbarLayout[] = []; - // for (const segment of segmentData.groups) { - // let segmentLayout = new SegmentScrollbarLayout(); - // segmentLayout.count = segment.count; - // segmentLayout.height = getSegmentHeight(segment.count); - // segmentLayout.timeGroup = segment.timeGroup; - // result.push(segmentLayout); - // } - // return result; - }; + // const getLayoutDistance = () => { + // let result: SegmentScrollbarLayout[] = []; + // for (const segment of segmentData.groups) { + // let segmentLayout = new SegmentScrollbarLayout(); + // segmentLayout.count = segment.count; + // segmentLayout.height = getSegmentHeight(segment.count); + // segmentLayout.timeGroup = segment.timeGroup; + // result.push(segmentLayout); + // } + // return result; + // }; const handleMouseMove = (e: MouseEvent, currentDate: Date) => { currentMouseYLocation = e.clientY - 71 - 30; diff --git a/web/src/lib/components/shared-components/side-bar/side-bar-button.svelte b/web/src/lib/components/shared-components/side-bar/side-bar-button.svelte index 1139b713d3..ae772efa26 100644 --- a/web/src/lib/components/shared-components/side-bar/side-bar-button.svelte +++ b/web/src/lib/components/shared-components/side-bar/side-bar-button.svelte @@ -1,5 +1,7 @@