2019-10-20 14:07:09 +02:00
|
|
|
<template lang="pug">
|
2022-07-01 15:55:09 +02:00
|
|
|
v-container
|
|
|
|
v-card-title {{$t('common.federation')}}
|
|
|
|
v-card-text
|
2024-02-28 22:36:33 +01:00
|
|
|
v-switch.mt-0(v-model='enable_federation'
|
2022-07-01 15:55:09 +02:00
|
|
|
:label="$t('admin.enable_federation')"
|
|
|
|
persistent-hint
|
|
|
|
inset
|
|
|
|
:hint="$t('admin.enable_federation_help')")
|
2019-11-03 00:54:23 +01:00
|
|
|
|
2022-07-01 15:55:09 +02:00
|
|
|
template(v-if='enable_federation')
|
2019-11-03 00:54:23 +01:00
|
|
|
|
2022-07-01 15:55:09 +02:00
|
|
|
v-switch.mt-4(v-model='enable_resources'
|
|
|
|
:label="$t('admin.enable_resources')"
|
|
|
|
:hint="$t('admin.enable_resources_help')"
|
|
|
|
persistent-hint inset)
|
2019-11-03 00:54:23 +01:00
|
|
|
|
2022-07-01 15:55:09 +02:00
|
|
|
v-switch.mt-4(v-model='hide_boosts'
|
|
|
|
:label="$t('admin.hide_boost_bookmark')"
|
|
|
|
:hint="$t('admin.hide_boost_bookmark_help')"
|
|
|
|
persistent-hint inset)
|
2020-02-21 17:33:20 +01:00
|
|
|
|
2022-07-01 15:55:09 +02:00
|
|
|
//- div.mt-4 {{$t('admin.instance_name')}}
|
2023-12-26 13:04:20 +01:00
|
|
|
//- v-text-field.mt-5(v-model='instance_name'
|
|
|
|
//- :label="$t('admin.instance_name')"
|
|
|
|
//- :hint="`${$t('admin.instance_name_help')} ${instance_ap_url}`"
|
|
|
|
//- placeholder='Instance name' persistent-hint
|
|
|
|
//- @blur='save("instance_name", instance_name)')
|
2019-10-30 15:01:15 +01:00
|
|
|
|
2023-12-26 13:04:20 +01:00
|
|
|
//- v-switch.mt-4(v-model='enable_trusted_instances'
|
|
|
|
//- :label="$t('admin.enable_trusted_instances')"
|
|
|
|
//- persistent-hint inset
|
|
|
|
//- :hint="$t('admin.trusted_instances_help')")
|
2020-03-18 10:11:24 +01:00
|
|
|
|
2024-02-28 15:10:16 +01:00
|
|
|
//- //- template(v-if='enable_trusted_instances')
|
|
|
|
//- v-text-field.mt-4(v-model='instance_place'
|
|
|
|
//- :label="$t('admin.instance_place')"
|
|
|
|
//- persistent-hint
|
|
|
|
//- :hint="$t('admin.instance_place_help')"
|
|
|
|
//- @blur='save("instance_place", instance_place)'
|
|
|
|
//- )
|
2020-03-18 10:11:24 +01:00
|
|
|
|
2024-10-31 12:31:21 +01:00
|
|
|
v-combobox.mt-4(v-model='default_fedi_hashtags'
|
|
|
|
:prepend-icon="mdiTagMultiple"
|
|
|
|
:label="$t('admin.default_fedi_hashtags')"
|
|
|
|
persistent-hint inset multiple
|
|
|
|
:delimiters="[',', ';']"
|
|
|
|
chips small-chips deletable-chips
|
|
|
|
:hint="$t('admin.default_fedi_hashtags_help')"
|
|
|
|
@blur='save("default_fedi_hashtags", default_fedi_hashtags)')
|
|
|
|
template(v-slot:selection="{ item, on, attrs, selected, parent }")
|
|
|
|
v-chip(v-bind="attrs" close :close-icon='mdiCloseCircle' @click:close='parent.selectItem(item)'
|
|
|
|
:input-value="selected" label small) {{ item }}
|
|
|
|
|
|
|
|
|
2023-12-26 13:04:20 +01:00
|
|
|
v-text-field.mt-4(v-model='trusted_instances_label'
|
|
|
|
:label="$t('admin.trusted_instances_label')"
|
|
|
|
persistent-hint inset
|
|
|
|
:hint="$t('admin.trusted_instances_label_help')"
|
|
|
|
@blur='save("trusted_instances_label", trusted_instances_label)'
|
|
|
|
)
|
2022-11-21 00:52:02 +01:00
|
|
|
|
2023-12-26 13:04:20 +01:00
|
|
|
v-dialog(v-model='dialogAddInstance' width='500px' :fullscreen='$vuetify.breakpoint.xsOnly')
|
|
|
|
v-card
|
|
|
|
v-card-title {{$t('admin.add_trusted_instance')}}
|
|
|
|
v-card-text
|
|
|
|
v-form(v-model='valid' @submit.prevent='createTrustedInstance' ref='form' lazy-validation)
|
|
|
|
v-text-field.mt-4(v-model='instance_url'
|
|
|
|
persistent-hint
|
|
|
|
:rules="[$validators.required('common.url')]"
|
|
|
|
:loading='loading'
|
|
|
|
:hint="$t('admin.add_trusted_instance')"
|
|
|
|
:label="$t('common.url')")
|
|
|
|
v-card-actions
|
|
|
|
v-spacer
|
|
|
|
v-btn(outlined color='error' @click='dialogAddInstance=false') {{$t('common.cancel')}}
|
|
|
|
v-btn(outlined color='primary' :disabled='!valid || loading' :loading='loading' @click='createTrustedInstance') {{$t('common.ok')}}
|
2020-03-14 18:45:20 +01:00
|
|
|
|
2023-12-26 13:04:20 +01:00
|
|
|
v-btn.mt-4(@click='dialogAddInstance = true' color='primary' text) <v-icon v-text='mdiPlus'></v-icon> {{$t('admin.add_instance')}}
|
|
|
|
v-data-table(
|
2023-12-26 21:04:48 +01:00
|
|
|
v-if='trusted_instances.length'
|
2024-02-28 22:36:33 +01:00
|
|
|
dense
|
2023-12-26 21:04:48 +01:00
|
|
|
:hide-default-footer='trusted_instances.length<10'
|
2023-12-26 13:04:20 +01:00
|
|
|
:footer-props='{ prevIcon: mdiChevronLeft, nextIcon: mdiChevronRight }'
|
|
|
|
:header-props='{ sortIcon: mdiChevronDown }'
|
|
|
|
:headers='headers'
|
2023-12-26 21:04:48 +01:00
|
|
|
:items='trusted_instances')
|
2023-12-28 00:47:31 +01:00
|
|
|
template(v-slot:item.logo="{item}")
|
|
|
|
v-img(height=20 width=20 :src="item?.object?.icon?.url")
|
|
|
|
template(v-slot:item.name="{item}")
|
2024-05-07 22:30:56 +02:00
|
|
|
span {{ item.object.name }}<br/>
|
|
|
|
span @{{ item?.object?.preferredUsername ?? item?.instance?.data?.metadata?.nodeName}}@{{ item.instance.domain }}
|
2023-12-28 00:47:31 +01:00
|
|
|
template(v-slot:item.info="{item}")
|
2024-05-07 22:30:56 +02:00
|
|
|
span {{ item?.object?.summary ?? item?.instance?.data?.metadata?.nodeDescription}}
|
2023-12-28 00:47:31 +01:00
|
|
|
template(v-slot:item.url="{item}")
|
2024-05-07 22:30:56 +02:00
|
|
|
a(:href='item.object.url') {{ item.object.url }}
|
2024-02-28 22:36:33 +01:00
|
|
|
template(v-slot:item.following="{ item }")
|
|
|
|
v-switch(:input-value='item.following' :disabled='item.loading' :loading="item.loading === true" @change="() => toggleFollowing(item)" inset hide-details)
|
|
|
|
template(v-slot:item.follower="{item}")
|
2023-12-28 00:47:31 +01:00
|
|
|
v-icon(v-if='item.following' v-text='mdiDownload')
|
|
|
|
v-icon(v-if='item.follower' v-text='mdiUpload')
|
|
|
|
|
2024-02-28 22:36:33 +01:00
|
|
|
template(v-slot:item.actions="{item}")
|
2023-12-26 13:04:20 +01:00
|
|
|
v-btn(icon @click='deleteInstance(item)' color='error')
|
|
|
|
v-icon(v-text='mdiDeleteForever')
|
2024-02-28 22:36:33 +01:00
|
|
|
|
|
|
|
v-card-title Stats
|
|
|
|
v-card-text
|
|
|
|
span {{$t('admin.stats', stats)}}
|
2020-03-14 18:45:20 +01:00
|
|
|
|
2019-10-20 14:07:09 +02:00
|
|
|
</template>
|
|
|
|
<script>
|
2020-02-05 00:41:23 +01:00
|
|
|
import { mapActions, mapState } from 'vuex'
|
2024-10-31 12:31:21 +01:00
|
|
|
import { mdiDeleteForever, mdiPlus, mdiChevronLeft, mdiChevronRight, mdiChevronDown, mdiDownload, mdiUpload, mdiTagMultiple, mdiCloseCircle } from '@mdi/js'
|
2019-12-04 01:20:31 +01:00
|
|
|
|
2019-10-20 14:07:09 +02:00
|
|
|
export default {
|
|
|
|
name: 'Federation',
|
2020-07-25 21:41:22 +02:00
|
|
|
data ({ $store, $options }) {
|
2020-03-14 18:45:20 +01:00
|
|
|
return {
|
2024-10-31 12:31:21 +01:00
|
|
|
mdiDeleteForever, mdiPlus, mdiChevronLeft, mdiChevronRight, mdiChevronDown, mdiDownload, mdiUpload, mdiCloseCircle, mdiTagMultiple,
|
2020-03-18 10:11:24 +01:00
|
|
|
instance_url: '',
|
|
|
|
instance_name: $store.state.settings.instance_name,
|
2022-11-21 00:52:02 +01:00
|
|
|
trusted_instances_label: $store.state.settings.trusted_instances_label,
|
2020-07-28 12:24:39 +02:00
|
|
|
url2host: $options.filters.url2host,
|
|
|
|
dialogAddInstance: false,
|
2024-02-28 22:36:33 +01:00
|
|
|
stats: {},
|
2021-06-04 12:45:59 +02:00
|
|
|
loading: false,
|
2023-12-26 21:04:48 +01:00
|
|
|
trusted_instances: [],
|
2024-02-28 22:36:33 +01:00
|
|
|
loading_instances: {},
|
2020-08-05 17:29:15 +02:00
|
|
|
valid: false,
|
2020-07-28 12:24:39 +02:00
|
|
|
headers: [
|
2023-12-28 00:47:31 +01:00
|
|
|
{ value: 'logo', text: 'Logo', width: 60, sortable: false },
|
|
|
|
{ value: 'name', text: 'Name' },
|
|
|
|
{ value: 'info', text: 'Info' },
|
|
|
|
{ value: 'url', text: 'URL' },
|
2024-02-28 22:36:33 +01:00
|
|
|
{ value: 'following', text: 'Following' },
|
|
|
|
{ value: 'follower', text: 'Follower' },
|
2020-07-28 12:24:39 +02:00
|
|
|
{ value: 'actions', text: 'Actions', align: 'right' }
|
|
|
|
]
|
2020-03-14 18:45:20 +01:00
|
|
|
}
|
|
|
|
},
|
2023-11-09 16:54:24 +01:00
|
|
|
async fetch() {
|
2024-02-28 22:36:33 +01:00
|
|
|
this.stats = await this.$axios.$get('/instances/stats')
|
|
|
|
const trusted_instances = await this.$axios.$get('/instances/trusted')
|
|
|
|
this.trusted_instances = trusted_instances.map(t => {
|
|
|
|
t.loading = false
|
|
|
|
return t
|
|
|
|
})
|
2023-11-09 16:54:24 +01:00
|
|
|
},
|
2019-10-20 14:07:09 +02:00
|
|
|
computed: {
|
|
|
|
...mapState(['settings']),
|
|
|
|
enable_federation: {
|
|
|
|
get () { return this.settings.enable_federation },
|
|
|
|
set (value) { this.setSetting({ key: 'enable_federation', value }) }
|
|
|
|
},
|
2019-12-04 01:20:31 +01:00
|
|
|
enable_resources: {
|
|
|
|
get () { return this.settings.enable_resources },
|
|
|
|
set (value) { this.setSetting({ key: 'enable_resources', value }) }
|
2019-10-22 01:01:41 +02:00
|
|
|
},
|
2024-10-31 12:31:21 +01:00
|
|
|
default_fedi_hashtags: {
|
|
|
|
get () { return this.settings.default_fedi_hashtags },
|
|
|
|
set (value) { this.setSetting({ key: 'default_fedi_hashtags', value }) }
|
|
|
|
},
|
2019-12-04 01:20:31 +01:00
|
|
|
hide_boosts: {
|
|
|
|
get () { return this.settings.hide_boosts },
|
|
|
|
set (value) { this.setSetting({ key: 'hide_boosts', value }) }
|
2020-03-18 10:11:24 +01:00
|
|
|
},
|
|
|
|
enable_trusted_instances: {
|
|
|
|
get () { return this.settings.enable_trusted_instances },
|
|
|
|
set (value) { this.setSetting({ key: 'enable_trusted_instances', value }) }
|
2020-09-05 01:21:47 +02:00
|
|
|
},
|
|
|
|
instance_ap_url () {
|
|
|
|
const instance_url = this.settings.baseurl.match(/^https?:\/\/(.[^/:]+)/i)[1]
|
|
|
|
return `(@${this.instance_name}@${instance_url})`
|
2019-10-28 17:33:20 +01:00
|
|
|
}
|
2020-02-05 00:41:23 +01:00
|
|
|
},
|
2020-02-21 17:33:20 +01:00
|
|
|
methods: {
|
|
|
|
...mapActions(['setSetting']),
|
2020-03-18 10:11:24 +01:00
|
|
|
async createTrustedInstance () {
|
2020-11-17 00:31:55 +01:00
|
|
|
if (!this.$refs.form.validate()) { return }
|
2021-06-04 12:45:59 +02:00
|
|
|
this.loading = true
|
2020-03-18 10:11:24 +01:00
|
|
|
try {
|
2022-05-03 17:23:48 +02:00
|
|
|
this.instance_url = this.instance_url.replace(/\/$/, '')
|
2023-12-26 21:04:48 +01:00
|
|
|
await this.$axios.$post('/instances/add_trust', { url: this.instance_url })
|
2020-11-17 00:31:55 +01:00
|
|
|
this.$refs.form.reset()
|
2023-11-20 23:15:28 +01:00
|
|
|
this.$fetch()
|
2020-11-17 00:31:55 +01:00
|
|
|
this.dialogAddInstance = false
|
2023-11-20 23:15:28 +01:00
|
|
|
this.$root.$emit('update_friendly_instances')
|
2020-03-18 10:11:24 +01:00
|
|
|
} catch (e) {
|
2020-10-07 11:12:13 +02:00
|
|
|
this.$root.$message(e, { color: 'error' })
|
2020-03-18 10:11:24 +01:00
|
|
|
}
|
2021-06-04 12:45:59 +02:00
|
|
|
this.loading = false
|
2020-03-18 10:11:24 +01:00
|
|
|
},
|
2020-07-28 12:24:39 +02:00
|
|
|
async deleteInstance (instance) {
|
2020-10-07 11:12:13 +02:00
|
|
|
const ret = await this.$root.$confirm('admin.delete_trusted_instance_confirm')
|
2020-07-28 12:24:39 +02:00
|
|
|
if (!ret) { return }
|
2023-11-20 23:15:28 +01:00
|
|
|
try {
|
2023-12-26 21:04:48 +01:00
|
|
|
await this.$axios.$delete('/instances/trust', { params: { ap_id: instance.ap_id }})
|
2023-11-20 23:15:28 +01:00
|
|
|
this.$fetch()
|
|
|
|
this.$root.$emit('update_friendly_instances')
|
|
|
|
this.$root.$message('admin.instance_removed', { color: 'success' })
|
|
|
|
} catch (e) {
|
|
|
|
this.$root.$message(e, { color: 'error' })
|
|
|
|
}
|
2020-03-18 10:11:24 +01:00
|
|
|
},
|
2024-02-28 22:36:33 +01:00
|
|
|
async toggleFollowing (instance) {
|
|
|
|
try {
|
|
|
|
instance.loading = true
|
|
|
|
await this.$axios.$put('/instances/follow', { ap_id: instance.ap_id })
|
|
|
|
this.$root.$message('common.ok', { color: 'success' })
|
|
|
|
} catch (e) {
|
|
|
|
this.$root.$message(e, { color: 'error' })
|
|
|
|
}
|
|
|
|
instance.loading = false
|
|
|
|
this.$fetch()
|
|
|
|
},
|
2020-02-21 17:33:20 +01:00
|
|
|
save (key, value) {
|
|
|
|
if (this.settings[key] !== value) {
|
|
|
|
this.setSetting({ key, value })
|
|
|
|
}
|
2020-03-02 15:36:11 +01:00
|
|
|
}
|
2020-02-21 17:33:20 +01:00
|
|
|
}
|
2019-10-20 14:07:09 +02:00
|
|
|
}
|
2019-10-28 17:33:20 +01:00
|
|
|
</script>
|