index.vue 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104
  1. <template>
  2. <div>
  3. <modal title="Edit Song" class="song-modal">
  4. <template #body>
  5. <div class="left-section">
  6. <div class="top-section">
  7. <div class="player-section">
  8. <div id="editSongPlayer"></div>
  9. <div v-show="youtubeError" class="player-error">
  10. <h2>{{ youtubeErrorMessage }}</h2>
  11. </div>
  12. <canvas
  13. ref="durationCanvas"
  14. v-show="!youtubeError"
  15. height="20"
  16. width="530"
  17. ></canvas>
  18. <div class="player-footer">
  19. <div class="player-footer-left">
  20. <i
  21. class="material-icons player-play-pause"
  22. @click="play()"
  23. @keyup.enter="play()"
  24. tabindex="0"
  25. v-if="video.paused"
  26. >play_arrow</i
  27. >
  28. <i
  29. class="material-icons player-play-pause"
  30. @click="settings('pause')"
  31. @keyup.enter="settings('pause')"
  32. tabindex="0"
  33. v-if="!video.paused"
  34. >pause</i
  35. >
  36. <i
  37. class="material-icons player-stop"
  38. @click="settings('stop')"
  39. @keyup.enter="settings('stop')"
  40. tabindex="0"
  41. >stop</i
  42. >
  43. <i
  44. class="material-icons player-fast-forward"
  45. @click="settings('skipToLast10Secs')"
  46. @keyup.enter="
  47. settings('skipToLast10Secs')
  48. "
  49. tabindex="0"
  50. >fast_forward</i
  51. >
  52. </div>
  53. <div class="player-footer-center">
  54. <img src="/assets/social/youtube.svg" />
  55. <span>
  56. <span>
  57. {{ youtubeVideoCurrentTime }}
  58. </span>
  59. /
  60. <span>
  61. {{ youtubeVideoDuration }}
  62. {{ youtubeVideoNote }}
  63. </span>
  64. </span>
  65. </div>
  66. <div class="player-footer-right">
  67. <input
  68. type="range"
  69. v-model="volumeSliderValue"
  70. min="0"
  71. max="10000"
  72. class="active"
  73. @change="changeVolume()"
  74. @input="changeVolume()"
  75. />
  76. </div>
  77. </div>
  78. </div>
  79. <img
  80. class="thumbnail-preview"
  81. :src="song.thumbnail"
  82. onerror="this.src='/assets/notes-transparent.png'"
  83. ref="thumbnailElement"
  84. v-if="songDataLoaded"
  85. />
  86. </div>
  87. <div class="edit-section" v-if="songDataLoaded">
  88. <div class="control is-grouped">
  89. <div class="title-container">
  90. <label class="label">Title</label>
  91. <p class="control has-addons">
  92. <input
  93. class="input"
  94. type="text"
  95. ref="title-input"
  96. v-model="song.title"
  97. @keyup.shift.enter="
  98. getAlbumData('title')
  99. "
  100. />
  101. <button
  102. class="button album-get-button"
  103. @click="getAlbumData('title')"
  104. >
  105. <i class="material-icons">album</i>
  106. </button>
  107. </p>
  108. </div>
  109. <div class="duration-container">
  110. <label class="label">Duration</label>
  111. <p class="control has-addons">
  112. <input
  113. class="input"
  114. type="text"
  115. v-model.number="song.duration"
  116. @keyup.shift.enter="fillDuration()"
  117. />
  118. <button
  119. class="button duration-fill-button"
  120. @click="fillDuration()"
  121. >
  122. <i class="material-icons">sync</i>
  123. </button>
  124. </p>
  125. </div>
  126. <div class="skip-duration-container">
  127. <label class="label">Skip duration</label>
  128. <p class="control">
  129. <input
  130. class="input"
  131. type="text"
  132. v-model.number="song.skipDuration"
  133. />
  134. </p>
  135. </div>
  136. </div>
  137. <div class="control is-grouped">
  138. <div class="album-art-container">
  139. <label class="label">Album art</label>
  140. <p class="control has-addons">
  141. <input
  142. class="input"
  143. type="text"
  144. v-model="song.thumbnail"
  145. @keyup.shift.enter="
  146. getAlbumData('albumArt')
  147. "
  148. />
  149. <button
  150. class="button album-get-button"
  151. @click="getAlbumData('albumArt')"
  152. >
  153. <i class="material-icons">album</i>
  154. </button>
  155. </p>
  156. </div>
  157. </div>
  158. <div class="control is-grouped">
  159. <div class="artists-container">
  160. <label class="label">Artists</label>
  161. <p class="control has-addons">
  162. <input
  163. class="input"
  164. type="text"
  165. ref="new-artist"
  166. v-model="artistInputValue"
  167. @blur="blurArtistInput()"
  168. @focus="focusArtistInput()"
  169. @keydown="keydownArtistInput()"
  170. @keyup.exact.enter="addTag('artists')"
  171. @keyup.shift.enter="
  172. getAlbumData('artists')
  173. "
  174. />
  175. <button
  176. class="button album-get-button"
  177. @click="getAlbumData('artists')"
  178. >
  179. <i class="material-icons">album</i>
  180. </button>
  181. <button
  182. class="button is-info add-button"
  183. @click="addTag('artists')"
  184. >
  185. <i class="material-icons">add</i>
  186. </button>
  187. </p>
  188. <div
  189. class="autosuggest-container"
  190. v-if="
  191. (artistInputFocussed ||
  192. artistAutosuggestContainerFocussed) &&
  193. artistAutosuggestItems.length > 0
  194. "
  195. @mouseover="focusArtistContainer()"
  196. @mouseleave="blurArtistContainer()"
  197. >
  198. <span
  199. class="autosuggest-item"
  200. tabindex="0"
  201. @click="selectArtistAutosuggest(item)"
  202. v-for="item in artistAutosuggestItems"
  203. :key="item"
  204. >{{ item }}</span
  205. >
  206. </div>
  207. <div class="list-container">
  208. <div
  209. class="list-item"
  210. v-for="artist in song.artists"
  211. :key="artist"
  212. >
  213. <div
  214. class="list-item-circle"
  215. @click="
  216. removeTag('artists', artist)
  217. "
  218. >
  219. <i class="material-icons">close</i>
  220. </div>
  221. <p>{{ artist }}</p>
  222. </div>
  223. </div>
  224. </div>
  225. <div class="genres-container">
  226. <label class="label">
  227. <span>Genres</span>
  228. <i
  229. class="material-icons"
  230. @click="toggleGenreHelper"
  231. @dblclick="resetGenreHelper"
  232. >info</i
  233. >
  234. </label>
  235. <p class="control has-addons">
  236. <input
  237. class="input"
  238. type="text"
  239. ref="new-genre"
  240. v-model="genreInputValue"
  241. @blur="blurGenreInput()"
  242. @focus="focusGenreInput()"
  243. @keydown="keydownGenreInput()"
  244. @keyup.exact.enter="addTag('genres')"
  245. @keyup.shift.enter="
  246. getAlbumData('genres')
  247. "
  248. />
  249. <button
  250. class="button album-get-button"
  251. @click="getAlbumData('genres')"
  252. >
  253. <i class="material-icons">album</i>
  254. </button>
  255. <button
  256. class="button is-info add-button"
  257. @click="addTag('genres')"
  258. >
  259. <i class="material-icons">add</i>
  260. </button>
  261. </p>
  262. <div
  263. class="autosuggest-container"
  264. v-if="
  265. (genreInputFocussed ||
  266. genreAutosuggestContainerFocussed) &&
  267. genreAutosuggestItems.length > 0
  268. "
  269. @mouseover="focusGenreContainer()"
  270. @mouseleave="blurGenreContainer()"
  271. >
  272. <span
  273. class="autosuggest-item"
  274. @click="selectGenreAutosuggest(item)"
  275. v-for="item in genreAutosuggestItems"
  276. :key="item"
  277. >{{ item }}</span
  278. >
  279. </div>
  280. <div class="list-container">
  281. <div
  282. class="list-item"
  283. v-for="genre in song.genres"
  284. :key="genre"
  285. >
  286. <div
  287. class="list-item-circle"
  288. @click="removeTag('genres', genre)"
  289. >
  290. <i class="material-icons">close</i>
  291. </div>
  292. <p>{{ genre }}</p>
  293. </div>
  294. </div>
  295. </div>
  296. <div class="youtube-id-container">
  297. <label class="label">YouTube ID</label>
  298. <p class="control">
  299. <input
  300. class="input"
  301. type="text"
  302. v-model="song.youtubeId"
  303. />
  304. </p>
  305. </div>
  306. </div>
  307. </div>
  308. </div>
  309. <div class="right-section" v-if="songDataLoaded">
  310. <div id="tabs-container">
  311. <div id="tab-selection">
  312. <button
  313. class="button is-default"
  314. :class="{ selected: tab === 'discogs' }"
  315. ref="discogs-tab"
  316. @click="showTab('discogs')"
  317. >
  318. Discogs
  319. </button>
  320. <button
  321. class="button is-default"
  322. :class="{ selected: tab === 'reports' }"
  323. ref="reports-tab"
  324. @click="showTab('reports')"
  325. >
  326. Reports ({{ reports.length }})
  327. </button>
  328. <button
  329. class="button is-default"
  330. :class="{ selected: tab === 'youtube' }"
  331. ref="youtube-tab"
  332. @click="showTab('youtube')"
  333. >
  334. YouTube
  335. </button>
  336. </div>
  337. <discogs class="tab" v-show="tab === 'discogs'" />
  338. <reports class="tab" v-show="tab === 'reports'" />
  339. <youtube class="tab" v-show="tab === 'youtube'" />
  340. </div>
  341. </div>
  342. </template>
  343. <template #footer>
  344. <div>
  345. <save-button
  346. ref="saveButton"
  347. @clicked="save(song, false, false)"
  348. />
  349. <save-button
  350. ref="saveAndCloseButton"
  351. type="save-and-close"
  352. @clicked="save(song, false, true)"
  353. />
  354. <button
  355. class="button is-primary"
  356. @click="save(song, true, true)"
  357. >
  358. Save, verify and close
  359. </button>
  360. <button
  361. class="button is-danger"
  362. @click="stopEditingSongs()"
  363. v-if="modals.importAlbum && editingSongs"
  364. >
  365. Stop editing songs
  366. </button>
  367. <div class="right">
  368. <button
  369. v-if="song.status !== 'verified'"
  370. class="button is-success"
  371. @click="verify(song._id)"
  372. content="Verify Song"
  373. v-tippy
  374. >
  375. <i class="material-icons">check_circle</i>
  376. </button>
  377. <confirm
  378. v-if="song.status === 'verified'"
  379. placement="left"
  380. @confirm="unverify(song._id)"
  381. >
  382. <button
  383. class="button is-danger"
  384. content="Unverify Song"
  385. v-tippy
  386. >
  387. <i class="material-icons">cancel</i>
  388. </button>
  389. </confirm>
  390. <confirm
  391. v-if="song.status !== 'hidden'"
  392. placement="left"
  393. @confirm="hide(song._id)"
  394. >
  395. <button
  396. class="button is-danger"
  397. content="Hide Song"
  398. v-tippy
  399. >
  400. <i class="material-icons">visibility_off</i>
  401. </button>
  402. </confirm>
  403. <button
  404. v-if="song.status === 'hidden'"
  405. class="button is-success"
  406. @click="unhide(song._id)"
  407. content="Unhide Song"
  408. v-tippy
  409. >
  410. <i class="material-icons">visibility</i>
  411. </button>
  412. <!-- <confirm placement="left" @confirm="remove(song._id)">
  413. <button
  414. class="button is-danger"
  415. content="Remove Song"
  416. v-tippy
  417. >
  418. <i class="material-icons">delete</i>
  419. </button>
  420. </confirm> -->
  421. </div>
  422. </div>
  423. </template>
  424. </modal>
  425. <floating-box id="genreHelper" ref="genreHelper">
  426. <template #body>
  427. <span>Blues</span><span>Country</span><span>Disco</span
  428. ><span>Funk</span><span>Hip-Hop</span><span>Jazz</span
  429. ><span>Metal</span><span>Oldies</span><span>Other</span
  430. ><span>Pop</span><span>Rap</span><span>Reggae</span
  431. ><span>Rock</span><span>Techno</span><span>Trance</span
  432. ><span>Classical</span><span>Instrumental</span
  433. ><span>House</span><span>Electronic</span
  434. ><span>Christian Rap</span><span>Lo-Fi</span><span>Musical</span
  435. ><span>Rock 'n' Roll</span><span>Opera</span
  436. ><span>Drum & Bass</span><span>Club-House</span
  437. ><span>Indie</span><span>Heavy Metal</span
  438. ><span>Christian rock</span><span>Dubstep</span>
  439. </template>
  440. </floating-box>
  441. </div>
  442. </template>
  443. <script>
  444. import { mapState, mapGetters, mapActions } from "vuex";
  445. import Toast from "toasters";
  446. import aw from "@/aw";
  447. import validation from "@/validation";
  448. import keyboardShortcuts from "@/keyboardShortcuts";
  449. import Confirm from "@/components/Confirm.vue";
  450. import Modal from "../../Modal.vue";
  451. import FloatingBox from "../../FloatingBox.vue";
  452. import SaveButton from "../../SaveButton.vue";
  453. import Discogs from "./Tabs/Discogs.vue";
  454. import Reports from "./Tabs/Reports.vue";
  455. import Youtube from "./Tabs/Youtube.vue";
  456. export default {
  457. components: {
  458. Modal,
  459. FloatingBox,
  460. SaveButton,
  461. Confirm,
  462. Discogs,
  463. Reports,
  464. Youtube
  465. },
  466. props: {
  467. youtubeId: { type: String, default: null },
  468. songId: { type: String, default: null },
  469. discogsAlbum: { type: Object, default: null },
  470. // songType: { type: String, default: null },
  471. sector: { type: String, default: "admin" }
  472. },
  473. data() {
  474. return {
  475. songDataLoaded: false,
  476. youtubeError: false,
  477. youtubeErrorMessage: "",
  478. focusedElementBefore: null,
  479. youtubeVideoDuration: "0.000",
  480. youtubeVideoCurrentTime: 0,
  481. youtubeVideoNote: "",
  482. useHTTPS: false,
  483. volumeSliderValue: 0,
  484. skipToLast10SecsPressed: false,
  485. artistInputValue: "",
  486. genreInputValue: "",
  487. artistInputFocussed: false,
  488. genreInputFocussed: false,
  489. genreAutosuggestContainerFocussed: false,
  490. artistAutosuggestContainerFocussed: false,
  491. keydownArtistInputTimeout: 0,
  492. keydownGenreInputTimeout: 0,
  493. artistAutosuggestItems: [],
  494. genreAutosuggestItems: [],
  495. activityWatchVideoDataInterval: null,
  496. activityWatchVideoLastStatus: "",
  497. activityWatchVideoLastStartDuration: "",
  498. genres: [
  499. "Blues",
  500. "Country",
  501. "Disco",
  502. "Funk",
  503. "Hip-Hop",
  504. "Jazz",
  505. "Metal",
  506. "Oldies",
  507. "Other",
  508. "Pop",
  509. "Rap",
  510. "Reggae",
  511. "Rock",
  512. "Techno",
  513. "Trance",
  514. "Classical",
  515. "Instrumental",
  516. "House",
  517. "Electronic",
  518. "Christian Rap",
  519. "Lo-Fi",
  520. "Musical",
  521. "Rock 'n' Roll",
  522. "Opera",
  523. "Drum & Bass",
  524. "Club-House",
  525. "Indie",
  526. "Heavy Metal",
  527. "Christian rock",
  528. "Dubstep"
  529. ]
  530. };
  531. },
  532. computed: {
  533. ...mapState("modals/editSong", {
  534. tab: state => state.tab,
  535. video: state => state.video,
  536. song: state => state.song,
  537. originalSong: state => state.originalSong,
  538. reports: state => state.reports
  539. }),
  540. ...mapState("modals/importAlbum", {
  541. editingSongs: state => state.editingSongs
  542. }),
  543. ...mapState("modalVisibility", {
  544. modals: state => state.modals
  545. }),
  546. ...mapGetters({
  547. socket: "websockets/getSocket"
  548. })
  549. },
  550. watch: {
  551. /* eslint-disable */
  552. "song.duration": function() {
  553. this.drawCanvas();
  554. },
  555. "song.skipDuration": function() {
  556. this.drawCanvas();
  557. }
  558. /* eslint-enable */
  559. },
  560. async mounted() {
  561. // if (this.modals.editSong = false) this.video.player.stopVideo();
  562. // this.loadVideoById(
  563. // this.song.youtubeId,
  564. // this.song.skipDuration
  565. // );
  566. this.activityWatchVideoDataInterval = setInterval(() => {
  567. this.sendActivityWatchVideoData();
  568. }, 1000);
  569. this.useHTTPS = await lofig.get("cookie.secure");
  570. this.socket.dispatch(`songs.getSongFromSongId`, this.song._id, res => {
  571. if (res.status === "success") {
  572. const { song } = res.data;
  573. // this.song = { ...song };
  574. // if (this.song.discogs === undefined)
  575. // this.song.discogs = null;
  576. if (this.song.discogs)
  577. this.editSong({ ...song, discogs: this.song.discogs });
  578. else this.editSong(song);
  579. this.songDataLoaded = true;
  580. this.socket.dispatch(
  581. "apis.joinRoom",
  582. `edit-song.${this.song._id}`
  583. );
  584. // this.edit(res.data.song);
  585. this.interval = setInterval(() => {
  586. if (
  587. this.song.duration !== -1 &&
  588. this.video.paused === false &&
  589. this.playerReady &&
  590. (this.video.player.getCurrentTime() -
  591. this.song.skipDuration >
  592. this.song.duration ||
  593. (this.video.player.getCurrentTime() > 0 &&
  594. this.video.player.getCurrentTime() >=
  595. this.video.player.getDuration()))
  596. ) {
  597. this.video.paused = true;
  598. this.video.player.stopVideo();
  599. this.drawCanvas();
  600. }
  601. if (this.playerReady) {
  602. this.youtubeVideoCurrentTime = this.video.player
  603. .getCurrentTime()
  604. .toFixed(3);
  605. }
  606. if (this.video.paused === false) this.drawCanvas();
  607. }, 200);
  608. if (window.YT && window.YT.Player) {
  609. this.video.player = new window.YT.Player("editSongPlayer", {
  610. height: 298,
  611. width: 530,
  612. videoId: this.song.youtubeId,
  613. host: "https://www.youtube-nocookie.com",
  614. playerVars: {
  615. controls: 0,
  616. iv_load_policy: 3,
  617. rel: 0,
  618. showinfo: 0,
  619. autoplay: 0
  620. },
  621. startSeconds: this.song.skipDuration,
  622. events: {
  623. onReady: () => {
  624. let volume = parseInt(
  625. localStorage.getItem("volume")
  626. );
  627. volume =
  628. typeof volume === "number" ? volume : 20;
  629. this.video.player.setVolume(volume);
  630. if (volume > 0) this.video.player.unMute();
  631. const duration = this.video.player.getDuration();
  632. this.youtubeVideoDuration = duration.toFixed(3);
  633. this.youtubeVideoNote = "(~)";
  634. this.playerReady = true;
  635. this.drawCanvas();
  636. },
  637. onStateChange: event => {
  638. this.drawCanvas();
  639. let skipToLast10SecsPressed = false;
  640. if (
  641. event.data === 1 &&
  642. this.skipToLast10SecsPressed
  643. ) {
  644. this.skipToLast10SecsPressed = false;
  645. skipToLast10SecsPressed = true;
  646. }
  647. if (
  648. event.data === 1 &&
  649. !skipToLast10SecsPressed
  650. ) {
  651. this.video.paused = false;
  652. let youtubeDuration = this.video.player.getDuration();
  653. const newYoutubeVideoDuration = youtubeDuration.toFixed(
  654. 3
  655. );
  656. const songDurationNumber = Number(
  657. this.song.duration
  658. );
  659. const songDurationNumber2 =
  660. Number(this.song.duration) + 1;
  661. const songDurationNumber3 =
  662. Number(this.song.duration) - 1;
  663. const fixedSongDuration = songDurationNumber.toFixed(
  664. 3
  665. );
  666. const fixedSongDuration2 = songDurationNumber2.toFixed(
  667. 3
  668. );
  669. const fixedSongDuration3 = songDurationNumber3.toFixed(
  670. 3
  671. );
  672. if (
  673. this.youtubeVideoDuration !==
  674. newYoutubeVideoDuration &&
  675. (fixedSongDuration ===
  676. this.youtubeVideoDuration ||
  677. fixedSongDuration2 ===
  678. this.youtubeVideoDuration ||
  679. fixedSongDuration3 ===
  680. this.youtubeVideoDuration)
  681. )
  682. this.song.duration = newYoutubeVideoDuration;
  683. this.youtubeVideoDuration = newYoutubeVideoDuration;
  684. this.youtubeVideoNote = "";
  685. if (this.song.duration === -1)
  686. this.song.duration = youtubeDuration;
  687. youtubeDuration -= this.song.skipDuration;
  688. if (
  689. this.song.duration >
  690. youtubeDuration + 1
  691. ) {
  692. this.video.player.stopVideo();
  693. this.video.paused = true;
  694. return new Toast(
  695. "Video can't play. Specified duration is bigger than the YouTube song duration."
  696. );
  697. }
  698. if (this.song.duration <= 0) {
  699. this.video.player.stopVideo();
  700. this.video.paused = true;
  701. return new Toast(
  702. "Video can't play. Specified duration has to be more than 0 seconds."
  703. );
  704. }
  705. if (
  706. this.video.player.getCurrentTime() <
  707. this.song.skipDuration
  708. ) {
  709. return this.video.player.seekTo(
  710. this.song.skipDuration
  711. );
  712. }
  713. } else if (event.data === 2) {
  714. this.video.paused = true;
  715. }
  716. return false;
  717. }
  718. }
  719. });
  720. } else {
  721. this.youtubeError = true;
  722. this.youtubeErrorMessage = "Player could not be loaded.";
  723. }
  724. } else {
  725. new Toast("Song with that ID not found");
  726. this.closeModal("editSong");
  727. }
  728. });
  729. this.socket.dispatch(
  730. "reports.getReportsForSong",
  731. this.song._id,
  732. res => {
  733. this.updateReports(res.data.reports);
  734. }
  735. );
  736. let volume = parseFloat(localStorage.getItem("volume"));
  737. volume =
  738. typeof volume === "number" && !Number.isNaN(volume) ? volume : 20;
  739. localStorage.setItem("volume", volume);
  740. this.volumeSliderValue = volume * 100;
  741. this.socket.on(
  742. "event:admin.hiddenSong.created",
  743. res => {
  744. if (res.data.song._id === this.song._id)
  745. this.song.status = res.data.song.status;
  746. },
  747. { modal: "editSong" }
  748. );
  749. this.socket.on(
  750. "event:admin.unverifiedSong.created",
  751. res => {
  752. if (res.data.song._id === this.song._id)
  753. this.song.status = res.data.song.status;
  754. },
  755. { modal: "editSong" }
  756. );
  757. this.socket.on(
  758. "event:admin.verifiedSong.created",
  759. res => {
  760. if (res.data.song._id === this.song._id)
  761. this.song.status = res.data.song.status;
  762. },
  763. { modal: "editSong" }
  764. );
  765. keyboardShortcuts.registerShortcut("editSong.pauseResumeVideo", {
  766. keyCode: 101,
  767. preventDefault: true,
  768. handler: () => {
  769. if (this.video.paused) this.play();
  770. else this.settings("pause");
  771. }
  772. });
  773. keyboardShortcuts.registerShortcut("editSong.stopVideo", {
  774. keyCode: 101,
  775. ctrl: true,
  776. preventDefault: true,
  777. handler: () => {
  778. this.settings("stop");
  779. }
  780. });
  781. keyboardShortcuts.registerShortcut("editSong.skipToLast10Secs", {
  782. keyCode: 102,
  783. preventDefault: true,
  784. handler: () => {
  785. this.settings("skipToLast10Secs");
  786. }
  787. });
  788. keyboardShortcuts.registerShortcut("editSong.lowerVolumeLarge", {
  789. keyCode: 98,
  790. preventDefault: true,
  791. handler: () => {
  792. this.volumeSliderValue = Math.max(
  793. 0,
  794. this.volumeSliderValue - 1000
  795. );
  796. this.changeVolume();
  797. }
  798. });
  799. keyboardShortcuts.registerShortcut("editSong.lowerVolumeSmall", {
  800. keyCode: 98,
  801. ctrl: true,
  802. preventDefault: true,
  803. handler: () => {
  804. this.volumeSliderValue = Math.max(
  805. 0,
  806. this.volumeSliderValue - 100
  807. );
  808. this.changeVolume();
  809. }
  810. });
  811. keyboardShortcuts.registerShortcut("editSong.increaseVolumeLarge", {
  812. keyCode: 104,
  813. preventDefault: true,
  814. handler: () => {
  815. this.volumeSliderValue = Math.min(
  816. 10000,
  817. this.volumeSliderValue + 1000
  818. );
  819. this.changeVolume();
  820. }
  821. });
  822. keyboardShortcuts.registerShortcut("editSong.increaseVolumeSmall", {
  823. keyCode: 104,
  824. ctrl: true,
  825. preventDefault: true,
  826. handler: () => {
  827. this.volumeSliderValue = Math.min(
  828. 10000,
  829. this.volumeSliderValue + 100
  830. );
  831. this.changeVolume();
  832. }
  833. });
  834. keyboardShortcuts.registerShortcut("editSong.save", {
  835. keyCode: 83,
  836. ctrl: true,
  837. preventDefault: true,
  838. handler: () => {
  839. this.save(this.song, false, false);
  840. }
  841. });
  842. keyboardShortcuts.registerShortcut("editSong.saveClose", {
  843. keyCode: 83,
  844. ctrl: true,
  845. alt: true,
  846. preventDefault: true,
  847. handler: () => {
  848. this.save(this.song, true);
  849. }
  850. });
  851. keyboardShortcuts.registerShortcut("editSong.saveVerifyClose", {
  852. keyCode: 86,
  853. ctrl: true,
  854. alt: true,
  855. preventDefault: true,
  856. handler: () => {
  857. // alert("not implemented yet");
  858. }
  859. });
  860. keyboardShortcuts.registerShortcut("editSong.close", {
  861. keyCode: 115,
  862. preventDefault: true,
  863. handler: () => {
  864. this.closeModal("editSong");
  865. setTimeout(() => {
  866. window.focusedElementBefore.focus();
  867. }, 500);
  868. }
  869. });
  870. keyboardShortcuts.registerShortcut("editSong.focusTitle", {
  871. keyCode: 36,
  872. preventDefault: true,
  873. handler: () => {
  874. this.$refs["title-input"].focus();
  875. }
  876. });
  877. keyboardShortcuts.registerShortcut("editSong.useAllDiscogs", {
  878. keyCode: 68,
  879. alt: true,
  880. ctrl: true,
  881. preventDefault: true,
  882. handler: () => {
  883. this.getAlbumData("title");
  884. this.getAlbumData("albumArt");
  885. this.getAlbumData("artists");
  886. this.getAlbumData("genres");
  887. }
  888. });
  889. /*
  890. editSong.pauseResume - Num 5 - Pause/resume song
  891. editSong.stopVideo - Ctrl - Num 5 - Stop
  892. editSong.skipToLast10Secs - Num 6 - Skip to last 10 seconds
  893. editSong.lowerVolumeLarge - Num 2 - Volume down by 10
  894. editSong.lowerVolumeSmall - Ctrl - Num 2 - Volume down by 1
  895. editSong.increaseVolumeLarge - Num 8 - Volume up by 10
  896. editSong.increaseVolumeSmall - Ctrl - Num 8 - Volume up by 1
  897. editSong.focusTitle - Home - Focus the title input
  898. editSong.focusDicogs - End - Focus the discogs input
  899. editSong.save - Ctrl - S - Saves song
  900. editSong.save - Ctrl - Alt - S - Saves song and closes the modal
  901. editSong.save - Ctrl - Alt - V - Saves song, verifies songs and then closes the modal
  902. editSong.close - F4 - Closes modal without saving
  903. editSong.useAllDiscogs - Ctrl - Alt - D - Sets all fields to the Discogs data
  904. Inside Discogs inputs: Ctrl - D - Sets this field to the Discogs data
  905. */
  906. },
  907. beforeUnmount() {
  908. this.video.player.stopVideo();
  909. this.playerReady = false;
  910. clearInterval(this.interval);
  911. clearInterval(this.activityWatchVideoDataInterval);
  912. this.socket.dispatch("apis.leaveRoom", `edit-song.${this.song._id}`);
  913. const shortcutNames = [
  914. "editSong.pauseResume",
  915. "editSong.stopVideo",
  916. "editSong.skipToLast10Secs",
  917. "editSong.lowerVolumeLarge",
  918. "editSong.lowerVolumeSmall",
  919. "editSong.increaseVolumeLarge",
  920. "editSong.increaseVolumeSmall",
  921. "editSong.focusTitle",
  922. "editSong.focusDicogs",
  923. "editSong.save",
  924. "editSong.saveClose",
  925. "editSong.saveVerifyClose",
  926. "editSong.close",
  927. "editSong.useAllDiscogs"
  928. ];
  929. shortcutNames.forEach(shortcutName => {
  930. keyboardShortcuts.unregisterShortcut(shortcutName);
  931. });
  932. },
  933. methods: {
  934. stopEditingSongs() {
  935. this.updateEditingSongs(false);
  936. this.closeModal("editSong");
  937. },
  938. importAlbum(result) {
  939. this.selectDiscogsAlbum(result);
  940. this.openModal("importAlbum");
  941. this.closeModal("editSong");
  942. },
  943. save(songToCopy, verify, close) {
  944. const song = JSON.parse(JSON.stringify(songToCopy));
  945. let saveButtonRef = this.$refs.saveButton;
  946. if (close) saveButtonRef = this.$refs.saveAndCloseButton;
  947. if (!this.youtubeError && this.youtubeVideoDuration === "0.000") {
  948. saveButtonRef.handleFailedSave();
  949. return new Toast("The video appears to not be working.");
  950. }
  951. if (!song.title) {
  952. saveButtonRef.handleFailedSave();
  953. return new Toast("Please fill in all fields");
  954. }
  955. if (!song.thumbnail) {
  956. saveButtonRef.handleFailedSave();
  957. return new Toast("Please fill in all fields");
  958. }
  959. // const thumbnailHeight = this.$refs.thumbnailElement.naturalHeight;
  960. // const thumbnailWidth = this.$refs.thumbnailElement.naturalWidth;
  961. // if (thumbnailHeight < 80 || thumbnailWidth < 80) {
  962. // saveButtonRef.handleFailedSave();
  963. // return new Toast(
  964. // "Thumbnail width and height must be at least 80px."
  965. // );
  966. // }
  967. // if (thumbnailHeight > 4000 || thumbnailWidth > 4000) {
  968. // saveButtonRef.handleFailedSave();
  969. // return new Toast(
  970. // "Thumbnail width and height must be less than 4000px."
  971. // );
  972. // }
  973. // if (thumbnailHeight - thumbnailWidth > 5) {
  974. // saveButtonRef.handleFailedSave();
  975. // return new Toast("Thumbnail cannot be taller than it is wide.");
  976. // }
  977. // Youtube Id
  978. if (
  979. this.youtubeError &&
  980. this.originalSong.youtubeId !== song.youtubeId
  981. ) {
  982. saveButtonRef.handleFailedSave();
  983. return new Toast(
  984. "You're not allowed to change the YouTube id while the player is not working"
  985. );
  986. }
  987. // Duration
  988. if (
  989. Number(song.skipDuration) + Number(song.duration) >
  990. this.youtubeVideoDuration &&
  991. (!this.youtubeError ||
  992. this.originalSong.duration !== song.duration)
  993. ) {
  994. saveButtonRef.handleFailedSave();
  995. return new Toast(
  996. "Duration can't be higher than the length of the video"
  997. );
  998. }
  999. // Title
  1000. if (!validation.isLength(song.title, 1, 100)) {
  1001. saveButtonRef.handleFailedSave();
  1002. return new Toast(
  1003. "Title must have between 1 and 100 characters."
  1004. );
  1005. }
  1006. // Artists
  1007. if (song.artists.length < 1 || song.artists.length > 10) {
  1008. saveButtonRef.handleFailedSave();
  1009. return new Toast(
  1010. "Invalid artists. You must have at least 1 artist and a maximum of 10 artists."
  1011. );
  1012. }
  1013. let error;
  1014. song.artists.forEach(artist => {
  1015. if (!validation.isLength(artist, 1, 64)) {
  1016. error = "Artist must have between 1 and 64 characters.";
  1017. return error;
  1018. }
  1019. if (artist === "NONE") {
  1020. error =
  1021. 'Invalid artist format. Artists are not allowed to be named "NONE".';
  1022. return error;
  1023. }
  1024. return false;
  1025. });
  1026. if (error) {
  1027. saveButtonRef.handleFailedSave();
  1028. return new Toast(error);
  1029. }
  1030. // Genres
  1031. error = undefined;
  1032. song.genres.forEach(genre => {
  1033. if (!validation.isLength(genre, 1, 32)) {
  1034. error = "Genre must have between 1 and 32 characters.";
  1035. return error;
  1036. }
  1037. if (!validation.regex.ascii.test(genre)) {
  1038. error =
  1039. "Invalid genre format. Only ascii characters are allowed.";
  1040. return error;
  1041. }
  1042. return false;
  1043. });
  1044. if (song.genres.length < 1 || song.genres.length > 16)
  1045. error = "You must have between 1 and 16 genres.";
  1046. if (error) {
  1047. saveButtonRef.handleFailedSave();
  1048. return new Toast(error);
  1049. }
  1050. // Thumbnail
  1051. if (!validation.isLength(song.thumbnail, 1, 256)) {
  1052. saveButtonRef.handleFailedSave();
  1053. return new Toast(
  1054. "Thumbnail must have between 8 and 256 characters."
  1055. );
  1056. }
  1057. if (this.useHTTPS && song.thumbnail.indexOf("https://") !== 0) {
  1058. saveButtonRef.handleFailedSave();
  1059. return new Toast('Thumbnail must start with "https://".');
  1060. }
  1061. if (
  1062. !this.useHTTPS &&
  1063. song.thumbnail.indexOf("http://") !== 0 &&
  1064. song.thumbnail.indexOf("https://") !== 0
  1065. ) {
  1066. saveButtonRef.handleFailedSave();
  1067. return new Toast('Thumbnail must start with "http://".');
  1068. }
  1069. saveButtonRef.status = "disabled";
  1070. return this.socket.dispatch(`songs.update`, song._id, song, res => {
  1071. new Toast(res.message);
  1072. if (res.status === "success")
  1073. saveButtonRef.handleSuccessfulSave();
  1074. else saveButtonRef.handleFailedSave();
  1075. if (verify) this.verify(this.song._id);
  1076. if (close) this.closeModal("editSong");
  1077. });
  1078. },
  1079. getAlbumData(type) {
  1080. if (!this.song.discogs) return;
  1081. if (type === "title")
  1082. this.updateSongField({
  1083. field: "title",
  1084. value: this.song.discogs.track.title
  1085. });
  1086. if (type === "albumArt")
  1087. this.updateSongField({
  1088. field: "thumbnail",
  1089. value: this.song.discogs.album.albumArt
  1090. });
  1091. if (type === "genres")
  1092. this.updateSongField({
  1093. field: "genres",
  1094. value: JSON.parse(
  1095. JSON.stringify(this.song.discogs.album.genres)
  1096. )
  1097. });
  1098. if (type === "artists")
  1099. this.updateSongField({
  1100. field: "artists",
  1101. value: JSON.parse(
  1102. JSON.stringify(this.song.discogs.album.artists)
  1103. )
  1104. });
  1105. },
  1106. fillDuration() {
  1107. this.song.duration =
  1108. this.youtubeVideoDuration - this.song.skipDuration;
  1109. },
  1110. blurArtistInput() {
  1111. this.artistInputFocussed = false;
  1112. },
  1113. focusArtistInput() {
  1114. this.artistInputFocussed = true;
  1115. },
  1116. blurArtistContainer() {
  1117. this.artistAutosuggestContainerFocussed = false;
  1118. },
  1119. focusArtistContainer() {
  1120. this.artistAutosuggestContainerFocussed = true;
  1121. },
  1122. keydownArtistInput() {
  1123. clearTimeout(this.keydownArtistInputTimeout);
  1124. this.keydownArtistInputTimeout = setTimeout(() => {
  1125. // Do things here to query the artist
  1126. }, 1000);
  1127. },
  1128. selectArtistAutosuggest(value) {
  1129. this.artistInputValue = value;
  1130. },
  1131. blurGenreInput() {
  1132. this.genreInputFocussed = false;
  1133. },
  1134. focusGenreInput() {
  1135. this.genreInputFocussed = true;
  1136. },
  1137. blurGenreContainer() {
  1138. this.genreAutosuggestContainerFocussed = false;
  1139. },
  1140. focusGenreContainer() {
  1141. this.genreAutosuggestContainerFocussed = true;
  1142. },
  1143. keydownGenreInput() {
  1144. clearTimeout(this.keydownGenreInputTimeout);
  1145. this.keydownGenreInputTimeout = setTimeout(() => {
  1146. if (this.genreInputValue.length > 1) {
  1147. this.genreAutosuggestItems = this.genres.filter(genre => {
  1148. return genre
  1149. .toLowerCase()
  1150. .startsWith(this.genreInputValue.toLowerCase());
  1151. });
  1152. } else this.genreAutosuggestItems = [];
  1153. }, 1000);
  1154. },
  1155. selectGenreAutosuggest(value) {
  1156. this.genreInputValue = value;
  1157. },
  1158. settings(type) {
  1159. switch (type) {
  1160. default:
  1161. break;
  1162. case "stop":
  1163. this.stopVideo();
  1164. this.pauseVideo(true);
  1165. break;
  1166. case "pause":
  1167. this.pauseVideo(true);
  1168. break;
  1169. case "play":
  1170. this.pauseVideo(false);
  1171. break;
  1172. case "skipToLast10Secs":
  1173. this.skipToLast10SecsPressed = true;
  1174. if (this.video.paused) this.pauseVideo(false);
  1175. this.video.player.seekTo(
  1176. this.song.duration - 10 + this.song.skipDuration
  1177. );
  1178. break;
  1179. }
  1180. },
  1181. play() {
  1182. if (
  1183. this.video.player.getVideoData().video_id !==
  1184. this.song.youtubeId
  1185. ) {
  1186. this.song.duration = -1;
  1187. this.loadVideoById(this.song.youtubeId, this.song.skipDuration);
  1188. }
  1189. this.settings("play");
  1190. },
  1191. changeVolume() {
  1192. const volume = this.volumeSliderValue;
  1193. localStorage.setItem("volume", volume / 100);
  1194. this.video.player.setVolume(volume / 100);
  1195. if (volume > 0) this.video.player.unMute();
  1196. },
  1197. addTag(type) {
  1198. if (type === "genres") {
  1199. const genre = this.genreInputValue.trim();
  1200. if (
  1201. this.song.genres
  1202. .map(genre => genre.toLowerCase())
  1203. .indexOf(genre.toLowerCase()) !== -1
  1204. )
  1205. return new Toast("Genre already exists");
  1206. if (genre) {
  1207. this.song.genres.push(genre);
  1208. this.genreInputValue = "";
  1209. return false;
  1210. }
  1211. return new Toast("Genre cannot be empty");
  1212. }
  1213. if (type === "artists") {
  1214. const artist = this.artistInputValue;
  1215. if (this.song.artists.indexOf(artist) !== -1)
  1216. return new Toast("Artist already exists");
  1217. if (artist !== "") {
  1218. this.song.artists.push(artist);
  1219. this.artistInputValue = "";
  1220. return false;
  1221. }
  1222. return new Toast("Artist cannot be empty");
  1223. }
  1224. return false;
  1225. },
  1226. removeTag(type, value) {
  1227. if (type === "genres")
  1228. this.song.genres.splice(this.song.genres.indexOf(value), 1);
  1229. else if (type === "artists")
  1230. this.song.artists.splice(this.song.artists.indexOf(value), 1);
  1231. },
  1232. drawCanvas() {
  1233. const canvasElement = this.$refs.durationCanvas;
  1234. const ctx = canvasElement.getContext("2d");
  1235. const videoDuration = Number(this.youtubeVideoDuration);
  1236. const skipDuration = Number(this.song.skipDuration);
  1237. const duration = Number(this.song.duration);
  1238. const afterDuration = videoDuration - (skipDuration + duration);
  1239. const width = 530;
  1240. const currentTime =
  1241. this.video.player && this.video.player.getCurrentTime
  1242. ? this.video.player.getCurrentTime()
  1243. : 0;
  1244. const widthSkipDuration = (skipDuration / videoDuration) * width;
  1245. const widthDuration = (duration / videoDuration) * width;
  1246. const widthAfterDuration = (afterDuration / videoDuration) * width;
  1247. const widthCurrentTime = (currentTime / videoDuration) * width;
  1248. const skipDurationColor = "#F42003";
  1249. const durationColor = "#03A9F4";
  1250. const afterDurationColor = "#41E841";
  1251. const currentDurationColor = "#3b25e8";
  1252. ctx.fillStyle = skipDurationColor;
  1253. ctx.fillRect(0, 0, widthSkipDuration, 20);
  1254. ctx.fillStyle = durationColor;
  1255. ctx.fillRect(widthSkipDuration, 0, widthDuration, 20);
  1256. ctx.fillStyle = afterDurationColor;
  1257. ctx.fillRect(
  1258. widthSkipDuration + widthDuration,
  1259. 0,
  1260. widthAfterDuration,
  1261. 20
  1262. );
  1263. ctx.fillStyle = currentDurationColor;
  1264. ctx.fillRect(widthCurrentTime, 0, 1, 20);
  1265. },
  1266. toggleGenreHelper() {
  1267. this.$refs.genreHelper.toggleBox();
  1268. },
  1269. resetGenreHelper() {
  1270. this.$refs.genreHelper.resetBox();
  1271. },
  1272. sendActivityWatchVideoData() {
  1273. if (!this.video.paused) {
  1274. if (this.activityWatchVideoLastStatus !== "playing") {
  1275. this.activityWatchVideoLastStatus = "playing";
  1276. if (
  1277. this.song.skipDuration > 0 &&
  1278. parseFloat(this.youtubeVideoCurrentTime) === 0
  1279. ) {
  1280. this.activityWatchVideoLastStartDuration = Math.floor(
  1281. this.song.skipDuration +
  1282. parseFloat(this.youtubeVideoCurrentTime)
  1283. );
  1284. } else {
  1285. this.activityWatchVideoLastStartDuration = Math.floor(
  1286. parseFloat(this.youtubeVideoCurrentTime)
  1287. );
  1288. }
  1289. }
  1290. const videoData = {
  1291. title: this.song.title,
  1292. artists: this.song.artists
  1293. ? this.song.artists.join(", ")
  1294. : null,
  1295. youtubeId: this.song.youtubeId,
  1296. muted: this.muted,
  1297. volume: this.volumeSliderValue / 100,
  1298. startedDuration:
  1299. this.activityWatchVideoLastStartDuration <= 0
  1300. ? 0
  1301. : this.activityWatchVideoLastStartDuration,
  1302. source: `editSong#${this.song.youtubeId}`,
  1303. hostname: window.location.hostname
  1304. };
  1305. aw.sendVideoData(videoData);
  1306. } else {
  1307. this.activityWatchVideoLastStatus = "not_playing";
  1308. }
  1309. },
  1310. verify(id) {
  1311. this.socket.dispatch("songs.verify", id, res => {
  1312. new Toast(res.message);
  1313. });
  1314. },
  1315. unverify(id) {
  1316. this.socket.dispatch("songs.unverify", id, res => {
  1317. new Toast(res.message);
  1318. });
  1319. },
  1320. hide(id) {
  1321. this.socket.dispatch("songs.hide", id, res => {
  1322. new Toast(res.message);
  1323. });
  1324. },
  1325. unhide(id) {
  1326. this.socket.dispatch("songs.unhide", id, res => {
  1327. new Toast(res.message);
  1328. });
  1329. },
  1330. // remove(id) {
  1331. // this.socket.dispatch("songs.remove", id, res => {
  1332. // new Toast(res.message);
  1333. // });
  1334. // },
  1335. ...mapActions("modals/importAlbum", [
  1336. "selectDiscogsAlbum",
  1337. "updateEditingSongs"
  1338. ]),
  1339. ...mapActions({
  1340. showTab(dispatch, payload) {
  1341. this.$refs[`${payload}-tab`].scrollIntoView();
  1342. return dispatch("modals/editSong/showTab", payload);
  1343. }
  1344. }),
  1345. ...mapActions("modals/editSong", [
  1346. "stopVideo",
  1347. "loadVideoById",
  1348. "pauseVideo",
  1349. "getCurrentTime",
  1350. "editSong",
  1351. "updateSongField",
  1352. "updateReports"
  1353. ]),
  1354. ...mapActions("modalVisibility", ["closeModal", "openModal"])
  1355. }
  1356. };
  1357. </script>
  1358. <style lang="scss">
  1359. // .song-modal {
  1360. // .modal-card-title {
  1361. // text-align: center;
  1362. // margin-left: 24px;
  1363. // }
  1364. // .modal-card {
  1365. // width: 1160px;
  1366. // height: 100%;
  1367. // .modal-card-body {
  1368. // padding: 16px;
  1369. // display: flex;
  1370. // }
  1371. // .modal-card-foot {
  1372. // .right {
  1373. // display: flex;
  1374. // margin-left: auto;
  1375. // margin-right: 0;
  1376. // // button,
  1377. // // a,
  1378. // // span {
  1379. // // &:not(:last-child) {
  1380. // // margin-right: 5px;
  1381. // // }
  1382. // // }
  1383. // }
  1384. // }
  1385. // }
  1386. // }
  1387. </style>
  1388. <style lang="scss" scoped>
  1389. .night-mode {
  1390. .edit-section,
  1391. .player-footer,
  1392. #tabs-container {
  1393. background-color: var(--dark-grey-3) !important;
  1394. }
  1395. }
  1396. .song-modal {
  1397. &::v-deep {
  1398. .modal-card-title {
  1399. text-align: center;
  1400. margin-left: 24px;
  1401. }
  1402. .modal-card {
  1403. width: 1160px;
  1404. height: 100%;
  1405. .modal-card-body {
  1406. padding: 16px;
  1407. display: flex;
  1408. > div {
  1409. display: flex;
  1410. height: 100%;
  1411. }
  1412. }
  1413. .modal-card-foot {
  1414. .right {
  1415. display: flex;
  1416. margin-left: auto;
  1417. margin-right: 0;
  1418. }
  1419. }
  1420. }
  1421. }
  1422. }
  1423. .left-section {
  1424. display: flex;
  1425. flex-direction: column;
  1426. margin-right: 16px;
  1427. .top-section {
  1428. display: flex;
  1429. .player-section {
  1430. width: 530px;
  1431. display: flex;
  1432. flex-direction: column;
  1433. .player-error {
  1434. height: 318px;
  1435. width: 530px;
  1436. display: block;
  1437. border: 1px rgba(163, 224, 255, 0.75) solid;
  1438. border-radius: 5px 5px 0px 0px;
  1439. display: flex;
  1440. align-items: center;
  1441. * {
  1442. margin: 0;
  1443. flex: 1;
  1444. font-size: 30px;
  1445. text-align: center;
  1446. }
  1447. }
  1448. .player-footer {
  1449. background-color: var(--light-grey);
  1450. border: 1px rgba(163, 224, 255, 0.75) solid;
  1451. border-radius: 0px 0px 5px 5px;
  1452. display: flex;
  1453. justify-content: space-between;
  1454. height: 54px;
  1455. > * {
  1456. width: 33.3%;
  1457. display: flex;
  1458. align-items: center;
  1459. }
  1460. .player-footer-left {
  1461. flex: 1;
  1462. .material-icons {
  1463. font-size: 38px;
  1464. cursor: pointer;
  1465. }
  1466. .player-play-pause {
  1467. color: var(--primary-color);
  1468. }
  1469. .player-stop {
  1470. color: var(--red);
  1471. }
  1472. .player-fast-forward {
  1473. color: var(--green);
  1474. }
  1475. }
  1476. .player-footer-center {
  1477. justify-content: center;
  1478. align-items: center;
  1479. flex: 2;
  1480. font-size: 21px;
  1481. font-weight: 400;
  1482. img {
  1483. height: 21px;
  1484. margin-right: 12px;
  1485. filter: invert(26%) sepia(54%) saturate(6317%)
  1486. hue-rotate(2deg) brightness(92%) contrast(115%);
  1487. }
  1488. }
  1489. .player-footer-right {
  1490. justify-content: right;
  1491. flex: 1;
  1492. #volumeSlider {
  1493. width: 126px;
  1494. margin-right: 10px;
  1495. background-color: var(--light-grey);
  1496. }
  1497. }
  1498. }
  1499. }
  1500. .thumbnail-preview {
  1501. width: 189px;
  1502. height: 189px;
  1503. margin-left: 16px;
  1504. }
  1505. }
  1506. .edit-section {
  1507. width: 735px;
  1508. background-color: var(--light-grey);
  1509. border: 1px rgba(163, 224, 255, 0.75) solid;
  1510. margin-top: 16px;
  1511. flex: 1;
  1512. overflow: auto;
  1513. border-radius: 5px;
  1514. .album-get-button {
  1515. background-color: var(--purple);
  1516. color: var(--white);
  1517. width: 32px;
  1518. text-align: center;
  1519. border-width: 0;
  1520. }
  1521. .duration-fill-button {
  1522. background-color: var(--red);
  1523. color: var(--white);
  1524. width: 32px;
  1525. text-align: center;
  1526. border-width: 0;
  1527. }
  1528. .add-button {
  1529. background-color: var(--primary-color) !important;
  1530. width: 32px;
  1531. i {
  1532. font-size: 32px;
  1533. }
  1534. }
  1535. .album-get-button,
  1536. .duration-fill-button,
  1537. .add-button {
  1538. &:focus,
  1539. &:hover {
  1540. filter: contrast(0.75);
  1541. border: 1px solid var(--black) !important;
  1542. }
  1543. }
  1544. > div {
  1545. margin: 16px;
  1546. }
  1547. input {
  1548. width: 100%;
  1549. }
  1550. .title-container {
  1551. width: calc((100% - 32px) / 2);
  1552. }
  1553. .duration-container {
  1554. margin-right: 16px;
  1555. margin-left: 16px;
  1556. width: calc((100% - 32px) / 4);
  1557. }
  1558. .skip-duration-container {
  1559. width: calc((100% - 32px) / 4);
  1560. }
  1561. .album-art-container {
  1562. width: 100%;
  1563. }
  1564. .artists-container {
  1565. width: calc((100% - 32px) / 3);
  1566. position: relative;
  1567. }
  1568. .genres-container {
  1569. width: calc((100% - 32px) / 3);
  1570. margin-left: 16px;
  1571. margin-right: 16px;
  1572. position: relative;
  1573. label {
  1574. display: flex;
  1575. i {
  1576. font-size: 15px;
  1577. align-self: center;
  1578. margin-left: 5px;
  1579. color: var(--primary-color);
  1580. cursor: pointer;
  1581. -webkit-user-select: none;
  1582. -moz-user-select: none;
  1583. -ms-user-select: none;
  1584. user-select: none;
  1585. }
  1586. }
  1587. }
  1588. .youtube-id-container {
  1589. width: calc((100% - 32px) / 3);
  1590. }
  1591. .list-item-circle {
  1592. background-color: var(--primary-color);
  1593. width: 16px;
  1594. height: 16px;
  1595. border-radius: 8px;
  1596. cursor: pointer;
  1597. margin-right: 8px;
  1598. float: left;
  1599. -webkit-touch-callout: none;
  1600. -webkit-user-select: none;
  1601. -khtml-user-select: none;
  1602. -moz-user-select: none;
  1603. -ms-user-select: none;
  1604. user-select: none;
  1605. i {
  1606. color: var(--primary-color);
  1607. font-size: 14px;
  1608. margin-left: 1px;
  1609. }
  1610. }
  1611. .list-item-circle:hover,
  1612. .list-item-circle:focus {
  1613. i {
  1614. color: var(--white);
  1615. }
  1616. }
  1617. .list-item > p {
  1618. line-height: 16px;
  1619. word-wrap: break-word;
  1620. width: calc(100% - 24px);
  1621. left: 24px;
  1622. float: left;
  1623. margin-bottom: 8px;
  1624. }
  1625. .list-item:last-child > p {
  1626. margin-bottom: 0;
  1627. }
  1628. .autosuggest-container {
  1629. position: absolute;
  1630. background: var(--white);
  1631. width: calc(100% + 1px);
  1632. top: 57px;
  1633. z-index: 200;
  1634. overflow: auto;
  1635. max-height: 100%;
  1636. clear: both;
  1637. .autosuggest-item {
  1638. padding: 8px;
  1639. display: block;
  1640. border: 1px solid var(--light-grey-2);
  1641. margin-top: -1px;
  1642. line-height: 16px;
  1643. cursor: pointer;
  1644. -webkit-user-select: none;
  1645. -ms-user-select: none;
  1646. -moz-user-select: none;
  1647. user-select: none;
  1648. }
  1649. .autosuggest-item:hover,
  1650. .autosuggest-item:focus {
  1651. background-color: var(--light-grey);
  1652. }
  1653. .autosuggest-item:first-child {
  1654. border-top: none;
  1655. }
  1656. .autosuggest-item:last-child {
  1657. border-radius: 0 0 3px 3px;
  1658. }
  1659. }
  1660. }
  1661. }
  1662. .right-section {
  1663. display: flex;
  1664. flex-wrap: wrap;
  1665. #tabs-container {
  1666. width: 376px;
  1667. background-color: var(--light-grey);
  1668. border: 1px rgba(163, 224, 255, 0.75) solid;
  1669. border-radius: 5px;
  1670. // padding: 16px;
  1671. overflow: auto;
  1672. height: 100%;
  1673. #tab-selection {
  1674. display: flex;
  1675. overflow-x: auto;
  1676. .button {
  1677. border-radius: 5px 5px 0 0;
  1678. border: 0;
  1679. text-transform: uppercase;
  1680. font-size: 14px;
  1681. color: var(--dark-grey-3);
  1682. background-color: var(--light-grey-2);
  1683. flex-grow: 1;
  1684. height: 32px;
  1685. &:not(:first-of-type) {
  1686. margin-left: 5px;
  1687. }
  1688. }
  1689. .selected {
  1690. background-color: var(--primary-color) !important;
  1691. color: var(--white) !important;
  1692. font-weight: 600;
  1693. }
  1694. }
  1695. .tab {
  1696. // border: 1px solid var(--light-grey-3);
  1697. padding: 15px;
  1698. // border-radius: 0 0 5px 5px;
  1699. }
  1700. }
  1701. // .api-section {
  1702. // width: 376px;
  1703. // background-color: var(--light-grey);
  1704. // border: 1px rgba(163, 224, 255, 0.75) solid;
  1705. // border-radius: 5px;
  1706. // padding: 16px;
  1707. // overflow: auto;
  1708. // height: 100%;
  1709. // > label {
  1710. // margin-top: 12px;
  1711. // }
  1712. // .top-container {
  1713. // display: flex;
  1714. // img {
  1715. // height: 85px;
  1716. // width: 85px;
  1717. // }
  1718. // .right-container {
  1719. // padding: 8px;
  1720. // display: flex;
  1721. // flex-direction: column;
  1722. // flex: 1;
  1723. // .album-title {
  1724. // flex: 1;
  1725. // font-weight: 600;
  1726. // }
  1727. // .bottom-row {
  1728. // display: flex;
  1729. // flex-flow: row;
  1730. // line-height: 15px;
  1731. // img {
  1732. // height: 15px;
  1733. // align-self: end;
  1734. // flex: 1;
  1735. // user-select: none;
  1736. // -moz-user-select: none;
  1737. // -ms-user-select: none;
  1738. // -webkit-user-select: none;
  1739. // cursor: pointer;
  1740. // }
  1741. // p {
  1742. // text-align: right;
  1743. // }
  1744. // .type-year {
  1745. // font-size: 13px;
  1746. // align-self: end;
  1747. // }
  1748. // }
  1749. // }
  1750. // }
  1751. // .bottom-container {
  1752. // padding: 12px;
  1753. // .bottom-container-field {
  1754. // line-height: 16px;
  1755. // margin-bottom: 8px;
  1756. // font-weight: 600;
  1757. // span {
  1758. // font-weight: 400;
  1759. // }
  1760. // }
  1761. // .bottom-container-field:last-of-type {
  1762. // margin-bottom: 0;
  1763. // }
  1764. // }
  1765. // .selected-discogs-info {
  1766. // background-color: var(--white);
  1767. // border: 1px solid var(--purple);
  1768. // border-radius: 5px;
  1769. // margin-bottom: 16px;
  1770. // .selected-discogs-info-none {
  1771. // font-size: 18px;
  1772. // text-align: center;
  1773. // }
  1774. // .bottom-row > p {
  1775. // flex: 1;
  1776. // }
  1777. // }
  1778. // .api-result {
  1779. // background-color: var(--white);
  1780. // border: 0.5px solid var(--primary-color);
  1781. // border-radius: 5px;
  1782. // margin-bottom: 16px;
  1783. // }
  1784. // button {
  1785. // background-color: var(--primary-color) !important;
  1786. // &:focus,
  1787. // &:hover {
  1788. // filter: contrast(0.75);
  1789. // }
  1790. // }
  1791. // .tracks {
  1792. // margin-top: 12px;
  1793. // .track:first-child {
  1794. // margin-top: 0;
  1795. // border-radius: 3px 3px 0 0;
  1796. // }
  1797. // .track:last-child {
  1798. // border-radius: 0 0 3px 3px;
  1799. // }
  1800. // .track {
  1801. // border: 0.5px solid var(--black);
  1802. // margin-top: -1px;
  1803. // line-height: 16px;
  1804. // display: flex;
  1805. // cursor: pointer;
  1806. // span {
  1807. // font-weight: 600;
  1808. // display: inline-block;
  1809. // margin-top: 7px;
  1810. // margin-bottom: 7px;
  1811. // margin-left: 7px;
  1812. // }
  1813. // p {
  1814. // display: inline-block;
  1815. // margin: 7px;
  1816. // flex: 1;
  1817. // }
  1818. // }
  1819. // .track:hover,
  1820. // .track:focus {
  1821. // background-color: var(--light-grey);
  1822. // }
  1823. // }
  1824. // .discogs-load-more {
  1825. // margin-bottom: 8px;
  1826. // }
  1827. // }
  1828. }
  1829. .modal-card-foot .is-primary {
  1830. width: 200px;
  1831. }
  1832. input[type="range"] {
  1833. -webkit-appearance: none;
  1834. width: 100%;
  1835. margin: 8.5px 0;
  1836. }
  1837. input[type="range"]:focus {
  1838. outline-style: outset;
  1839. }
  1840. input[type="range"]::-webkit-slider-runnable-track {
  1841. width: 100%;
  1842. height: 3px;
  1843. cursor: pointer;
  1844. box-shadow: none;
  1845. background: var(--grey-3);
  1846. border-radius: none;
  1847. border: none;
  1848. }
  1849. input[type="range"]::-webkit-slider-thumb {
  1850. box-shadow: none;
  1851. border: none;
  1852. height: 20px;
  1853. width: 20px;
  1854. border-radius: 100px;
  1855. background: var(--primary-color);
  1856. cursor: pointer;
  1857. -webkit-appearance: none;
  1858. margin-top: -8.5px;
  1859. }
  1860. input[type="range"]:focus::-webkit-slider-runnable-track {
  1861. background: var(--grey-3);
  1862. }
  1863. input[type="range"]::-moz-range-track {
  1864. width: 100%;
  1865. height: 3px;
  1866. cursor: pointer;
  1867. box-shadow: none;
  1868. background: var(--grey-3);
  1869. border-radius: none;
  1870. border: none;
  1871. }
  1872. input[type="range"]::-moz-range-thumb {
  1873. box-shadow: none;
  1874. border: none;
  1875. height: 20px;
  1876. width: 20px;
  1877. border-radius: 100px;
  1878. background: var(--primary-color);
  1879. cursor: pointer;
  1880. }
  1881. input[type="range"]::-ms-track {
  1882. width: 100%;
  1883. height: 3px;
  1884. cursor: pointer;
  1885. background: transparent;
  1886. border-color: transparent;
  1887. color: transparent;
  1888. }
  1889. input[type="range"]::-ms-fill-lower {
  1890. background: var(--grey-2);
  1891. border: none;
  1892. border-radius: none;
  1893. box-shadow: none;
  1894. }
  1895. input[type="range"]::-ms-fill-upper {
  1896. background: var(--grey-3);
  1897. border: none;
  1898. border-radius: none;
  1899. box-shadow: none;
  1900. }
  1901. input[type="range"]::-ms-thumb {
  1902. box-shadow: none;
  1903. border: none;
  1904. height: 20px;
  1905. width: 20px;
  1906. border-radius: 100px;
  1907. background: var(--primary-color);
  1908. cursor: pointer;
  1909. height: 3px;
  1910. }
  1911. input[type="range"]:focus::-ms-fill-lower {
  1912. background: var(--grey-3);
  1913. }
  1914. input[type="range"]:focus::-ms-fill-upper {
  1915. background: var(--grey-3);
  1916. }
  1917. </style>