2021-07-16 22:56:41 +00:00
|
|
|
<template>
|
2021-08-25 19:55:30 +00:00
|
|
|
<h1 class="uk-text-bold uk-text-center" v-t="'titles.feed'" />
|
2021-07-16 22:56:41 +00:00
|
|
|
|
2021-09-04 15:02:59 +00:00
|
|
|
<button
|
|
|
|
v-if="authenticated"
|
|
|
|
@click="exportHandler"
|
|
|
|
class="uk-button uk-button-small"
|
|
|
|
style="background: #222; margin-right: 0.5rem"
|
|
|
|
type="button"
|
|
|
|
>
|
|
|
|
<router-link to="/subscriptions">
|
|
|
|
Subscriptions
|
|
|
|
</router-link>
|
|
|
|
</button>
|
2021-07-16 22:56:41 +00:00
|
|
|
|
2021-09-04 15:02:59 +00:00
|
|
|
<span>
|
2021-09-04 15:24:36 +00:00
|
|
|
<a :href="getRssUrl"><font-awesome-icon icon="rss" style="padding-top: 0.2rem"></font-awesome-icon></a>
|
2021-09-04 15:02:59 +00:00
|
|
|
</span>
|
|
|
|
|
|
|
|
<span class="uk-align-right">
|
2021-09-05 21:31:46 +00:00
|
|
|
<label for="ddlSortBy">{{ $t("actions.sort_by") }}</label>
|
|
|
|
<select id="ddlSortBy" class="uk-select uk-width-auto" v-model="selectedSort" @change="onChange()">
|
2021-09-04 15:02:59 +00:00
|
|
|
<option value="descending" v-t="'actions.most_recent'" />
|
|
|
|
<option value="ascending" v-t="'actions.least_recent'" />
|
|
|
|
<option value="channel_ascending" v-t="'actions.channel_name_asc'" />
|
|
|
|
<option value="channel_descending" v-t="'actions.channel_name_desc'" />
|
|
|
|
</select>
|
|
|
|
</span>
|
2021-07-19 19:44:55 +00:00
|
|
|
|
2021-07-16 22:56:41 +00:00
|
|
|
<hr />
|
|
|
|
|
|
|
|
<div class="uk-grid-xl" uk-grid="parallax: 0">
|
|
|
|
<div
|
|
|
|
:style="[{ background: backgroundColor }]"
|
|
|
|
class="uk-width-1-2 uk-width-1-3@s uk-width-1-4@m uk-width-1-5@l uk-width-1-6@xl"
|
|
|
|
v-bind:key="video.url"
|
|
|
|
v-for="video in videos"
|
|
|
|
>
|
2021-07-21 12:32:17 +00:00
|
|
|
<VideoItem :video="video" />
|
2021-07-16 22:56:41 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-07-21 12:32:17 +00:00
|
|
|
import VideoItem from "@/components/VideoItem.vue";
|
|
|
|
|
2021-07-16 22:56:41 +00:00
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
videos: [],
|
2021-07-27 18:04:27 +00:00
|
|
|
selectedSort: "descending",
|
2021-07-16 22:56:41 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
2021-08-22 10:27:09 +00:00
|
|
|
this.fetchFeed().then(videos => {
|
|
|
|
this.videos = videos;
|
|
|
|
this.updateWatched(this.videos);
|
|
|
|
});
|
2021-07-16 22:56:41 +00:00
|
|
|
},
|
2021-07-21 10:59:53 +00:00
|
|
|
activated() {
|
2021-08-25 19:55:30 +00:00
|
|
|
document.title = this.$t("titles.feed") + " - Piped";
|
2021-08-22 10:27:09 +00:00
|
|
|
if (this.videos.length > 0) this.updateWatched(this.videos);
|
2021-07-21 10:59:53 +00:00
|
|
|
},
|
2021-07-16 22:56:41 +00:00
|
|
|
methods: {
|
|
|
|
async fetchFeed() {
|
|
|
|
return await this.fetchJson(this.apiUrl() + "/feed", {
|
|
|
|
authToken: this.getAuthToken(),
|
|
|
|
});
|
|
|
|
},
|
2021-07-27 18:04:27 +00:00
|
|
|
onChange() {
|
|
|
|
switch (this.selectedSort) {
|
|
|
|
case "ascending":
|
|
|
|
this.videos.sort((a, b) => a.uploaded - b.uploaded);
|
|
|
|
break;
|
|
|
|
case "descending":
|
|
|
|
this.videos.sort((a, b) => b.uploaded - a.uploaded);
|
|
|
|
break;
|
|
|
|
case "channel_ascending":
|
|
|
|
this.videos.sort((a, b) => a.uploaderName.localeCompare(b.uploaderName));
|
|
|
|
break;
|
|
|
|
case "channel_descending":
|
|
|
|
this.videos.sort((a, b) => b.uploaderName.localeCompare(a.uploaderName));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
2021-07-16 22:56:41 +00:00
|
|
|
},
|
2021-07-19 19:44:55 +00:00
|
|
|
computed: {
|
|
|
|
getRssUrl(_this) {
|
|
|
|
return _this.apiUrl() + "/feed/rss?authToken=" + _this.getAuthToken();
|
|
|
|
},
|
|
|
|
},
|
2021-07-21 12:32:17 +00:00
|
|
|
components: {
|
|
|
|
VideoItem,
|
|
|
|
},
|
2021-07-16 22:56:41 +00:00
|
|
|
};
|
|
|
|
</script>
|