Home.vue 5.0 KB

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