Added stash menu with remove and rename.

This commit is contained in:
2024-03-27 00:06:03 +01:00
parent e4638324f7
commit c018f54a12
22 changed files with 620 additions and 623 deletions

View File

@@ -97,7 +97,7 @@ const pageStash = pageContext.pageProps.stash;
// console.log(props.actor);
const favorited = ref(props.actor.stashes?.some((sceneStash) => sceneStash.primary) || false);
const favorited = ref(props.actor.stashes?.some((sceneStash) => sceneStash.isPrimary) || false);
async function stash() {
try {

View File

@@ -68,6 +68,14 @@ const activePage = computed(() => pageContext.urlParsed.pathname.split('/')[1]);
font-weight: bold;
font-size: .9rem;
&:first-child {
padding-left: .5rem;
}
&:last-child {
padding-right: .5rem;
}
&:hover {
cursor: pointer;

View File

@@ -67,10 +67,13 @@
placeholder="Search"
class="input"
@focus="searchFocused = true"
@blur="searchFocused = false"
@blur="blurSearch"
>
<button class="search-button">
<button
class="search-button"
data-search
>
<Icon icon="search" />
</button>
</form>
@@ -104,7 +107,7 @@
class="menu-button nolink"
>
<Icon icon="user7" />
My profile
Profile
</a>
</li>
@@ -148,7 +151,12 @@
</template>
<script setup>
import { ref, computed, inject } from 'vue';
import {
ref,
computed,
inject,
} from 'vue';
import navigate from '#/src/navigate.js';
import { del } from '#/src/api.js';
@@ -172,6 +180,12 @@ async function logout() {
del('/session');
navigate('/login', null, { redirect: true });
}
function blurSearch(event) {
if (!event.relatedTarget || !Object.hasOwn(event.relatedTarget?.dataset, 'search')) {
searchFocused.value = false;
}
}
</script>
<style scoped>

View File

@@ -129,7 +129,7 @@ const pageStash = pageContext.pageProps.stash;
const currentYear = new Date().getFullYear();
const fbCutoff = 20;
const favorited = ref(props.movie.stashes.some((sceneStash) => sceneStash.primary));
const favorited = ref(props.movie.stashes.some((sceneStash) => sceneStash.isPrimary));
async function stash() {
try {

View File

@@ -8,15 +8,15 @@
>
<div class="poster-container">
<Link
:href="`/scene/${scene.id}/${scene.slug}`"
:href="`/scene/${scene.id}/${scene.slug || ''}`"
:title="scene.title"
target="_blank"
class="poster"
>
<img
v-if="scene.poster"
:src="scene.poster.isS3 ? `https://cdndev.traxxx.me/${scene.poster.thumbnail}` : `/media/${scene.poster.thumbnail}`"
:style="{ 'background-image': scene.poster.isS3 ? `url(https://cdndev.traxxx.me/${scene.poster.lazy})` : `url(/media/${scene.poster.lazy})` }"
:src="getPath(scene.poster, 'thumbnail')"
:style="{ 'background-image': `url(${getPath(scene.poster, 'lazy')})` }"
loading="lazy"
class="thumbnail"
>
@@ -73,7 +73,7 @@
</div>
<Link
:href="`/scene/${scene.id}/${scene.slug}`"
:href="`/scene/${scene.id}/${scene.slug || ''}`"
:title="scene.title"
target="_blank"
class="row title nolink"
@@ -119,6 +119,7 @@ import { format } from 'date-fns';
import { post, del } from '#/src/api.js';
import events from '#/src/events.js';
import getPath from '#/src/get-path.js';
import ellipsis from '#/utils/ellipsis.js';
import Icon from '../icon/icon.vue';
@@ -134,7 +135,7 @@ const pageContext = inject('pageContext');
const user = pageContext.user;
const pageStash = pageContext.pageProps.stash;
const favorited = ref(props.scene.stashes.some((sceneStash) => sceneStash.primary));
const favorited = ref(props.scene.stashes.some((sceneStash) => sceneStash.isPrimary));
const fbCutoff = 20;
async function stash() {

View File

@@ -7,66 +7,78 @@
class="sidebar"
@click.stop
>
<Link href="/updates">
<h1 class="title">
<div
class="logo"
v-html="logo"
/>
</h1>
</Link>
<div class="nav">
<Link href="/updates">
<h1 class="title">
<div
class="logo"
v-html="logo"
/>
</h1>
</Link>
<ul class="nolist menu">
<li
class="menu-item"
:class="{ active: activePage === 'updates' }"
>
<a
href="/updates"
class="menu-link nolink"
>Updates</a>
</li>
<ul class="nolist menu">
<li
class="menu-item"
:class="{ active: activePage === 'updates' }"
>
<a
href="/updates"
class="menu-link nolink"
>Updates</a>
</li>
<li
class="menu-item"
:class="{ active: activePage === 'actors' }"
>
<a
href="/actors"
class="menu-link nolink"
>Actors</a>
</li>
<li
class="menu-item"
:class="{ active: activePage === 'actors' }"
>
<a
href="/actors"
class="menu-link nolink"
>Actors</a>
</li>
<li
class="menu-item"
:class="{ active: activePage === 'channels' }"
>
<a
href="/channels"
class="menu-link nolink"
>Channels</a>
</li>
<li
class="menu-item"
:class="{ active: activePage === 'channels' }"
>
<a
href="/channels"
class="menu-link nolink"
>Channels</a>
</li>
<li
class="menu-item"
:class="{ active: activePage === 'tags' }"
>
<a
href="/tags"
class="menu-link nolink"
>Tags</a>
</li>
<li
class="menu-item"
:class="{ active: activePage === 'tags' }"
>
<a
href="/tags"
class="menu-link nolink"
>Tags</a>
</li>
<li
class="menu-item"
:class="{ active: activePage === 'movies' }"
>
<a
href="/movies"
class="menu-link nolink"
>Movies</a>
</li>
</ul>
<li
class="menu-item"
:class="{ active: activePage === 'movies' }"
>
<a
href="/movies"
class="menu-link nolink"
>Movies</a>
</li>
</ul>
</div>
<div
class="footer"
@click="emit('sidebar')"
>
<Icon
icon="cross2"
class="close"
/>
</div>
</div>
</div>
</template>
@@ -96,6 +108,8 @@ const activePage = computed(() => pageContext.urlParsed.pathname.split('/')[1]);
}
.sidebar {
display: flex;
flex-direction: column;
width: 15rem;
max-width: 100%;
height: 100%;
@@ -104,6 +118,10 @@ const activePage = computed(() => pageContext.urlParsed.pathname.split('/')[1]);
box-shadow: 0 0 3px var(--shadow-strong-30);
}
.nav {
flex-grow: 1;
}
.title {
margin: 0;
}
@@ -134,4 +152,27 @@ const activePage = computed(() => pageContext.urlParsed.pathname.split('/')[1]);
color: var(--primary);
}
}
.footer {
height: 3rem;
display: flex;
align-items: stretch;
justify-content: flex-end;
box-shadow: 0 0 3px var(--shadow-weak-30);
.close {
width: 1rem;
padding: 0 1rem;
height: auto;
fill: var(--shadow);
}
&:hover {
cursor: pointer;
.icon {
fill: var(--primary);
}
}
}
</style>

View File

@@ -3,7 +3,7 @@
<div class="header">
<h2 class="title">
<Icon
v-if="stash.primary"
v-if="stash.isPrimary"
icon="heart7"
/>

331
components/stashes/tile.vue Normal file
View File

@@ -0,0 +1,331 @@
<template>
<div class="stash">
<div class="stash-header">
<a
:href="`/stash/${profile.username}/${stash.slug}`"
class="stash-name ellipsis nolink"
>
<span class="ellipsis">{{ stash.name }}</span>
<Icon
v-if="stash.isPrimary"
icon="heart7"
class="primary"
/>
</a>
<Icon
v-if="!stash.public"
v-tooltip="'This stash is private'"
icon="eye-blocked"
class="private noselect"
/>
<VDropdown>
<Icon
v-if="profile.id === user?.id"
icon="more2"
class="stash-more noselect"
/>
<template #popper>
<ul class="stash-menu nolist">
<li
v-if="stash.public"
class="menu-item"
@click="setPublic(false)"
>
<Icon
icon="eye-blocked"
class="noselect"
/>Set private
</li>
<li
v-else
class="menu-item"
@click="setPublic(true)"
>
<Icon
icon="eye"
class="noselect"
/>Set public
</li>
<li
v-if="!stash.isPrimary"
v-close-popper
class="menu-item"
@click="showRenameDialog = true"
>
<Icon
icon="pencil5"
class="noselect"
/>Rename
</li>
<li
v-if="!stash.isPrimary"
class="menu-item remove"
@click="remove()"
>
<Icon
icon="bin"
class="noselect"
/>Remove
</li>
</ul>
</template>
</VDropdown>
</div>
<div class="stash-counts">
<a
:href="`/stash/${profile.username}/${stash.slug}/scenes`"
class="stash-count nolink"
><Icon icon="clapboard-play" />{{ abbreviateNumber(stash.stashedScenes) }}</a>
<a
:href="`/stash/${profile.username}/${stash.slug}/actors`"
class="stash-count nolink"
><Icon icon="star" />{{ abbreviateNumber(stash.stashedActors) }}</a>
<a
:href="`/stash/${profile.username}/${stash.slug}/movies`"
class="stash-count nolink"
><Icon icon="movie" />{{ abbreviateNumber(stash.stashedMovies) }}</a>
</div>
<Dialog
v-if="showRenameDialog"
title="Rename stash"
@close="showRenameDialog = false"
@open="stashNameInput?.focus()"
>
<form
class="dialog-body"
@submit.prevent="rename"
>
<input
ref="stashNameInput"
v-model="stashName"
class="input"
placeholder="Stash name"
maxlength="24"
>
<button
class="button button-submit"
>Rename stash</button>
</form>
</Dialog>
</div>
</template>
<script setup>
import { ref, inject } from 'vue';
import { del, patch } from '#/src/api.js';
import Dialog from '#/components/dialog/dialog.vue';
const props = defineProps({
stash: {
type: Object,
default: null,
},
profile: {
type: Object,
default: null,
},
});
const emit = defineEmits(['reload']);
const pageContext = inject('pageContext');
const user = pageContext.user;
const stashName = ref(props.stash.name);
const stashNameInput = ref(null);
const showRenameDialog = ref(false);
const done = ref(true);
function abbreviateNumber(number) {
return number?.toLocaleString('en-US', { notation: 'compact' }) || 0;
}
async function setPublic(isPublic) {
if (done.value === false) {
return;
}
done.value = false;
await patch(`/stashes/${props.stash.id}`, { public: isPublic }, {
undoFeedback: !isPublic && `Stash '${props.stash.name}' set to private`,
successFeedback: isPublic && `Stash '${props.stash.name}' set to public`,
errorFeedback: 'Failed to update stash',
appendErrorMessage: true,
}).finally(() => { done.value = true; });
emit('reload');
}
async function remove() {
if (done.value === false) {
return;
}
if (!confirm(`Are you sure you want to remove the stash '${props.stash.name}' and all its scenes, movies and actors? This is permament, it cannot be undone by you or staff!`)) { // eslint-disable-line no-restricted-globals, no-alert
return;
}
done.value = false;
await del(`/stashes/${props.stash.id}`, {
undoFeedback: `Stash '${props.stash.name}' removed`,
errorFeedback: 'Failed to remove stash',
appendErrorMessage: true,
}).finally(() => { done.value = true; });
emit('reload');
}
async function rename() {
if (done.value === false) {
return;
}
done.value = false;
await patch(`/stashes/${props.stash.id}`, { name: stashName.value }, {
successFeedback: `Stash renamed to ${stashName.value}`,
errorFeedback: 'Failed to rename stash',
appendErrorMessage: true,
}).finally(() => { done.value = true; });
emit('reload');
showRenameDialog.value = false;
}
</script>
<style scoped>
.stash {
width: 100%;
border-radius: .25rem;
background: var(--background);
box-shadow: 0 0 3px var(--shadow-weak-30);
&:hover {
box-shadow: 0 0 3px var(--shadow-weak-20);
}
}
.stash-header {
display: flex;
align-items: stretch;
border-bottom: solid 1px var(--shadow-weak-30);
font-weight: bold;
}
.stash-more {
display: flex;
height: 100%;
padding: 0 .75rem;
fill: var(--shadow);
&:hover {
cursor: pointer;
fill: var(--shadow-strong-30);
}
}
.stash-name {
display: flex;
flex-grow: 1;
padding: .5rem;
overflow: hidden;
.icon {
margin-left: .75rem;
}
.icon.primary {
fill: var(--primary);
transform: translateY(1px);
}
}
.stash-counts {
display: flex;
justify-content: space-between;
}
.stash-count {
display: inline-flex;
align-items: center;
padding: .5rem;
flex-grow: 1;
font-size: .9rem;
.icon {
margin-right: .5rem;
fill: var(--shadow);
}
&:hover {
color: var(--primary);
.icon {
fill: var(--primary);
}
}
}
.icon.private {
display: flex;
height: auto;
fill: var(--shadow-weak-20);
padding-left: .5rem;
}
.menu-item {
display: flex;
align-items: center;
padding: .75rem;
.icon {
display: flex;
margin-right: .75rem;
fill: var(--shadow);
}
&.remove {
.icon {
fill: var(--error);
}
}
&:hover {
color: var(--primary);
cursor: pointer;
&.remove {
color: var(--error);
}
.icon {
fill: var(--primary);
}
}
}
.dialog-body {
padding: 1rem;
.input {
margin-bottom: .5rem;
}
}
</style>

View File

@@ -1,275 +0,0 @@
<template>
<div
class="tile"
:class="{
unstashed: !favorited && pageStash && user && pageStash.id === user.primaryStash?.id
}"
>
<span class="name">{{ actor.name }}</span>
<div class="avatar-container">
<Link
:href="`/actor/${actor.id}/${actor.slug}`"
class="avatar-link no-link"
>
<img
v-if="actor.avatar"
:src="actor.avatar.isS3 ? `https://cdndev.traxxx.me/${actor.avatar.thumbnail}` : `/media/${actor.avatar.thumbnail}`"
:style="{ 'background-image': actor.avatar.isS3 ? `url(https://cdndev.traxxx.me/${actor.avatar.lazy})` : `url(/media/${actor.avatar.lazy})` }"
loading="lazy"
class="avatar"
>
<img
v-else
:src="`/img/avatars/${actor.gender || 'female'}.svg`"
loading="lazy"
class="fallback"
>
</Link>
<Icon
v-show="favorited"
icon="heart7"
class="heart favorited"
@click.native.stop="unstash"
/>
<Icon
v-show="!favorited && user"
icon="heart8"
class="heart"
@click.native.stop="stash"
/>
</div>
<div class="details">
<span class="birth">
<Gender :gender="actor.gender" />
<span
v-if="actor.ageFromBirth"
:title="`Born ${formatDate(actor.dateOfBirth, 'MMMM d, yyyy')}`"
class="age"
>{{ actor.ageFromBirth }}</span>
<span
v-if="actor.ageThen && actor.ageThen < actor.ageFromBirth"
title="Age on date of release"
class="age age-then"
>{{ actor.ageThen }}</span>
</span>
<span
v-if="actor.origin?.country"
:title="`Born in ${actor.origin.country.name}`"
class="country"
>
{{ actor.origin.country.alpha2 }}
<img
:src="`/img/flags/${actor.origin.country.alpha2.toLowerCase()}.svg`"
class="flag"
>
</span>
</div>
</div>
</template>
<script setup>
import { ref, inject } from 'vue';
import { formatDate } from '#/utils/format.js';
import { post, del } from '#/src/api.js';
import events from '#/src/events.js';
import Gender from './gender.vue';
const props = defineProps({
actor: {
type: Object,
default: null,
},
});
const pageContext = inject('pageContext');
const { user } = pageContext;
const pageStash = pageContext.pageProps.stash;
// console.log(props.actor);
const favorited = ref(props.actor.stashes?.some((sceneStash) => sceneStash.primary) || false);
async function stash() {
try {
favorited.value = true;
await post(`/stashes/${user.primaryStash.id}/actors`, { actorId: props.actor.id });
events.emit('feedback', {
type: 'success',
message: `${props.actor.name} stashed to ${user.primaryStash.name}`,
});
} catch (error) {
favorited.value = false;
events.emit('feedback', {
type: 'error',
message: `Failed to stash ${props.actor.name} to ${user.primaryStash.name}`,
});
}
}
async function unstash() {
try {
favorited.value = false;
await del(`/stashes/${user.primaryStash.id}/actors/${props.actor.id}`);
events.emit('feedback', {
type: 'remove',
message: `${props.actor.name} unstashed from ${user.primaryStash.name}`,
});
} catch (error) {
favorited.value = true;
console.error(error);
events.emit('feedback', {
type: 'error',
message: `Failed to unstash ${props.actor.name} from ${user.primaryStash.name}`,
});
}
}
</script>
<style scoped>
.tile {
display: flex;
flex-direction: column;
width: 100%;
aspect-ratio: 2/3;
position: relative;
border-radius: .25rem;
margin: .25rem;
box-shadow: 0 0 3px var(--shadow-weak-30);
overflow: hidden;
&:hover {
box-shadow: 0 0 3px var(--shadow-weak-20);
.name {
color: var(--primary);
}
}
&.unstashed {
opacity: .5;
}
}
.name {
flex-shrink: 0;
padding: .25rem .5rem;
font-weight: bold;
font-size: .9rem;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
user-select: all;
}
.avatar-container {
position: relative;
flex-grow: 1;
overflow: hidden;
background: var(--grey-dark-40);
}
.avatar-link {
height: 100%;
display: block;
overflow: hidden;
}
.avatar {
height: 100%;
width: 100%;
object-fit: cover;
object-position: center 0;
background-size: cover;
background-position: center 0;
}
.fallback {
height: 100%;
width: 100%;
display: block;
object-fit: contain;
opacity: .1;
}
.icon.heart {
width: 2rem;
height: 1.5rem;
position: absolute;
top: 0;
right: 0;
padding: .5rem .5rem 1rem 1rem;
fill: var(--highlight-strong-10);
filter: drop-shadow(0 0 3px var(--shadow));
&:hover {
cursor: pointer;
fill: var(--primary);
}
&.favorited {
fill: var(--primary);
}
}
.details {
width: 100%;
height: 1.5rem;
display: flex;
justify-content: space-between;
align-items: center;
position: absolute;
bottom: 0;
box-sizing: border-box;
padding: 0 .5rem;
color: var(--text-light);
background: var(--shadow);
font-size: .9rem;
font-weight: bold;
}
.gender {
display: inline-block;
padding: .25rem 0;
margin-right: .25rem;
transform: translateY(1px);
}
.birth {
display: flex;
align-items: center;
}
.age {
margin-right: .25rem;
}
.age-then {
color: var(--grey-light-20);
font-weight: normal;
}
.country {
display: flex;
align-items: center;
}
.flag {
height: .75rem;
margin-left: .25rem;
}
</style>

View File

@@ -1,39 +0,0 @@
<template>
<span
v-if="gender"
class="gender"
:class="{ [gender]: true }"
>
<Icon :icon="gender" />
</span>
</template>
<script setup>
defineProps({
gender: {
type: String,
default: null,
},
});
</script>
<style scoped>
.gender {
&.female .icon {
fill: var(--female);
filter: drop-shadow(0 0 1px var(--shadow-weak-20));
}
&.male .icon {
fill: var(--male);
filter: drop-shadow(0 0 1px var(--shadow-weak-20));
}
&.transsexual .icon {
fill: var(--text-light);
filter: drop-shadow(1px 0 0 var(--female)) drop-shadow(-1px 0 0 var(--female)) drop-shadow(0 1px 0 var(--female)) drop-shadow(0 -1px 0 var(--female))
drop-shadow(1px 0 0 var(--male)) drop-shadow(-1px 0 0 var(--male)) drop-shadow(0 1px 0 var(--male)) drop-shadow(0 -1px 0 var(--male))
drop-shadow(0 0 1px var(--shadow-weak-20))
}
}
</style>