ServerFeed.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <div class="discover-serverfeeds-component">
  3. <div class="container-fluid mt-3">
  4. <div class="row">
  5. <div class="col-md-4 col-lg-3">
  6. <sidebar :user="profile" />
  7. </div>
  8. <div class="col-md-6 col-lg-6">
  9. <b-breadcrumb class="font-default" :items="breadcrumbItems"></b-breadcrumb>
  10. <h1 class="font-default">Server Timelines</h1>
  11. <p class="font-default lead">Browse timelines of a specific instance</p>
  12. <hr>
  13. <b-spinner v-if="isLoading && !initialTab" />
  14. <status-card
  15. v-if="!isLoading"
  16. v-for="(post, idx) in feed"
  17. :key="'ti1:'+idx+':'+post.id"
  18. :profile="profile"
  19. :status="post"
  20. />
  21. <p v-if="!initialTab && !isLoading && feed.length == 0" class="lead">No posts found :(</p>
  22. <div v-if="initialTab === true">
  23. <p v-if="config.server.mode == 'allowlist'" class="lead">Select an instance from the menu</p>
  24. </div>
  25. </div>
  26. <div class="col-md-2 col-lg-3">
  27. <div v-if="config.server.mode === 'allowlist'" class="nav flex-column nav-pills font-default">
  28. <a
  29. v-for="(tag, idx) in domains"
  30. class="nav-link"
  31. :class="{ active: tagIndex == idx }"
  32. href="#"
  33. @click.prevent="toggleTag(idx)">
  34. {{ tag }}
  35. </a>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. </template>
  42. <script type="text/javascript">
  43. import Drawer from './../partials/drawer.vue';
  44. import Sidebar from './../partials/sidebar.vue';
  45. import StatusCard from './../partials/TimelineStatus.vue';
  46. export default {
  47. components: {
  48. "drawer": Drawer,
  49. "sidebar": Sidebar,
  50. "status-card": StatusCard
  51. },
  52. data() {
  53. return {
  54. isLoaded: false,
  55. isLoading: true,
  56. initialTab: true,
  57. config: {},
  58. profile: window._sharedData.user,
  59. tagIndex: undefined,
  60. domains: [],
  61. feed: [],
  62. breadcrumbItems: [
  63. {
  64. text: 'Discover',
  65. href: '/i/web/discover'
  66. },
  67. {
  68. text: 'Server Timelines',
  69. active: true
  70. }
  71. ]
  72. }
  73. },
  74. mounted() {
  75. this.fetchConfig();
  76. },
  77. methods: {
  78. fetchConfig() {
  79. axios.get('/api/pixelfed/v2/discover/meta')
  80. .then(res => {
  81. this.config = res.data;
  82. if(this.config.server.enabled == false) {
  83. this.$router.push('/i/web/discover');
  84. }
  85. if(this.config.server.mode === 'allowlist') {
  86. this.domains = this.config.server.domains.split(',');
  87. }
  88. })
  89. },
  90. fetchFeed(domain) {
  91. this.isLoading = true;
  92. axios.get('/api/pixelfed/v2/discover/server-timeline', {
  93. params: {
  94. domain: domain
  95. }
  96. }).then(res => {
  97. this.feed = res.data;
  98. this.isLoading = false;
  99. this.isLoaded = true;
  100. })
  101. .catch(err => {
  102. this.feed = [];
  103. this.tagIndex = null;
  104. this.isLoaded = true;
  105. this.isLoading = false;
  106. })
  107. },
  108. toggleTag(tag) {
  109. this.initialTab = false;
  110. this.tagIndex = tag;
  111. this.fetchFeed(this.domains[tag]);
  112. }
  113. }
  114. }
  115. </script>
  116. <style lang="scss" scoped>
  117. .discover-serverfeeds-component {
  118. .bg-stellar {
  119. background: #7474BF;
  120. background: -webkit-linear-gradient(to right, #348AC7, #7474BF);
  121. background: linear-gradient(to right, #348AC7, #7474BF);
  122. }
  123. .font-default {
  124. font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  125. letter-spacing: -0.7px;
  126. }
  127. .active {
  128. font-weight: 700;
  129. }
  130. }
  131. </style>