index.vue 58 KB

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