Home.vue 5.9 KB

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