admin-fe/src/views/relays/index.vue

86 lines
2.3 KiB
Vue
Raw Normal View History

2019-10-17 20:59:25 +00:00
<template>
2021-02-06 22:15:31 +00:00
<div v-if="!loading" class="relays-container" data-search="relays">
2020-02-09 16:52:17 +00:00
<div class="follow-relay-container">
<el-input v-model="newRelay" :placeholder="$t('settings.followRelay')" class="follow-relay" @keyup.enter.native="followRelay"/>
<el-button @click.native="followRelay">{{ $t('settings.follow') }}</el-button>
2020-02-09 16:52:17 +00:00
</div>
<el-table :data="relays">
2019-10-17 20:59:25 +00:00
<el-table-column
2019-10-23 19:13:15 +00:00
:label="$t('settings.instanceUrl')"
prop="actor"/>
<el-table-column
:label="$t('settings.followedBack')"
2020-08-18 23:56:05 +00:00
:width="getLabelWidth"
prop="followed_back"
align="center">
<template slot-scope="scope">
<i :class="scope.row.followed_back ? 'el-icon-check' : 'el-icon-minus'"/>
</template>
</el-table-column>
2020-08-18 23:56:05 +00:00
<el-table-column :label="$t('table.actions')" :width="getLabelWidth" fixed="right" align="center">
2019-10-17 20:59:25 +00:00
<template slot-scope="scope">
<el-button
type="text"
size="small"
@click.native="deleteRelay(scope.row.actor)">
{{ $t('table.unfollow') }}
2019-10-23 19:13:15 +00:00
</el-button>
2019-10-17 20:59:25 +00:00
</template>
</el-table-column>
</el-table>
</div>
</template>
<script>
export default {
name: 'Relays',
data() {
return {
newRelay: ''
}
},
computed: {
2020-08-18 23:56:05 +00:00
getLabelWidth() {
return this.isDesktop ? '130px' : '85px'
},
isDesktop() {
return this.$store.state.app.device === 'desktop'
2019-10-17 20:59:25 +00:00
},
loading() {
return this.$store.state.relays.loading
2020-08-18 23:56:05 +00:00
},
relays() {
return this.$store.state.relays.fetchedRelays
2021-02-06 22:15:31 +00:00
},
searchQuery() {
return this.$store.state.settings.searchQuery
2019-10-17 20:59:25 +00:00
}
},
mounted() {
this.$store.dispatch('FetchRelays')
2021-02-06 22:15:31 +00:00
if (this.searchQuery.length > 0) {
const selectedSetting = document.querySelector(`[data-search="${this.searchQuery}"]`)
if (selectedSetting) {
selectedSetting.scrollIntoView({ block: 'start', behavior: 'smooth' })
}
this.$store.dispatch('SetSearchQuery', '')
}
2019-10-17 20:59:25 +00:00
},
methods: {
followRelay() {
this.$store.dispatch('AddRelay', this.newRelay)
2020-08-18 21:53:02 +00:00
this.newRelay = ''
2019-10-17 20:59:25 +00:00
},
deleteRelay(relay) {
this.$store.dispatch('DeleteRelay', relay)
2019-10-17 20:59:25 +00:00
}
}
}
</script>
<style rel='stylesheet/scss' lang='scss'>
2021-03-08 11:42:55 +00:00
@import '../styles/settings';
2019-10-17 20:59:25 +00:00
@include settings
</style>