Home.vue 5.5 KB

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