<script>
    import Preview from "../files/Preview.svelte";
    import {fileurl} from "../files/imageserver"

    export let record;
    export let schema;
</script>

{#if schema.type === "files"}
    <div class="row mb-4">
        <div class="col" style="max-width:276px">
            <Preview {record} size="large"/>
        </div>
        <div class="col">
            <ul class="list-group ">
                <li class="list-group-item border-primary">
                    <span class="text-muted">Filename</span>
                    <span>{record._file.path}</span>
                </li>
                <li class="list-group-item border-primary">
                    <span class="text-muted">Original name</span>
                    <span>{record._file.originalName}</span>
                </li>
                <li class="list-group-item border-primary">
                    <span class="text-muted">Mime type</span>
                    <span>{record._file.mime}</span>
                </li>
                {#if record._file.width}
                    <li class="list-group-item border-primary">
                        <span class="text-muted">Dimensions</span>
                        <span>{record._file.width}x{record._file.height}</span>
                    </li>
                {/if}
                <li class="list-group-item border-primary">
                    <span class="text-muted">File size</span>
                    <span>{(record._file.size / 1024).toFixed(1)}kB</span>
                </li>
                <li class="list-group-item border-primary">
                    <span class="text-muted">Checksum</span>
                    <span>{record._file.checksum}</span>
                </li>
                <li class="list-group-item border-primary">
                    <span class="text-muted">Download</span>
                    <a href="{fileurl(record)}">{record._file.path}</a>
                </li>
            </ul>
        </div>
    </div>
{/if}

<style>
    .list-group {
        font-size: 14px;
    }
</style>
