2020-01-30 04:37:25 +09:00
|
|
|
<template>
|
2020-01-30 11:10:42 +09:00
|
|
|
<div class="shaynizk _card">
|
2020-01-30 04:37:25 +09:00
|
|
|
<div class="_title" v-if="antenna.name">{{ antenna.name }}</div>
|
|
|
|
<div class="_content body">
|
2020-10-17 20:12:00 +09:00
|
|
|
<MkInput v-model:value="name">
|
2020-12-26 10:47:36 +09:00
|
|
|
<span>{{ $ts.name }}</span>
|
2020-10-17 20:12:00 +09:00
|
|
|
</MkInput>
|
|
|
|
<MkSelect v-model:value="src">
|
2020-12-26 10:47:36 +09:00
|
|
|
<template #label>{{ $ts.antennaSource }}</template>
|
|
|
|
<option value="all">{{ $ts._antennaSources.all }}</option>
|
|
|
|
<option value="home">{{ $ts._antennaSources.homeTimeline }}</option>
|
|
|
|
<option value="users">{{ $ts._antennaSources.users }}</option>
|
|
|
|
<option value="list">{{ $ts._antennaSources.userList }}</option>
|
|
|
|
<option value="group">{{ $ts._antennaSources.userGroup }}</option>
|
2020-10-17 20:12:00 +09:00
|
|
|
</MkSelect>
|
|
|
|
<MkSelect v-model:value="userListId" v-if="src === 'list'">
|
2020-12-26 10:47:36 +09:00
|
|
|
<template #label>{{ $ts.userList }}</template>
|
2020-01-30 04:37:25 +09:00
|
|
|
<option v-for="list in userLists" :value="list.id" :key="list.id">{{ list.name }}</option>
|
2020-10-17 20:12:00 +09:00
|
|
|
</MkSelect>
|
|
|
|
<MkSelect v-model:value="userGroupId" v-else-if="src === 'group'">
|
2020-12-26 10:47:36 +09:00
|
|
|
<template #label>{{ $ts.userGroup }}</template>
|
2020-02-15 01:03:59 +09:00
|
|
|
<option v-for="group in userGroups" :value="group.id" :key="group.id">{{ group.name }}</option>
|
2020-10-17 20:12:00 +09:00
|
|
|
</MkSelect>
|
|
|
|
<MkTextarea v-model:value="users" v-else-if="src === 'users'">
|
2020-12-26 10:47:36 +09:00
|
|
|
<span>{{ $ts.users }}</span>
|
|
|
|
<template #desc>{{ $ts.antennaUsersDescription }} <button class="_textButton" @click="addUser">{{ $ts.addUser }}</button></template>
|
2020-10-17 20:12:00 +09:00
|
|
|
</MkTextarea>
|
2020-12-26 10:47:36 +09:00
|
|
|
<MkSwitch v-model:value="withReplies">{{ $ts.withReplies }}</MkSwitch>
|
2020-10-17 20:12:00 +09:00
|
|
|
<MkTextarea v-model:value="keywords">
|
2020-12-26 10:47:36 +09:00
|
|
|
<span>{{ $ts.antennaKeywords }}</span>
|
|
|
|
<template #desc>{{ $ts.antennaKeywordsDescription }}</template>
|
2020-10-17 20:12:00 +09:00
|
|
|
</MkTextarea>
|
|
|
|
<MkTextarea v-model:value="excludeKeywords">
|
2020-12-26 10:47:36 +09:00
|
|
|
<span>{{ $ts.antennaExcludeKeywords }}</span>
|
|
|
|
<template #desc>{{ $ts.antennaKeywordsDescription }}</template>
|
2020-10-17 20:12:00 +09:00
|
|
|
</MkTextarea>
|
2020-12-26 10:47:36 +09:00
|
|
|
<MkSwitch v-model:value="caseSensitive">{{ $ts.caseSensitive }}</MkSwitch>
|
|
|
|
<MkSwitch v-model:value="withFile">{{ $ts.withFileAntenna }}</MkSwitch>
|
|
|
|
<MkSwitch v-model:value="notify">{{ $ts.notifyAntenna }}</MkSwitch>
|
2020-01-30 04:37:25 +09:00
|
|
|
</div>
|
|
|
|
<div class="_footer">
|
2021-04-20 23:22:59 +09:00
|
|
|
<MkButton inline @click="saveAntenna()" primary><i class="fas fa-save"></i> {{ $ts.save }}</MkButton>
|
|
|
|
<MkButton inline @click="deleteAntenna()" v-if="antenna.id != null"><i class="fas fa-trash"></i> {{ $ts.delete }}</MkButton>
|
2020-01-30 04:37:25 +09:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 20:12:00 +09:00
|
|
|
import { defineComponent } from 'vue';
|
2021-03-23 17:30:14 +09:00
|
|
|
import MkButton from '@client/components/ui/button.vue';
|
|
|
|
import MkInput from '@client/components/ui/input.vue';
|
|
|
|
import MkTextarea from '@client/components/ui/textarea.vue';
|
|
|
|
import MkSelect from '@client/components/ui/select.vue';
|
|
|
|
import MkSwitch from '@client/components/ui/switch.vue';
|
2021-07-15 20:45:32 +09:00
|
|
|
import { getAcct } from '@/misc/acct';
|
2021-03-23 17:30:14 +09:00
|
|
|
import * as os from '@client/os';
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
export default defineComponent({
|
2020-01-30 04:37:25 +09:00
|
|
|
components: {
|
|
|
|
MkButton, MkInput, MkTextarea, MkSelect, MkSwitch
|
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
antenna: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
name: '',
|
|
|
|
src: '',
|
|
|
|
userListId: null,
|
2020-02-15 01:03:59 +09:00
|
|
|
userGroupId: null,
|
2020-01-30 04:37:25 +09:00
|
|
|
users: '',
|
|
|
|
keywords: '',
|
2020-02-21 00:28:45 +09:00
|
|
|
excludeKeywords: '',
|
2020-01-30 04:37:25 +09:00
|
|
|
caseSensitive: false,
|
|
|
|
withReplies: false,
|
|
|
|
withFile: false,
|
|
|
|
notify: false,
|
|
|
|
userLists: null,
|
2020-02-15 01:03:59 +09:00
|
|
|
userGroups: null,
|
2020-01-30 04:37:25 +09:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
async src() {
|
|
|
|
if (this.src === 'list' && this.userLists === null) {
|
2020-10-17 20:12:00 +09:00
|
|
|
this.userLists = await os.api('users/lists/list');
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
2020-02-15 01:03:59 +09:00
|
|
|
|
|
|
|
if (this.src === 'group' && this.userGroups === null) {
|
2020-10-17 20:12:00 +09:00
|
|
|
const groups1 = await os.api('users/groups/owned');
|
|
|
|
const groups2 = await os.api('users/groups/joined');
|
2020-02-15 01:03:59 +09:00
|
|
|
|
|
|
|
this.userGroups = [...groups1, ...groups2];
|
|
|
|
}
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
this.name = this.antenna.name;
|
|
|
|
this.src = this.antenna.src;
|
|
|
|
this.userListId = this.antenna.userListId;
|
2020-02-15 01:03:59 +09:00
|
|
|
this.userGroupId = this.antenna.userGroupId;
|
2020-01-30 04:37:25 +09:00
|
|
|
this.users = this.antenna.users.join('\n');
|
|
|
|
this.keywords = this.antenna.keywords.map(x => x.join(' ')).join('\n');
|
2020-02-21 00:28:45 +09:00
|
|
|
this.excludeKeywords = this.antenna.excludeKeywords.map(x => x.join(' ')).join('\n');
|
2020-01-30 04:37:25 +09:00
|
|
|
this.caseSensitive = this.antenna.caseSensitive;
|
|
|
|
this.withReplies = this.antenna.withReplies;
|
|
|
|
this.withFile = this.antenna.withFile;
|
|
|
|
this.notify = this.antenna.notify;
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
async saveAntenna() {
|
|
|
|
if (this.antenna.id == null) {
|
2020-10-17 20:12:00 +09:00
|
|
|
await os.api('antennas/create', {
|
2020-01-30 04:37:25 +09:00
|
|
|
name: this.name,
|
|
|
|
src: this.src,
|
|
|
|
userListId: this.userListId,
|
2020-02-15 01:03:59 +09:00
|
|
|
userGroupId: this.userGroupId,
|
2020-01-30 04:37:25 +09:00
|
|
|
withReplies: this.withReplies,
|
|
|
|
withFile: this.withFile,
|
|
|
|
notify: this.notify,
|
|
|
|
caseSensitive: this.caseSensitive,
|
|
|
|
users: this.users.trim().split('\n').map(x => x.trim()),
|
2020-02-21 00:28:45 +09:00
|
|
|
keywords: this.keywords.trim().split('\n').map(x => x.trim().split(' ')),
|
|
|
|
excludeKeywords: this.excludeKeywords.trim().split('\n').map(x => x.trim().split(' ')),
|
2020-01-30 04:37:25 +09:00
|
|
|
});
|
|
|
|
this.$emit('created');
|
|
|
|
} else {
|
2020-10-17 20:12:00 +09:00
|
|
|
await os.api('antennas/update', {
|
2020-01-30 04:37:25 +09:00
|
|
|
antennaId: this.antenna.id,
|
|
|
|
name: this.name,
|
|
|
|
src: this.src,
|
|
|
|
userListId: this.userListId,
|
2020-02-15 01:03:59 +09:00
|
|
|
userGroupId: this.userGroupId,
|
2020-01-30 04:37:25 +09:00
|
|
|
withReplies: this.withReplies,
|
|
|
|
withFile: this.withFile,
|
|
|
|
notify: this.notify,
|
|
|
|
caseSensitive: this.caseSensitive,
|
|
|
|
users: this.users.trim().split('\n').map(x => x.trim()),
|
2020-02-21 00:28:45 +09:00
|
|
|
keywords: this.keywords.trim().split('\n').map(x => x.trim().split(' ')),
|
|
|
|
excludeKeywords: this.excludeKeywords.trim().split('\n').map(x => x.trim().split(' ')),
|
2020-01-30 04:37:25 +09:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
os.success();
|
2020-01-30 04:37:25 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
async deleteAntenna() {
|
2020-10-17 20:12:00 +09:00
|
|
|
const { canceled } = await os.dialog({
|
2020-01-30 04:37:25 +09:00
|
|
|
type: 'warning',
|
|
|
|
text: this.$t('removeAreYouSure', { x: this.antenna.name }),
|
|
|
|
showCancelButton: true
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
await os.api('antennas/delete', {
|
2020-01-30 04:37:25 +09:00
|
|
|
antennaId: this.antenna.id,
|
|
|
|
});
|
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
os.success();
|
2020-01-30 04:37:25 +09:00
|
|
|
this.$emit('deleted');
|
|
|
|
},
|
|
|
|
|
|
|
|
addUser() {
|
2020-10-17 20:12:00 +09:00
|
|
|
os.selectUser().then(user => {
|
2020-01-30 04:37:25 +09:00
|
|
|
this.users = this.users.trim();
|
|
|
|
this.users += '\n@' + getAcct(user);
|
|
|
|
this.users = this.users.trim();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.shaynizk {
|
|
|
|
> .body {
|
|
|
|
max-height: 250px;
|
|
|
|
overflow: auto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|