2018-04-14 18:50:37 +02:00
|
|
|
|
<template>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<div class="ui form">
|
|
|
|
|
|
<div class="fields">
|
|
|
|
|
|
<div class="ui six wide field">
|
|
|
|
|
|
<input type="text" v-model="search" placeholder="Search by username, domain..." />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="ui four wide inline field">
|
|
|
|
|
|
<div class="ui checkbox">
|
|
|
|
|
|
<input v-model="pending" type="checkbox">
|
2018-06-30 15:28:47 +02:00
|
|
|
|
<label>
|
2018-07-01 15:31:34 +02:00
|
|
|
|
<translate>Pending approval</translate>
|
2018-06-30 15:28:47 +02:00
|
|
|
|
</label>
|
2018-04-14 18:50:37 +02:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="ui hidden divider"></div>
|
|
|
|
|
|
<table v-if="result" class="ui very basic single line unstackable table">
|
|
|
|
|
|
<thead>
|
|
|
|
|
|
<tr>
|
2018-06-30 15:28:47 +02:00
|
|
|
|
<th>{{ $gettext('Actor') }}</th>
|
|
|
|
|
|
<th>{{ $gettext('Creation date') }}</th>
|
|
|
|
|
|
<th>{{ $gettext('Status') }}</th>
|
|
|
|
|
|
<th>{{ $gettext('Actions') }}</th>
|
2018-04-14 18:50:37 +02:00
|
|
|
|
</tr>
|
|
|
|
|
|
</thead>
|
|
|
|
|
|
<tbody>
|
|
|
|
|
|
<tr v-for="follow in result.results">
|
|
|
|
|
|
<td>
|
|
|
|
|
|
{{ follow.actor.preferred_username }}@{{ follow.actor.domain }}
|
|
|
|
|
|
</td>
|
|
|
|
|
|
<td>
|
|
|
|
|
|
<human-date :date="follow.creation_date"></human-date>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
<td>
|
|
|
|
|
|
<template v-if="follow.approved === true">
|
2018-06-30 15:28:47 +02:00
|
|
|
|
<i class="check icon"></i>
|
2018-07-01 15:31:34 +02:00
|
|
|
|
<translate>Approved</translate>
|
2018-04-14 18:50:37 +02:00
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else-if="follow.approved === false">
|
2018-06-30 15:28:47 +02:00
|
|
|
|
<i class="x icon"></i>
|
2018-07-01 15:31:34 +02:00
|
|
|
|
<translate>Refused</translate>
|
2018-04-14 18:50:37 +02:00
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else>
|
2018-06-30 15:28:47 +02:00
|
|
|
|
<i class="clock icon"></i>
|
2018-07-01 15:31:34 +02:00
|
|
|
|
<translate>Pending</translate>
|
2018-04-14 18:50:37 +02:00
|
|
|
|
</template>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
<td>
|
|
|
|
|
|
<dangerous-button v-if="follow.approved !== false" class="tiny basic labeled icon" color='red' @confirm="updateFollow(follow, false)">
|
2018-06-30 15:28:47 +02:00
|
|
|
|
<i class="x icon"></i>
|
2018-07-01 15:31:34 +02:00
|
|
|
|
<translate>Deny</translate>
|
2018-06-30 15:28:47 +02:00
|
|
|
|
<p slot="modal-header">
|
2018-07-01 15:31:34 +02:00
|
|
|
|
<translate>Deny access?</translate>
|
2018-06-30 15:28:47 +02:00
|
|
|
|
</p>
|
2018-04-15 15:23:58 +01:00
|
|
|
|
<p slot="modal-content">
|
2018-06-30 15:28:47 +02:00
|
|
|
|
<translate
|
|
|
|
|
|
:translate-params="{username: follow.actor.preferred_username + '@' + follow.actor.domain}">
|
|
|
|
|
|
By confirming, %{ username } will be denied access to your library.
|
|
|
|
|
|
</translate>
|
|
|
|
|
|
</p>
|
|
|
|
|
|
<p slot="modal-confirm">
|
2018-07-01 15:31:34 +02:00
|
|
|
|
<translate>Deny</translate>
|
2018-04-15 15:23:58 +01:00
|
|
|
|
</p>
|
2018-04-14 18:50:37 +02:00
|
|
|
|
</dangerous-button>
|
|
|
|
|
|
<dangerous-button v-if="follow.approved !== true" class="tiny basic labeled icon" color='green' @confirm="updateFollow(follow, true)">
|
2018-06-30 15:28:47 +02:00
|
|
|
|
<i class="check icon"></i>
|
2018-07-01 15:31:34 +02:00
|
|
|
|
<translate>Approve</translate>
|
2018-06-30 15:28:47 +02:00
|
|
|
|
<p slot="modal-header">
|
2018-07-01 15:31:34 +02:00
|
|
|
|
<translate>Approve access?</translate>
|
2018-06-30 15:28:47 +02:00
|
|
|
|
</p>
|
2018-04-15 15:23:58 +01:00
|
|
|
|
<p slot="modal-content">
|
2018-06-30 15:28:47 +02:00
|
|
|
|
<translate
|
|
|
|
|
|
:translate-params="{username: follow.actor.preferred_username + '@' + follow.actor.domain}">
|
|
|
|
|
|
By confirming, %{ username } will be granted access to your library.
|
|
|
|
|
|
</translate>
|
|
|
|
|
|
<p slot="modal-confirm">
|
2018-07-01 15:31:34 +02:00
|
|
|
|
<translate>Approve</translate>
|
2018-06-30 15:28:47 +02:00
|
|
|
|
</p>
|
2018-04-14 18:50:37 +02:00
|
|
|
|
</dangerous-button>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
</tbody>
|
|
|
|
|
|
<tfoot class="full-width">
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
<th>
|
|
|
|
|
|
<pagination
|
|
|
|
|
|
v-if="result && result.results.length > 0"
|
|
|
|
|
|
@page-changed="selectPage"
|
|
|
|
|
|
:compact="true"
|
|
|
|
|
|
:current="page"
|
|
|
|
|
|
:paginate-by="paginateBy"
|
|
|
|
|
|
:total="result.count"
|
|
|
|
|
|
></pagination>
|
|
|
|
|
|
</th>
|
|
|
|
|
|
<th v-if="result && result.results.length > 0">
|
2018-06-30 15:28:47 +02:00
|
|
|
|
<translate
|
|
|
|
|
|
:translate-params="{start: ((page-1) * paginateBy) + 1, end: ((page-1) * paginateBy) + result.results.length, total: result.count}">
|
|
|
|
|
|
Showing results %{ start }-%{ end } on %{ total }
|
|
|
|
|
|
</translate>
|
2018-04-15 15:23:58 +01:00
|
|
|
|
</th>
|
2018-04-14 18:50:37 +02:00
|
|
|
|
<th></th>
|
|
|
|
|
|
<th></th>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
</tfoot>
|
|
|
|
|
|
</table>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
import axios from 'axios'
|
|
|
|
|
|
import _ from 'lodash'
|
|
|
|
|
|
|
|
|
|
|
|
import Pagination from '@/components/Pagination'
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
|
props: {
|
|
|
|
|
|
filters: {type: Object, required: false, default: () => {}}
|
|
|
|
|
|
},
|
|
|
|
|
|
components: {
|
|
|
|
|
|
Pagination
|
|
|
|
|
|
},
|
|
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
|
|
|
|
|
isLoading: false,
|
|
|
|
|
|
result: null,
|
|
|
|
|
|
page: 1,
|
|
|
|
|
|
paginateBy: 25,
|
|
|
|
|
|
search: '',
|
|
|
|
|
|
pending: false
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
created () {
|
|
|
|
|
|
this.fetchData()
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
fetchData () {
|
|
|
|
|
|
let params = _.merge({
|
|
|
|
|
|
'page': this.page,
|
|
|
|
|
|
'page_size': this.paginateBy,
|
|
|
|
|
|
'q': this.search
|
|
|
|
|
|
}, this.filters)
|
|
|
|
|
|
if (this.pending) {
|
|
|
|
|
|
params.pending = true
|
|
|
|
|
|
}
|
|
|
|
|
|
let self = this
|
|
|
|
|
|
self.isLoading = true
|
|
|
|
|
|
axios.get('/federation/libraries/followers/', {params: params}).then((response) => {
|
|
|
|
|
|
self.result = response.data
|
|
|
|
|
|
self.isLoading = false
|
|
|
|
|
|
}, error => {
|
|
|
|
|
|
self.isLoading = false
|
|
|
|
|
|
self.errors = error.backendErrors
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
selectPage: function (page) {
|
|
|
|
|
|
this.page = page
|
|
|
|
|
|
},
|
|
|
|
|
|
updateFollow (follow, approved) {
|
|
|
|
|
|
let payload = {
|
|
|
|
|
|
follow: follow.id,
|
|
|
|
|
|
approved: approved
|
|
|
|
|
|
}
|
|
|
|
|
|
let self = this
|
|
|
|
|
|
axios.patch('/federation/libraries/followers/', payload).then((response) => {
|
|
|
|
|
|
follow.approved = response.data.approved
|
|
|
|
|
|
self.isLoading = false
|
|
|
|
|
|
}, error => {
|
|
|
|
|
|
self.isLoading = false
|
|
|
|
|
|
self.errors = error.backendErrors
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
search (newValue) {
|
|
|
|
|
|
if (newValue.length > 0) {
|
|
|
|
|
|
this.fetchData()
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
page () {
|
|
|
|
|
|
this.fetchData()
|
|
|
|
|
|
},
|
|
|
|
|
|
pending () {
|
|
|
|
|
|
this.fetchData()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|