index.vue 54 KB

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