2020-01-29 13:37:25 -06:00
|
|
|
<template>
|
|
|
|
<div class="mk-instance-emojis">
|
2020-10-17 06:12:00 -05:00
|
|
|
<div class="_section" style="padding: 0;">
|
2020-11-16 23:59:15 -06:00
|
|
|
<MkTab v-model:value="tab">
|
2020-12-25 19:47:36 -06:00
|
|
|
<option value="local">{{ $ts.local }}</option>
|
|
|
|
<option value="remote">{{ $ts.remote }}</option>
|
2020-11-16 23:59:15 -06:00
|
|
|
</MkTab>
|
2020-10-17 06:12:00 -05:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="_section">
|
2020-11-02 19:54:41 -06:00
|
|
|
<div class="local" v-if="tab === 'local'">
|
2020-12-25 19:47:36 -06:00
|
|
|
<MkButton primary @click="add" style="margin: 0 auto var(--margin) auto;"><Fa :icon="faPlus"/> {{ $ts.addEmoji }}</MkButton>
|
|
|
|
<MkInput v-model:value="query" :debounce="true" type="search"><template #icon><Fa :icon="faSearch"/></template><span>{{ $ts.search }}</span></MkInput>
|
2020-10-17 06:12:00 -05:00
|
|
|
<MkPagination :pagination="pagination" ref="emojis">
|
2020-12-25 19:47:36 -06:00
|
|
|
<template #empty><span>{{ $ts.noCustomEmojis }}</span></template>
|
2020-01-29 13:37:25 -06:00
|
|
|
<template #default="{items}">
|
2020-10-17 06:12:00 -05:00
|
|
|
<div class="emojis">
|
|
|
|
<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">
|
2020-10-18 04:50:45 -05:00
|
|
|
<div class="name">{{ emoji.name }}</div>
|
|
|
|
<div class="info">{{ emoji.category }}</div>
|
2020-10-17 06:12:00 -05:00
|
|
|
</div>
|
|
|
|
</button>
|
2020-01-29 13:37:25 -06:00
|
|
|
</div>
|
|
|
|
</template>
|
2020-10-17 06:12:00 -05:00
|
|
|
</MkPagination>
|
2020-01-29 13:37:25 -06:00
|
|
|
</div>
|
2020-10-17 06:12:00 -05:00
|
|
|
|
2020-11-02 19:54:41 -06:00
|
|
|
<div class="remote" v-else-if="tab === 'remote'">
|
2020-12-25 19:47:36 -06:00
|
|
|
<MkInput v-model:value="queryRemote" :debounce="true" type="search"><template #icon><Fa :icon="faSearch"/></template><span>{{ $ts.search }}</span></MkInput>
|
|
|
|
<MkInput v-model:value="host" :debounce="true"><span>{{ $ts.host }}</span></MkInput>
|
2020-10-17 06:12:00 -05:00
|
|
|
<MkPagination :pagination="remotePagination" ref="remoteEmojis">
|
2020-12-25 19:47:36 -06:00
|
|
|
<template #empty><span>{{ $ts.noCustomEmojis }}</span></template>
|
2020-01-29 13:37:25 -06:00
|
|
|
<template #default="{items}">
|
2020-10-17 06:12:00 -05:00
|
|
|
<div class="emojis">
|
|
|
|
<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">
|
2020-10-18 04:50:45 -05:00
|
|
|
<div class="name">{{ emoji.name }}</div>
|
|
|
|
<div class="info">{{ emoji.host }}</div>
|
2020-10-17 06:12:00 -05:00
|
|
|
</div>
|
2020-01-29 13:37:25 -06:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
2020-10-17 06:12:00 -05:00
|
|
|
</MkPagination>
|
2020-01-29 13:37:25 -06:00
|
|
|
</div>
|
2020-10-17 06:12:00 -05:00
|
|
|
</div>
|
2020-01-29 13:37:25 -06:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 06:12:00 -05:00
|
|
|
import { computed, defineComponent } from 'vue';
|
|
|
|
import { faPlus, faSave, faSearch } from '@fortawesome/free-solid-svg-icons';
|
2020-01-29 13:37:25 -06:00
|
|
|
import { faTrashAlt, faLaugh } from '@fortawesome/free-regular-svg-icons';
|
2020-10-17 06:12:00 -05:00
|
|
|
import MkButton from '@/components/ui/button.vue';
|
|
|
|
import MkInput from '@/components/ui/input.vue';
|
|
|
|
import MkPagination from '@/components/ui/pagination.vue';
|
|
|
|
import MkTab from '@/components/tab.vue';
|
|
|
|
import { selectFile } from '@/scripts/select-file';
|
|
|
|
import * as os from '@/os';
|
|
|
|
|
|
|
|
export default defineComponent({
|
2020-01-29 13:37:25 -06:00
|
|
|
components: {
|
2020-10-17 06:12:00 -05:00
|
|
|
MkTab,
|
2020-01-29 13:37:25 -06:00
|
|
|
MkButton,
|
|
|
|
MkInput,
|
|
|
|
MkPagination,
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2020-10-17 06:12:00 -05:00
|
|
|
INFO: {
|
2020-12-25 19:47:36 -06:00
|
|
|
title: this.$ts.customEmojis,
|
2020-11-03 05:36:12 -06:00
|
|
|
icon: faLaugh,
|
2020-10-17 06:12:00 -05:00
|
|
|
action: {
|
|
|
|
icon: faPlus,
|
|
|
|
handler: this.add
|
|
|
|
}
|
|
|
|
},
|
|
|
|
tab: 'local',
|
|
|
|
query: null,
|
|
|
|
queryRemote: null,
|
2020-01-29 13:37:25 -06:00
|
|
|
host: '',
|
|
|
|
pagination: {
|
|
|
|
endpoint: 'admin/emoji/list',
|
2020-11-02 19:54:41 -06:00
|
|
|
limit: 30,
|
2020-10-17 06:12:00 -05:00
|
|
|
params: computed(() => ({
|
|
|
|
query: (this.query && this.query !== '') ? this.query : null
|
|
|
|
}))
|
2020-01-29 13:37:25 -06:00
|
|
|
},
|
|
|
|
remotePagination: {
|
|
|
|
endpoint: 'admin/emoji/list-remote',
|
2020-11-02 19:54:41 -06:00
|
|
|
limit: 30,
|
2020-10-17 06:12:00 -05:00
|
|
|
params: computed(() => ({
|
|
|
|
query: (this.queryRemote && this.queryRemote !== '') ? this.queryRemote : null,
|
|
|
|
host: (this.host && this.host !== '') ? this.host : null
|
|
|
|
}))
|
2020-01-29 13:37:25 -06:00
|
|
|
},
|
2020-10-17 06:12:00 -05:00
|
|
|
faTrashAlt, faPlus, faLaugh, faSave, faSearch,
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2020-02-13 10:09:39 -06:00
|
|
|
async add(e) {
|
2020-10-17 06:12:00 -05:00
|
|
|
const files = await selectFile(e.currentTarget || e.target, null, true);
|
2020-01-29 13:37:25 -06:00
|
|
|
|
2020-10-17 20:11:34 -05:00
|
|
|
const promise = Promise.all(files.map(file => os.api('admin/emoji/add', {
|
2020-02-13 10:09:39 -06:00
|
|
|
fileId: file.id,
|
2020-10-17 20:11:34 -05:00
|
|
|
})));
|
|
|
|
promise.then(() => {
|
2020-01-29 13:37:25 -06:00
|
|
|
this.$refs.emojis.reload();
|
|
|
|
});
|
2020-10-17 20:11:34 -05:00
|
|
|
os.promiseDialog(promise);
|
2020-01-29 13:37:25 -06:00
|
|
|
},
|
|
|
|
|
2020-11-03 00:22:55 -06:00
|
|
|
edit(emoji) {
|
|
|
|
os.popup(import('./emoji-edit-dialog.vue'), {
|
2020-10-17 06:12:00 -05: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 10:09:39 -06:00
|
|
|
},
|
|
|
|
|
2020-10-17 06:12:00 -05:00
|
|
|
im(emoji) {
|
|
|
|
os.apiWithDialog('admin/emoji/copy', {
|
|
|
|
emojiId: emoji.id,
|
2020-01-29 13:37:25 -06:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-10-17 06:12:00 -05:00
|
|
|
remoteMenu(emoji, ev) {
|
|
|
|
os.modalMenu([{
|
|
|
|
type: 'label',
|
|
|
|
text: ':' + emoji.name + ':',
|
|
|
|
}, {
|
2020-12-25 19:47:36 -06:00
|
|
|
text: this.$ts.import,
|
2020-10-17 06:12:00 -05:00
|
|
|
icon: faPlus,
|
|
|
|
action: () => { this.im(emoji) }
|
|
|
|
}], ev.currentTarget || ev.target);
|
|
|
|
}
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.mk-instance-emojis {
|
2020-10-17 06:12:00 -05:00
|
|
|
> ._section {
|
|
|
|
> .local {
|
|
|
|
.emojis {
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
|
|
|
|
grid-gap: var(--margin);
|
|
|
|
|
2020-01-29 13:37:25 -06:00
|
|
|
> .emoji {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
2020-10-17 06:12:00 -05:00
|
|
|
padding: 12px;
|
|
|
|
text-align: left;
|
2020-01-29 13:37:25 -06:00
|
|
|
|
2020-10-17 06:12:00 -05:00
|
|
|
&:hover {
|
|
|
|
color: var(--accent);
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
> .img {
|
2020-10-17 06:12:00 -05:00
|
|
|
width: 42px;
|
|
|
|
height: 42px;
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
> .body {
|
2020-10-17 06:12:00 -05:00
|
|
|
padding: 0 0 0 8px;
|
|
|
|
white-space: nowrap;
|
2021-02-26 20:18:53 -06:00
|
|
|
overflow: hidden; // overflow: clip; をSafariが対応したら消す
|
|
|
|
overflow: clip;
|
2020-01-29 13:37:25 -06:00
|
|
|
|
|
|
|
> .name {
|
2020-10-17 06:12:00 -05:00
|
|
|
text-overflow: ellipsis;
|
2021-02-26 20:18:53 -06:00
|
|
|
overflow: hidden; // overflow: clip; をSafariが対応したら消す
|
|
|
|
overflow: clip;
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
2020-02-13 10:09:39 -06:00
|
|
|
|
|
|
|
> .info {
|
|
|
|
opacity: 0.5;
|
2020-10-18 04:50:45 -05:00
|
|
|
text-overflow: ellipsis;
|
2021-02-26 20:18:53 -06:00
|
|
|
overflow: hidden; // overflow: clip; をSafariが対応したら消す
|
|
|
|
overflow: clip;
|
2020-02-13 10:09:39 -06:00
|
|
|
}
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-17 06:12:00 -05:00
|
|
|
> .remote {
|
|
|
|
.emojis {
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
|
|
|
|
grid-gap: var(--margin);
|
|
|
|
|
2020-01-29 13:37:25 -06:00
|
|
|
> .emoji {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
2020-10-17 06:12:00 -05:00
|
|
|
padding: 12px;
|
|
|
|
text-align: left;
|
2020-01-29 13:37:25 -06:00
|
|
|
|
2020-10-17 06:12:00 -05:00
|
|
|
&:hover {
|
|
|
|
color: var(--accent);
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
> .img {
|
|
|
|
width: 32px;
|
|
|
|
height: 32px;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .body {
|
2020-10-17 06:12:00 -05:00
|
|
|
padding: 0 0 0 8px;
|
|
|
|
white-space: nowrap;
|
2021-02-26 20:18:53 -06:00
|
|
|
overflow: hidden; // overflow: clip; をSafariが対応したら消す
|
|
|
|
overflow: clip;
|
2020-01-29 13:37:25 -06:00
|
|
|
|
|
|
|
> .name {
|
2020-10-17 06:12:00 -05:00
|
|
|
text-overflow: ellipsis;
|
2021-02-26 20:18:53 -06:00
|
|
|
overflow: hidden; // overflow: clip; をSafariが対応したら消す
|
|
|
|
overflow: clip;
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
|
|
|
|
2020-02-13 10:09:39 -06:00
|
|
|
> .info {
|
2020-01-29 13:37:25 -06:00
|
|
|
opacity: 0.5;
|
2020-10-17 06:12:00 -05:00
|
|
|
text-overflow: ellipsis;
|
2021-02-26 20:18:53 -06:00
|
|
|
overflow: hidden; // overflow: clip; をSafariが対応したら消す
|
|
|
|
overflow: clip;
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|