1
0
mirror of https://github.com/TeamPiped/Piped.git synced 2024-12-13 22:00:28 +05:30

Add page to see subscriptions.

Closes #301
This commit is contained in:
FireMasterK 2021-07-23 01:35:48 +05:30
parent d3f4653e8a
commit 0485857ae2
No known key found for this signature in database
GPG Key ID: 49451E4482CC5BCD
3 changed files with 68 additions and 0 deletions

View File

@ -3,6 +3,9 @@
<small>You can import subscriptions from <router-link to="/import">here</router-link>.</small>
<br />
<router-link to="/subscriptions" class="uk-text-center">View Subscriptions</router-link>
<div class="uk-align-right">
<a :href="getRssUrl"><font-awesome-icon icon="rss"></font-awesome-icon></a>
</div>

View File

@ -0,0 +1,60 @@
<template>
<h1 class="uk-text-bold uk-text-center">Subscriptions</h1>
<div :key="subscription.url" v-for="subscription in subscriptions">
<div class="uk-text-primary" :style="[{ background: backgroundColor }]">
<a :href="subscription.url">
<img :src="subscription.avatar" class="uk-margin-small-right" width="50" height="50" />
<span class="uk-text-truncate">{{ subscription.name }}</span>
</a>
<button
class="uk-button uk-button-small"
style="background: #222"
type="button"
@click="handleButton(subscription)"
>
{{ subscription.subscribed ? "Unsubscribe" : "Subscribe" }}
</button>
</div>
</div>
</template>
<script>
export default {
data() {
return {
subscriptions: [],
};
},
mounted() {
if (this.authenticated)
this.fetchJson(this.apiUrl() + "/subscriptions", null, {
headers: {
Authorization: this.getAuthToken(),
},
}).then(json => {
this.subscriptions = json;
this.subscriptions.forEach(subscription => (subscription.subscribed = true));
});
else this.$router.push("/login");
},
activated() {
document.title = "Subscriptions - Piped";
},
methods: {
handleButton(subscription) {
this.fetchJson(this.apiUrl() + (subscription.subscribed ? "/unsubscribe" : "/subscribe"), null, {
method: "POST",
body: JSON.stringify({
channelId: subscription.url.split("/")[2],
}),
headers: {
Authorization: this.getAuthToken(),
"Content-Type": "application/json",
},
});
subscription.subscribed = !subscription.subscribed;
},
},
};
</script>

View File

@ -55,6 +55,11 @@ const routes = [
path: "/:videoId([a-zA-Z0-9_-]{11})",
component: () => import("../components/VideoRedirect.vue"),
},
{
path: "/subscriptions",
name: "Subscriptions",
component: () => import("../components/SubscriptionsPage.vue"),
},
];
const router = createRouter({