2021-04-04 19:52:19 +00:00
|
|
|
<template>
|
|
|
|
<Dialog
|
|
|
|
title="Add alert"
|
|
|
|
@close="$emit('close')"
|
|
|
|
>
|
2023-11-24 00:29:22 +00:00
|
|
|
<div
|
|
|
|
v-if="error"
|
|
|
|
class="dialog-error"
|
|
|
|
>{{ error }}</div>
|
|
|
|
|
2021-04-04 19:52:19 +00:00
|
|
|
<form
|
|
|
|
class="dialog-body"
|
|
|
|
@submit.prevent="addAlert"
|
|
|
|
>
|
|
|
|
<div class="dialog-section">
|
|
|
|
<h3 class="dialog-heading">
|
|
|
|
When<span class="dialog-description">All to appear in the same scene</span>
|
|
|
|
</h3>
|
|
|
|
|
|
|
|
<div class="alert-section">
|
|
|
|
<h4
|
|
|
|
v-if="actors.length > 1"
|
|
|
|
class="alert-heading"
|
|
|
|
>Actors</h4>
|
|
|
|
|
|
|
|
<h4
|
|
|
|
v-else
|
|
|
|
class="alert-heading"
|
|
|
|
>Actor</h4>
|
|
|
|
|
|
|
|
<ul class="actors nolist">
|
|
|
|
<li
|
|
|
|
v-for="actor in actors"
|
|
|
|
:key="`actor-${actor.id}`"
|
|
|
|
class="actor"
|
|
|
|
>
|
|
|
|
<ActorPreview :actor="actor" />
|
|
|
|
|
|
|
|
<Icon
|
|
|
|
icon="cross3"
|
|
|
|
class="remove"
|
|
|
|
@click.native="removeActor(actor)"
|
|
|
|
/>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<Tooltip>
|
|
|
|
<li class="actor placeholder"><template v-if="actors.length === 0">Any actor</template>
|
|
|
|
<Icon
|
|
|
|
icon="plus3"
|
|
|
|
class="add"
|
|
|
|
/>
|
|
|
|
</li>
|
|
|
|
|
2022-02-01 20:18:54 +00:00
|
|
|
<template #tooltip>
|
2021-04-04 19:52:19 +00:00
|
|
|
<Search
|
|
|
|
content="actors"
|
|
|
|
@select="actor => addActor(actor)"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
</Tooltip>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="alert-section">
|
|
|
|
<h4
|
|
|
|
v-if="actors.length > 1"
|
|
|
|
class="alert-heading"
|
|
|
|
>Do</h4>
|
|
|
|
|
|
|
|
<h4
|
|
|
|
v-else
|
|
|
|
class="alert-heading"
|
|
|
|
>Does</h4>
|
|
|
|
|
|
|
|
<ul class="tags nolist">
|
|
|
|
<li
|
|
|
|
v-for="tag in tags"
|
|
|
|
:key="`tag-${tag.id}`"
|
|
|
|
class="tag"
|
|
|
|
>{{ tag.name }}
|
|
|
|
<Icon
|
|
|
|
icon="cross3"
|
|
|
|
class="remove"
|
|
|
|
@click.native="removeTag(tag)"
|
|
|
|
/>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<Tooltip>
|
|
|
|
<li class="tag placeholder"><template v-if="tags.length === 0">Any type of scene</template>
|
|
|
|
<Icon
|
|
|
|
icon="plus3"
|
|
|
|
class="add"
|
|
|
|
/>
|
|
|
|
</li>
|
|
|
|
|
2022-02-01 20:18:54 +00:00
|
|
|
<template #tooltip>
|
2021-04-04 19:52:19 +00:00
|
|
|
<Search
|
|
|
|
content="tags"
|
|
|
|
:defaults="['anal', 'blowbang', 'mfm', 'dp', 'gangbang', 'airtight']"
|
|
|
|
@select="tag => addTag(tag)"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
</Tooltip>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="alert-section">
|
|
|
|
<h4 class="alert-heading">For</h4>
|
|
|
|
|
|
|
|
<div class="entities">
|
|
|
|
<div
|
|
|
|
v-if="entity"
|
|
|
|
class="entity"
|
|
|
|
>
|
|
|
|
<Entity :entity="entity" />
|
|
|
|
|
|
|
|
<Icon
|
|
|
|
icon="cross3"
|
|
|
|
class="remove"
|
|
|
|
@click.native="removeEntity(entity)"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<Tooltip v-if="!entity">
|
|
|
|
<div class="entity placeholder">
|
|
|
|
Any channel
|
|
|
|
|
|
|
|
<Icon
|
|
|
|
icon="plus3"
|
|
|
|
class="add"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
2022-02-01 20:18:54 +00:00
|
|
|
<template #tooltip>
|
2021-04-04 19:52:19 +00:00
|
|
|
<Search
|
|
|
|
label="Search channels"
|
|
|
|
content="entities"
|
|
|
|
@select="entity => addEntity(entity)"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-11-24 00:29:22 +00:00
|
|
|
|
|
|
|
<div class="alert-section">
|
|
|
|
<h4 class="alert-heading">Matching</h4>
|
|
|
|
|
|
|
|
<ul class="matches nolist">
|
|
|
|
<li
|
|
|
|
v-for="(match, index) in matches"
|
|
|
|
:key="`match-${index}`"
|
|
|
|
class="match"
|
|
|
|
>
|
|
|
|
<span class="match-property">{{ match.property }}: </span>
|
|
|
|
|
|
|
|
<span
|
|
|
|
v-if="match.expression.slice(0, 1) === '/' && match.expression.slice(-1) === '/'"
|
|
|
|
class="match-expression"
|
|
|
|
><span class="match-slash">/</span>{{ match.expression.slice(1, -1) }}<span class="match-slash">/</span></span>
|
|
|
|
|
|
|
|
<span
|
|
|
|
v-else
|
|
|
|
class="match-expression"
|
|
|
|
>{{ match.expression }}</span>
|
|
|
|
|
|
|
|
<Icon
|
|
|
|
icon="cross3"
|
|
|
|
class="remove"
|
|
|
|
@click.native="removeMatch(index)"
|
|
|
|
/>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<Tooltip
|
|
|
|
v-if="!entity"
|
|
|
|
@open="$refs.expression?.focus()"
|
|
|
|
>
|
|
|
|
<li class="match placeholder">
|
|
|
|
Anything
|
|
|
|
|
|
|
|
<Icon
|
|
|
|
icon="plus3"
|
|
|
|
class="add"
|
|
|
|
/>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<template #tooltip>
|
|
|
|
<form
|
|
|
|
class="pattern-tooltip"
|
|
|
|
@submit.prevent="addMatch"
|
|
|
|
>
|
|
|
|
<select
|
|
|
|
v-model="matchProperty"
|
|
|
|
class="input"
|
|
|
|
>
|
|
|
|
<option value="title">Title</option>
|
|
|
|
<option value="description">Description</option>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<input
|
|
|
|
ref="expression"
|
|
|
|
v-model="matchExpression"
|
|
|
|
class="input"
|
|
|
|
placeholder="Expression, // for RegExp"
|
|
|
|
>
|
|
|
|
</form>
|
|
|
|
</template>
|
|
|
|
</Tooltip>
|
|
|
|
</ul>
|
|
|
|
</div>
|
2021-04-04 19:52:19 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="dialog-section">
|
|
|
|
<h3 class="dialog-heading">Then</h3>
|
|
|
|
|
|
|
|
<label class="alert-label">
|
|
|
|
<Checkbox
|
|
|
|
:checked="notify"
|
|
|
|
@change="checked => notify = checked"
|
|
|
|
/>Notify me in traxxx
|
|
|
|
</label>
|
|
|
|
|
2021-04-27 01:56:38 +00:00
|
|
|
<!--
|
2021-04-04 19:52:19 +00:00
|
|
|
<label class="alert-label">
|
|
|
|
<Checkbox
|
|
|
|
:checked="email"
|
|
|
|
@change="checked => email = checked"
|
|
|
|
/>Send me an e-mail
|
|
|
|
</label>
|
2021-04-27 01:56:38 +00:00
|
|
|
-->
|
2021-04-04 19:52:19 +00:00
|
|
|
|
|
|
|
<div class="stashes-container">
|
|
|
|
<ul class="stashes nolist">
|
|
|
|
<li
|
|
|
|
v-for="stash in stashes"
|
|
|
|
:key="`stash-${stash.id}`"
|
|
|
|
class="stash"
|
|
|
|
>{{ stash.name }}
|
|
|
|
|
|
|
|
<Icon
|
|
|
|
icon="cross3"
|
|
|
|
class="remove"
|
|
|
|
@click.native="removeStash(stash)"
|
|
|
|
/>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<Tooltip>
|
|
|
|
<li class="stash placeholder">
|
|
|
|
Add to stash
|
|
|
|
<Icon
|
|
|
|
icon="plus3"
|
|
|
|
class="add"
|
|
|
|
/>
|
|
|
|
</li>
|
|
|
|
|
2022-02-01 20:18:54 +00:00
|
|
|
<template #tooltip>
|
2021-04-04 19:52:19 +00:00
|
|
|
<Search
|
|
|
|
content="stashes"
|
|
|
|
@select="stash => addStash(stash)"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
</Tooltip>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="dialog-actions right">
|
|
|
|
<button
|
2023-11-24 00:29:22 +00:00
|
|
|
:disabled="actors.length === 0 && tags.length === 0 && !entity && matches.length === 0"
|
2021-04-04 19:52:19 +00:00
|
|
|
type="submit"
|
|
|
|
class="button button-primary"
|
|
|
|
>Add alert</button>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</Dialog>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import ActorPreview from '../actors/preview.vue';
|
|
|
|
import Entity from '../entities/tile.vue';
|
|
|
|
import Checkbox from '../form/checkbox.vue';
|
|
|
|
import Search from './search.vue';
|
|
|
|
|
|
|
|
async function addAlert() {
|
2023-11-24 00:29:22 +00:00
|
|
|
this.error = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
await this.$store.dispatch('addAlert', {
|
|
|
|
actors: this.actors.map((actor) => actor.id),
|
|
|
|
tags: this.tags.map((tag) => tag.id),
|
|
|
|
matches: this.matches,
|
|
|
|
entity: this.entity?.id,
|
|
|
|
notify: this.notify,
|
|
|
|
email: this.email,
|
|
|
|
stashes: this.stashes.map((stash) => stash.id),
|
|
|
|
});
|
|
|
|
|
|
|
|
this.$emit('close', true);
|
|
|
|
} catch (error) {
|
|
|
|
this.error = error.message;
|
|
|
|
}
|
2021-04-04 19:52:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function addActor(actor) {
|
2022-02-01 20:18:54 +00:00
|
|
|
if (!this.actors.some((selectedActor) => selectedActor.id === actor.id)) {
|
2021-04-04 19:52:19 +00:00
|
|
|
this.actors = this.actors.concat(actor);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.events.emit('blur');
|
|
|
|
}
|
|
|
|
|
|
|
|
function addEntity(entity) {
|
|
|
|
this.entity = entity;
|
|
|
|
this.events.emit('blur');
|
|
|
|
}
|
|
|
|
|
|
|
|
function addTag(tag) {
|
2022-02-01 20:18:54 +00:00
|
|
|
if (!this.tags.some((selectedTag) => selectedTag.id === tag.id)) {
|
2021-04-04 19:52:19 +00:00
|
|
|
this.tags = this.tags.concat(tag);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.events.emit('blur');
|
|
|
|
}
|
|
|
|
|
|
|
|
function removeActor(actor) {
|
2022-02-01 20:18:54 +00:00
|
|
|
this.actors = this.actors.filter((listedActor) => listedActor.id !== actor.id);
|
2021-04-04 19:52:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function removeEntity() {
|
|
|
|
this.entity = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
function removeTag(tag) {
|
2022-02-01 20:18:54 +00:00
|
|
|
this.tags = this.tags.filter((listedTag) => listedTag.id !== tag.id);
|
2021-04-04 19:52:19 +00:00
|
|
|
}
|
|
|
|
|
2023-11-24 00:29:22 +00:00
|
|
|
function addMatch() {
|
|
|
|
if (!this.matchExpression) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.matches = this.matches.concat({
|
|
|
|
property: this.matchProperty,
|
|
|
|
expression: this.matchExpression,
|
|
|
|
});
|
|
|
|
|
|
|
|
this.matchProperty = 'title';
|
|
|
|
this.matchExpression = null;
|
|
|
|
|
|
|
|
this.events.emit('blur');
|
|
|
|
}
|
|
|
|
|
|
|
|
function removeMatch(removeIndex) {
|
|
|
|
this.matches = this.matches.filter((match, matchIndex) => matchIndex !== removeIndex);
|
|
|
|
}
|
|
|
|
|
2021-04-04 19:52:19 +00:00
|
|
|
function addStash(stash) {
|
2022-02-01 20:18:54 +00:00
|
|
|
if (!this.stashes.some((selectedStash) => selectedStash.id === stash.id)) {
|
2021-04-04 19:52:19 +00:00
|
|
|
this.stashes = this.stashes.concat(stash);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.events.emit('blur');
|
|
|
|
}
|
|
|
|
|
|
|
|
function removeStash(stash) {
|
2022-02-01 20:18:54 +00:00
|
|
|
this.stashes = this.stashes.filter((listedStash) => listedStash.id !== stash.id);
|
2021-04-04 19:52:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
ActorPreview,
|
|
|
|
Checkbox,
|
|
|
|
Entity,
|
|
|
|
Search,
|
|
|
|
},
|
2022-02-01 20:18:54 +00:00
|
|
|
emits: ['close'],
|
2021-04-04 19:52:19 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2023-11-24 00:29:22 +00:00
|
|
|
error: null,
|
2021-04-04 19:52:19 +00:00
|
|
|
actors: [],
|
|
|
|
tags: [],
|
|
|
|
entity: null,
|
2023-11-24 00:29:22 +00:00
|
|
|
matches: [],
|
|
|
|
matchProperty: 'title',
|
|
|
|
matchExpression: null,
|
2021-04-04 19:52:19 +00:00
|
|
|
notify: true,
|
|
|
|
email: false,
|
|
|
|
stashes: [],
|
|
|
|
availableStashes: this.$store.state.auth.user.stashes,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
addActor,
|
|
|
|
addAlert,
|
|
|
|
addEntity,
|
2023-11-24 00:29:22 +00:00
|
|
|
addMatch,
|
2021-04-04 19:52:19 +00:00
|
|
|
addTag,
|
|
|
|
addStash,
|
|
|
|
removeActor,
|
|
|
|
removeEntity,
|
2023-11-24 00:29:22 +00:00
|
|
|
removeMatch,
|
2021-04-04 19:52:19 +00:00
|
|
|
removeTag,
|
|
|
|
removeStash,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.dialog-section {
|
|
|
|
width: 30rem;
|
|
|
|
max-width: 100%;
|
|
|
|
|
|
|
|
&:first-child {
|
|
|
|
border-bottom: solid 1px var(--shadow-hint);
|
|
|
|
margin: 0 0 1rem 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.dialog-heading {
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
align-items: center;
|
|
|
|
margin: 0 0 .25rem 0;
|
|
|
|
color: var(--primary);
|
|
|
|
}
|
|
|
|
|
|
|
|
.dialog-description {
|
|
|
|
color: var(--shadow);
|
|
|
|
font-size: .9rem;
|
|
|
|
font-weight: normal;
|
|
|
|
}
|
|
|
|
|
2023-11-24 00:29:22 +00:00
|
|
|
.dialog-error {
|
|
|
|
padding: 1rem;
|
|
|
|
margin-bottom: 1rem;
|
|
|
|
background: var(--error);
|
|
|
|
color: var(--text-light);
|
|
|
|
font-weight: bold;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
|
2021-04-04 19:52:19 +00:00
|
|
|
.alert-heading {
|
|
|
|
margin: .75rem 0 .25rem 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.actors,
|
|
|
|
.entities,
|
|
|
|
.tags {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
flex-wrap: wrap;
|
|
|
|
font-size: 0;
|
|
|
|
}
|
|
|
|
|
2023-11-24 00:29:22 +00:00
|
|
|
.match {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
padding: .25rem 0;
|
|
|
|
font-family: inherit;
|
|
|
|
|
|
|
|
.remove {
|
|
|
|
position: relative;
|
|
|
|
top: -.1rem;
|
|
|
|
right: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.match-property {
|
|
|
|
text-transform: capitalize;
|
|
|
|
color: var(--shadow);
|
|
|
|
}
|
|
|
|
|
|
|
|
.match-expression {
|
|
|
|
flex-grow: 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
.match-slash {
|
|
|
|
padding: 0 .1rem;
|
|
|
|
color: var(--primary);
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
|
2021-04-04 19:52:19 +00:00
|
|
|
.actors > .actor,
|
|
|
|
.entity,
|
|
|
|
.tag,
|
|
|
|
.stash {
|
|
|
|
position: relative;
|
|
|
|
font-size: 1rem;
|
|
|
|
margin: 0 .5rem .5rem 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.entity .tile {
|
|
|
|
width: 10rem;
|
|
|
|
height: 2.5rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.tag:not(.placeholder),
|
|
|
|
.stash:not(.placeholder) {
|
|
|
|
padding: .5rem .75rem;
|
|
|
|
border: solid 1px var(--shadow-hint);
|
|
|
|
margin: 0 .75rem 0 0;
|
|
|
|
font-size: .9rem;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
|
|
|
|
.stashes {
|
|
|
|
margin: 0 0 0 .25rem;
|
|
|
|
color: var(--text);
|
|
|
|
}
|
|
|
|
|
2023-11-24 00:29:22 +00:00
|
|
|
.pattern-tooltip {
|
|
|
|
display: flex;
|
|
|
|
gap: .5rem;
|
|
|
|
position: relative;
|
|
|
|
padding: .5rem;
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
|
|
|
|
2021-04-04 19:52:19 +00:00
|
|
|
.remove {
|
|
|
|
width: 1rem;
|
|
|
|
height: 1rem;
|
|
|
|
position: absolute;
|
|
|
|
top: -.35rem;
|
|
|
|
right: -.35rem;
|
|
|
|
z-index: 1;
|
|
|
|
border: solid 1px var(--darken-hint);
|
|
|
|
border-radius: 50%;
|
|
|
|
background: var(--background);
|
|
|
|
fill: var(--shadow-weak);
|
|
|
|
box-shadow: 0 0 1px var(--shadow);
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
fill: var(--text-light);
|
|
|
|
background: var(--primary);
|
|
|
|
border: solid 1px var(--primary);
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.placeholder {
|
|
|
|
display: inline-flex;
|
|
|
|
align-items: center;
|
|
|
|
color: var(--shadow-strong);
|
|
|
|
padding: .75rem 0;
|
|
|
|
margin: 0 0 .5rem 0;
|
|
|
|
font-size: 1rem;
|
|
|
|
|
|
|
|
.add {
|
|
|
|
fill: var(--shadow);
|
|
|
|
margin: 0 0 0 .5rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
color: var(--primary);
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
.add {
|
|
|
|
fill: var(--primary);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.alert-label {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
padding: .5rem 0;
|
|
|
|
margin: 0 0 .25rem 0;
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
.stashes-heading {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
margin: 0 0 .5rem 0;
|
|
|
|
font-size: 1rem;
|
|
|
|
|
|
|
|
.alert-label {
|
|
|
|
display: inline-block;
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.tooltip-container {
|
|
|
|
display: inline-block;
|
|
|
|
}
|
|
|
|
|
|
|
|
.check-container {
|
|
|
|
display: inline-block;
|
|
|
|
margin: 0 .5rem 0 0;
|
|
|
|
}
|
|
|
|
</style>
|