Home.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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.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. </div>
  27. </div>
  28. <div class="group">
  29. <div class="group-title">Community Stations <i class="material-icons ccs-button" @click="toggleModal('createCommunityStation')" v-if="$parent.loggedIn">add_circle_outline</i></div>
  30. <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">
  31. <div class="card-image">
  32. <figure class="image is-square">
  33. <img :src="station.currentSong.thumbnail" onerror="this.src='/assets/notes.png'" />
  34. </figure>
  35. </div>
  36. <div class="card-content">
  37. <div class="media">
  38. <div class="media-left displayName">
  39. <h5>{{ station.displayName }}</h5>
  40. </div>
  41. <div class="media-content"></div>
  42. <div class="media-right">
  43. <div>{{ station.userCount }}&nbsp;&nbsp;<i class="material-icons">perm_identity</i></div>
  44. </div>
  45. </div>
  46. <div class="content">
  47. {{ station.description }}
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. <main-footer></main-footer>
  53. </div>
  54. </template>
  55. <script>
  56. import MainHeader from '../MainHeader.vue';
  57. import MainFooter from '../MainFooter.vue';
  58. import auth from '../../auth';
  59. import io from '../../io';
  60. export default {
  61. data() {
  62. return {
  63. isRegisterActive: false,
  64. isLoginActive: false,
  65. recaptcha: {
  66. key: ''
  67. },
  68. stations: {
  69. official: [],
  70. community: []
  71. }
  72. }
  73. },
  74. ready() {
  75. let _this = this;
  76. auth.getStatus((authenticated, role, username, userId) => {
  77. io.getSocket((socket) => {
  78. _this.socket = socket;
  79. if (_this.socket.connected) {
  80. _this.init();
  81. }
  82. io.onConnect(() => {
  83. _this.init();
  84. });
  85. _this.socket.on('event:stations.created', station => {
  86. console.log("CREATED!!!", station);
  87. if (!station.currentSong) station.currentSong = {thumbnail: '/assets/notes.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. _this.socket.emit("stations.index", data => {
  107. _this.stations.community = [];
  108. _this.stations.official = [];
  109. if (data.status === "success") data.stations.forEach(station => {
  110. if (!station.currentSong) station.currentSong = { thumbnail: '/assets/notes.png' };
  111. console.log(station.privacy);
  112. if (station.privacy !== 'public') {
  113. console.log(123);
  114. station.class = {'station-red': true}
  115. } else if (station.type === 'community') {
  116. auth.getStatus((authenticated, role, username, userId) => {
  117. if (station.owner === userId) {
  118. station.class = {'station-blue': true}
  119. }
  120. });
  121. }
  122. if (station.type == 'official') _this.stations.official.push(station);
  123. else _this.stations.community.push(station);
  124. });
  125. });
  126. _this.socket.emit("apis.joinRoom", 'home', () => {});
  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 {
  148. font-size: 15px;
  149. }
  150. }
  151. @media only screen and (min-width: 992px) {
  152. html {
  153. font-size: 14.5px;
  154. }
  155. }
  156. @media only screen and (min-width: 0) {
  157. html {
  158. font-size: 14px;
  159. }
  160. }
  161. .group {
  162. min-height: 64px;
  163. }
  164. .station-card {
  165. margin: 10px;
  166. cursor: pointer;
  167. }
  168. .ccs-button {
  169. cursor: pointer;
  170. transition: .25s ease color;
  171. font-size: 30px;
  172. }
  173. .ccs-button:hover {
  174. color: #03a9f4;
  175. }
  176. .station-blue {
  177. outline: 5px solid #03a9f4;
  178. }
  179. .station-red {
  180. outline: 5px solid #f45703;
  181. }
  182. .label {
  183. display: flex;
  184. }
  185. .g-recaptcha {
  186. display: flex;
  187. justify-content: center;
  188. margin-top: 20px;
  189. }
  190. .group {
  191. text-align: center;
  192. width: 100%;
  193. margin: 64px 0 0 0;
  194. .group-title {
  195. float: left;
  196. clear: none;
  197. width: 100%;
  198. height: 64px;
  199. line-height: 48px;
  200. text-align: center;
  201. font-size: 48px;
  202. margin-bottom: 25px;
  203. }
  204. }
  205. .group .card {
  206. display: inline-block;
  207. height: 415px;
  208. overflow: hidden;
  209. }
  210. .displayName {
  211. word-wrap: break-word;
  212. width: 80%;
  213. }
  214. .content {
  215. word-wrap: break-word;
  216. }
  217. </style>