2020-01-30 04:37:25 +09:00
|
|
|
<template>
|
2021-08-07 17:55:16 +09:00
|
|
|
<div class="shaynizk">
|
|
|
|
<div class="form">
|
2021-10-12 21:46:18 +09:00
|
|
|
<MkInput v-model="name" class="_formBlock">
|
2021-08-06 22:29:19 +09:00
|
|
|
<template #label>{{ $ts.name }}</template>
|
2020-10-17 20:12:00 +09:00
|
|
|
</MkInput>
|
2021-10-12 21:46:18 +09:00
|
|
|
<MkSelect v-model="src" class="_formBlock">
|
2020-12-26 10:47:36 +09:00
|
|
|
<template #label>{{ $ts.antennaSource }}</template>
|
|
|
|
<option value="all">{{ $ts._antennaSources.all }}</option>
|
2022-03-22 00:07:43 +09:00
|
|
|
<!--<option value="home">{{ $ts._antennaSources.homeTimeline }}</option>-->
|
2020-12-26 10:47:36 +09:00
|
|
|
<option value="users">{{ $ts._antennaSources.users }}</option>
|
2022-03-22 00:07:43 +09:00
|
|
|
<!--<option value="list">{{ $ts._antennaSources.userList }}</option>-->
|
|
|
|
<!--<option value="group">{{ $ts._antennaSources.userGroup }}</option>-->
|
2020-10-17 20:12:00 +09:00
|
|
|
</MkSelect>
|
2021-11-19 19:36:12 +09:00
|
|
|
<MkSelect v-if="src === 'list'" v-model="userListId" class="_formBlock">
|
2020-12-26 10:47:36 +09:00
|
|
|
<template #label>{{ $ts.userList }}</template>
|
2021-11-19 19:36:12 +09:00
|
|
|
<option v-for="list in userLists" :key="list.id" :value="list.id">{{ list.name }}</option>
|
2020-10-17 20:12:00 +09:00
|
|
|
</MkSelect>
|
2021-11-19 19:36:12 +09:00
|
|
|
<MkSelect v-else-if="src === 'group'" v-model="userGroupId" class="_formBlock">
|
2020-12-26 10:47:36 +09:00
|
|
|
<template #label>{{ $ts.userGroup }}</template>
|
2021-11-19 19:36:12 +09:00
|
|
|
<option v-for="group in userGroups" :key="group.id" :value="group.id">{{ group.name }}</option>
|
2020-10-17 20:12:00 +09:00
|
|
|
</MkSelect>
|
2021-11-19 19:36:12 +09:00
|
|
|
<MkTextarea v-else-if="src === 'users'" v-model="users" class="_formBlock">
|
2021-08-06 22:29:19 +09:00
|
|
|
<template #label>{{ $ts.users }}</template>
|
|
|
|
<template #caption>{{ $ts.antennaUsersDescription }} <button class="_textButton" @click="addUser">{{ $ts.addUser }}</button></template>
|
2020-10-17 20:12:00 +09:00
|
|
|
</MkTextarea>
|
2021-10-12 21:46:18 +09:00
|
|
|
<MkSwitch v-model="withReplies" class="_formBlock">{{ $ts.withReplies }}</MkSwitch>
|
|
|
|
<MkTextarea v-model="keywords" class="_formBlock">
|
2021-08-06 22:29:19 +09:00
|
|
|
<template #label>{{ $ts.antennaKeywords }}</template>
|
|
|
|
<template #caption>{{ $ts.antennaKeywordsDescription }}</template>
|
2020-10-17 20:12:00 +09:00
|
|
|
</MkTextarea>
|
2021-10-12 21:46:18 +09:00
|
|
|
<MkTextarea v-model="excludeKeywords" class="_formBlock">
|
2021-08-06 22:29:19 +09:00
|
|
|
<template #label>{{ $ts.antennaExcludeKeywords }}</template>
|
|
|
|
<template #caption>{{ $ts.antennaKeywordsDescription }}</template>
|
2020-10-17 20:12:00 +09:00
|
|
|
</MkTextarea>
|
2021-10-12 21:46:18 +09: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-30 04:37:25 +09:00
|
|
|
</div>
|
2021-08-07 17:55:16 +09:00
|
|
|
<div class="actions">
|
2021-11-19 19:36:12 +09:00
|
|
|
<MkButton inline primary @click="saveAntenna()"><i class="fas fa-save"></i> {{ $ts.save }}</MkButton>
|
|
|
|
<MkButton v-if="antenna.id != null" inline danger @click="deleteAntenna()"><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-11-12 02:02:25 +09: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-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) {
|
2021-08-07 17:55:16 +09:00
|
|
|
await os.apiWithDialog('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 {
|
2021-08-07 17:55:16 +09:00
|
|
|
await os.apiWithDialog('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
|
|
|
});
|
2021-08-07 17:55:16 +09:00
|
|
|
this.$emit('updated');
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
async deleteAntenna() {
|
2021-11-18 18:45:58 +09:00
|
|
|
const { canceled } = await os.confirm({
|
2020-01-30 04:37:25 +09:00
|
|
|
type: 'warning',
|
|
|
|
text: this.$t('removeAreYouSure', { x: this.antenna.name }),
|
|
|
|
});
|
|
|
|
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();
|
2021-11-12 02:02:25 +09:00
|
|
|
this.users += '\n@' + Acct.toString(user);
|
2020-01-30 04:37:25 +09:00
|
|
|
this.users = this.users.trim();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.shaynizk {
|
2021-08-07 17:55:16 +09:00
|
|
|
> .form {
|
|
|
|
padding: 32px;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .actions {
|
|
|
|
padding: 24px 32px;
|
|
|
|
border-top: solid 0.5px var(--divider);
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|