2020-01-29 21:37:25 +02:00
|
|
|
<template>
|
2021-04-22 16:29:33 +03:00
|
|
|
<div class="ogwlenmc">
|
|
|
|
<MkTab v-model:value="tab">
|
|
|
|
<option value="local">{{ $ts.local }}</option>
|
|
|
|
<option value="remote">{{ $ts.remote }}</option>
|
|
|
|
</MkTab>
|
|
|
|
|
|
|
|
<div class="local" v-if="tab === 'local'">
|
|
|
|
<MkButton primary @click="add" style="margin: var(--margin) auto;"><i class="fas fa-plus"></i> {{ $ts.addEmoji }}</MkButton>
|
2021-08-06 16:29:19 +03:00
|
|
|
<MkInput v-model="query" :debounce="true" type="search" style="margin: var(--margin);">
|
|
|
|
<template #prefix><i class="fas fa-search"></i></template>
|
|
|
|
<template #label>{{ $ts.search }}</template>
|
|
|
|
</MkInput>
|
2021-04-22 16:29:33 +03:00
|
|
|
<MkPagination :pagination="pagination" ref="emojis">
|
|
|
|
<template #empty><span>{{ $ts.noCustomEmojis }}</span></template>
|
|
|
|
<template #default="{items}">
|
|
|
|
<div class="ldhfsamy">
|
|
|
|
<button class="emoji _panel _button" v-for="emoji in items" :key="emoji.id" @click="edit(emoji)">
|
|
|
|
<img :src="emoji.url" class="img" :alt="emoji.name"/>
|
|
|
|
<div class="body">
|
|
|
|
<div class="name _monospace">{{ emoji.name }}</div>
|
|
|
|
<div class="info">{{ emoji.category }}</div>
|
|
|
|
</div>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</MkPagination>
|
2020-10-17 14:12:00 +03:00
|
|
|
</div>
|
|
|
|
|
2021-04-22 16:29:33 +03:00
|
|
|
<div class="remote" v-else-if="tab === 'remote'">
|
2021-08-06 16:29:19 +03:00
|
|
|
<MkInput v-model="queryRemote" :debounce="true" type="search" style="margin: var(--margin);">
|
|
|
|
<template #prefix><i class="fas fa-search"></i></template>
|
|
|
|
<template #label>{{ $ts.search }}</template>
|
|
|
|
</MkInput>
|
|
|
|
<MkInput v-model="host" :debounce="true" style="margin: var(--margin);">
|
|
|
|
<template #label>{{ $ts.host }}</template>
|
|
|
|
</MkInput>
|
2021-04-22 16:29:33 +03:00
|
|
|
<MkPagination :pagination="remotePagination" ref="remoteEmojis">
|
|
|
|
<template #empty><span>{{ $ts.noCustomEmojis }}</span></template>
|
|
|
|
<template #default="{items}">
|
|
|
|
<div class="ldhfsamy">
|
|
|
|
<div class="emoji _panel _button" v-for="emoji in items" :key="emoji.id" @click="remoteMenu(emoji, $event)">
|
|
|
|
<img :src="emoji.url" class="img" :alt="emoji.name"/>
|
|
|
|
<div class="body">
|
|
|
|
<div class="name _monospace">{{ emoji.name }}</div>
|
|
|
|
<div class="info">{{ emoji.host }}</div>
|
2020-01-29 21:37:25 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-04-22 16:29:33 +03:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</MkPagination>
|
2020-10-17 14:12:00 +03:00
|
|
|
</div>
|
2020-01-29 21:37:25 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 14:12:00 +03:00
|
|
|
import { computed, defineComponent } from 'vue';
|
2021-03-23 10:30:14 +02:00
|
|
|
import MkButton from '@client/components/ui/button.vue';
|
|
|
|
import MkInput from '@client/components/ui/input.vue';
|
|
|
|
import MkPagination from '@client/components/ui/pagination.vue';
|
|
|
|
import MkTab from '@client/components/tab.vue';
|
|
|
|
import { selectFile } from '@client/scripts/select-file';
|
|
|
|
import * as os from '@client/os';
|
2021-04-10 06:54:12 +03:00
|
|
|
import * as symbols from '@client/symbols';
|
2020-10-17 14:12:00 +03:00
|
|
|
|
|
|
|
export default defineComponent({
|
2020-01-29 21:37:25 +02:00
|
|
|
components: {
|
2020-10-17 14:12:00 +03:00
|
|
|
MkTab,
|
2020-01-29 21:37:25 +02:00
|
|
|
MkButton,
|
|
|
|
MkInput,
|
|
|
|
MkPagination,
|
|
|
|
},
|
|
|
|
|
2021-04-22 16:29:33 +03:00
|
|
|
emits: ['info'],
|
|
|
|
|
2020-01-29 21:37:25 +02:00
|
|
|
data() {
|
|
|
|
return {
|
2021-04-10 06:54:12 +03:00
|
|
|
[symbols.PAGE_INFO]: {
|
2020-12-26 03:47:36 +02:00
|
|
|
title: this.$ts.customEmojis,
|
2021-04-20 17:22:59 +03:00
|
|
|
icon: 'fas fa-laugh',
|
2020-10-17 14:12:00 +03:00
|
|
|
action: {
|
2021-04-20 17:22:59 +03:00
|
|
|
icon: 'fas fa-plus',
|
2020-10-17 14:12:00 +03:00
|
|
|
handler: this.add
|
|
|
|
}
|
|
|
|
},
|
|
|
|
tab: 'local',
|
|
|
|
query: null,
|
|
|
|
queryRemote: null,
|
2020-01-29 21:37:25 +02:00
|
|
|
host: '',
|
|
|
|
pagination: {
|
|
|
|
endpoint: 'admin/emoji/list',
|
2020-11-03 03:54:41 +02:00
|
|
|
limit: 30,
|
2020-10-17 14:12:00 +03:00
|
|
|
params: computed(() => ({
|
|
|
|
query: (this.query && this.query !== '') ? this.query : null
|
|
|
|
}))
|
2020-01-29 21:37:25 +02:00
|
|
|
},
|
|
|
|
remotePagination: {
|
|
|
|
endpoint: 'admin/emoji/list-remote',
|
2020-11-03 03:54:41 +02:00
|
|
|
limit: 30,
|
2020-10-17 14:12:00 +03:00
|
|
|
params: computed(() => ({
|
|
|
|
query: (this.queryRemote && this.queryRemote !== '') ? this.queryRemote : null,
|
|
|
|
host: (this.host && this.host !== '') ? this.host : null
|
|
|
|
}))
|
2020-01-29 21:37:25 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-04-22 16:29:33 +03:00
|
|
|
async mounted() {
|
|
|
|
this.$emit('info', this[symbols.PAGE_INFO]);
|
|
|
|
},
|
|
|
|
|
2020-01-29 21:37:25 +02:00
|
|
|
methods: {
|
2020-02-13 18:09:39 +02:00
|
|
|
async add(e) {
|
2020-10-17 14:12:00 +03:00
|
|
|
const files = await selectFile(e.currentTarget || e.target, null, true);
|
2020-01-29 21:37:25 +02:00
|
|
|
|
2020-10-18 04:11:34 +03:00
|
|
|
const promise = Promise.all(files.map(file => os.api('admin/emoji/add', {
|
2020-02-13 18:09:39 +02:00
|
|
|
fileId: file.id,
|
2020-10-18 04:11:34 +03:00
|
|
|
})));
|
|
|
|
promise.then(() => {
|
2020-01-29 21:37:25 +02:00
|
|
|
this.$refs.emojis.reload();
|
|
|
|
});
|
2020-10-18 04:11:34 +03:00
|
|
|
os.promiseDialog(promise);
|
2020-01-29 21:37:25 +02:00
|
|
|
},
|
|
|
|
|
2020-11-03 08:22:55 +02:00
|
|
|
edit(emoji) {
|
|
|
|
os.popup(import('./emoji-edit-dialog.vue'), {
|
2020-10-17 14:12:00 +03:00
|
|
|
emoji: emoji
|
|
|
|
}, {
|
|
|
|
done: result => {
|
|
|
|
if (result.updated) {
|
|
|
|
this.$refs.emojis.replaceItem(item => item.id === emoji.id, {
|
|
|
|
...emoji,
|
|
|
|
...result.updated
|
|
|
|
});
|
|
|
|
} else if (result.deleted) {
|
|
|
|
this.$refs.emojis.removeItem(item => item.id === emoji.id);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}, 'closed');
|
2020-02-13 18:09:39 +02:00
|
|
|
},
|
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
im(emoji) {
|
|
|
|
os.apiWithDialog('admin/emoji/copy', {
|
|
|
|
emojiId: emoji.id,
|
2020-01-29 21:37:25 +02:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
remoteMenu(emoji, ev) {
|
|
|
|
os.modalMenu([{
|
|
|
|
type: 'label',
|
|
|
|
text: ':' + emoji.name + ':',
|
|
|
|
}, {
|
2020-12-26 03:47:36 +02:00
|
|
|
text: this.$ts.import,
|
2021-04-20 17:22:59 +03:00
|
|
|
icon: 'fas fa-plus',
|
2020-10-17 14:12:00 +03:00
|
|
|
action: () => { this.im(emoji) }
|
|
|
|
}], ev.currentTarget || ev.target);
|
|
|
|
}
|
2020-01-29 21:37:25 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-04-22 16:29:33 +03:00
|
|
|
.ogwlenmc {
|
|
|
|
> .local {
|
|
|
|
.ldhfsamy {
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
|
|
|
|
grid-gap: 12px;
|
|
|
|
margin: var(--margin);
|
|
|
|
|
|
|
|
> .emoji {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
padding: 12px;
|
|
|
|
text-align: left;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
color: var(--accent);
|
|
|
|
}
|
2020-01-29 21:37:25 +02:00
|
|
|
|
2021-04-22 16:29:33 +03:00
|
|
|
> .img {
|
|
|
|
width: 42px;
|
|
|
|
height: 42px;
|
|
|
|
}
|
2020-01-29 21:37:25 +02:00
|
|
|
|
2021-04-22 16:29:33 +03:00
|
|
|
> .body {
|
|
|
|
padding: 0 0 0 8px;
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
2020-01-29 21:37:25 +02:00
|
|
|
|
2021-04-22 16:29:33 +03:00
|
|
|
> .name {
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
2020-02-13 18:09:39 +02:00
|
|
|
|
2021-04-22 16:29:33 +03:00
|
|
|
> .info {
|
|
|
|
opacity: 0.5;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
overflow: hidden;
|
2020-01-29 21:37:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-04-22 16:29:33 +03:00
|
|
|
}
|
2020-01-29 21:37:25 +02:00
|
|
|
|
2021-04-22 16:29:33 +03:00
|
|
|
> .remote {
|
|
|
|
.ldhfsamy {
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
|
|
|
|
grid-gap: 12px;
|
|
|
|
margin: var(--margin);
|
|
|
|
|
|
|
|
> .emoji {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
padding: 12px;
|
|
|
|
text-align: left;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
color: var(--accent);
|
|
|
|
}
|
2020-10-17 14:12:00 +03:00
|
|
|
|
2021-04-22 16:29:33 +03:00
|
|
|
> .img {
|
|
|
|
width: 32px;
|
|
|
|
height: 32px;
|
|
|
|
}
|
2020-01-29 21:37:25 +02:00
|
|
|
|
2021-04-22 16:29:33 +03:00
|
|
|
> .body {
|
|
|
|
padding: 0 0 0 8px;
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
2020-01-29 21:37:25 +02:00
|
|
|
|
2021-04-22 16:29:33 +03:00
|
|
|
> .name {
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
overflow: hidden;
|
2020-01-29 21:37:25 +02:00
|
|
|
}
|
|
|
|
|
2021-04-22 16:29:33 +03:00
|
|
|
> .info {
|
|
|
|
opacity: 0.5;
|
|
|
|
font-size: 90%;
|
|
|
|
text-overflow: ellipsis;
|
2021-03-02 15:57:16 +02:00
|
|
|
overflow: hidden;
|
2020-01-29 21:37:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|