Home.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <div class="app">
  3. <main-header></main-header>
  4. <div class="group">
  5. <div class="group-title">Official Stations</div>
  6. <div class="card station-card" v-for="station in stations.official" v-link="{ path: '/official/' + station._id }" @click="this.$dispatch('joinStation', station._id)">
  7. <div class="card-image">
  8. <figure class="image is-square">
  9. <img :src="station.currentSong.thumbnail" onerror="this.src='/assets/notes-transparent.png'" />
  10. </figure>
  11. </div>
  12. <div class="card-content">
  13. <div class="media">
  14. <div class="media-left displayName">
  15. <h5>{{ station.displayName }}</h5>
  16. </div>
  17. </div>
  18. <div class="content">
  19. {{ station.description }}
  20. <div class="right">
  21. (
  22. <span class='station-privacy'>{{ station.privacy }}</span>
  23. <span v-if='station.owner === userId'>, Your Station</span>
  24. )
  25. </div>
  26. </div>
  27. </div>
  28. <a @click="this.$dispatch('joinStation', station._id)" href='#' class='absolute-a'></a>
  29. </div>
  30. </div>
  31. <div class="group">
  32. <div class="group-title">Community Stations <a @click="toggleModal('createCommunityStation')" v-if="$parent.loggedIn" href='#'><i class="material-icons community-button">add_circle_outline</i></a></div>
  33. <div class="card station-card" v-for="station in stations.community" v-link="{ path: '/community/' + station._id }" @click="this.$dispatch('joinStation', station._id)">
  34. <div class="card-image">
  35. <figure class="image is-square">
  36. <img :src="station.currentSong.thumbnail" onerror="this.src='/assets/notes-transparent.png'" />
  37. </figure>
  38. </div>
  39. <div class="card-content">
  40. <div class="media">
  41. <div class="media-left displayName">
  42. <h5>{{ station.displayName }}</h5>
  43. </div>
  44. </div>
  45. <div class="content">
  46. {{ station.description }}
  47. <div class="right">
  48. (
  49. <span class='station-privacy'>{{ station.privacy }}</span>
  50. <span v-if='station.owner === userId'>, Your Station</span>
  51. )
  52. </div>
  53. </div>
  54. </div>
  55. <a @click="this.$dispatch('joinStation', station._id)" href='#' class='absolute-a'></a>
  56. </div>
  57. </div>
  58. <main-footer></main-footer>
  59. </div>
  60. </template>
  61. <script>
  62. import MainHeader from '../MainHeader.vue';
  63. import MainFooter from '../MainFooter.vue';
  64. import auth from '../../auth';
  65. import io from '../../io';
  66. export default {
  67. data() {
  68. return {
  69. isRegisterActive: false,
  70. isLoginActive: false,
  71. recaptcha: {
  72. key: ''
  73. },
  74. stations: {
  75. official: [],
  76. community: []
  77. }
  78. }
  79. },
  80. ready() {
  81. let _this = this;
  82. auth.getStatus((authenticated, role, username, userId) => {
  83. io.getSocket((socket) => {
  84. _this.socket = socket;
  85. if (_this.socket.connected) _this.init();
  86. io.onConnect(() => {
  87. _this.init();
  88. });
  89. _this.socket.on('event:stations.created', station => {
  90. if (!station.currentSong) station.currentSong = { thumbnail: '/assets/notes-transparent.png' };
  91. if (station.currentSong && !station.currentSong.thumbnail) station.currentSong.thumbnail = "/assets/notes-transparent.png";
  92. _this.stations[station.type].push(station);
  93. });
  94. });
  95. });
  96. },
  97. methods: {
  98. toggleModal: function (type) {
  99. this.$dispatch('toggleModal', type);
  100. },
  101. init: function() {
  102. let _this = this;
  103. auth.getStatus((authenticated, role, username, userId) => {
  104. _this.socket.emit('stations.index', data => {
  105. _this.stations.community = [];
  106. _this.stations.official = [];
  107. if (data.status === "success") data.stations.forEach(station => {
  108. if (!station.currentSong) station.currentSong = { thumbnail: '/assets/notes-transparent.png' };
  109. if (station.currentSong && !station.currentSong.thumbnail) station.currentSong.thumbnail = "/assets/notes-transparent.png";
  110. if (station.privacy !== 'public') station.class = { 'station-red': true }
  111. else if (station.type === 'community' && station.owner === userId) station.class = { 'station-blue': true }
  112. if (station.type == 'official') _this.stations.official.push(station);
  113. else _this.stations.community.push(station);
  114. });
  115. });
  116. _this.socket.emit("apis.joinRoom", 'home', () => {
  117. });
  118. });
  119. }
  120. },
  121. components: { MainHeader, MainFooter }
  122. }
  123. </script>
  124. <style lang='scss'>
  125. @import 'theme.scss';
  126. * { box-sizing: border-box; }
  127. html {
  128. width: 100%;
  129. height: 100%;
  130. color: rgba(0, 0, 0, 0.87);
  131. body {
  132. width: 100%;
  133. height: 100%;
  134. margin: 0;
  135. padding: 0;
  136. }
  137. }
  138. @media only screen and (min-width: 1200px) {
  139. html { font-size: 15px; }
  140. }
  141. @media only screen and (min-width: 992px) {
  142. html { font-size: 14.5px; }
  143. }
  144. @media only screen and (min-width: 0) {
  145. html { font-size: 14px; }
  146. }
  147. .group { min-height: 64px; }
  148. .station-card {
  149. margin: 10px;
  150. cursor: pointer;
  151. }
  152. .community-button {
  153. cursor: pointer;
  154. transition: .25s ease color;
  155. font-size: 30px;
  156. color: black;
  157. }
  158. .community-button:hover { color: #03a9f4; }
  159. .station-privacy { text-transform: capitalize; }
  160. .label { display: flex; }
  161. .g-recaptcha {
  162. display: flex;
  163. justify-content: center;
  164. margin-top: 20px;
  165. }
  166. .group {
  167. text-align: center;
  168. width: 100%;
  169. margin: 64px 0 0 0;
  170. .group-title {
  171. float: left;
  172. clear: none;
  173. width: 100%;
  174. height: 64px;
  175. line-height: 48px;
  176. text-align: center;
  177. font-size: 48px;
  178. margin-bottom: 25px;
  179. }
  180. }
  181. .group .card {
  182. display: inline-flex;
  183. flex-direction: column;
  184. overflow: hidden;
  185. }
  186. .displayName {
  187. word-wrap: break-word;
  188. width: 80%;
  189. }
  190. .content {
  191. text-align: left;
  192. word-wrap: break-word;
  193. }
  194. </style>