2020-01-29 19:37:25 +00:00
|
|
|
<template>
|
2021-08-07 08:55:16 +00:00
|
|
|
<div class="shaynizk">
|
|
|
|
<div class="form">
|
2021-10-12 12:46:18 +00:00
|
|
|
<MkInput v-model="name" class="_formBlock">
|
2021-08-06 13:29:19 +00:00
|
|
|
<template #label>{{ $ts.name }}</template>
|
2020-10-17 11:12:00 +00:00
|
|
|
</MkInput>
|
2021-10-12 12:46:18 +00:00
|
|
|
<MkSelect v-model="src" class="_formBlock">
|
2020-12-26 01:47:36 +00: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 11:12:00 +00:00
|
|
|
</MkSelect>
|
2021-10-12 12:46:18 +00:00
|
|
|
<MkSelect v-model="userListId" v-if="src === 'list'" class="_formBlock">
|
2020-12-26 01:47:36 +00:00
|
|
|
<template #label>{{ $ts.userList }}</template>
|
2020-01-29 19:37:25 +00:00
|
|
|
<option v-for="list in userLists" :value="list.id" :key="list.id">{{ list.name }}</option>
|
2020-10-17 11:12:00 +00:00
|
|
|
</MkSelect>
|
2021-10-12 12:46:18 +00:00
|
|
|
<MkSelect v-model="userGroupId" v-else-if="src === 'group'" class="_formBlock">
|
2020-12-26 01:47:36 +00:00
|
|
|
<template #label>{{ $ts.userGroup }}</template>
|
2020-02-14 16:03:59 +00:00
|
|
|
<option v-for="group in userGroups" :value="group.id" :key="group.id">{{ group.name }}</option>
|
2020-10-17 11:12:00 +00:00
|
|
|
</MkSelect>
|
2021-10-12 12:46:18 +00:00
|
|
|
<MkTextarea v-model="users" v-else-if="src === 'users'" class="_formBlock">
|
2021-08-06 13:29:19 +00:00
|
|
|
<template #label>{{ $ts.users }}</template>
|
|
|
|
<template #caption>{{ $ts.antennaUsersDescription }} <button class="_textButton" @click="addUser">{{ $ts.addUser }}</button></template>
|
2020-10-17 11:12:00 +00:00
|
|
|
</MkTextarea>
|
2021-10-12 12:46:18 +00:00
|
|
|
<MkSwitch v-model="withReplies" class="_formBlock">{{ $ts.withReplies }}</MkSwitch>
|
|
|
|
<MkTextarea v-model="keywords" class="_formBlock">
|
2021-08-06 13:29:19 +00:00
|
|
|
<template #label>{{ $ts.antennaKeywords }}</template>
|
|
|
|
<template #caption>{{ $ts.antennaKeywordsDescription }}</template>
|
2020-10-17 11:12:00 +00:00
|
|
|
</MkTextarea>
|
2021-10-12 12:46:18 +00:00
|
|
|
<MkTextarea v-model="excludeKeywords" class="_formBlock">
|
2021-08-06 13:29:19 +00:00
|
|
|
<template #label>{{ $ts.antennaExcludeKeywords }}</template>
|
|
|
|
<template #caption>{{ $ts.antennaKeywordsDescription }}</template>
|
2020-10-17 11:12:00 +00:00
|
|
|
</MkTextarea>
|
2021-10-12 12:46:18 +00:00
|
|
|
<MkSwitch v-model="caseSensitive" class="_formBlock">{{ $ts.caseSensitive }}</MkSwitch>
|
|
|
|
<MkSwitch v-model="withFile" class="_formBlock">{{ $ts.withFileAntenna }}</MkSwitch>
|
|
|
|
<MkSwitch v-model="notify" class="_formBlock">{{ $ts.notifyAntenna }}</MkSwitch>
|
2020-01-29 19:37:25 +00:00
|
|
|
</div>
|
2021-08-07 08:55:16 +00:00
|
|
|
<div class="actions">
|
2021-04-20 14:22:59 +00:00
|
|
|
<MkButton inline @click="saveAntenna()" primary><i class="fas fa-save"></i> {{ $ts.save }}</MkButton>
|
2021-08-07 08:55:16 +00:00
|
|
|
<MkButton inline @click="deleteAntenna()" v-if="antenna.id != null" danger><i class="fas fa-trash"></i> {{ $ts.delete }}</MkButton>
|
2020-01-29 19:37:25 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 11:12:00 +00:00
|
|
|
import { defineComponent } from 'vue';
|
2021-11-11 17:02:25 +00:00
|
|
|
import MkButton from '@/components/ui/button.vue';
|
|
|
|
import MkInput from '@/components/form/input.vue';
|
|
|
|
import MkTextarea from '@/components/form/textarea.vue';
|
|
|
|
import MkSelect from '@/components/form/select.vue';
|
|
|
|
import MkSwitch from '@/components/form/switch.vue';
|
|
|
|
import * as Acct from 'misskey-js/built/acct';
|
|
|
|
import * as os from '@/os';
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
export default defineComponent({
|
2020-01-29 19:37:25 +00:00
|
|
|
components: {
|
|
|
|
MkButton, MkInput, MkTextarea, MkSelect, MkSwitch
|
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
antenna: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
name: '',
|
|
|
|
src: '',
|
|
|
|
userListId: null,
|
2020-02-14 16:03:59 +00:00
|
|
|
userGroupId: null,
|
2020-01-29 19:37:25 +00:00
|
|
|
users: '',
|
|
|
|
keywords: '',
|
2020-02-20 15:28:45 +00:00
|
|
|
excludeKeywords: '',
|
2020-01-29 19:37:25 +00:00
|
|
|
caseSensitive: false,
|
|
|
|
withReplies: false,
|
|
|
|
withFile: false,
|
|
|
|
notify: false,
|
|
|
|
userLists: null,
|
2020-02-14 16:03:59 +00:00
|
|
|
userGroups: null,
|
2020-01-29 19:37:25 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
async src() {
|
|
|
|
if (this.src === 'list' && this.userLists === null) {
|
2020-10-17 11:12:00 +00:00
|
|
|
this.userLists = await os.api('users/lists/list');
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
2020-02-14 16:03:59 +00:00
|
|
|
|
|
|
|
if (this.src === 'group' && this.userGroups === null) {
|
2020-10-17 11:12:00 +00:00
|
|
|
const groups1 = await os.api('users/groups/owned');
|
|
|
|
const groups2 = await os.api('users/groups/joined');
|
2020-02-14 16:03:59 +00:00
|
|
|
|
|
|
|
this.userGroups = [...groups1, ...groups2];
|
|
|
|
}
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
this.name = this.antenna.name;
|
|
|
|
this.src = this.antenna.src;
|
|
|
|
this.userListId = this.antenna.userListId;
|
2020-02-14 16:03:59 +00:00
|
|
|
this.userGroupId = this.antenna.userGroupId;
|
2020-01-29 19:37:25 +00:00
|
|
|
this.users = this.antenna.users.join('\n');
|
|
|
|
this.keywords = this.antenna.keywords.map(x => x.join(' ')).join('\n');
|
2020-02-20 15:28:45 +00:00
|
|
|
this.excludeKeywords = this.antenna.excludeKeywords.map(x => x.join(' ')).join('\n');
|
2020-01-29 19:37:25 +00: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) {
|
2021-08-07 08:55:16 +00:00
|
|
|
await os.apiWithDialog('antennas/create', {
|
2020-01-29 19:37:25 +00:00
|
|
|
name: this.name,
|
|
|
|
src: this.src,
|
|
|
|
userListId: this.userListId,
|
2020-02-14 16:03:59 +00:00
|
|
|
userGroupId: this.userGroupId,
|
2020-01-29 19:37:25 +00: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 15:28:45 +00: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 19:37:25 +00:00
|
|
|
});
|
|
|
|
this.$emit('created');
|
|
|
|
} else {
|
2021-08-07 08:55:16 +00:00
|
|
|
await os.apiWithDialog('antennas/update', {
|
2020-01-29 19:37:25 +00:00
|
|
|
antennaId: this.antenna.id,
|
|
|
|
name: this.name,
|
|
|
|
src: this.src,
|
|
|
|
userListId: this.userListId,
|
2020-02-14 16:03:59 +00:00
|
|
|
userGroupId: this.userGroupId,
|
2020-01-29 19:37:25 +00: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 15:28:45 +00: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 19:37:25 +00:00
|
|
|
});
|
2021-08-07 08:55:16 +00:00
|
|
|
this.$emit('updated');
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
async deleteAntenna() {
|
2021-11-18 09:45:58 +00:00
|
|
|
const { canceled } = await os.confirm({
|
2020-01-29 19:37:25 +00:00
|
|
|
type: 'warning',
|
|
|
|
text: this.$t('removeAreYouSure', { x: this.antenna.name }),
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
await os.api('antennas/delete', {
|
2020-01-29 19:37:25 +00:00
|
|
|
antennaId: this.antenna.id,
|
|
|
|
});
|
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
os.success();
|
2020-01-29 19:37:25 +00:00
|
|
|
this.$emit('deleted');
|
|
|
|
},
|
|
|
|
|
|
|
|
addUser() {
|
2020-10-17 11:12:00 +00:00
|
|
|
os.selectUser().then(user => {
|
2020-01-29 19:37:25 +00:00
|
|
|
this.users = this.users.trim();
|
2021-11-11 17:02:25 +00:00
|
|
|
this.users += '\n@' + Acct.toString(user);
|
2020-01-29 19:37:25 +00:00
|
|
|
this.users = this.users.trim();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.shaynizk {
|
2021-08-07 08:55:16 +00:00
|
|
|
> .form {
|
|
|
|
padding: 32px;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .actions {
|
|
|
|
padding: 24px 32px;
|
|
|
|
border-top: solid 0.5px var(--divider);
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|