2020-02-18 08:57:00 +01:00
|
|
|
<template>
|
|
|
|
<div class="resource-wrapper">
|
|
|
|
<a :href="resource.resourceUrl" target="_blank">
|
|
|
|
<div class="preview">
|
2020-11-30 10:24:11 +01:00
|
|
|
<div
|
|
|
|
v-if="
|
|
|
|
resource.type &&
|
|
|
|
Object.keys(mapServiceTypeToIcon).includes(resource.type)
|
|
|
|
"
|
|
|
|
>
|
2020-02-18 08:57:00 +01:00
|
|
|
<b-icon :icon="mapServiceTypeToIcon[resource.type]" size="is-large" />
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
class="preview-image"
|
|
|
|
v-else-if="resource.metadata && resource.metadata.imageRemoteUrl"
|
|
|
|
:style="`background-image: url(${resource.metadata.imageRemoteUrl})`"
|
|
|
|
/>
|
|
|
|
<div class="preview-type" v-else>
|
|
|
|
<b-icon icon="link" size="is-large" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="body">
|
2021-06-14 15:13:08 +02:00
|
|
|
<div class="title-wrapper">
|
|
|
|
<img
|
|
|
|
class="favicon"
|
|
|
|
v-if="resource.metadata && resource.metadata.faviconUrl"
|
|
|
|
:src="resource.metadata.faviconUrl"
|
|
|
|
/>
|
|
|
|
<h3>{{ resource.title }}</h3>
|
|
|
|
</div>
|
|
|
|
<div class="metadata-wrapper">
|
|
|
|
<span class="host" v-if="!inline || preview">{{ urlHostname }}</span>
|
|
|
|
<span
|
|
|
|
class="published-at is-hidden-mobile"
|
|
|
|
v-if="resource.updatedAt || resource.publishedAt"
|
|
|
|
>{{
|
|
|
|
(resource.updatedAt || resource.publishedAt)
|
|
|
|
| formatDateTimeString
|
|
|
|
}}</span
|
|
|
|
>
|
|
|
|
</div>
|
2020-02-18 08:57:00 +01:00
|
|
|
</div>
|
|
|
|
</a>
|
|
|
|
<resource-dropdown
|
|
|
|
class="actions"
|
2021-06-14 15:13:08 +02:00
|
|
|
v-if="!inline || !preview"
|
2020-02-18 08:57:00 +01:00
|
|
|
@delete="$emit('delete', resource.id)"
|
2020-06-25 18:47:17 +02:00
|
|
|
@move="$emit('move', resource)"
|
2020-02-18 08:57:00 +01:00
|
|
|
@rename="$emit('rename', resource)"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
|
|
import { Component, Prop, Vue } from "vue-property-decorator";
|
|
|
|
import { IResource, mapServiceTypeToIcon } from "@/types/resource";
|
|
|
|
import ResourceDropdown from "@/components/Resource/ResourceDropdown.vue";
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
components: { ResourceDropdown },
|
|
|
|
})
|
|
|
|
export default class ResourceItem extends Vue {
|
|
|
|
@Prop({ required: true, type: Object }) resource!: IResource;
|
|
|
|
|
|
|
|
@Prop({ required: false, default: false }) inline!: boolean;
|
2021-06-14 15:13:08 +02:00
|
|
|
@Prop({ required: false, default: false }) preview!: boolean;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
|
|
|
list = [];
|
|
|
|
|
|
|
|
mapServiceTypeToIcon = mapServiceTypeToIcon;
|
|
|
|
|
2021-02-24 19:06:48 +01:00
|
|
|
get urlHostname(): string | undefined {
|
|
|
|
if (this.resource?.resourceUrl) {
|
|
|
|
return new URL(this.resource.resourceUrl).hostname.replace(
|
|
|
|
/^(www\.)/,
|
|
|
|
""
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return undefined;
|
2020-02-18 08:57:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.resource-wrapper {
|
|
|
|
display: flex;
|
|
|
|
flex: 1;
|
|
|
|
align-items: center;
|
2021-06-14 15:13:08 +02:00
|
|
|
width: 100%;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
|
|
|
.actions {
|
|
|
|
flex: 0;
|
|
|
|
display: block;
|
2021-06-14 15:13:08 +02:00
|
|
|
margin: auto 1rem;
|
2020-02-18 08:57:00 +01:00
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
a {
|
|
|
|
display: flex;
|
|
|
|
font-size: 14px;
|
|
|
|
color: #444b5d;
|
|
|
|
text-decoration: none;
|
|
|
|
overflow: hidden;
|
|
|
|
flex: 1;
|
|
|
|
|
|
|
|
.preview {
|
2020-07-09 17:24:28 +02:00
|
|
|
flex: 0 0 50px;
|
2020-02-18 08:57:00 +01:00
|
|
|
position: relative;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
|
|
|
|
.preview-image {
|
|
|
|
border-radius: 4px 0 0 4px;
|
|
|
|
display: block;
|
|
|
|
margin: 0;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
object-fit: cover;
|
|
|
|
background-size: cover;
|
|
|
|
background-position: 50%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.body {
|
2021-06-14 15:13:08 +02:00
|
|
|
padding: 8px;
|
2020-02-18 08:57:00 +01:00
|
|
|
flex: 1 1 auto;
|
|
|
|
overflow: hidden;
|
|
|
|
|
2021-06-14 15:13:08 +02:00
|
|
|
.title-wrapper {
|
|
|
|
display: flex;
|
|
|
|
max-width: calc(100vw - 122px);
|
|
|
|
}
|
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
img.favicon {
|
|
|
|
display: inline-block;
|
|
|
|
width: 16px;
|
|
|
|
height: 16px;
|
|
|
|
margin-right: 6px;
|
|
|
|
vertical-align: middle;
|
|
|
|
}
|
|
|
|
|
|
|
|
h3 {
|
|
|
|
white-space: nowrap;
|
|
|
|
display: inline-block;
|
|
|
|
font-weight: 500;
|
|
|
|
color: $primary;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
text-decoration: none;
|
|
|
|
vertical-align: middle;
|
|
|
|
}
|
|
|
|
|
2021-06-14 15:13:08 +02:00
|
|
|
.metadata-wrapper {
|
|
|
|
max-width: calc(100vw - 122px);
|
2020-02-18 08:57:00 +01:00
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
white-space: nowrap;
|
2021-06-14 15:13:08 +02:00
|
|
|
span {
|
|
|
|
&:last-child::before {
|
|
|
|
content: "⋅";
|
|
|
|
padding: 0 5px;
|
|
|
|
}
|
|
|
|
&:first-child::before {
|
|
|
|
content: "";
|
|
|
|
padding: initial;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.host,
|
|
|
|
&.published-at {
|
|
|
|
font-size: 13px;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
white-space: nowrap;
|
|
|
|
}
|
|
|
|
}
|
2020-02-18 08:57:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|