test with trusted instances

This commit is contained in:
les 2020-03-14 18:45:20 +01:00
parent 366c5992f6
commit 2818930089
3 changed files with 58 additions and 9 deletions

View file

@ -15,6 +15,15 @@
i.el-icon-share
span.hidden-xs-only {{$t('common.share')}}
el-submenu(v-if='settings.trusted_instances && settings.trusted_instances.length' index=4)
template(slot='title')
i.el-icon-guide
span.hidden-xs-only {{$t('common.places')}}
el-menu-item(v-for='instance in settings.trusted_instances' :key='instance.name')
a(:href='instance.url' target='_link')
img(:src='`${instance.url}/favicon.ico`')
span.ml-1 {{instance.name}}
el-menu-item(v-if='!$auth.loggedIn' index='/login')
i.el-icon-user
span.hidden-xs-only {{$t('common.login')}}
@ -56,7 +65,30 @@ export default {
logout () {
Message({ showClose: true, message: this.$t('common.logout_ok'), type: 'success' })
this.$auth.logout()
}
},
async createTrustedInstance () {
let url = this.instance_url
if (!url.match(/^https?:\/\//)) {
url = `https://${url}`
}
try {
const instance = await this.$axios.$get(`${url}/.well-known/nodeinfo/2.0`)
const trusted_instance = {
url,
name: instance.metadata.nodeName,
description: instance.metadata.nodeDescription,
place: instance.metadata.placeDescription
}
this.setSetting({ key: 'trusted_instances', value: this.settings.trusted_instances.concat(trusted_instance) })
} catch (e) {
console.error(e)
Message({
showClose: true,
type: 'error',
message: e
})
}
},
}
}
</script>

View file

@ -12,15 +12,37 @@
small.text-secondary {{$t('admin.hide_boost_bookmark_help')}}
div.mt-4 {{$t('admin.instance_name')}}
el-input.w-25(v-model='instance_name' placeholder='Instance name')
el-input(v-model='instance_name' placeholder='Instance name')
small.d-block.text-secondary {{$t('admin.instance_name_help')}} (<u>@{{instance_name}}@{{settings.baseurl|url2host}}</u>)
div.mt-4 {{$t('admin.trusted_instances')}}
el-input(v-model='instance_url')
el-button(slot='append' @click='createTrustedInstance') {{$t('common.send')}}
el-table(:data='settings.trusted_instances')
el-table-column(:label="$t('common.name')")
template(slot-scope='data')
span {{data.row.name}}
el-table-column(:label="$t('common.url')")
template(slot-scope='data')
span {{data.row.url}}
el-table-column(:label="$t('common.action')")
template(slot-scope='data')
el-button(size='mini'
type='danger'
@click='delete_instance(data.row)') {{$t('admin.delete_user')}}
</template>
<script>
import { mapActions, mapState } from 'vuex'
export default {
name: 'Federation',
data () {
return {
instance_url: ''
}
},
computed: {
...mapState(['settings']),
instance_name: {

View file

@ -19,17 +19,12 @@ const defaultSettings = {
recurrent_event_visible: false,
enable_federation: true,
enable_resources: false,
hide_boosts: true
hide_boosts: true,
trusted_instances: []
}
/**
* Settings controller: store instance settings
* Current supported settings:
*
* Usage:
* backend/fediverse/api:
*
* frontend:
*/
const settingsController = {