gancio-upstream/pages/event/followMe.vue

63 lines
1.6 KiB
Vue
Raw Normal View History

2019-11-06 11:33:14 +01:00
<template lang='pug'>
div
2019-12-04 01:20:31 +01:00
p(v-html="$t('event.follow_me_description', { title: settings.title, account: `@${settings.instance_name}@${domain}`})")
2020-02-05 00:45:36 +01:00
el-input(v-model='instance_hostname' ref='instance')
2019-11-06 11:33:14 +01:00
a(slot='append' :href='link' target='_blank')
el-button(:disabled='(!couldGo || !proceed)' plain type="primary" icon='el-icon-document') {{$t("common.follow")}}
p.mt-2 <img class='instance_thumb' :src="instance.thumbnail"/> {{instance.title}}
</template>
<script>
import { mapState } from 'vuex'
import debounce from 'lodash/debounce'
import url from 'url'
export default {
2020-01-27 00:47:03 +01:00
name: 'EmbedEvent',
2019-11-06 11:33:14 +01:00
data () {
return {
instance_hostname: '',
proceed: false,
instance: {},
get_instance_info: debounce(this.getInstanceInfo, 500)
}
},
2020-01-27 00:47:03 +01:00
2019-11-06 11:33:14 +01:00
computed: {
...mapState(['settings']),
domain () {
const URL = url.parse(this.settings.baseurl)
return URL.hostname
},
couldGo () {
2020-02-05 00:45:36 +01:00
console.error(this.instance_hostname)
2019-11-06 11:33:14 +01:00
// check if is mastodon
this.get_instance_info()
return true
},
link () {
// check if exists
2019-12-04 01:20:31 +01:00
return `https://${this.instance_hostname}/authorize_interaction?uri=${this.settings.instance_name}@${this.domain}`
2019-11-06 11:33:14 +01:00
}
2020-01-27 00:47:03 +01:00
},
methods: {
getInstanceInfo () {
const instance_url = `https://${this.instance_hostname}/api/v1/instance`
this.$axios.$get(instance_url)
.then(ret => {
this.instance = ret
this.proceed = true
})
.catch(e => {
this.proceed = false
})
}
2019-11-06 11:33:14 +01:00
}
}
</script>
<style lang="less">
.instance_thumb {
height: 20px;
}
2020-01-27 00:47:03 +01:00
</style>