wip upload files and select
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
<script>
|
||||
import Icon from "../common/Icon.svelte";
|
||||
import {imgurl} from "./imageserver.js";
|
||||
import {getContext} from "svelte";
|
||||
import { imgurl } from "./imageserver.js";
|
||||
import { getContext } from "svelte";
|
||||
|
||||
export let record;
|
||||
export let file;
|
||||
const channel = getContext("channel");
|
||||
export let size = "small";
|
||||
export let showFilename = false;
|
||||
@@ -28,50 +28,49 @@
|
||||
fontSize = "13";
|
||||
}
|
||||
</script>
|
||||
<div style="display: flex;align-items: center;gap: 5px;">
|
||||
{#if record}
|
||||
|
||||
{#if record._file.mime.startsWith("image")}
|
||||
<div style="display: flex;align-items: center;gap: 5px;">
|
||||
{#if file}
|
||||
{#if file.mime.startsWith("image")}
|
||||
<!-- href={imgurl(record)} -->
|
||||
<a
|
||||
href="{channel.lucentUrl}/records/{record.id}"
|
||||
title={record._file.originalName}
|
||||
style="width:{imageSide}px;height:{imageSide}px"
|
||||
href="{channel.lucentUrl}/files/{file.id}"
|
||||
title={file.filename}
|
||||
style="width:{imageSide}px;height:{imageSide}px"
|
||||
>
|
||||
<img
|
||||
class="rounded w-100"
|
||||
src={imgurl(channel,record)}
|
||||
alt={record._file.path}
|
||||
class="rounded w-100"
|
||||
src={imgurl(channel, file)}
|
||||
alt={file.path}
|
||||
/>
|
||||
</a>
|
||||
{:else}
|
||||
<a
|
||||
href="{channel.lucentUrl}/records/{record.id}"
|
||||
title={record._file.path}
|
||||
class="file-preview-small"
|
||||
style="width:{imageSide}px;height:{imageSide}px"
|
||||
href="{channel.lucentUrl}/files/{file.id}"
|
||||
title={file.path}
|
||||
class="file-preview-small"
|
||||
style="width:{imageSide}px;height:{imageSide}px"
|
||||
>
|
||||
<Icon icon="file" width={fileSide} height={fileSide}/>
|
||||
<Icon icon="file" width={fileSide} height={fileSide} />
|
||||
<span class="ms-2"
|
||||
>.{record._file.path.split(".").pop().toLowerCase()}</span
|
||||
>.{file.path.split(".").pop().toLowerCase()}</span
|
||||
>
|
||||
</a>
|
||||
{/if}
|
||||
{/if}
|
||||
{#if showFilename}
|
||||
<a
|
||||
href="{channel.lucentUrl}/records/{record.id}"
|
||||
title={record._file.path}
|
||||
class="preview-file-filename lx-small-text text-decoration-none"
|
||||
>{record._file.path} </a
|
||||
>
|
||||
href="{channel.lucentUrl}/files/{file.id}"
|
||||
title={file.path}
|
||||
class="preview-file-filename lx-small-text text-decoration-none"
|
||||
>{file.path}
|
||||
</a>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
img{
|
||||
img {
|
||||
border-radius: 12px;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -1,30 +1,29 @@
|
||||
export function imgurl(channel, record) {
|
||||
if (record._file.mime === "image/svg+xml") {
|
||||
return fileurl(channel, record);
|
||||
export function imgurl(channel, file) {
|
||||
if (file.mime === "image/svg+xml") {
|
||||
return fileurl(channel, file);
|
||||
}
|
||||
return channel.filesUrl + `/thumbs/${file.path}`;
|
||||
}
|
||||
|
||||
export function fileurl(channel, file) {
|
||||
return channel.filesUrl + `/${file.path}`;
|
||||
}
|
||||
|
||||
export function htmlurl(channel, file, preset) {
|
||||
let html = "";
|
||||
let url = fileurl(channel, file);
|
||||
|
||||
if (file.width > 0) {
|
||||
let presetUrl = url;
|
||||
if (preset) {
|
||||
presetUrl = channel.filesUrl + `/templates/${preset}/${file.path}`;
|
||||
}
|
||||
return channel.disks[record._file.disk] + `/thumbs/${record._file.path}`;
|
||||
}
|
||||
|
||||
export function fileurl(channel, record) {
|
||||
return channel.disks[record._file.disk] + `/${record._file.path}`;
|
||||
}
|
||||
|
||||
export function htmlurl(channel, record, preset) {
|
||||
|
||||
let html = "";
|
||||
let url = fileurl(channel, record)
|
||||
|
||||
if (record._file.width > 0) {
|
||||
let presetUrl = url;
|
||||
if (preset) {
|
||||
presetUrl = channel.disks[record._file.disk] + `/templates/${preset}/${record._file.path}`;
|
||||
}
|
||||
html = `<img src="${presetUrl}" alt="${record._file.path}" />`
|
||||
} else if (record._file.mime === "image/svg+xml") {
|
||||
html = `<img src="${url}" alt="${record._file.path}"/>`
|
||||
} else {
|
||||
html = `<a href="${url}">${record._file.originalName}</a>`
|
||||
}
|
||||
|
||||
return html;
|
||||
html = `<img src="${presetUrl}" alt="${file.path}" />`;
|
||||
} else if (file.mime === "image/svg+xml") {
|
||||
html = `<img src="${url}" alt="${file.path}"/>`;
|
||||
} else {
|
||||
html = `<a href="${url}">${file.originalName}</a>`;
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user