2020-01-29 11:37:25 -08:00
|
|
|
<template>
|
2021-04-22 06:29:33 -07: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>
|
|
|
|
<MkInput v-model:value="query" :debounce="true" type="search" style="margin: var(--margin);"><template #icon><i class="fas fa-search"></i></template><span>{{ $ts.search }}</span></MkInput>
|
|
|
|
<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 04:12:00 -07:00
|
|
|
</div>
|
|
|
|
|
2021-04-22 06:29:33 -07:00
|
|
|
<div class="remote" v-else-if="tab === 'remote'">
|
|
|
|
<MkInput v-model:value="queryRemote" :debounce="true" type="search" style="margin: var(--margin);"><template #icon><i class="fas fa-search"></i></template><span>{{ $ts.search }}</span></MkInput>
|
|
|
|
<MkInput v-model:value="host" :debounce="true" style="margin: var(--margin);"><span>{{ $ts.host }}</span></MkInput>
|
|
|
|
<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 11:37:25 -08:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-04-22 06:29:33 -07:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</MkPagination>
|
2020-10-17 04:12:00 -07:00
|
|
|
</div>
|
2020-01-29 11:37:25 -08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 04:12:00 -07:00
|
|
|
import { computed, defineComponent } from 'vue';
|
2021-03-23 01:30:14 -07: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-09 20:54:12 -07:00
|
|
|
import * as symbols from '@client/symbols';
|
2020-10-17 04:12:00 -07:00
|
|
|
|
|
|
|
export default defineComponent({
|
2020-01-29 11:37:25 -08:00
|
|
|
components: {
|
2020-10-17 04:12:00 -07:00
|
|
|
MkTab,
|
2020-01-29 11:37:25 -08:00
|
|
|
MkButton,
|
|
|
|
MkInput,
|
|
|
|
MkPagination,
|
|
|
|
},
|
|
|
|
|
2021-04-22 06:29:33 -07:00
|
|
|
emits: ['info'],
|
|
|
|
|
2020-01-29 11:37:25 -08:00
|
|
|
data() {
|
|
|
|
return {
|
2021-04-09 20:54:12 -07:00
|
|
|
[symbols.PAGE_INFO]: {
|
2020-12-25 17:47:36 -08:00
|
|
|
title: this.$ts.customEmojis,
|
2021-04-20 07:22:59 -07:00
|
|
|
icon: 'fas fa-laugh',
|
2020-10-17 04:12:00 -07:00
|
|
|
action: {
|
2021-04-20 07:22:59 -07:00
|
|
|
icon: 'fas fa-plus',
|
2020-10-17 04:12:00 -07:00
|
|
|
handler: this.add
|
|
|
|
}
|
|
|
|
},
|
|
|
|
tab: 'local',
|
|
|
|
query: null,
|
|
|
|
queryRemote: null,
|
2020-01-29 11:37:25 -08:00
|
|
|
host: '',
|
|
|
|
pagination: {
|
|
|
|
endpoint: 'admin/emoji/list',
|
2020-11-02 17:54:41 -08:00
|
|
|
limit: 30,
|
2020-10-17 04:12:00 -07:00
|
|
|
params: computed(() => ({
|
|
|
|
query: (this.query && this.query !== '') ? this.query : null
|
|
|
|
}))
|
2020-01-29 11:37:25 -08:00
|
|
|
},
|
|
|
|
remotePagination: {
|
|
|
|
endpoint: 'admin/emoji/list-remote',
|
2020-11-02 17:54:41 -08:00
|
|
|
limit: 30,
|
2020-10-17 04:12:00 -07:00
|
|
|
params: computed(() => ({
|
|
|
|
query: (this.queryRemote && this.queryRemote !== '') ? this.queryRemote : null,
|
|
|
|
host: (this.host && this.host !== '') ? this.host : null
|
|
|
|
}))
|
2020-01-29 11:37:25 -08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-04-22 06:29:33 -07:00
|
|
|
async mounted() {
|
|
|
|
this.$emit('info', this[symbols.PAGE_INFO]);
|
|
|
|
},
|
|
|
|
|
2020-01-29 11:37:25 -08:00
|
|
|
methods: {
|
2020-02-13 08:09:39 -08:00
|
|
|
async add(e) {
|
2020-10-17 04:12:00 -07:00
|
|
|
const files = await selectFile(e.currentTarget || e.target, null, true);
|
2020-01-29 11:37:25 -08:00
|
|
|
|
2020-10-17 18:11:34 -07:00
|
|
|
const promise = Promise.all(files.map(file => os.api('admin/emoji/add', {
|
2020-02-13 08:09:39 -08:00
|
|
|
fileId: file.id,
|
2020-10-17 18:11:34 -07:00
|
|
|
})));
|
|
|
|
promise.then(() => {
|
2020-01-29 11:37:25 -08:00
|
|
|
this.$refs.emojis.reload();
|
|
|
|
});
|
2020-10-17 18:11:34 -07:00
|
|
|
os.promiseDialog(promise);
|
2020-01-29 11:37:25 -08:00
|
|
|
},
|
|
|
|
|
2020-11-02 22:22:55 -08:00
|
|
|
edit(emoji) {
|
|
|
|
os.popup(import('./emoji-edit-dialog.vue'), {
|
2020-10-17 04:12:00 -07: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 08:09:39 -08:00
|
|
|
},
|
|
|
|
|
2020-10-17 04:12:00 -07:00
|
|
|
im(emoji) {
|
|
|
|
os.apiWithDialog('admin/emoji/copy', {
|
|
|
|
emojiId: emoji.id,
|
2020-01-29 11:37:25 -08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-10-17 04:12:00 -07:00
|
|
|
remoteMenu(emoji, ev) {
|
|
|
|
os.modalMenu([{
|
|
|
|
type: 'label',
|
|
|
|
text: ':' + emoji.name + ':',
|
|
|
|
}, {
|
2020-12-25 17:47:36 -08:00
|
|
|
text: this.$ts.import,
|
2021-04-20 07:22:59 -07:00
|
|
|
icon: 'fas fa-plus',
|
2020-10-17 04:12:00 -07:00
|
|
|
action: () => { this.im(emoji) }
|
|
|
|
}], ev.currentTarget || ev.target);
|
|
|
|
}
|
2020-01-29 11:37:25 -08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-04-22 06:29:33 -07: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 11:37:25 -08:00
|
|
|
|
2021-04-22 06:29:33 -07:00
|
|
|
> .img {
|
|
|
|
width: 42px;
|
|
|
|
height: 42px;
|
|
|
|
}
|
2020-01-29 11:37:25 -08:00
|
|
|
|
2021-04-22 06:29:33 -07:00
|
|
|
> .body {
|
|
|
|
padding: 0 0 0 8px;
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
2020-01-29 11:37:25 -08:00
|
|
|
|
2021-04-22 06:29:33 -07:00
|
|
|
> .name {
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
2020-02-13 08:09:39 -08:00
|
|
|
|
2021-04-22 06:29:33 -07:00
|
|
|
> .info {
|
|
|
|
opacity: 0.5;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
overflow: hidden;
|
2020-01-29 11:37:25 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-04-22 06:29:33 -07:00
|
|
|
}
|
2020-01-29 11:37:25 -08:00
|
|
|
|
2021-04-22 06:29:33 -07: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 04:12:00 -07:00
|
|
|
|
2021-04-22 06:29:33 -07:00
|
|
|
> .img {
|
|
|
|
width: 32px;
|
|
|
|
height: 32px;
|
|
|
|
}
|
2020-01-29 11:37:25 -08:00
|
|
|
|
2021-04-22 06:29:33 -07:00
|
|
|
> .body {
|
|
|
|
padding: 0 0 0 8px;
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
2020-01-29 11:37:25 -08:00
|
|
|
|
2021-04-22 06:29:33 -07:00
|
|
|
> .name {
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
overflow: hidden;
|
2020-01-29 11:37:25 -08:00
|
|
|
}
|
|
|
|
|
2021-04-22 06:29:33 -07:00
|
|
|
> .info {
|
|
|
|
opacity: 0.5;
|
|
|
|
font-size: 90%;
|
|
|
|
text-overflow: ellipsis;
|
2021-03-02 05:57:16 -08:00
|
|
|
overflow: hidden;
|
2020-01-29 11:37:25 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|