Home.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  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" v-if="station.privacy !== 'public'" title="This station is not visible to other users." style="border-right: 1px solid #4a4a4a;padding-right: 3px;">lock</i>
  23. <i class='material-icons' title="How many users there are in the station.">people</i>
  24. <span class="users-count" title="How many users there are in the station.">&nbsp;{{station.userCount}}</span>
  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" v-if="station.privacy !== 'public'" title="This station is not visible to other users." style="border-right: 1px solid #4a4a4a;padding-right: 3px;">lock</i>
  53. <i class="material-icons" v-if="isOwner(station)" title="This is your station." style="border-right: 1px solid #4a4a4a;padding-right: 3px;">home</i>
  54. <i class='material-icons' title="How many users there are in the station.">people</i>
  55. <span class="users-count" title="How many users there are in the station.">&nbsp;{{station.userCount}}</span>
  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. text-align: left;
  188. height: 25px;
  189. bottom: 0;
  190. position: absolute;
  191. margin-bottom: 10px;
  192. line-height: 1;
  193. font-size: 24px;
  194. vertical-align: middle;
  195. * {
  196. z-index: 10;
  197. position: relative;
  198. }
  199. }
  200. .users-count {
  201. font-size: 20px;
  202. position: relative;
  203. top: -4px;
  204. }
  205. .right {
  206. float: right;
  207. }
  208. .group { min-height: 64px; }
  209. .station-card {
  210. margin: 10px;
  211. cursor: pointer;
  212. height: 475px;
  213. .card-content {
  214. max-height: 159px;
  215. .content {
  216. word-wrap: break-word;
  217. overflow: hidden;
  218. text-overflow: ellipsis;
  219. display: -webkit-box;
  220. -webkit-box-orient: vertical;
  221. -webkit-line-clamp: 3;
  222. line-height: 20px;
  223. max-height: 60px;
  224. }
  225. }
  226. }
  227. .station-card:hover {
  228. box-shadow: 0 2px 3px rgba(10, 10, 10, 0.3), 0 0 10px rgba(10, 10, 10, 0.3);
  229. }
  230. /*.isPrivate {
  231. background-color: #F8BBD0;
  232. }
  233. .isMine {
  234. background-color: #29B6F6;
  235. }*/
  236. .community-button {
  237. cursor: pointer;
  238. transition: .25s ease color;
  239. font-size: 30px;
  240. color: #4a4a4a;
  241. }
  242. .community-button:hover { color: #03a9f4; }
  243. .station-privacy { text-transform: capitalize; }
  244. .label { display: flex; }
  245. .g-recaptcha {
  246. display: flex;
  247. justify-content: center;
  248. margin-top: 20px;
  249. }
  250. .group {
  251. text-align: center;
  252. width: 100%;
  253. margin: 64px 0 0 0;
  254. .group-title {
  255. float: left;
  256. clear: none;
  257. width: 100%;
  258. height: 64px;
  259. line-height: 48px;
  260. text-align: center;
  261. font-size: 48px;
  262. margin-bottom: 25px;
  263. }
  264. }
  265. .group .card {
  266. display: inline-flex;
  267. flex-direction: column;
  268. overflow: hidden;
  269. .content {
  270. text-align: left;
  271. word-wrap: break-word;
  272. }
  273. .media {
  274. display: flex;
  275. align-items: center;
  276. .station-status { line-height: 13px; }
  277. h5 { margin: 0; }
  278. }
  279. }
  280. .displayName {
  281. word-wrap: break-word;
  282. width: 80%;
  283. }
  284. .nightMode {
  285. background-color: rgb(51, 51, 51);
  286. color: #e6e6e6;
  287. .community-button {
  288. cursor: pointer;
  289. transition: .25s ease color;
  290. font-size: 30px;
  291. color: #e6e6e6;
  292. }
  293. .community-button:hover { color: #03a9f4; }
  294. .station-card {
  295. margin: 10px;
  296. cursor: pointer;
  297. height: 475px;
  298. background-color: rgb(51, 51, 51);
  299. color: #e6e6e6;
  300. .card-content {
  301. max-height: 159px;
  302. color: #e6e6e6;
  303. .content {
  304. word-wrap: break-word;
  305. overflow: hidden;
  306. text-overflow: ellipsis;
  307. display: -webkit-box;
  308. -webkit-box-orient: vertical;
  309. -webkit-line-clamp: 3;
  310. line-height: 20px;
  311. max-height: 60px;
  312. color: #e6e6e6;
  313. }
  314. }
  315. }
  316. .station-card:hover {
  317. box-shadow: 0 2px 3px rgba(10, 10, 10, 0.3), 0 0 10px rgba(10, 10, 10, 0.3);
  318. }
  319. .isPrivate {
  320. background-color: #d01657;
  321. }
  322. .isMine {
  323. background-color: #0777ab;
  324. }
  325. }
  326. </style>