StationHeader.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  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_white}`"
  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="!noSong"
  119. class="sidebar-item skip-votes"
  120. href="#"
  121. @click="$parent.voteSkipStation()"
  122. >
  123. <span class="icon">
  124. <i class="material-icons">skip_next</i>
  125. </span>
  126. <span class="count">{{ currentSong.skipVotes }}</span>
  127. <span class="icon-purpose">Skip current song</span>
  128. </a>
  129. <a
  130. v-if="!noSong && !currentSong.simpleSong"
  131. class="sidebar-item"
  132. href="#"
  133. @click="
  134. openModal({
  135. sector: 'station',
  136. modal: 'report'
  137. })
  138. "
  139. >
  140. <span class="icon">
  141. <i class="material-icons">report</i>
  142. </span>
  143. <span class="icon-purpose">Report a song</span>
  144. </a>
  145. <a
  146. v-if="!noSong"
  147. class="sidebar-item"
  148. href="#"
  149. @click="
  150. openModal({
  151. sector: 'station',
  152. modal: 'addSongToPlaylist'
  153. })
  154. "
  155. >
  156. <span class="icon">
  157. <i class="material-icons">playlist_add</i>
  158. </span>
  159. <span class="icon-purpose"
  160. >Add current song to playlist</span
  161. >
  162. </a>
  163. <hr v-if="!noSong" />
  164. </div>
  165. <a
  166. v-if="
  167. station.partyMode === true ||
  168. station.type === 'official'
  169. "
  170. class="sidebar-item"
  171. href="#"
  172. @click="
  173. toggleSidebar({
  174. sector: 'station',
  175. sidebar: 'songslist'
  176. })
  177. "
  178. >
  179. <span class="icon">
  180. <i class="material-icons">queue_music</i>
  181. </span>
  182. <span class="icon-purpose">Show the station queue</span>
  183. </a>
  184. <a
  185. class="sidebar-item"
  186. href="#"
  187. @click="
  188. toggleSidebar({ sector: 'station', sidebar: 'users' })
  189. "
  190. >
  191. <span class="icon">
  192. <i class="material-icons">people</i>
  193. </span>
  194. <span class="icon-purpose"
  195. >Display users in the station</span
  196. >
  197. </a>
  198. <a
  199. v-if="loggedIn && station.type === 'community'"
  200. class="sidebar-item"
  201. href="#"
  202. @click="
  203. toggleSidebar({
  204. sector: 'station',
  205. sidebar: 'playlist'
  206. })
  207. "
  208. >
  209. <span class="icon">
  210. <i class="material-icons">library_music</i>
  211. </span>
  212. <span class="icon-purpose">Show your playlists</span>
  213. </a>
  214. </div>
  215. </div>
  216. </div>
  217. </template>
  218. <script>
  219. import { mapState, mapActions } from "vuex";
  220. export default {
  221. data() {
  222. return {
  223. title: this.$route.params.id,
  224. isMobile: false,
  225. controlBar: false,
  226. frontendDomain: "",
  227. siteSettings: {
  228. logo: "",
  229. siteName: ""
  230. }
  231. };
  232. },
  233. computed: mapState({
  234. loggedIn: state => state.user.auth.loggedIn,
  235. userId: state => state.user.auth.userId,
  236. username: state => state.user.auth.username,
  237. role: state => state.user.auth.role,
  238. station: state => state.station.station,
  239. paused: state => state.station.paused,
  240. noSong: state => state.station.noSong,
  241. currentSong: state => state.station.currentSong
  242. }),
  243. mounted() {
  244. lofig.get("frontendDomain").then(frontendDomain => {
  245. this.frontendDomain = frontendDomain;
  246. });
  247. lofig.get("siteSettings").then(siteSettings => {
  248. this.siteSettings = siteSettings;
  249. });
  250. },
  251. methods: {
  252. isOwner() {
  253. return (
  254. this.loggedIn &&
  255. (this.role === "admin" || this.userId === this.station.owner)
  256. );
  257. },
  258. settings() {
  259. this.editStation({
  260. _id: this.station._id,
  261. name: this.station.name,
  262. type: this.station.type,
  263. partyMode: this.station.partyMode,
  264. description: this.station.description,
  265. privacy: this.station.privacy,
  266. displayName: this.station.displayName,
  267. locked: this.station.locked
  268. });
  269. this.openModal({
  270. sector: "station",
  271. modal: "editStation"
  272. });
  273. },
  274. ...mapActions("modals", ["openModal"]),
  275. ...mapActions("sidebars", ["toggleSidebar"]),
  276. ...mapActions("station", ["editStation"]),
  277. ...mapActions("user/auth", ["logout"])
  278. }
  279. };
  280. </script>
  281. <style lang="scss" scoped>
  282. @import "styles/global.scss";
  283. .nav {
  284. background-color: $primary-color;
  285. line-height: 64px;
  286. border-radius: 0% 0% 33% 33% / 0% 0% 7% 7%;
  287. transition: border-radius 0.1s 0s linear;
  288. .is-brand {
  289. font-size: 2.1rem !important;
  290. line-height: 38px !important;
  291. padding: 0 20px;
  292. font-family: Pacifico, cursive;
  293. img {
  294. max-height: 38px;
  295. color: $musareBlue;
  296. }
  297. }
  298. }
  299. .header-sidebar-active .nav {
  300. border-radius: 0% 0% 0% 33% / 0% 0% 0% 7%;
  301. }
  302. a.nav-item {
  303. color: $white;
  304. font-size: 17px;
  305. &:hover {
  306. color: $white;
  307. }
  308. padding: 0 12px;
  309. .icon {
  310. height: 64px;
  311. i {
  312. font-size: 2rem;
  313. line-height: 64px;
  314. height: 64px;
  315. width: 34px;
  316. }
  317. }
  318. }
  319. a.nav-item.is-tab:hover {
  320. border-bottom: 1px solid transparent;
  321. border-top: 1px solid $white;
  322. }
  323. .admin strong {
  324. color: $purple;
  325. }
  326. .grouped {
  327. margin: 0;
  328. display: flex;
  329. text-decoration: none;
  330. }
  331. .skip-votes {
  332. flex-direction: column;
  333. .count {
  334. font-size: 18px;
  335. }
  336. }
  337. .nav-toggle {
  338. height: 64px;
  339. }
  340. @media screen and (max-width: 998px) {
  341. .nav-menu {
  342. background-color: $white;
  343. box-shadow: 0 4px 7px rgba(10, 10, 10, 0.1);
  344. left: 0;
  345. display: none;
  346. right: 0;
  347. top: 100%;
  348. position: absolute;
  349. }
  350. .nav-toggle {
  351. display: block;
  352. }
  353. }
  354. .logo {
  355. font-size: 2.1rem;
  356. line-height: 64px;
  357. padding-left: 20px !important;
  358. padding-right: 20px !important;
  359. }
  360. .nav-center {
  361. display: flex;
  362. align-items: center;
  363. color: $primary-color;
  364. font-size: 22px;
  365. position: absolute;
  366. margin: auto;
  367. top: 50%;
  368. left: 50%;
  369. transform: translate(-50%, -50%);
  370. }
  371. .nav-right.is-active .nav-item {
  372. background: $primary-color;
  373. border: 0;
  374. }
  375. .hidden {
  376. display: none;
  377. }
  378. .control-sidebar {
  379. position: fixed;
  380. z-index: 1;
  381. top: 0;
  382. left: 0;
  383. width: 64px;
  384. height: 100vh;
  385. background-color: $primary-color;
  386. box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16),
  387. 0 2px 10px 0 rgba(0, 0, 0, 0.12);
  388. @media (max-width: 998px) {
  389. display: none;
  390. }
  391. .inner-wrapper {
  392. @media (min-width: 999px) {
  393. .mobile-only {
  394. display: none;
  395. }
  396. .desktop-only {
  397. display: flex;
  398. }
  399. }
  400. @media (max-width: 998px) {
  401. .mobile-only {
  402. display: flex;
  403. }
  404. .desktop-only {
  405. display: none;
  406. visibility: hidden;
  407. }
  408. }
  409. }
  410. }
  411. .show-controlBar {
  412. display: block;
  413. }
  414. .inner-wrapper {
  415. top: 64px;
  416. position: relative;
  417. }
  418. .control-sidebar .material-icons {
  419. width: 100%;
  420. font-size: 2rem;
  421. }
  422. .control-sidebar .sidebar-item {
  423. font-size: 2rem;
  424. height: 50px;
  425. color: $white;
  426. -webkit-box-align: center;
  427. -ms-flex-align: center;
  428. align-items: center;
  429. display: -webkit-box;
  430. display: -ms-flexbox;
  431. display: flex;
  432. -webkit-box-flex: 0;
  433. -ms-flex-positive: 0;
  434. flex-grow: 0;
  435. -ms-flex-negative: 0;
  436. flex-shrink: 0;
  437. -webkit-box-pack: center;
  438. -ms-flex-pack: center;
  439. justify-content: center;
  440. width: 100%;
  441. position: relative;
  442. }
  443. .control-sidebar .sidebar-top-hr {
  444. margin: 0 0 20px 0;
  445. }
  446. .sidebar-item .icon-purpose {
  447. visibility: hidden;
  448. width: 160px;
  449. font-size: 12px;
  450. background-color: rgba(3, 169, 244, 0.8);
  451. color: $white;
  452. text-align: center;
  453. border-radius: 6px;
  454. padding: 5px;
  455. position: absolute;
  456. z-index: 1;
  457. left: 115%;
  458. opacity: 0;
  459. transition: opacity 0.5s;
  460. display: none;
  461. }
  462. .sidebar-item .icon-purpose::after {
  463. content: "";
  464. position: absolute;
  465. top: 50%;
  466. right: 100%;
  467. margin-top: -5px;
  468. border-width: 5px;
  469. border-style: solid;
  470. border-color: transparent rgba(3, 169, 244, 0.8) transparent transparent;
  471. }
  472. .sidebar-item:hover .icon-purpose {
  473. visibility: visible;
  474. opacity: 1;
  475. display: block;
  476. }
  477. </style>