Home.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <div class="web-wrapper">
  3. <div v-if="isLoaded" class="container-fluid mt-3">
  4. <div class="row">
  5. <div class="col-md-4 col-lg-3">
  6. <sidebar
  7. :user="profile"
  8. @refresh="shouldRefresh = true" />
  9. </div>
  10. <div class="col-md-8 col-lg-6 px-0">
  11. <template v-if="showUpdateWarning && updateInfo && updateInfo.hasOwnProperty('running_latest')">
  12. <div class="card rounded-lg mb-4 ft-std" style="background: #e11d48;border: 3px dashed #fff">
  13. <div class="card-body">
  14. <div class="d-flex justify-content-between align-items-center flex-column flex-lg-row" style="gap:1rem">
  15. <div class="d-flex justify-content-between align-items-center" style="gap:1rem">
  16. <i class="d-none d-sm-block far fa-exclamation-triangle fa-5x text-white"></i>
  17. <div>
  18. <h1 class="h3 font-weight-bold text-light mb-0">New Update Available</h1>
  19. <p class="mb-0 text-white" style="font-size:18px;">Update your Pixelfed server as soon as possible!</p>
  20. <p class="mb-n1 text-white small" style="opacity:.7">Once you update, this message will disappear.</p>
  21. <p class="mb-0 text-white small d-flex" style="opacity:.5;gap:1rem;">
  22. <span>Current version: <strong>{{ updateInfo?.current ?? 'Unknown' }}</strong></span>
  23. <span>Latest version: <strong>{{ updateInfo?.latest?.version ?? 'Unknown' }}</strong></span>
  24. </p>
  25. </div>
  26. </div>
  27. <a v-if="updateInfo.latest.url" class="btn btn-light font-weight-bold" :href="updateInfo.latest.url" target="_blank">View Update</a>
  28. </div>
  29. </div>
  30. </div>
  31. </template>
  32. <template v-if="showUpdateConnectionWarning">
  33. <div class="card rounded-lg mb-4 ft-std" style="background: #e11d48;border: 3px dashed #fff">
  34. <div class="card-body">
  35. <div class="d-flex justify-content-between align-items-center flex-column flex-lg-row" style="gap:1rem">
  36. <div class="d-flex justify-content-between align-items-center" style="gap:1rem">
  37. <i class="d-none d-sm-block far fa-exclamation-triangle fa-5x text-white"></i>
  38. <div>
  39. <h1 class="h3 font-weight-bold text-light mb-1">Software Update Check Failed</h1>
  40. <p class="mb-1 text-white" style="font-size:18px;line-height: 1.2;">We attempted to check if there is a new version available, however we encountered an error. <a href="https://github.com/pixelfed/pixelfed/releases" class="text-white font-weight-bold" style="text-decoration: underline;" target="_blank">Click here</a> to view the latest releases.</p>
  41. <p class="mb-0 text-white small">You can set <code class="text-white">INSTANCE_SOFTWARE_UPDATE_DISABLE_FAILED_WARNING=true</code> to remove this warning.</p>
  42. <p class="mb-0 text-white small" style="opacity:.7">Current version: {{ updateInfo?.current ?? 'Unknown' }}</p>
  43. </div>
  44. </div>
  45. </div>
  46. </div>
  47. </div>
  48. </template>
  49. <story-carousel
  50. v-if="storiesEnabled"
  51. :profile="profile" />
  52. <timeline
  53. :profile="profile"
  54. :scope="scope"
  55. :key="scope"
  56. v-on:update-profile="updateProfile"
  57. :refresh="shouldRefresh"
  58. @refreshed="shouldRefresh = false" />
  59. </div>
  60. <div class="d-none d-lg-block col-lg-3">
  61. <rightbar class="sticky-top sidebar" />
  62. </div>
  63. </div>
  64. <drawer />
  65. </div>
  66. <div v-else class="d-flex justify-content-center align-items-center" style="height:calc(100vh - 58px);">
  67. <b-spinner />
  68. </div>
  69. </div>
  70. </template>
  71. <script type="text/javascript">
  72. import Drawer from './partials/drawer.vue';
  73. import Sidebar from './partials/sidebar.vue';
  74. import Rightbar from './partials/rightbar.vue';
  75. import Timeline from './sections/Timeline.vue';
  76. import Notifications from './sections/Notifications.vue';
  77. import StoryCarousel from './partials/timeline/StoryCarousel.vue';
  78. export default {
  79. props: {
  80. scope: {
  81. type: String,
  82. default: 'home'
  83. }
  84. },
  85. components: {
  86. "drawer": Drawer,
  87. "sidebar": Sidebar,
  88. "timeline": Timeline,
  89. "rightbar": Rightbar,
  90. "story-carousel": StoryCarousel,
  91. },
  92. data() {
  93. return {
  94. isLoaded: false,
  95. profile: undefined,
  96. recommended: [],
  97. trending: [],
  98. storiesEnabled: false,
  99. shouldRefresh: false,
  100. showUpdateWarning: false,
  101. showUpdateConnectionWarning: false,
  102. updateInfo: undefined,
  103. }
  104. },
  105. mounted() {
  106. this.init();
  107. },
  108. watch: {
  109. '$route': 'init'
  110. },
  111. methods: {
  112. init() {
  113. this.profile = window._sharedData.user;
  114. this.isLoaded = true;
  115. this.storiesEnabled = window.App?.config?.features?.hasOwnProperty('stories') ? window.App.config.features.stories : false;
  116. if(this.profile.is_admin) {
  117. this.softwareUpdateCheck();
  118. }
  119. },
  120. updateProfile(delta) {
  121. this.profile = Object.assign(this.profile, delta);
  122. },
  123. softwareUpdateCheck() {
  124. axios.get('/api/web-admin/software-update/check')
  125. .then(res => {
  126. if(!res || !res.data || !res.data.hasOwnProperty('running_latest') || res.data.running_latest) {
  127. return;
  128. }
  129. if(res.data.running_latest === null) {
  130. this.updateInfo = res.data;
  131. this.showUpdateConnectionWarning = true;
  132. return;
  133. }
  134. this.updateInfo = res.data;
  135. this.showUpdateWarning = !res.data.running_latest;
  136. })
  137. .catch(err => {
  138. this.showUpdateConnectionWarning = true;
  139. })
  140. }
  141. }
  142. }
  143. </script>
  144. <style lang="scss" scoped>
  145. .avatar {
  146. border-radius: 15px;
  147. }
  148. .username {
  149. margin-bottom: -6px;
  150. }
  151. .btn-white {
  152. background-color: #fff;
  153. border: 1px solid #F3F4F6;
  154. }
  155. .sidebar {
  156. top: 90px;
  157. }
  158. </style>