StationHeader.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. <template>
  2. <div>
  3. <nav class="nav">
  4. <div class="nav-left">
  5. <router-link class="nav-item is-brand" :to="{ path: '/' }">
  6. <img
  7. :src="`${this.siteSettings.logo}`"
  8. :alt="`${this.siteSettings.siteName}` || `Musare`"
  9. />
  10. </router-link>
  11. </div>
  12. <div class="nav-center stationDisplayName">
  13. {{ station.displayName }}
  14. </div>
  15. <span class="nav-toggle" v-on:click="controlBar = !controlBar">
  16. <span />
  17. <span />
  18. <span />
  19. </span>
  20. <div class="nav-right nav-menu" :class="{ 'is-active': isMobile }">
  21. <router-link
  22. v-if="role === 'admin'"
  23. class="nav-item is-tab admin"
  24. :to="{ path: '/admin' }"
  25. >
  26. <strong>Admin</strong>
  27. </router-link>
  28. <span v-if="loggedIn" class="grouped">
  29. <router-link
  30. class="nav-item is-tab"
  31. :to="{ path: '/u/' + username }"
  32. >Profile</router-link
  33. >
  34. <router-link class="nav-item is-tab" to="/settings"
  35. >Settings</router-link
  36. >
  37. <a class="nav-item is-tab" @click="logout()">Logout</a>
  38. </span>
  39. <span v-else class="grouped">
  40. <a
  41. class="nav-item"
  42. href="#"
  43. @click="openModal({ sector: 'header', modal: 'login' })"
  44. >Login</a
  45. >
  46. <a
  47. class="nav-item"
  48. href="#"
  49. @click="
  50. openModal({ sector: 'header', modal: 'register' })
  51. "
  52. >Register</a
  53. >
  54. </span>
  55. </div>
  56. </nav>
  57. <div class="control-sidebar" :class="{ 'show-controlBar': controlBar }">
  58. <div class="inner-wrapper">
  59. <div v-if="isOwner()">
  60. <a class="sidebar-item" href="#" @click="settings()">
  61. <span class="icon">
  62. <i class="material-icons">settings</i>
  63. </span>
  64. <span class="icon-purpose">Station settings</span>
  65. </a>
  66. <a
  67. class="sidebar-item"
  68. href="#"
  69. @click="$parent.skipStation()"
  70. >
  71. <span class="icon">
  72. <i class="material-icons">skip_next</i>
  73. </span>
  74. <span class="icon-purpose">Skip current song</span>
  75. </a>
  76. <a
  77. v-if="paused"
  78. class="sidebar-item"
  79. href="#"
  80. @click="$parent.resumeStation()"
  81. >
  82. <span class="icon">
  83. <i class="material-icons">play_arrow</i>
  84. </span>
  85. <span class="icon-purpose">Resume station</span>
  86. </a>
  87. <a
  88. v-if="!paused"
  89. class="sidebar-item"
  90. href="#"
  91. @click="$parent.pauseStation()"
  92. >
  93. <span class="icon">
  94. <i class="material-icons">pause</i>
  95. </span>
  96. <span class="icon-purpose">Pause station</span>
  97. </a>
  98. <hr />
  99. </div>
  100. <div v-if="loggedIn">
  101. <a
  102. v-if="station.type === 'official'"
  103. class="sidebar-item"
  104. href="#"
  105. @click="
  106. openModal({
  107. sector: 'station',
  108. modal: 'addSongToQueue'
  109. })
  110. "
  111. >
  112. <span class="icon">
  113. <i class="material-icons">queue</i>
  114. </span>
  115. <span class="icon-purpose">Add song to queue</span>
  116. </a>
  117. <a
  118. v-if="!isOwner() && !noSong"
  119. class="sidebar-item"
  120. href="#"
  121. @click="$parent.voteSkipStation()"
  122. >
  123. <span class="icon">
  124. <i class="material-icons">skip_next</i>
  125. </span>
  126. <span class="skip-votes">{{
  127. currentSong.skipVotes
  128. }}</span>
  129. <span class="icon-purpose">Skip current song</span>
  130. </a>
  131. <a
  132. v-if="!noSong && !currentSong.simpleSong"
  133. class="sidebar-item"
  134. href="#"
  135. @click="
  136. openModal({
  137. sector: 'station',
  138. modal: 'report'
  139. })
  140. "
  141. >
  142. <span class="icon">
  143. <i class="material-icons">report</i>
  144. </span>
  145. <span class="icon-purpose">Report a song</span>
  146. </a>
  147. <a
  148. v-if="!noSong"
  149. class="sidebar-item"
  150. href="#"
  151. @click="
  152. openModal({
  153. sector: 'station',
  154. modal: 'addSongToPlaylist'
  155. })
  156. "
  157. >
  158. <span class="icon">
  159. <i class="material-icons">playlist_add</i>
  160. </span>
  161. <span class="icon-purpose"
  162. >Add current song to playlist</span
  163. >
  164. </a>
  165. <hr v-if="!noSong" />
  166. </div>
  167. <a
  168. v-if="
  169. station.partyMode === true ||
  170. station.type === 'official'
  171. "
  172. class="sidebar-item"
  173. href="#"
  174. @click="$parent.toggleSidebar('songslist')"
  175. >
  176. <span class="icon">
  177. <i class="material-icons">queue_music</i>
  178. </span>
  179. <span class="icon-purpose">Show the station queue</span>
  180. </a>
  181. <a
  182. class="sidebar-item"
  183. href="#"
  184. @click="$parent.toggleSidebar('users')"
  185. >
  186. <span class="icon">
  187. <i class="material-icons">people</i>
  188. </span>
  189. <span class="icon-purpose"
  190. >Display users in the station</span
  191. >
  192. </a>
  193. <a
  194. v-if="loggedIn && station.type === 'community'"
  195. class="sidebar-item"
  196. href="#"
  197. @click="$parent.toggleSidebar('playlist')"
  198. >
  199. <span class="icon">
  200. <i class="material-icons">library_music</i>
  201. </span>
  202. <span class="icon-purpose">Show your playlists</span>
  203. </a>
  204. </div>
  205. </div>
  206. </div>
  207. </template>
  208. <script>
  209. import { mapState, mapActions } from "vuex";
  210. export default {
  211. data() {
  212. return {
  213. title: this.$route.params.id,
  214. isMobile: false,
  215. controlBar: false,
  216. frontendDomain: "",
  217. siteSettings: {
  218. logo: "",
  219. siteName: ""
  220. }
  221. };
  222. },
  223. computed: mapState({
  224. loggedIn: state => state.user.auth.loggedIn,
  225. userId: state => state.user.auth.userId,
  226. username: state => state.user.auth.username,
  227. role: state => state.user.auth.role,
  228. station: state => state.station.station,
  229. paused: state => state.station.paused,
  230. noSong: state => state.station.noSong,
  231. currentSong: state => state.station.currentSong
  232. }),
  233. mounted() {
  234. lofig.get("frontendDomain", res => {
  235. this.frontendDomain = res;
  236. return res;
  237. });
  238. lofig.get("siteSettings", res => {
  239. this.siteSettings = res;
  240. return res;
  241. });
  242. },
  243. methods: {
  244. isOwner() {
  245. return (
  246. this.loggedIn &&
  247. (this.role === "admin" || this.userId === this.station.owner)
  248. );
  249. },
  250. settings() {
  251. this.editStation({
  252. _id: this.station._id,
  253. name: this.station.name,
  254. type: this.station.type,
  255. partyMode: this.station.partyMode,
  256. description: this.station.description,
  257. privacy: this.station.privacy,
  258. displayName: this.station.displayName
  259. });
  260. this.openModal({
  261. sector: "station",
  262. modal: "editStation"
  263. });
  264. },
  265. ...mapActions("modals", ["openModal"]),
  266. ...mapActions("station", ["editStation"]),
  267. ...mapActions("user/auth", ["logout"])
  268. }
  269. };
  270. </script>
  271. <style lang="scss" scoped>
  272. @import "styles/global.scss";
  273. .nav {
  274. background-color: $primary-color;
  275. line-height: 64px;
  276. z-index: 3;
  277. border-radius: 0% 0% 33% 33% / 0% 0% 7% 7%;
  278. box-shadow: 2px 0 5px 0 rgba(0, 0, 0, 0.16),
  279. 2px 0 10px 0 rgba(0, 0, 0, 0.12);
  280. .is-brand {
  281. font-size: 2.1rem !important;
  282. line-height: 38px !important;
  283. padding: 0 20px;
  284. color: $white;
  285. font-family: Pacifico, cursive;
  286. filter: brightness(0) invert(1);
  287. img {
  288. max-height: 38px;
  289. }
  290. }
  291. }
  292. a.nav-item {
  293. color: $white;
  294. font-size: 17px;
  295. &:hover {
  296. color: $white;
  297. }
  298. padding: 0 12px;
  299. .icon {
  300. height: 64px;
  301. i {
  302. font-size: 2rem;
  303. line-height: 64px;
  304. height: 64px;
  305. width: 34px;
  306. }
  307. }
  308. }
  309. a.nav-item.is-tab:hover {
  310. border-bottom: none;
  311. border-top: solid 1px $white;
  312. }
  313. .admin strong {
  314. color: $purple;
  315. }
  316. .grouped {
  317. margin: 0;
  318. display: flex;
  319. text-decoration: none;
  320. }
  321. .skip-votes {
  322. position: relative;
  323. left: 11px;
  324. }
  325. .nav-toggle {
  326. height: 64px;
  327. }
  328. @media screen and (max-width: 998px) {
  329. .nav-menu {
  330. background-color: $white;
  331. box-shadow: 0 4px 7px rgba(10, 10, 10, 0.1);
  332. left: 0;
  333. display: none;
  334. right: 0;
  335. top: 100%;
  336. position: absolute;
  337. }
  338. .nav-toggle {
  339. display: block;
  340. }
  341. }
  342. .logo {
  343. font-size: 2.1rem;
  344. line-height: 64px;
  345. padding-left: 20px !important;
  346. padding-right: 20px !important;
  347. }
  348. .nav-center {
  349. display: flex;
  350. align-items: center;
  351. color: $primary-color;
  352. font-size: 22px;
  353. position: absolute;
  354. margin: auto;
  355. top: 50%;
  356. left: 50%;
  357. transform: translate(-50%, -50%);
  358. }
  359. .nav-right.is-active .nav-item {
  360. background: $primary-color;
  361. border: 0;
  362. }
  363. .hidden {
  364. display: none;
  365. }
  366. .control-sidebar {
  367. position: fixed;
  368. z-index: 2;
  369. top: 0;
  370. left: 0;
  371. width: 64px;
  372. height: 100vh;
  373. background-color: $primary-color;
  374. box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16),
  375. 0 2px 10px 0 rgba(0, 0, 0, 0.12);
  376. @media (max-width: 998px) {
  377. display: none;
  378. }
  379. .inner-wrapper {
  380. @media (min-width: 999px) {
  381. .mobile-only {
  382. display: none;
  383. }
  384. .desktop-only {
  385. display: flex;
  386. }
  387. }
  388. @media (max-width: 998px) {
  389. .mobile-only {
  390. display: flex;
  391. }
  392. .desktop-only {
  393. display: none;
  394. visibility: hidden;
  395. }
  396. }
  397. }
  398. }
  399. .show-controlBar {
  400. display: block;
  401. }
  402. .inner-wrapper {
  403. top: 64px;
  404. position: relative;
  405. }
  406. .control-sidebar .material-icons {
  407. width: 100%;
  408. font-size: 2rem;
  409. }
  410. .control-sidebar .sidebar-item {
  411. font-size: 2rem;
  412. height: 50px;
  413. color: $white;
  414. -webkit-box-align: center;
  415. -ms-flex-align: center;
  416. align-items: center;
  417. display: -webkit-box;
  418. display: -ms-flexbox;
  419. display: flex;
  420. -webkit-box-flex: 0;
  421. -ms-flex-positive: 0;
  422. flex-grow: 0;
  423. -ms-flex-negative: 0;
  424. flex-shrink: 0;
  425. -webkit-box-pack: center;
  426. -ms-flex-pack: center;
  427. justify-content: center;
  428. width: 100%;
  429. position: relative;
  430. }
  431. .control-sidebar .sidebar-top-hr {
  432. margin: 0 0 20px 0;
  433. }
  434. .sidebar-item .icon-purpose {
  435. visibility: hidden;
  436. width: 160px;
  437. font-size: 12px;
  438. background-color: rgba(3, 169, 244, 0.8);
  439. color: $white;
  440. text-align: center;
  441. border-radius: 6px;
  442. padding: 5px;
  443. position: absolute;
  444. z-index: 2;
  445. left: 115%;
  446. opacity: 0;
  447. transition: opacity 0.5s;
  448. display: none;
  449. }
  450. .sidebar-item .icon-purpose::after {
  451. content: "";
  452. position: absolute;
  453. top: 50%;
  454. right: 100%;
  455. margin-top: -5px;
  456. border-width: 5px;
  457. border-style: solid;
  458. border-color: transparent rgba(3, 169, 244, 0.8) transparent transparent;
  459. }
  460. .sidebar-item:hover .icon-purpose {
  461. visibility: visible;
  462. opacity: 1;
  463. display: block;
  464. }
  465. </style>