Home.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. <template>
  2. <div class="app" :class="{'nightMode': nightMode}">
  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: '/' + station.name }" @click="this.$dispatch('joinStation', station._id)" :class="{'isPrivate': station.privacy === 'private'}">
  7. <div class="card-image">
  8. <figure class="image is-square">
  9. <img :src="station.currentSong.thumbnail" onerror="this.src='/assets/notes-transparent.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>
  18. <div class="content">
  19. {{ station.description }}
  20. </div>
  21. <div class="under-content">
  22. <i class='material-icons' title="How many users there are in the station.">people</i>
  23. <span class="users-count" title="How many users there are in the station.">&nbsp;{{station.userCount}}</span>
  24. <i class="material-icons right-icon" v-if="station.privacy !== 'public'" title="This station is not visible to other users.">lock</i>
  25. </div>
  26. </div>
  27. <a @click="this.$dispatch('joinStation', station._id)" href='#' class='absolute-a' v-link="{ path: '/' + station.name }"></a>
  28. </div>
  29. </div>
  30. <div class="group">
  31. <div class="group-title">
  32. Community Stations&nbsp;
  33. <a @click='modals.createCommunityStation = !modals.createCommunityStation' v-if="$parent.loggedIn" href='#'>
  34. <i class="material-icons community-button">add_circle_outline</i></a>
  35. </div>
  36. <div class="card station-card" v-for="station in stations.community" v-link="{ path: '/community/' + station.name }" @click="this.$dispatch('joinStation', station._id)" :class="{'isPrivate': station.privacy === 'private','isMine': isOwner(station)}">
  37. <div class="card-image">
  38. <figure class="image is-square">
  39. <img :src="station.currentSong.thumbnail" onerror="this.src='/assets/notes-transparent.png'" />
  40. </figure>
  41. </div>
  42. <div class="card-content">
  43. <div class="media">
  44. <div class="media-left displayName">
  45. <h5>{{ station.displayName }}</h5>
  46. </div>
  47. </div>
  48. <div class="content">
  49. {{ station.description }}
  50. </div>
  51. <div class="under-content">
  52. <i class='material-icons' title="How many users there are in the station.">people</i>
  53. <span class="users-count" title="How many users there are in the station.">&nbsp;{{station.userCount}}</span>
  54. <i class="material-icons right-icon" v-if="station.privacy !== 'public'" title="This station is not visible to other users.">lock</i>
  55. <i class="material-icons right-icon" v-if="isOwner(station)" title="This is your station.">home</i>
  56. </div>
  57. </div>
  58. <a @click="this.$dispatch('joinStation', station._id)" href='#' class='absolute-a' v-link="{ path: '/community/' + station.name }"></a>
  59. </div>
  60. </div>
  61. <main-footer></main-footer>
  62. </div>
  63. <create-community-station v-if='modals.createCommunityStation'></create-community-station>
  64. </template>
  65. <script>
  66. import MainHeader from '../MainHeader.vue';
  67. import MainFooter from '../MainFooter.vue';
  68. import CreateCommunityStation from '../Modals/CreateCommunityStation.vue';
  69. import auth from '../../auth';
  70. import io from '../../io';
  71. export default {
  72. data() {
  73. return {
  74. recaptcha: {
  75. key: ''
  76. },
  77. stations: {
  78. official: [],
  79. community: []
  80. },
  81. modals: {
  82. createCommunityStation: false
  83. },
  84. nightMode: false
  85. }
  86. },
  87. ready() {
  88. let _this = this;
  89. auth.getStatus((authenticated, role, username, userId) => {
  90. io.getSocket((socket) => {
  91. _this.socket = socket;
  92. if (_this.socket.connected) _this.init();
  93. io.onConnect(() => {
  94. _this.init();
  95. });
  96. _this.socket.on('event:stations.created', station => {
  97. if (!station.currentSong) station.currentSong = { thumbnail: '/assets/notes-transparent.png' };
  98. if (station.currentSong && !station.currentSong.thumbnail) station.currentSong.thumbnail = "/assets/notes-transparent.png";
  99. _this.stations[station.type].push(station);
  100. });
  101. _this.socket.on('event:userCount.updated', (stationId, userCount) => {
  102. _this.stations.official.forEach((station) => {
  103. if (station._id === stationId) {
  104. station.userCount = userCount;
  105. }
  106. });
  107. _this.stations.community.forEach((station) => {
  108. if (station._id === stationId) {
  109. station.userCount = userCount;
  110. }
  111. });
  112. });
  113. _this.socket.on('event:station.nextSong', (stationId, newSong) => {
  114. _this.stations.official.forEach((station) => {
  115. if (station._id === stationId) {
  116. if (!newSong) newSong = { thumbnail: '/assets/notes-transparent.png' };
  117. if (newSong && !newSong.thumbnail) newSong.thumbnail = "/assets/notes-transparent.png";
  118. station.currentSong = newSong;
  119. }
  120. });
  121. _this.stations.community.forEach((station) => {
  122. if (station._id === stationId) {
  123. if (!newSong) newSong = { thumbnail: '/assets/notes-transparent.png' };
  124. if (newSong && !newSong.thumbnail) newSong.thumbnail = "/assets/notes-transparent.png";
  125. station.currentSong = newSong;
  126. }
  127. });
  128. });
  129. });
  130. });
  131. },
  132. methods: {
  133. toggleModal: function (type) {
  134. this.$dispatch('toggleModal', type);
  135. },
  136. init: function() {
  137. let _this = this;
  138. auth.getStatus((authenticated, role, username, userId) => {
  139. _this.socket.emit('stations.index', data => {
  140. _this.stations.community = [];
  141. _this.stations.official = [];
  142. if (data.status === "success") data.stations.forEach(station => {
  143. if (!station.currentSong) station.currentSong = { thumbnail: '/assets/notes-transparent.png' };
  144. if (station.currentSong && !station.currentSong.thumbnail) station.currentSong.thumbnail = "/assets/notes-transparent.png";
  145. if (station.privacy !== 'public') station.class = { 'station-red': true }
  146. else if (station.type === 'community' && station.owner === userId) station.class = { 'station-blue': true }
  147. if (station.type == 'official') _this.stations.official.push(station);
  148. else _this.stations.community.push(station);
  149. });
  150. });
  151. _this.socket.emit("apis.joinRoom", 'home', () => {
  152. });
  153. });
  154. },
  155. isOwner: function(station) {
  156. let _this = this;
  157. return station.owner === _this.$parent.userId && station.privacy === 'public';
  158. }
  159. },
  160. components: { MainHeader, MainFooter, CreateCommunityStation }
  161. }
  162. </script>
  163. <style lang='scss'>
  164. @import 'theme.scss';
  165. * { box-sizing: border-box; }
  166. html {
  167. width: 100%;
  168. height: 100%;
  169. color: rgba(0, 0, 0, 0.87);
  170. body {
  171. width: 100%;
  172. height: 100%;
  173. margin: 0;
  174. padding: 0;
  175. }
  176. }
  177. @media only screen and (min-width: 1200px) {
  178. html { font-size: 15px; }
  179. }
  180. @media only screen and (min-width: 992px) {
  181. html { font-size: 14.5px; }
  182. }
  183. @media only screen and (min-width: 0) {
  184. html { font-size: 14px; }
  185. }
  186. .under-content {
  187. width: calc(100% - 40px);
  188. left: 20px;
  189. right: 20px;
  190. bottom: 10px;
  191. text-align: left;
  192. height: 25px;
  193. position: absolute;
  194. margin-bottom: 10px;
  195. line-height: 1;
  196. font-size: 24px;
  197. vertical-align: middle;
  198. * {
  199. z-index: 10;
  200. position: relative;
  201. }
  202. .right-icon {
  203. float: right;
  204. }
  205. }
  206. .users-count {
  207. font-size: 20px;
  208. position: relative;
  209. top: -4px;
  210. }
  211. .right {
  212. float: right;
  213. }
  214. .group { min-height: 64px; }
  215. .station-card {
  216. margin: 10px;
  217. cursor: pointer;
  218. height: 475px;
  219. transition: all ease-in-out 0.2s;
  220. .card-content {
  221. max-height: 159px;
  222. .content {
  223. word-wrap: break-word;
  224. overflow: hidden;
  225. text-overflow: ellipsis;
  226. display: -webkit-box;
  227. -webkit-box-orient: vertical;
  228. -webkit-line-clamp: 3;
  229. line-height: 20px;
  230. max-height: 60px;
  231. }
  232. }
  233. }
  234. .station-card:hover {
  235. box-shadow: 0 2px 3px rgba(10, 10, 10, 0.3), 0 0 10px rgba(10, 10, 10, 0.3);
  236. transition: all ease-in-out 0.2s;
  237. }
  238. /*.isPrivate {
  239. background-color: #F8BBD0;
  240. }
  241. .isMine {
  242. background-color: #29B6F6;
  243. }*/
  244. .community-button {
  245. cursor: pointer;
  246. transition: .25s ease color;
  247. font-size: 30px;
  248. color: #4a4a4a;
  249. }
  250. .community-button:hover { color: #03a9f4; }
  251. .station-privacy { text-transform: capitalize; }
  252. .label { display: flex; }
  253. .g-recaptcha {
  254. display: flex;
  255. justify-content: center;
  256. margin-top: 20px;
  257. }
  258. .group {
  259. text-align: center;
  260. width: 100%;
  261. margin: 64px 0 0 0;
  262. .group-title {
  263. float: left;
  264. clear: none;
  265. width: 100%;
  266. height: 64px;
  267. line-height: 48px;
  268. text-align: center;
  269. font-size: 48px;
  270. margin-bottom: 25px;
  271. }
  272. }
  273. .group .card {
  274. display: inline-flex;
  275. flex-direction: column;
  276. overflow: hidden;
  277. .content {
  278. text-align: left;
  279. word-wrap: break-word;
  280. }
  281. .media {
  282. display: flex;
  283. align-items: center;
  284. .station-status { line-height: 13px; }
  285. h5 { margin: 0; }
  286. }
  287. }
  288. .displayName {
  289. word-wrap: break-word;
  290. width: 80%;
  291. word-wrap: break-word;
  292. overflow: hidden;
  293. text-overflow: ellipsis;
  294. display: -webkit-box;
  295. -webkit-box-orient: vertical;
  296. -webkit-line-clamp: 1;
  297. line-height: 30px;
  298. max-height: 30px;
  299. }
  300. .nightMode {
  301. background-color: rgb(51, 51, 51);
  302. color: #e6e6e6;
  303. .community-button {
  304. cursor: pointer;
  305. transition: .25s ease color;
  306. font-size: 30px;
  307. color: #e6e6e6;
  308. }
  309. .community-button:hover { color: #03a9f4; }
  310. .station-card {
  311. margin: 10px;
  312. cursor: pointer;
  313. height: 475px;
  314. background-color: rgb(51, 51, 51);
  315. color: #e6e6e6;
  316. .card-content {
  317. max-height: 159px;
  318. color: #e6e6e6;
  319. .content {
  320. word-wrap: break-word;
  321. overflow: hidden;
  322. text-overflow: ellipsis;
  323. display: -webkit-box;
  324. -webkit-box-orient: vertical;
  325. -webkit-line-clamp: 3;
  326. line-height: 20px;
  327. max-height: 60px;
  328. color: #e6e6e6;
  329. }
  330. }
  331. }
  332. .station-card:hover {
  333. box-shadow: 0 2px 3px rgba(10, 10, 10, 0.3), 0 0 10px rgba(10, 10, 10, 0.3);
  334. }
  335. .isPrivate {
  336. background-color: #d01657;
  337. }
  338. .isMine {
  339. background-color: #0777ab;
  340. }
  341. }
  342. </style>