StationHeader.vue 11 KB

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