CommunityHeader.vue 9.0 KB

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