2020-01-29 21:37:25 +02:00
|
|
|
<template>
|
2020-01-30 04:10:42 +02:00
|
|
|
<div class="shaynizk _card">
|
2020-01-29 21:37:25 +02:00
|
|
|
<div class="_title" v-if="antenna.name">{{ antenna.name }}</div>
|
|
|
|
<div class="_content body">
|
2021-08-06 16:29:19 +03:00
|
|
|
<MkInput v-model="name">
|
|
|
|
<template #label>{{ $ts.name }}</template>
|
2020-10-17 14:12:00 +03:00
|
|
|
</MkInput>
|
2021-08-06 16:29:19 +03:00
|
|
|
<MkSelect v-model="src">
|
2020-12-26 03:47:36 +02: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 14:12:00 +03:00
|
|
|
</MkSelect>
|
2021-08-06 16:29:19 +03:00
|
|
|
<MkSelect v-model="userListId" v-if="src === 'list'">
|
2020-12-26 03:47:36 +02:00
|
|
|
<template #label>{{ $ts.userList }}</template>
|
2020-01-29 21:37:25 +02:00
|
|
|
<option v-for="list in userLists" :value="list.id" :key="list.id">{{ list.name }}</option>
|
2020-10-17 14:12:00 +03:00
|
|
|
</MkSelect>
|
2021-08-06 16:29:19 +03:00
|
|
|
<MkSelect v-model="userGroupId" v-else-if="src === 'group'">
|
2020-12-26 03:47:36 +02:00
|
|
|
<template #label>{{ $ts.userGroup }}</template>
|
2020-02-14 18:03:59 +02:00
|
|
|
<option v-for="group in userGroups" :value="group.id" :key="group.id">{{ group.name }}</option>
|
2020-10-17 14:12:00 +03:00
|
|
|
</MkSelect>
|
2021-08-06 16:29:19 +03:00
|
|
|
<MkTextarea v-model="users" v-else-if="src === 'users'">
|
|
|
|
<template #label>{{ $ts.users }}</template>
|
|
|
|
<template #caption>{{ $ts.antennaUsersDescription }} <button class="_textButton" @click="addUser">{{ $ts.addUser }}</button></template>
|
2020-10-17 14:12:00 +03:00
|
|
|
</MkTextarea>
|
2021-08-06 16:29:19 +03:00
|
|
|
<MkSwitch v-model="withReplies">{{ $ts.withReplies }}</MkSwitch>
|
|
|
|
<MkTextarea v-model="keywords">
|
|
|
|
<template #label>{{ $ts.antennaKeywords }}</template>
|
|
|
|
<template #caption>{{ $ts.antennaKeywordsDescription }}</template>
|
2020-10-17 14:12:00 +03:00
|
|
|
</MkTextarea>
|
2021-08-06 16:29:19 +03:00
|
|
|
<MkTextarea v-model="excludeKeywords">
|
|
|
|
<template #label>{{ $ts.antennaExcludeKeywords }}</template>
|
|
|
|
<template #caption>{{ $ts.antennaKeywordsDescription }}</template>
|
2020-10-17 14:12:00 +03:00
|
|
|
</MkTextarea>
|
2021-08-06 16:29:19 +03:00
|
|
|
<MkSwitch v-model="caseSensitive">{{ $ts.caseSensitive }}</MkSwitch>
|
|
|
|
<MkSwitch v-model="withFile">{{ $ts.withFileAntenna }}</MkSwitch>
|
|
|
|
<MkSwitch v-model="notify">{{ $ts.notifyAntenna }}</MkSwitch>
|
2020-01-29 21:37:25 +02:00
|
|
|
</div>
|
|
|
|
<div class="_footer">
|
2021-04-20 17:22:59 +03: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-29 21:37:25 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 14:12:00 +03:00
|
|
|
import { 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 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 14:45:32 +03:00
|
|
|
import { getAcct } from '@/misc/acct';
|
2021-03-23 10:30:14 +02:00
|
|
|
import * as os from '@client/os';
|
2020-01-29 21:37:25 +02:00
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
export default defineComponent({
|
2020-01-29 21:37:25 +02:00
|
|
|
components: {
|
|
|
|
MkButton, MkInput, MkTextarea, MkSelect, MkSwitch
|
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
antenna: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
name: '',
|
|
|
|
src: '',
|
|
|
|
userListId: null,
|
2020-02-14 18:03:59 +02:00
|
|
|
userGroupId: null,
|
2020-01-29 21:37:25 +02:00
|
|
|
users: '',
|
|
|
|
keywords: '',
|
2020-02-20 17:28:45 +02:00
|
|
|
excludeKeywords: '',
|
2020-01-29 21:37:25 +02:00
|
|
|
caseSensitive: false,
|
|
|
|
withReplies: false,
|
|
|
|
withFile: false,
|
|
|
|
notify: false,
|
|
|
|
userLists: null,
|
2020-02-14 18:03:59 +02:00
|
|
|
userGroups: null,
|
2020-01-29 21:37:25 +02:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
async src() {
|
|
|
|
if (this.src === 'list' && this.userLists === null) {
|
2020-10-17 14:12:00 +03:00
|
|
|
this.userLists = await os.api('users/lists/list');
|
2020-01-29 21:37:25 +02:00
|
|
|
}
|
2020-02-14 18:03:59 +02:00
|
|
|
|
|
|
|
if (this.src === 'group' && this.userGroups === null) {
|
2020-10-17 14:12:00 +03:00
|
|
|
const groups1 = await os.api('users/groups/owned');
|
|
|
|
const groups2 = await os.api('users/groups/joined');
|
2020-02-14 18:03:59 +02:00
|
|
|
|
|
|
|
this.userGroups = [...groups1, ...groups2];
|
|
|
|
}
|
2020-01-29 21:37:25 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
this.name = this.antenna.name;
|
|
|
|
this.src = this.antenna.src;
|
|
|
|
this.userListId = this.antenna.userListId;
|
2020-02-14 18:03:59 +02:00
|
|
|
this.userGroupId = this.antenna.userGroupId;
|
2020-01-29 21:37:25 +02:00
|
|
|
this.users = this.antenna.users.join('\n');
|
|
|
|
this.keywords = this.antenna.keywords.map(x => x.join(' ')).join('\n');
|
2020-02-20 17:28:45 +02:00
|
|
|
this.excludeKeywords = this.antenna.excludeKeywords.map(x => x.join(' ')).join('\n');
|
2020-01-29 21:37:25 +02: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 14:12:00 +03:00
|
|
|
await os.api('antennas/create', {
|
2020-01-29 21:37:25 +02:00
|
|
|
name: this.name,
|
|
|
|
src: this.src,
|
|
|
|
userListId: this.userListId,
|
2020-02-14 18:03:59 +02:00
|
|
|
userGroupId: this.userGroupId,
|
2020-01-29 21:37:25 +02: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-20 17:28:45 +02: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-29 21:37:25 +02:00
|
|
|
});
|
|
|
|
this.$emit('created');
|
|
|
|
} else {
|
2020-10-17 14:12:00 +03:00
|
|
|
await os.api('antennas/update', {
|
2020-01-29 21:37:25 +02:00
|
|
|
antennaId: this.antenna.id,
|
|
|
|
name: this.name,
|
|
|
|
src: this.src,
|
|
|
|
userListId: this.userListId,
|
2020-02-14 18:03:59 +02:00
|
|
|
userGroupId: this.userGroupId,
|
2020-01-29 21:37:25 +02: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-20 17:28:45 +02: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-29 21:37:25 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
os.success();
|
2020-01-29 21:37:25 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
async deleteAntenna() {
|
2020-10-17 14:12:00 +03:00
|
|
|
const { canceled } = await os.dialog({
|
2020-01-29 21:37:25 +02:00
|
|
|
type: 'warning',
|
|
|
|
text: this.$t('removeAreYouSure', { x: this.antenna.name }),
|
|
|
|
showCancelButton: true
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
await os.api('antennas/delete', {
|
2020-01-29 21:37:25 +02:00
|
|
|
antennaId: this.antenna.id,
|
|
|
|
});
|
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
os.success();
|
2020-01-29 21:37:25 +02:00
|
|
|
this.$emit('deleted');
|
|
|
|
},
|
|
|
|
|
|
|
|
addUser() {
|
2020-10-17 14:12:00 +03:00
|
|
|
os.selectUser().then(user => {
|
2020-01-29 21:37:25 +02: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>
|