2019-12-03 11:29:51 +01:00
|
|
|
<template>
|
2020-02-18 08:57:00 +01:00
|
|
|
<div>
|
|
|
|
<b-table
|
|
|
|
v-show="relayFollowers.elements.length > 0"
|
|
|
|
:data="relayFollowers.elements"
|
|
|
|
:loading="$apollo.queries.relayFollowers.loading"
|
|
|
|
ref="table"
|
|
|
|
:checked-rows.sync="checkedRows"
|
|
|
|
detailed
|
|
|
|
:show-detail-icon="false"
|
|
|
|
paginated
|
|
|
|
backend-pagination
|
|
|
|
:total="relayFollowers.total"
|
|
|
|
:per-page="perPage"
|
|
|
|
@page-change="onPageChange"
|
|
|
|
checkable
|
|
|
|
checkbox-position="left"
|
|
|
|
>
|
2020-08-18 15:50:50 +02:00
|
|
|
<b-table-column field="actor.id" label="ID" width="40" numeric v-slot="props">{{
|
|
|
|
props.row.actor.id
|
|
|
|
}}</b-table-column>
|
2019-12-03 11:29:51 +01:00
|
|
|
|
2020-08-18 15:50:50 +02:00
|
|
|
<b-table-column field="actor.type" :label="$t('Type')" width="80" v-slot="props">
|
|
|
|
<b-icon icon="lan" v-if="RelayMixin.isInstance(props.row.actor)" />
|
|
|
|
<b-icon icon="account-circle" v-else />
|
|
|
|
</b-table-column>
|
2019-12-03 11:29:51 +01:00
|
|
|
|
2020-08-18 15:50:50 +02:00
|
|
|
<b-table-column
|
|
|
|
field="approved"
|
|
|
|
:label="$t('Status')"
|
|
|
|
width="100"
|
|
|
|
sortable
|
|
|
|
centered
|
|
|
|
v-slot="props"
|
|
|
|
>
|
|
|
|
<span :class="`tag ${props.row.approved ? 'is-success' : 'is-danger'}`">{{
|
|
|
|
props.row.approved ? $t("Accepted") : $t("Pending")
|
|
|
|
}}</span>
|
|
|
|
</b-table-column>
|
2019-12-03 11:29:51 +01:00
|
|
|
|
2020-08-18 15:50:50 +02:00
|
|
|
<b-table-column field="actor.domain" :label="$t('Domain')" sortable>
|
|
|
|
<template v-slot:default="props">
|
|
|
|
<a @click="toggle(props.row)" v-if="RelayMixin.isInstance(props.row.actor)">{{
|
|
|
|
props.row.actor.domain
|
|
|
|
}}</a>
|
|
|
|
<a @click="toggle(props.row)" v-else>{{
|
|
|
|
`${props.row.actor.preferredUsername}@${props.row.actor.domain}`
|
|
|
|
}}</a>
|
|
|
|
</template>
|
|
|
|
</b-table-column>
|
2019-12-03 11:29:51 +01:00
|
|
|
|
2020-08-18 15:50:50 +02:00
|
|
|
<b-table-column field="targetActor.updatedAt" :label="$t('Date')" sortable v-slot="props">
|
|
|
|
<span :title="$options.filters.formatDateTimeString(props.row.updatedAt)">{{
|
|
|
|
timeago(props.row.updatedAt)
|
|
|
|
}}</span></b-table-column
|
|
|
|
>
|
2019-12-03 11:29:51 +01:00
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
<template slot="detail" slot-scope="props">
|
|
|
|
<article>
|
|
|
|
<div class="content">
|
2020-07-07 17:19:57 +02:00
|
|
|
<strong>{{ props.row.actor.name }}</strong>
|
|
|
|
<small v-if="props.row.actor.preferredUsername !== 'relay'"
|
|
|
|
>@{{ props.row.actor.preferredUsername }}</small
|
|
|
|
>
|
2020-02-18 08:57:00 +01:00
|
|
|
<p v-html="props.row.actor.summary" />
|
|
|
|
</div>
|
|
|
|
</article>
|
|
|
|
</template>
|
2019-12-03 11:29:51 +01:00
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
<template slot="bottom-left" v-if="checkedRows.length > 0">
|
|
|
|
<div class="buttons">
|
|
|
|
<b-button
|
|
|
|
@click="acceptRelays"
|
|
|
|
type="is-success"
|
|
|
|
v-if="checkedRowsHaveAtLeastOneToApprove"
|
|
|
|
>
|
|
|
|
{{
|
|
|
|
$tc(
|
|
|
|
"No instance to approve|Approve instance|Approve {number} instances",
|
|
|
|
checkedRows.length,
|
|
|
|
{ number: checkedRows.length }
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
</b-button>
|
|
|
|
<b-button @click="rejectRelays" type="is-danger">
|
|
|
|
{{
|
|
|
|
$tc(
|
|
|
|
"No instance to reject|Reject instance|Reject {number} instances",
|
|
|
|
checkedRows.length,
|
|
|
|
{ number: checkedRows.length }
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
</b-button>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</b-table>
|
|
|
|
<b-message type="is-danger" v-if="relayFollowers.elements.length === 0">{{
|
|
|
|
$t("No instance follows your instance yet.")
|
|
|
|
}}</b-message>
|
|
|
|
</div>
|
2019-12-03 11:29:51 +01:00
|
|
|
</template>
|
|
|
|
<script lang="ts">
|
2020-02-18 08:57:00 +01:00
|
|
|
import { Component, Mixins } from "vue-property-decorator";
|
2020-09-29 09:53:48 +02:00
|
|
|
import { SnackbarProgrammatic as Snackbar } from "buefy";
|
2020-02-18 08:57:00 +01:00
|
|
|
import { ACCEPT_RELAY, REJECT_RELAY, RELAY_FOLLOWERS } from "../../graphql/admin";
|
|
|
|
import { Paginate } from "../../types/paginate";
|
|
|
|
import { IFollower } from "../../types/actor/follower.model";
|
|
|
|
import RelayMixin from "../../mixins/relay";
|
2019-12-03 11:29:51 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
apollo: {
|
|
|
|
relayFollowers: {
|
|
|
|
query: RELAY_FOLLOWERS,
|
2020-02-18 08:57:00 +01:00
|
|
|
fetchPolicy: "cache-and-network",
|
2019-12-03 11:29:51 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
metaInfo() {
|
|
|
|
return {
|
2020-02-18 08:57:00 +01:00
|
|
|
title: this.$t("Followers") as string,
|
|
|
|
titleTemplate: "%s | Mobilizon",
|
2019-12-03 11:29:51 +01:00
|
|
|
};
|
|
|
|
},
|
|
|
|
})
|
|
|
|
export default class Followers extends Mixins(RelayMixin) {
|
|
|
|
relayFollowers: Paginate<IFollower> = { elements: [], total: 0 };
|
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
RelayMixin = RelayMixin;
|
|
|
|
|
2020-09-29 09:53:48 +02:00
|
|
|
async acceptRelays(): Promise<void> {
|
2019-12-03 11:29:51 +01:00
|
|
|
await this.checkedRows.forEach((row: IFollower) => {
|
|
|
|
this.acceptRelay(`${row.actor.preferredUsername}@${row.actor.domain}`);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-09-29 09:53:48 +02:00
|
|
|
async rejectRelays(): Promise<void> {
|
2019-12-03 11:29:51 +01:00
|
|
|
await this.checkedRows.forEach((row: IFollower) => {
|
|
|
|
this.rejectRelay(`${row.actor.preferredUsername}@${row.actor.domain}`);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-09-29 09:53:48 +02:00
|
|
|
async acceptRelay(address: string): Promise<void> {
|
|
|
|
try {
|
|
|
|
await this.$apollo.mutate({
|
|
|
|
mutation: ACCEPT_RELAY,
|
|
|
|
variables: {
|
|
|
|
address,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
await this.$apollo.queries.relayFollowers.refetch();
|
|
|
|
this.checkedRows = [];
|
|
|
|
} catch (e) {
|
|
|
|
Snackbar.open({ message: e.message, type: "is-danger", position: "is-bottom" });
|
|
|
|
}
|
2019-12-03 11:29:51 +01:00
|
|
|
}
|
|
|
|
|
2020-09-29 09:53:48 +02:00
|
|
|
async rejectRelay(address: string): Promise<void> {
|
|
|
|
try {
|
|
|
|
await this.$apollo.mutate({
|
|
|
|
mutation: REJECT_RELAY,
|
|
|
|
variables: {
|
|
|
|
address,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
await this.$apollo.queries.relayFollowers.refetch();
|
|
|
|
this.checkedRows = [];
|
|
|
|
} catch (e) {
|
|
|
|
Snackbar.open({ message: e.message, type: "is-danger", position: "is-bottom" });
|
|
|
|
}
|
2019-12-03 11:29:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
get checkedRowsHaveAtLeastOneToApprove(): boolean {
|
2020-02-18 08:57:00 +01:00
|
|
|
return this.checkedRows.some((checkedRow) => !checkedRow.approved);
|
2019-12-03 11:29:51 +01:00
|
|
|
}
|
|
|
|
}
|
2020-02-18 08:57:00 +01:00
|
|
|
</script>
|