Home.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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" 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" 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. export default {
  60. data() {
  61. return {
  62. isRegisterActive: false,
  63. isLoginActive: false,
  64. recaptcha: {
  65. key: ''
  66. },
  67. stations: {
  68. official: [],
  69. community: []
  70. }
  71. }
  72. },
  73. ready() {
  74. let _this = this;
  75. auth.getStatus((authenticated, role, username, userId) => {
  76. _this.socket = _this.$parent.socket;
  77. if (_this.socket.connected) {
  78. this.init();
  79. }
  80. _this.socket.on('event:stations.created', station => {
  81. console.log("CREATED!!!", station);
  82. if (!station.currentSong) station.currentSong = {thumbnail: '/assets/notes.png'};
  83. if (station.privacy !== 'public') {
  84. station.class = {'station-red': true}
  85. } else if (station.type === 'community') {
  86. if (station.owner === userId) {
  87. station.class = {'station-blue': true}
  88. }
  89. }
  90. _this.stations[station.type].push(station);
  91. });
  92. });
  93. },
  94. methods: {
  95. toggleModal: function (type) {
  96. this.$dispatch('toggleModal', type);
  97. },
  98. init: function() {
  99. let _this = this;
  100. _this.socket.emit("stations.index", data => {
  101. _this.stations.community = [];
  102. _this.stations.official = [];
  103. if (data.status === "success") data.stations.forEach(station => {
  104. if (!station.currentSong) station.currentSong = { thumbnail: '/assets/notes.png' };
  105. console.log(station.privacy);
  106. if (station.privacy !== 'public') {
  107. console.log(123);
  108. station.class = {'station-red': true}
  109. } else if (station.type === 'community') {
  110. if (station.owner === userId) {
  111. station.class = {'station-blue': true}
  112. }
  113. }
  114. if (station.type == 'official') _this.stations.official.push(station);
  115. else _this.stations.community.push(station);
  116. });
  117. });
  118. _this.socket.emit("apis.joinRoom", 'home', () => {});
  119. }
  120. },
  121. events: {
  122. 'handleSocketConnection': function() {
  123. if (this.$parent.socketConnected) {
  124. this.init();
  125. }
  126. }
  127. },
  128. components: { MainHeader, MainFooter }
  129. }
  130. </script>
  131. <style lang='scss'>
  132. @import 'theme.scss';
  133. * { box-sizing: border-box; }
  134. html {
  135. width: 100%;
  136. height: 100%;
  137. color: rgba(0, 0, 0, 0.87);
  138. body {
  139. width: 100%;
  140. height: 100%;
  141. margin: 0;
  142. padding: 0;
  143. }
  144. }
  145. @media only screen and (min-width: 1200px) {
  146. html {
  147. font-size: 15px;
  148. }
  149. }
  150. @media only screen and (min-width: 992px) {
  151. html {
  152. font-size: 14.5px;
  153. }
  154. }
  155. @media only screen and (min-width: 0) {
  156. html {
  157. font-size: 14px;
  158. }
  159. }
  160. .group {
  161. min-height: 64px;
  162. }
  163. .card {
  164. margin: 10px;
  165. cursor: pointer;
  166. }
  167. .ccs-button {
  168. cursor: pointer;
  169. transition: .25s ease color;
  170. font-size: 30px;
  171. }
  172. .ccs-button:hover {
  173. color: #03a9f4;
  174. }
  175. .station-blue {
  176. outline: 5px solid #03a9f4;
  177. }
  178. .station-red {
  179. outline: 5px solid #f45703;
  180. }
  181. .label {
  182. display: flex;
  183. }
  184. .g-recaptcha {
  185. display: flex;
  186. justify-content: center;
  187. margin-top: 20px;
  188. }
  189. .group {
  190. text-align: center;
  191. width: 100%;
  192. margin: 64px 0 0 0;
  193. .group-title {
  194. float: left;
  195. clear: none;
  196. width: 100%;
  197. height: 64px;
  198. line-height: 48px;
  199. text-align: center;
  200. font-size: 48px;
  201. margin-bottom: 25px;
  202. }
  203. }
  204. .group .card {
  205. display: inline-block;
  206. height: 415px;
  207. overflow: hidden;
  208. }
  209. .displayName {
  210. word-wrap: break-word;
  211. width: 80%;
  212. }
  213. .content {
  214. word-wrap: break-word;
  215. }
  216. </style>