mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
chore(server,cli,web): housekeeping and stricter code style (#6751)
* add unicorn to eslint * fix lint errors for cli * fix merge * fix album name extraction * Update cli/src/commands/upload.command.ts Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> * es2k23 * use lowercase os * return undefined album name * fix bug in asset response dto * auto fix issues * fix server code style * es2022 and formatting * fix compilation error * fix test * fix config load * fix last lint errors * set string type * bump ts * start work on web * web formatting * Fix UUIDParamDto as UUIDParamDto * fix library service lint * fix web errors * fix errors * formatting * wip * lints fixed * web can now start * alphabetical package json * rename error * chore: clean up --------- Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
This commit is contained in:
parent
e4d0560d49
commit
f44fa45aa0
218 changed files with 2471 additions and 1244 deletions
|
|
@ -30,13 +30,12 @@
|
|||
});
|
||||
|
||||
$: {
|
||||
if (search.length > 0 && albums.length > 0) {
|
||||
filteredAlbums = albums.filter((album) => {
|
||||
return album.albumName.toLowerCase().includes(search.toLowerCase());
|
||||
});
|
||||
} else {
|
||||
filteredAlbums = albums;
|
||||
}
|
||||
filteredAlbums =
|
||||
search.length > 0 && albums.length > 0
|
||||
? albums.filter((album) => {
|
||||
return album.albumName.toLowerCase().includes(search.toLowerCase());
|
||||
})
|
||||
: albums;
|
||||
}
|
||||
|
||||
const handleSelect = (album: AlbumResponseDto) => {
|
||||
|
|
|
|||
|
|
@ -18,15 +18,15 @@
|
|||
if (browser) {
|
||||
const scrollTop = document.documentElement.scrollTop;
|
||||
const scrollLeft = document.documentElement.scrollLeft;
|
||||
window.onscroll = function () {
|
||||
window.addEventListener('scroll', function () {
|
||||
window.scrollTo(scrollLeft, scrollTop);
|
||||
};
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
if (browser) {
|
||||
window.onscroll = null;
|
||||
window.addEventListener('scroll', () => {});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -29,10 +29,10 @@
|
|||
};
|
||||
|
||||
const handleConfirm = () => {
|
||||
if (!point) {
|
||||
dispatch('cancel');
|
||||
} else {
|
||||
if (point) {
|
||||
dispatch('confirm', point);
|
||||
} else {
|
||||
dispatch('cancel');
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@
|
|||
|
||||
const handleCreateSharedLink = async () => {
|
||||
const expirationTime = getExpirationTimeInMillisecond();
|
||||
const currentTime = new Date().getTime();
|
||||
const currentTime = Date.now();
|
||||
const expirationDate = expirationTime ? new Date(currentTime + expirationTime).toISOString() : undefined;
|
||||
|
||||
try {
|
||||
|
|
@ -84,8 +84,8 @@
|
|||
},
|
||||
});
|
||||
sharedLink = makeSharedLinkUrl($serverConfig.externalDomain, data.key);
|
||||
} catch (e) {
|
||||
handleError(e, 'Failed to create shared link');
|
||||
} catch (error) {
|
||||
handleError(error, 'Failed to create shared link');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -99,20 +99,27 @@
|
|||
|
||||
const getExpirationTimeInMillisecond = () => {
|
||||
switch (expirationTime) {
|
||||
case '30 minutes':
|
||||
case '30 minutes': {
|
||||
return 30 * 60 * 1000;
|
||||
case '1 hour':
|
||||
}
|
||||
case '1 hour': {
|
||||
return 60 * 60 * 1000;
|
||||
case '6 hours':
|
||||
}
|
||||
case '6 hours': {
|
||||
return 6 * 60 * 60 * 1000;
|
||||
case '1 day':
|
||||
}
|
||||
case '1 day': {
|
||||
return 24 * 60 * 60 * 1000;
|
||||
case '7 days':
|
||||
}
|
||||
case '7 days': {
|
||||
return 7 * 24 * 60 * 60 * 1000;
|
||||
case '30 days':
|
||||
}
|
||||
case '30 days': {
|
||||
return 30 * 24 * 60 * 60 * 1000;
|
||||
default:
|
||||
}
|
||||
default: {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -123,7 +130,7 @@
|
|||
|
||||
try {
|
||||
const expirationTime = getExpirationTimeInMillisecond();
|
||||
const currentTime = new Date().getTime();
|
||||
const currentTime = Date.now();
|
||||
const expirationDate: string | null = expirationTime
|
||||
? new Date(currentTime + expirationTime).toISOString()
|
||||
: null;
|
||||
|
|
@ -146,8 +153,8 @@
|
|||
});
|
||||
|
||||
dispatch('close');
|
||||
} catch (e) {
|
||||
handleError(e, 'Failed to edit shared link');
|
||||
} catch (error) {
|
||||
handleError(error, 'Failed to edit shared link');
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
export let fullWidth = false;
|
||||
export let src = empty1Url;
|
||||
|
||||
const noop = () => undefined;
|
||||
const noop = () => {};
|
||||
|
||||
$: handler = actionHandler || noop;
|
||||
$: width = fullWidth ? 'w-full' : 'w-[50%]';
|
||||
|
|
|
|||
|
|
@ -17,14 +17,14 @@
|
|||
|
||||
const selectAssetHandler = (event: CustomEvent) => {
|
||||
const { asset }: { asset: AssetResponseDto } = event.detail;
|
||||
let temp = new Set(selectedAssets);
|
||||
let temporary = new Set(selectedAssets);
|
||||
if (selectedAssets.has(asset)) {
|
||||
temp.delete(asset);
|
||||
temporary.delete(asset);
|
||||
} else {
|
||||
temp.add(asset);
|
||||
temporary.add(asset);
|
||||
}
|
||||
|
||||
selectedAssets = temp;
|
||||
selectedAssets = temporary;
|
||||
dispatch('select', { asset, selectedAssets });
|
||||
};
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -35,15 +35,15 @@
|
|||
|
||||
const selectAssetHandler = (event: CustomEvent) => {
|
||||
const { asset }: { asset: AssetResponseDto } = event.detail;
|
||||
let temp = new Set(selectedAssets);
|
||||
let temporary = new Set(selectedAssets);
|
||||
|
||||
if (selectedAssets.has(asset)) {
|
||||
temp.delete(asset);
|
||||
temporary.delete(asset);
|
||||
} else {
|
||||
temp.add(asset);
|
||||
temporary.add(asset);
|
||||
}
|
||||
|
||||
selectedAssets = temp;
|
||||
selectedAssets = temporary;
|
||||
};
|
||||
|
||||
const navigateAssetForward = () => {
|
||||
|
|
@ -53,8 +53,8 @@
|
|||
selectedAsset = assets[currentViewAssetIndex];
|
||||
pushState(selectedAsset.id);
|
||||
}
|
||||
} catch (e) {
|
||||
handleError(e, 'Cannot navigate to the next asset');
|
||||
} catch (error) {
|
||||
handleError(error, 'Cannot navigate to the next asset');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -65,8 +65,8 @@
|
|||
selectedAsset = assets[currentViewAssetIndex];
|
||||
pushState(selectedAsset.id);
|
||||
}
|
||||
} catch (e) {
|
||||
handleError(e, 'Cannot navigate to previous asset');
|
||||
} catch (error) {
|
||||
handleError(error, 'Cannot navigate to previous asset');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
let map: maplibregl.Map;
|
||||
let marker: maplibregl.Marker | null = null;
|
||||
|
||||
// eslint-disable-next-line unicorn/prefer-top-level-await
|
||||
$: style = (async () => {
|
||||
const { data } = await api.systemConfigApi.getMapStyle({
|
||||
theme: $mapSettings.allowDarkMode ? $colorTheme.value : Theme.LIGHT,
|
||||
|
|
@ -60,7 +61,7 @@
|
|||
}
|
||||
|
||||
const mapSource = map?.getSource('geojson') as GeoJSONSource;
|
||||
mapSource.getClusterLeaves(clusterId, 10000, 0, (error, leaves) => {
|
||||
mapSource.getClusterLeaves(clusterId, 10_000, 0, (error, leaves) => {
|
||||
if (error) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,10 +30,10 @@
|
|||
const logOut = async () => {
|
||||
resetSavedUser();
|
||||
const { data } = await api.authenticationApi.logout();
|
||||
if (!data.redirectUri.startsWith('/')) {
|
||||
window.location.href = data.redirectUri;
|
||||
} else {
|
||||
if (data.redirectUri.startsWith('/')) {
|
||||
goto(data.redirectUri);
|
||||
} else {
|
||||
window.location.href = data.redirectUri;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@
|
|||
}
|
||||
};
|
||||
|
||||
let removeNotificationTimeout: NodeJS.Timeout | undefined = undefined;
|
||||
let removeNotificationTimeout: NodeJS.Timeout | undefined;
|
||||
|
||||
onMount(() => {
|
||||
removeNotificationTimeout = setTimeout(discard, notificationInfo.timeout);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ export enum NotificationType {
|
|||
}
|
||||
|
||||
export class ImmichNotification {
|
||||
id = new Date().getTime() + Math.random();
|
||||
id = Date.now() + Math.random();
|
||||
type!: NotificationType;
|
||||
message!: string;
|
||||
action!: NotificationAction;
|
||||
|
|
|
|||
|
|
@ -4,21 +4,21 @@
|
|||
/**
|
||||
* Usage: <div use:portal={'css selector'}> or <div use:portal={document.body}>
|
||||
*/
|
||||
export function portal(el: HTMLElement, target: HTMLElement | string = 'body') {
|
||||
let targetEl;
|
||||
export function portal(element: HTMLElement, target: HTMLElement | string = 'body') {
|
||||
let targetElement;
|
||||
async function update(newTarget: HTMLElement | string) {
|
||||
target = newTarget;
|
||||
if (typeof target === 'string') {
|
||||
targetEl = document.querySelector(target);
|
||||
if (targetEl === null) {
|
||||
targetElement = document.querySelector(target);
|
||||
if (targetElement === null) {
|
||||
await tick();
|
||||
targetEl = document.querySelector(target);
|
||||
targetElement = document.querySelector(target);
|
||||
}
|
||||
if (targetEl === null) {
|
||||
if (targetElement === null) {
|
||||
throw new Error(`No element found matching css selector: "${target}"`);
|
||||
}
|
||||
} else if (target instanceof HTMLElement) {
|
||||
targetEl = target;
|
||||
targetElement = target;
|
||||
} else {
|
||||
throw new TypeError(
|
||||
`Unknown portal target type: ${
|
||||
|
|
@ -26,13 +26,13 @@
|
|||
}. Allowed types: string (CSS selector) or HTMLElement.`,
|
||||
);
|
||||
}
|
||||
targetEl.appendChild(el);
|
||||
el.hidden = false;
|
||||
targetElement.append(element);
|
||||
element.hidden = false;
|
||||
}
|
||||
|
||||
function destroy() {
|
||||
if (el.parentNode) {
|
||||
el.parentNode.removeChild(el);
|
||||
if (element.parentNode) {
|
||||
element.remove();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,18 +26,18 @@
|
|||
const canvas = document.createElement('canvas');
|
||||
canvas.width = img.width;
|
||||
canvas.height = img.height;
|
||||
const ctx = canvas.getContext('2d');
|
||||
if (!ctx) {
|
||||
const context = canvas.getContext('2d');
|
||||
if (!context) {
|
||||
throw new Error('Could not get canvas context.');
|
||||
}
|
||||
ctx.drawImage(img, 0, 0);
|
||||
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
||||
context.drawImage(img, 0, 0);
|
||||
const imageData = context.getImageData(0, 0, canvas.width, canvas.height);
|
||||
const data = imageData?.data;
|
||||
if (!data) {
|
||||
throw new Error('Could not get image data.');
|
||||
}
|
||||
for (let i = 0; i < data.length; i += 4) {
|
||||
if (data[i + 3] < 255) {
|
||||
for (let index = 0; index < data.length; index += 4) {
|
||||
if (data[index + 3] < 255) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -62,8 +62,8 @@
|
|||
message: 'Profile picture set.',
|
||||
timeout: 3000,
|
||||
});
|
||||
} catch (err) {
|
||||
handleError(err, 'Error setting profile picture.');
|
||||
} catch (error) {
|
||||
handleError(error, 'Error setting profile picture.');
|
||||
}
|
||||
dispatch('close');
|
||||
};
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
const calculateSegments = (buckets: AssetBucket[]) => {
|
||||
let height = 0;
|
||||
let prev: Segment;
|
||||
let previous: Segment;
|
||||
return buckets.map((bucket) => {
|
||||
const segment = new Segment();
|
||||
segment.count = bucket.assets.length;
|
||||
|
|
@ -42,13 +42,13 @@
|
|||
segment.timeGroup = bucket.bucketDate;
|
||||
segment.date = fromLocalDateTime(segment.timeGroup);
|
||||
|
||||
if (prev?.date.year !== segment.date.year && height > MIN_YEAR_LABEL_DISTANCE) {
|
||||
prev.hasLabel = true;
|
||||
if (previous?.date.year !== segment.date.year && height > MIN_YEAR_LABEL_DISTANCE) {
|
||||
previous.hasLabel = true;
|
||||
height = 0;
|
||||
}
|
||||
|
||||
height += segment.height;
|
||||
prev = segment;
|
||||
previous = segment;
|
||||
return segment;
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -26,14 +26,14 @@
|
|||
$savedSearchTerms = $savedSearchTerms.filter((item) => item !== value);
|
||||
saveSearchTerm(value);
|
||||
|
||||
const params = new URLSearchParams({
|
||||
const parameters = new URLSearchParams({
|
||||
q: searchValue,
|
||||
smart: smartSearch,
|
||||
});
|
||||
|
||||
showBigSearchBar = false;
|
||||
$isSearchEnabled = false;
|
||||
goto(`${AppRoute.SEARCH}?${params}`, { invalidateAll: true });
|
||||
goto(`${AppRoute.SEARCH}?${parameters}`, { invalidateAll: true });
|
||||
}
|
||||
|
||||
const clearSearchTerm = (searchTerm: string) => {
|
||||
|
|
@ -140,7 +140,7 @@
|
|||
</div>
|
||||
{/if}
|
||||
|
||||
{#each $savedSearchTerms as savedSearchTerm, i (i)}
|
||||
{#each $savedSearchTerms as savedSearchTerm, index (index)}
|
||||
<div
|
||||
class="flex w-full items-center justify-between text-sm text-black hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-500/10"
|
||||
>
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@
|
|||
}
|
||||
|
||||
showModal = true;
|
||||
} catch (err) {
|
||||
console.error('Error [VersionAnnouncementBox]:', err);
|
||||
} catch (error) {
|
||||
console.error('Error [VersionAnnouncementBox]:', error);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue