waclaw66 dd2c7400a6
chore(web): another missing translations (#10274)
* chore(web): another missing translations

* unused removed

* more keys

* lint fix

* test fixed

* dynamic translation fix

* fixes

* people search translation

* params fixed

* keep filter setting fix

* lint fix

* $t fixes

* Update web/src/lib/i18n/en.json

Co-authored-by: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com>

* another missing

* activity translation

* link sharing translations

* expiration dropdown fix - didn't work localized

* notification title

* device logout

* search results

* reset to default

* unsaved change

* select from computer

* selected

* select-2

* select-3

* unmerge

* pluralize, force icu message

* Update web/src/lib/components/asset-viewer/asset-viewer.svelte

Co-authored-by: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com>

* review fixes

* remove user

* plural fixes

* ffmpeg settings

* fixes

* error title

* plural fixes

* onboarding

* change password

* more more

* console log fix

* another

* api key desc

* map marker

* format fix

* key fix

* asset-utils

* utils

* misc

---------

Co-authored-by: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com>
2024-06-24 09:50:01 -04:00

90 lines
2.8 KiB
Svelte

<script lang="ts">
import { deleteAllSessions, deleteSession, getSessions, type SessionResponseDto } from '@immich/sdk';
import { handleError } from '../../utils/handle-error';
import Button from '../elements/buttons/button.svelte';
import { notificationController, NotificationType } from '../shared-components/notification/notification';
import DeviceCard from './device-card.svelte';
import { dialogController } from '$lib/components/shared-components/dialog/dialog';
import { t } from 'svelte-i18n';
export let devices: SessionResponseDto[];
const refresh = () => getSessions().then((_devices) => (devices = _devices));
$: currentDevice = devices.find((device) => device.current);
$: otherDevices = devices.filter((device) => !device.current);
const handleDelete = async (device: SessionResponseDto) => {
const isConfirmed = await dialogController.show({
id: 'log-out-device',
prompt: $t('logout_this_device_confirmation'),
});
if (!isConfirmed) {
return;
}
try {
await deleteSession({ id: device.id });
notificationController.show({ message: $t('logged_out_device'), type: NotificationType.Info });
} catch (error) {
handleError(error, $t('errors.unable_to_log_out_device'));
} finally {
await refresh();
}
};
const handleDeleteAll = async () => {
const isConfirmed = await dialogController.show({
id: 'log-out-all-devices',
prompt: $t('logout_all_device_confirmation'),
});
if (!isConfirmed) {
return;
}
try {
await deleteAllSessions();
notificationController.show({
message: $t('logged_out_all_devices'),
type: NotificationType.Info,
});
} catch (error) {
handleError(error, $t('errors.unable_to_log_out_all_devices'));
} finally {
await refresh();
}
};
</script>
<section class="my-4">
{#if currentDevice}
<div class="mb-6">
<h3 class="mb-2 text-xs font-medium text-immich-primary dark:text-immich-dark-primary">
{$t('current_device').toUpperCase()}
</h3>
<DeviceCard device={currentDevice} />
</div>
{/if}
{#if otherDevices.length > 0}
<div class="mb-6">
<h3 class="mb-2 text-xs font-medium text-immich-primary dark:text-immich-dark-primary">
{$t('other_devices').toUpperCase()}
</h3>
{#each otherDevices as device, index}
<DeviceCard {device} on:delete={() => handleDelete(device)} />
{#if index !== otherDevices.length - 1}
<hr class="my-3" />
{/if}
{/each}
</div>
<h3 class="mb-2 text-xs font-medium text-immich-primary dark:text-immich-dark-primary">
{$t('log_out_all_devices').toUpperCase()}
</h3>
<div class="flex justify-end">
<Button color="red" size="sm" on:click={handleDeleteAll}>{$t('log_out_all_devices')}</Button>
</div>
{/if}
</section>