Home.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <div class="app">
  3. <main-header></main-header>
  4. <div class="modal" :class="{ 'is-active': isRegisterActive }">
  5. <div class="modal-background"></div>
  6. <div class="modal-card">
  7. <header class="modal-card-head">
  8. <p class="modal-card-title">Register</p>
  9. <button class="delete" @click="toggleModal('register')"></button>
  10. </header>
  11. <section class="modal-card-body">
  12. <!-- validation to check if exists http://bulma.io/documentation/elements/form/ -->
  13. <label class="label">Email</label>
  14. <p class="control">
  15. <input class="input" type="text" placeholder="Email..." v-model="$parent.register.email">
  16. </p>
  17. <label class="label">Username</label>
  18. <p class="control">
  19. <input class="input" type="text" placeholder="Username..." v-model="$parent.register.username">
  20. </p>
  21. <label class="label">Password</label>
  22. <p class="control">
  23. <input class="input" type="password" placeholder="Password..." v-model="$parent.register.password">
  24. </p>
  25. <div class="g-recaptcha" :data-sitekey="recaptcha.key"></div>
  26. </section>
  27. <footer class="modal-card-foot">
  28. <a class="button is-primary" @click="submitModal('register')">Submit</a>
  29. </footer>
  30. </div>
  31. </div>
  32. <div class="modal" :class="{ 'is-active': isLoginActive }">
  33. <div class="modal-background"></div>
  34. <div class="modal-card">
  35. <header class="modal-card-head">
  36. <p class="modal-card-title">Login</p>
  37. <button class="delete" @click="toggleModal('login')"></button>
  38. </header>
  39. <section class="modal-card-body">
  40. <!-- validation to check if exists http://bulma.io/documentation/elements/form/ -->
  41. <label class="label">Email</label>
  42. <p class="control">
  43. <input class="input" type="text" placeholder="Email..." v-model="$parent.login.email">
  44. </p>
  45. <label class="label">Password</label>
  46. <p class="control">
  47. <input class="input" type="password" placeholder="Password..." v-model="$parent.login.password">
  48. </p>
  49. </section>
  50. <footer class="modal-card-foot">
  51. <a class="button is-primary" @click="submitModal('login')">Submit</a>
  52. </footer>
  53. </div>
  54. </div>
  55. <div class="group">
  56. <div class="group-title">Official Stations</div>
  57. <div class="group-stations">
  58. <div class="stations-station" v-for="station in stations.official" v-link="{ path: '/' + station.name }" @click="this.$dispatch('joinStation', station.id)">
  59. <img class="station-image" :src="station.playlist[station.currentSongIndex].thumbnail" />
  60. <div class="station-info">
  61. <div class="station-grid-left">
  62. <h3>{{ station.displayName }}</h3>
  63. <p>{{ station.description }}</p>
  64. </div>
  65. <div class="station-grid-right">
  66. <div>{{ station.userCount }}&nbsp;&nbsp;<i class="material-icons">perm_identity</i></div>
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. <div class="group" v-if="stations.community.length">
  73. <div class="group-title">Community Stations</div>
  74. <div class="group-stations">
  75. <div class="stations-station" v-for="station in stations.community" v-link="{ path: '/community/' + station.name }" @click="this.$dispatch('joinStation', station.id)">
  76. <img class="station-image" :src="station.playlist[station.currentSongIndex].thumbnail" />
  77. <div class="station-info">
  78. <div class="station-grid-left">
  79. <h3>{{ station.displayName }}</h3>
  80. <p>{{ station.description }}</p>
  81. </div>
  82. <div class="station-grid-right">
  83. <div>{{ station.userCount }}&nbsp;&nbsp;<i class="material-icons">perm_identity</i></div>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. <main-footer></main-footer>
  90. </div>
  91. </template>
  92. <script>
  93. import MainHeader from '../MainHeader.vue'
  94. import MainFooter from '../MainFooter.vue'
  95. export default {
  96. data() {
  97. return {
  98. isRegisterActive: false,
  99. isLoginActive: false,
  100. recaptcha: {
  101. key: ''
  102. },
  103. stations: {
  104. official: [],
  105. community: []
  106. }
  107. }
  108. },
  109. ready() {
  110. let _this = this;
  111. lofig.get('recaptcha.key', function(key) {
  112. _this.recaptcha.key = key;
  113. });
  114. let socketInterval = setInterval(() => {
  115. if (!!_this.$parent.socket) {
  116. _this.socket = _this.$parent.socket;
  117. _this.socket.emit("stations.index", data => {
  118. if (data.status === "success") data.stations.forEach(station => {
  119. if (station.type == 'official') _this.stations.official.push(station);
  120. else _this.stations.community.push(station);
  121. });
  122. });
  123. _this.socket.emit("");
  124. _this.socket.on("");
  125. clearInterval(socketInterval);
  126. }
  127. }, 100);
  128. },
  129. methods: {
  130. toggleModal: function(type) {
  131. switch(type) {
  132. case 'register':
  133. this.isRegisterActive = !this.isRegisterActive;
  134. break;
  135. case 'login':
  136. this.isLoginActive = !this.isLoginActive;
  137. break;
  138. }
  139. },
  140. submitModal: function(type) {
  141. switch(type) {
  142. case 'register':
  143. this.$dispatch('register');
  144. this.toggleModal('register');
  145. break;
  146. case 'login':
  147. this.$dispatch('login');
  148. this.toggleModal('login');
  149. break;
  150. }
  151. }
  152. },
  153. components: { MainHeader, MainFooter }
  154. }
  155. </script>
  156. <style lang="scss">
  157. @import 'theme.scss';
  158. * { box-sizing: border-box; }
  159. html {
  160. width: 100%;
  161. height: 100%;
  162. color: rgba(0, 0, 0, 0.87);
  163. body {
  164. width: 100%;
  165. height: 100%;
  166. margin: 0;
  167. padding: 0;
  168. }
  169. }
  170. @media only screen and (min-width: 1200px) {
  171. html {
  172. font-size: 15px;
  173. }
  174. }
  175. @media only screen and (min-width: 992px) {
  176. html {
  177. font-size: 14.5px;
  178. }
  179. }
  180. @media only screen and (min-width: 0) {
  181. html {
  182. font-size: 14px;
  183. }
  184. }
  185. .label {
  186. display: flex;
  187. }
  188. .g-recaptcha {
  189. display: flex;
  190. justify-content: center;
  191. margin-top: 20px;
  192. }
  193. .group {
  194. width: 100%;
  195. height: 448px;
  196. margin: 64px 0 0 0;
  197. .group-title {
  198. float: left;
  199. clear: none;
  200. width: 100%;
  201. height: 64px;
  202. line-height: 48px;
  203. text-align: center;
  204. font-size: 48px;
  205. }
  206. .group-stations {
  207. white-space: nowrap;
  208. text-align: center;
  209. overflow: hidden;
  210. float: left;
  211. clear: none;
  212. width: 100%;
  213. height: 400px;
  214. .stations-station {
  215. position: relative;
  216. top: 16px;
  217. display: inline-block;
  218. clear: none;
  219. width: 256px;
  220. height: 370px;
  221. margin: 0 16px 0 16px;
  222. box-shadow: 0 1px 6px 2px rgba(0, 0, 0, 0.25);
  223. cursor: pointer;
  224. .station-info {
  225. display: flex;
  226. flex-direction: row;
  227. align-items: center;
  228. }
  229. .station-image {
  230. width: 100%;
  231. height: 256px;
  232. object-fit: cover;
  233. }
  234. .station-grid-left {
  235. display: flex;
  236. flex-direction: column;
  237. width: 75%;
  238. text-align: left;
  239. padding-left: 10px;
  240. h3 {
  241. color: $blue;
  242. margin: 0;
  243. white-space: normal;
  244. padding-top: 10px;
  245. }
  246. p {
  247. margin: 0;
  248. white-space: normal;
  249. padding-top: 10px;
  250. }
  251. }
  252. .station-grid-right {
  253. display: flex;
  254. flex-direction: column;
  255. width: 25%;
  256. i {
  257. color: $blue;
  258. }
  259. }
  260. }
  261. }
  262. }
  263. </style>