StationHeader.vue 10 KB

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