fix(webui): fix PDF viewer
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
08a67af1cf
commit
faaf7a956d
1 changed files with 14 additions and 2 deletions
|
@ -11,6 +11,8 @@
|
||||||
import api from '$lib/api';
|
import api from '$lib/api';
|
||||||
import { createEventDispatcher } from 'svelte';
|
import { createEventDispatcher } from 'svelte';
|
||||||
import { getTypes } from '$lib/util/mediatypes';
|
import { getTypes } from '$lib/util/mediatypes';
|
||||||
|
import { i18n } from '$lib/i18n';
|
||||||
|
import Icon from '$lib/components/utils/Icon.svelte';
|
||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
|
@ -18,6 +20,7 @@
|
||||||
export let detail: boolean;
|
export let detail: boolean;
|
||||||
|
|
||||||
let handled = false;
|
let handled = false;
|
||||||
|
let confirmedLoad = false;
|
||||||
|
|
||||||
$: ({ entity, entityInfo } = useEntity(address));
|
$: ({ entity, entityInfo } = useEntity(address));
|
||||||
$: types = $entity && $entityInfo && getTypes($entity, $entityInfo);
|
$: types = $entity && $entityInfo && getTypes($entity, $entityInfo);
|
||||||
|
@ -58,8 +61,17 @@
|
||||||
{#if types?.image}
|
{#if types?.image}
|
||||||
<ImageViewer {address} {detail} />
|
<ImageViewer {address} {detail} />
|
||||||
{/if}
|
{/if}
|
||||||
{#if types?.pdf && size < 15_000}
|
{#if types?.pdf}
|
||||||
<iframe src="{api.apiUrl}/raw/{address}?inline" title="PDF document of {address}" />
|
{#if size < 15_000_000 || confirmedLoad}
|
||||||
|
<iframe src="{api.apiUrl}/raw/{address}?inline" title="PDF document of {address}" />
|
||||||
|
{:else}
|
||||||
|
<button on:click={() => (confirmedLoad = true)}>
|
||||||
|
<Icon name="download" />
|
||||||
|
{$i18n.t('This PDF is large. ({{sizeMb}}MB) Click to load.', {
|
||||||
|
sizeMb: Math.round(size / 1_000_000 / 100) * 100
|
||||||
|
})}
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
{#if types?.model}
|
{#if types?.model}
|
||||||
<ModelViewer src="{api.apiUrl}/raw/{address}" />
|
<ModelViewer src="{api.apiUrl}/raw/{address}" />
|
||||||
|
|
Loading…
Reference in a new issue