StationHeader.vue 9.8 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_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="!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").then(frontendDomain => {
  235. this.frontendDomain = frontendDomain;
  236. });
  237. lofig.get("siteSettings").then(siteSettings => {
  238. this.siteSettings = siteSettings;
  239. });
  240. },
  241. methods: {
  242. isOwner() {
  243. return (
  244. this.loggedIn &&
  245. (this.role === "admin" || this.userId === this.station.owner)
  246. );
  247. },
  248. settings() {
  249. this.editStation({
  250. _id: this.station._id,
  251. name: this.station.name,
  252. type: this.station.type,
  253. partyMode: this.station.partyMode,
  254. description: this.station.description,
  255. privacy: this.station.privacy,
  256. displayName: this.station.displayName,
  257. locked: this.station.locked,
  258. theme: this.station.theme
  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 "scss/variables/colors.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. font-family: Pacifico, cursive;
  285. img {
  286. max-height: 38px;
  287. color: $musareBlue;
  288. }
  289. }
  290. }
  291. a.nav-item {
  292. color: $white;
  293. font-size: 17px;
  294. &:hover {
  295. color: $white;
  296. }
  297. padding: 0 12px;
  298. .icon {
  299. height: 64px;
  300. i {
  301. font-size: 2rem;
  302. line-height: 64px;
  303. height: 64px;
  304. width: 34px;
  305. }
  306. }
  307. }
  308. a.nav-item.is-tab:hover {
  309. border-bottom: none;
  310. border-top: solid 1px $white;
  311. }
  312. .admin strong {
  313. color: $purple;
  314. }
  315. .grouped {
  316. margin: 0;
  317. display: flex;
  318. text-decoration: none;
  319. }
  320. .skip-votes {
  321. position: relative;
  322. left: 11px;
  323. }
  324. .nav-toggle {
  325. height: 64px;
  326. }
  327. @media screen and (max-width: 998px) {
  328. .nav-menu {
  329. background-color: $white;
  330. box-shadow: 0 4px 7px rgba(10, 10, 10, 0.1);
  331. left: 0;
  332. display: none;
  333. right: 0;
  334. top: 100%;
  335. position: absolute;
  336. }
  337. .nav-toggle {
  338. display: block;
  339. }
  340. }
  341. .logo {
  342. font-size: 2.1rem;
  343. line-height: 64px;
  344. padding-left: 20px !important;
  345. padding-right: 20px !important;
  346. }
  347. .nav-center {
  348. display: flex;
  349. align-items: center;
  350. color: $primary-color;
  351. font-size: 22px;
  352. position: absolute;
  353. margin: auto;
  354. top: 50%;
  355. left: 50%;
  356. transform: translate(-50%, -50%);
  357. }
  358. .nav-right.is-active .nav-item {
  359. background: $primary-color;
  360. border: 0;
  361. }
  362. .hidden {
  363. display: none;
  364. }
  365. .control-sidebar {
  366. position: fixed;
  367. z-index: 2;
  368. top: 0;
  369. left: 0;
  370. width: 64px;
  371. height: 100vh;
  372. background-color: $primary-color;
  373. box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16),
  374. 0 2px 10px 0 rgba(0, 0, 0, 0.12);
  375. @media (max-width: 998px) {
  376. display: none;
  377. }
  378. .inner-wrapper {
  379. @media (min-width: 999px) {
  380. .mobile-only {
  381. display: none;
  382. }
  383. .desktop-only {
  384. display: flex;
  385. }
  386. }
  387. @media (max-width: 998px) {
  388. .mobile-only {
  389. display: flex;
  390. }
  391. .desktop-only {
  392. display: none;
  393. visibility: hidden;
  394. }
  395. }
  396. }
  397. }
  398. .show-controlBar {
  399. display: block;
  400. }
  401. .inner-wrapper {
  402. top: 64px;
  403. position: relative;
  404. }
  405. .control-sidebar .material-icons {
  406. width: 100%;
  407. font-size: 2rem;
  408. }
  409. .control-sidebar .sidebar-item {
  410. font-size: 2rem;
  411. height: 50px;
  412. color: $white;
  413. -webkit-box-align: center;
  414. -ms-flex-align: center;
  415. align-items: center;
  416. display: -webkit-box;
  417. display: -ms-flexbox;
  418. display: flex;
  419. -webkit-box-flex: 0;
  420. -ms-flex-positive: 0;
  421. flex-grow: 0;
  422. -ms-flex-negative: 0;
  423. flex-shrink: 0;
  424. -webkit-box-pack: center;
  425. -ms-flex-pack: center;
  426. justify-content: center;
  427. width: 100%;
  428. position: relative;
  429. }
  430. .control-sidebar .sidebar-top-hr {
  431. margin: 0 0 20px 0;
  432. }
  433. .sidebar-item .icon-purpose {
  434. visibility: hidden;
  435. width: 160px;
  436. font-size: 12px;
  437. background-color: rgba(3, 169, 244, 0.8);
  438. color: $white;
  439. text-align: center;
  440. border-radius: 6px;
  441. padding: 5px;
  442. position: absolute;
  443. z-index: 2;
  444. left: 115%;
  445. opacity: 0;
  446. transition: opacity 0.5s;
  447. display: none;
  448. }
  449. .sidebar-item .icon-purpose::after {
  450. content: "";
  451. position: absolute;
  452. top: 50%;
  453. right: 100%;
  454. margin-top: -5px;
  455. border-width: 5px;
  456. border-style: solid;
  457. border-color: transparent rgba(3, 169, 244, 0.8) transparent transparent;
  458. }
  459. .sidebar-item:hover .icon-purpose {
  460. visibility: visible;
  461. opacity: 1;
  462. display: block;
  463. }
  464. </style>