index.vue 83 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569
  1. <script setup lang="ts">
  2. import { storeToRefs } from "pinia";
  3. import {
  4. defineAsyncComponent,
  5. ref,
  6. computed,
  7. watch,
  8. onMounted,
  9. onBeforeUnmount
  10. } from "vue";
  11. import Toast from "toasters";
  12. import aw from "@/aw";
  13. import validation from "@/validation";
  14. import keyboardShortcuts from "@/keyboardShortcuts";
  15. import { useForm } from "@/composables/useForm";
  16. import { useSoundcloudPlayer } from "@/composables/useSoundcloudPlayer";
  17. import { Song } from "@/types/song.js";
  18. import { useWebsocketsStore } from "@/stores/websockets";
  19. import { useConfigStore } from "@/stores/config";
  20. import { useModalsStore } from "@/stores/modals";
  21. import { useEditSongStore } from "@/stores/editSong";
  22. import { useStationStore } from "@/stores/station";
  23. import { useUserAuthStore } from "@/stores/userAuth";
  24. import Modal from "@/components/Modal.vue";
  25. const TAG = "[EDITSONG]";
  26. const FloatingBox = defineAsyncComponent(
  27. () => import("@/components/FloatingBox.vue")
  28. );
  29. const SaveButton = defineAsyncComponent(
  30. () => import("@/components/SaveButton.vue")
  31. );
  32. const AutoSuggest = defineAsyncComponent(
  33. () => import("@/components/AutoSuggest.vue")
  34. );
  35. const MediaItem = defineAsyncComponent(
  36. () => import("@/components/MediaItem.vue")
  37. );
  38. const Discogs = defineAsyncComponent(() => import("./Tabs/Discogs.vue"));
  39. const ReportsTab = defineAsyncComponent(() => import("./Tabs/Reports.vue"));
  40. const Youtube = defineAsyncComponent(() => import("./Tabs/Youtube.vue"));
  41. const MusareSongs = defineAsyncComponent(() => import("./Tabs/Songs.vue"));
  42. const SongThumbnail = defineAsyncComponent(
  43. () => import("@/components/SongThumbnail.vue")
  44. );
  45. const props = defineProps({
  46. modalUuid: { type: String, required: true },
  47. modalModulePath: {
  48. type: String,
  49. default: "modals/editSong/MODAL_UUID"
  50. },
  51. discogsAlbum: { type: Object, default: null },
  52. song: { type: Object, default: null },
  53. songs: { type: Array, default: null }
  54. });
  55. const editSongStore = useEditSongStore({ modalUuid: props.modalUuid });
  56. const stationStore = useStationStore();
  57. const { socket } = useWebsocketsStore();
  58. const userAuthStore = useUserAuthStore();
  59. const {
  60. soundcloudIframeElement,
  61. soundcloudLoadTrack,
  62. soundcloudSeekTo,
  63. soundcloudPlay,
  64. soundcloudPause,
  65. soundcloudSetVolume,
  66. soundcloudGetPosition,
  67. soundcloudGetDuration,
  68. soundcloudGetCurrentSound,
  69. soundcloudGetTrackId,
  70. soundcloudBindListener,
  71. soundcloudUnload
  72. } = useSoundcloudPlayer();
  73. const { openModal, closeCurrentModal, preventCloseCbs } = useModalsStore();
  74. const { hasPermission } = userAuthStore;
  75. // eslint-disable-next-line vue/no-dupe-keys
  76. const {
  77. tab,
  78. video,
  79. song,
  80. mediaSource,
  81. prefillData,
  82. reports,
  83. newSong,
  84. bulk,
  85. mediaSources,
  86. songPrefillData
  87. } = storeToRefs(editSongStore);
  88. const songDataLoaded = ref(false);
  89. const songDeleted = ref(false);
  90. const youtubeError = ref(false);
  91. const youtubeErrorMessage = ref("");
  92. const youtubeVideoDuration = ref("0.000");
  93. const youtubeVideoCurrentTime = ref<number | string>(0);
  94. const youtubeVideoNote = ref("");
  95. const muted = ref(false);
  96. const volumeSliderValue = ref(0);
  97. const activityWatchMediaDataInterval = ref(null);
  98. const activityWatchMediaLastStatus = ref("");
  99. const activityWatchMediaLastStartDuration = ref(0);
  100. const recommendedGenres = ref([
  101. "Blues",
  102. "Country",
  103. "Disco",
  104. "Funk",
  105. "Hip-Hop",
  106. "Jazz",
  107. "Metal",
  108. "Oldies",
  109. "Other",
  110. "Pop",
  111. "Rap",
  112. "Reggae",
  113. "Rock",
  114. "Techno",
  115. "Trance",
  116. "Classical",
  117. "Instrumental",
  118. "House",
  119. "Electronic",
  120. "Christian Rap",
  121. "Lo-Fi",
  122. "Musical",
  123. "Rock 'n' Roll",
  124. "Opera",
  125. "Drum & Bass",
  126. "Club-House",
  127. "Indie",
  128. "Heavy Metal",
  129. "Christian rock",
  130. "Dubstep"
  131. ]);
  132. const autosuggest = ref({
  133. allItems: {
  134. artists: [],
  135. genres: [],
  136. tags: []
  137. }
  138. });
  139. const songNotFound = ref(false);
  140. const showRateDropdown = ref(false);
  141. const thumbnailElement = ref();
  142. const thumbnailNotSquare = ref(false);
  143. const thumbnailWidth = ref(null);
  144. const thumbnailHeight = ref(null);
  145. const thumbnailLoadError = ref(false);
  146. const tabs = ref([]);
  147. const youtubePlayerReady = ref(true);
  148. const interval = ref();
  149. const saveButtonRefs = ref([]);
  150. const canvasElement = ref();
  151. const genreHelper = ref();
  152. const saveButtonRefName = ref();
  153. // EditSongs
  154. const items = ref([]);
  155. const currentSong = ref<Song>({});
  156. const flagFilter = ref(false);
  157. const sidebarMobileActive = ref(false);
  158. const songItems = ref([]);
  159. const editingItemIndex = computed(() =>
  160. items.value.findIndex(
  161. item => item.song.mediaSource === currentSong.value.mediaSource
  162. )
  163. );
  164. const filteredItems = computed({
  165. get: () =>
  166. items.value.filter(item => (flagFilter.value ? item.flagged : true)),
  167. set: (newItem: any) => {
  168. const index = items.value.findIndex(
  169. item => item.song.mediaSource === newItem.mediaSource
  170. );
  171. items.value[index] = newItem;
  172. }
  173. });
  174. const filteredEditingItemIndex = computed(() =>
  175. filteredItems.value.findIndex(
  176. item => item.song.mediaSource === currentSong.value.mediaSource
  177. )
  178. );
  179. const currentSongFlagged = computed(
  180. () =>
  181. items.value.find(
  182. item => item.song.mediaSource === currentSong.value.mediaSource
  183. )?.flagged
  184. );
  185. // EditSongs end
  186. const configStore = useConfigStore();
  187. const { discogsEnabled, experimental } = storeToRefs(configStore);
  188. const {
  189. editSong,
  190. stopVideo,
  191. loadVideoById,
  192. pauseVideo,
  193. setSong,
  194. resetSong,
  195. updateReports,
  196. setPlaybackRate
  197. } = editSongStore;
  198. const { updateMediaModalPlayingAudio } = stationStore;
  199. const playerHardStop = () => {
  200. if (
  201. youtubePlayerReady.value &&
  202. video.value.player &&
  203. video.value.player.stopVideo
  204. )
  205. video.value.player.stopVideo();
  206. soundcloudUnload();
  207. };
  208. const unloadSong = (_mediaSource, songId?) => {
  209. songDataLoaded.value = false;
  210. songDeleted.value = false;
  211. pauseVideo(true);
  212. playerHardStop();
  213. resetSong(_mediaSource);
  214. thumbnailNotSquare.value = false;
  215. thumbnailWidth.value = null;
  216. thumbnailHeight.value = null;
  217. youtubeVideoCurrentTime.value = "0.000";
  218. youtubeVideoDuration.value = "0.000";
  219. youtubeVideoNote.value = "";
  220. if (songId) socket.dispatch("apis.leaveRoom", `edit-song.${songId}`);
  221. if (saveButtonRefs.value.saveButton)
  222. saveButtonRefs.value.saveButton.status = "default";
  223. };
  224. const loadSong = (_mediaSource: string, reset?: boolean) => {
  225. songNotFound.value = false;
  226. socket.dispatch(`songs.getSongsFromMediaSources`, [_mediaSource], res => {
  227. const { songs } = res.data;
  228. if (res.status === "success" && songs.length > 0) {
  229. let _song = songs[0];
  230. _song = Object.assign(_song, prefillData.value);
  231. setSong(_song, reset);
  232. // Reset the youtube data one more time so it can properly reset
  233. youtubeVideoCurrentTime.value = "0.000";
  234. youtubeVideoDuration.value = "0.000";
  235. youtubeVideoNote.value = "";
  236. songDataLoaded.value = true;
  237. if (_song._id) {
  238. socket.dispatch("apis.joinRoom", `edit-song.${_song._id}`);
  239. socket.dispatch("reports.getReportsForSong", _song._id, res => {
  240. updateReports(res.data.reports);
  241. });
  242. newSong.value = false;
  243. }
  244. } else {
  245. new Toast("Song with that ID not found");
  246. if (bulk.value) songNotFound.value = true;
  247. if (!bulk.value) closeCurrentModal();
  248. }
  249. });
  250. };
  251. const onSavedSuccess = mediaSource => {
  252. const itemIndex = items.value.findIndex(
  253. item => item.song.mediaSource === mediaSource
  254. );
  255. if (itemIndex > -1) {
  256. items.value[itemIndex].status = "done";
  257. items.value[itemIndex].flagged = false;
  258. }
  259. };
  260. const onSavedError = mediaSource => {
  261. const itemIndex = items.value.findIndex(
  262. item => item.song.mediaSource === mediaSource
  263. );
  264. if (itemIndex > -1) items.value[itemIndex].status = "error";
  265. };
  266. const onSaving = mediaSource => {
  267. const itemIndex = items.value.findIndex(
  268. item => item.song.mediaSource === mediaSource
  269. );
  270. if (itemIndex > -1) items.value[itemIndex].status = "saving";
  271. };
  272. const getCurrentSongMediaType = mediaSource => {
  273. if (!mediaSource || mediaSource.indexOf(":") === -1) return "none";
  274. return mediaSource.split(":")[0];
  275. };
  276. const getCurrentSongMediaValue = mediaSource => {
  277. if (!mediaSource || mediaSource.indexOf(":") === -1) return null;
  278. return mediaSource.split(":")[1];
  279. };
  280. const { inputs, unsavedChanges, save, setValue, setOriginalValue } = useForm(
  281. {
  282. title: {
  283. value: "",
  284. validate: value => {
  285. if (!validation.isLength(value, 1, 100))
  286. return "Title must have between 1 and 100 characters.";
  287. return true;
  288. }
  289. },
  290. duration: {
  291. value: 0,
  292. validate: value => {
  293. // If the original duration is the same as the current value, just accept the validation
  294. if (inputs.value.duration.originalValue === value) return true;
  295. // Sum of the specified duration and skipDuration
  296. const totalDuration =
  297. Number(inputs.value.skipDuration.value) + Number(value);
  298. // Duration of the video itself
  299. const videoDuration = Number.parseFloat(
  300. youtubeVideoDuration.value
  301. );
  302. // If the total duration specified is bigger than the video duration
  303. if (totalDuration > videoDuration)
  304. if ((!newSong.value || bulk.value) && !youtubeError.value)
  305. // If there is no youtube error and this is in bulk mode or not a new song, throw an error
  306. return "Duration can't be higher than the length of the video";
  307. // In all other cases, pass validation
  308. return true;
  309. }
  310. },
  311. skipDuration: 0,
  312. thumbnail: {
  313. value: "",
  314. validate: value => {
  315. if (!validation.isLength(value, 8, 256))
  316. return "Thumbnail must have between 8 and 256 characters.";
  317. if (configStore.urls.secure && value.indexOf("https://") !== 0)
  318. return 'Thumbnail must start with "https://".';
  319. if (
  320. !configStore.urls.secure &&
  321. value.indexOf("https://") !== 0 &&
  322. value.indexOf("http://") !== 0
  323. )
  324. return 'Thumbnail must start with "http(s)://".';
  325. return true;
  326. }
  327. },
  328. mediaSource: {
  329. value: "",
  330. validate: value => {
  331. if (
  332. getCurrentSongMediaType(inputs.value.mediaSource.value) ===
  333. "none"
  334. )
  335. return "Media source type is not valid.";
  336. if (!getCurrentSongMediaValue(inputs.value.mediaSource.value))
  337. return "Media source value is not valid.";
  338. if (
  339. getCurrentSongMediaType(inputs.value.mediaSource.value) ===
  340. "youtube" &&
  341. !newSong.value &&
  342. youtubeError.value &&
  343. inputs.value.mediaSource.originalValue !== value
  344. )
  345. return "You're not allowed to change the media source while the player is not working";
  346. return true;
  347. }
  348. },
  349. verified: false,
  350. addArtist: {
  351. value: "",
  352. ignoreUnsaved: true,
  353. required: false
  354. },
  355. artists: {
  356. value: [],
  357. validate: value => {
  358. if (
  359. (inputs.value.verified.value && value.length < 1) ||
  360. value.length > 10
  361. )
  362. return "Invalid artists. You must have at least 1 artist and a maximum of 10 artists.";
  363. let error;
  364. value.forEach(artist => {
  365. if (!validation.isLength(artist, 1, 64))
  366. error = "Artist must have between 1 and 64 characters.";
  367. if (artist === "NONE")
  368. error =
  369. 'Invalid artist format. Artists are not allowed to be named "NONE".';
  370. });
  371. return error || true;
  372. }
  373. },
  374. addGenre: {
  375. value: "",
  376. ignoreUnsaved: true,
  377. required: false
  378. },
  379. genres: {
  380. value: [],
  381. validate: value => {
  382. if (
  383. (inputs.value.verified.value && value.length < 1) ||
  384. value.length > 16
  385. )
  386. return "Invalid genres. You must have between 1 and 16 genres.";
  387. let error;
  388. value.forEach(genre => {
  389. if (!validation.isLength(genre, 1, 32))
  390. error = "Genre must have between 1 and 32 characters.";
  391. if (!validation.regex.ascii.test(genre))
  392. error =
  393. "Invalid genre format. Only ascii characters are allowed.";
  394. });
  395. return error || true;
  396. }
  397. },
  398. addTag: {
  399. value: "",
  400. ignoreUnsaved: true,
  401. required: false
  402. },
  403. tags: {
  404. value: [],
  405. validate: value => {
  406. let error;
  407. value.forEach(tag => {
  408. if (
  409. !/^[a-zA-Z0-9_]{1,64}$|^[a-zA-Z0-9_]{1,64}\[[a-zA-Z0-9_]{1,64}\]$/.test(
  410. tag
  411. )
  412. )
  413. error = "Invalid tag format.";
  414. });
  415. return error || true;
  416. }
  417. },
  418. discogs: {
  419. value: {},
  420. required: false
  421. }
  422. },
  423. ({ status, messages, values }, resolve, reject) => {
  424. const saveButtonRef = saveButtonRefs.value[saveButtonRefName.value];
  425. if (status === "success" || (status === "unchanged" && newSong.value)) {
  426. const mergedValues = Object.assign(song.value, values);
  427. const cb = res => {
  428. if (res.status === "error") {
  429. reject(new Error(res.message));
  430. return;
  431. }
  432. new Toast(res.message);
  433. saveButtonRef.handleSuccessfulSave();
  434. onSavedSuccess(values.mediaSource);
  435. if (newSong.value) loadSong(values.mediaSource, true);
  436. else setSong(mergedValues);
  437. resolve();
  438. };
  439. if (newSong.value)
  440. socket.dispatch("songs.create", mergedValues, cb);
  441. else
  442. socket.dispatch(
  443. "songs.update",
  444. song.value._id,
  445. mergedValues,
  446. cb
  447. );
  448. } else {
  449. if (status === "unchanged") {
  450. new Toast(messages.unchanged);
  451. saveButtonRef.handleSuccessfulSave();
  452. onSavedSuccess(values.mediaSource);
  453. } else {
  454. Object.values(messages).forEach(message => {
  455. new Toast({ content: message, timeout: 8000 });
  456. });
  457. saveButtonRef.handleFailedSave();
  458. onSavedError(values.mediaSource);
  459. }
  460. resolve();
  461. }
  462. },
  463. { modalUuid: props.modalUuid, preventCloseUnsaved: false }
  464. );
  465. const currentSongMediaType = computed(() =>
  466. getCurrentSongMediaType(inputs.value.mediaSource.value)
  467. );
  468. const currentSongMediaValue = computed(() =>
  469. getCurrentSongMediaValue(inputs.value.mediaSource.value)
  470. );
  471. const getCurrentPlayerTime = () =>
  472. new Promise<number>(resolve => {
  473. if (
  474. currentSongMediaType.value === "youtube" &&
  475. youtubePlayerReady.value
  476. ) {
  477. resolve(
  478. video.value.player && video.value.player.getCurrentTime
  479. ? video.value.player.getCurrentTime()
  480. : 0
  481. );
  482. return;
  483. }
  484. if (currentSongMediaType.value === "soundcloud") {
  485. soundcloudGetPosition(position => {
  486. resolve(position / 1000);
  487. });
  488. return;
  489. }
  490. resolve(0);
  491. });
  492. const getPlayerDuration = () =>
  493. new Promise<number>(resolve => {
  494. if (
  495. currentSongMediaType.value === "youtube" &&
  496. youtubePlayerReady.value
  497. ) {
  498. resolve(
  499. video.value.player && video.value.player.getDuration
  500. ? video.value.player.getDuration()
  501. : 0
  502. );
  503. return;
  504. }
  505. if (currentSongMediaType.value === "soundcloud") {
  506. soundcloudGetDuration(duration => {
  507. resolve(duration / 1000);
  508. });
  509. return;
  510. }
  511. resolve(0);
  512. });
  513. const showTab = payload => {
  514. if (tabs.value[`${payload}-tab`])
  515. tabs.value[`${payload}-tab`].scrollIntoView({ block: "nearest" });
  516. editSongStore.showTab(payload);
  517. };
  518. const toggleDone = (index, overwrite = null) => {
  519. const { status } = filteredItems.value[index];
  520. if (status === "done" && overwrite !== "done")
  521. filteredItems.value[index].status = "todo";
  522. else {
  523. filteredItems.value[index].status = "done";
  524. filteredItems.value[index].flagged = false;
  525. }
  526. };
  527. const toggleFlagFilter = () => {
  528. flagFilter.value = !flagFilter.value;
  529. };
  530. const toggleMobileSidebar = () => {
  531. sidebarMobileActive.value = !sidebarMobileActive.value;
  532. };
  533. const onCloseOrNext = (next?: boolean): Promise<void> =>
  534. new Promise(resolve => {
  535. const confirmReasons = [];
  536. if (unsavedChanges.value.length > 0) {
  537. confirmReasons.push(
  538. "You have unsaved changes. Are you sure you want to discard unsaved changes?"
  539. );
  540. }
  541. if (!next && bulk.value) {
  542. const doneItems = items.value.filter(
  543. item => item.status === "done"
  544. ).length;
  545. const flaggedItems = items.value.filter(
  546. item => item.flagged
  547. ).length;
  548. const notDoneItems = items.value.length - doneItems;
  549. if (doneItems > 0 && notDoneItems > 0)
  550. confirmReasons.push(
  551. "You have songs which are not done yet. Are you sure you want to stop editing songs?"
  552. );
  553. else if (flaggedItems > 0)
  554. confirmReasons.push(
  555. "You have songs which are flagged. Are you sure you want to stop editing songs?"
  556. );
  557. }
  558. if (confirmReasons.length > 0)
  559. openModal({
  560. modal: "confirm",
  561. props: {
  562. message: confirmReasons,
  563. onCompleted: resolve
  564. }
  565. });
  566. else resolve();
  567. });
  568. const pickSong = song => {
  569. onCloseOrNext(true).then(() => {
  570. editSong({
  571. mediaSource: song.mediaSource,
  572. prefill: songPrefillData.value[song.mediaSource]
  573. });
  574. currentSong.value = song;
  575. if (songItems.value[`edit-songs-item-${song.mediaSource}`])
  576. songItems.value[
  577. `edit-songs-item-${song.mediaSource}`
  578. ].scrollIntoView();
  579. });
  580. };
  581. const editNextSong = () => {
  582. const currentlyEditingSongIndex = filteredEditingItemIndex.value;
  583. let newEditingSongIndex = -1;
  584. const index =
  585. currentlyEditingSongIndex + 1 === filteredItems.value.length
  586. ? 0
  587. : currentlyEditingSongIndex + 1;
  588. for (let i = index; i < filteredItems.value.length; i += 1) {
  589. if (!flagFilter.value || filteredItems.value[i].flagged) {
  590. newEditingSongIndex = i;
  591. break;
  592. }
  593. }
  594. if (newEditingSongIndex > -1) {
  595. const nextSong = filteredItems.value[newEditingSongIndex].song;
  596. if (nextSong.removed) editNextSong();
  597. else pickSong(nextSong);
  598. }
  599. };
  600. const saveSong = (refName: string, closeOrNext?: boolean) => {
  601. saveButtonRefName.value = refName;
  602. onSaving(inputs.value.mediaSource.value);
  603. save(() => {
  604. if (closeOrNext && bulk.value) editNextSong();
  605. else if (closeOrNext) closeCurrentModal();
  606. });
  607. };
  608. const toggleFlag = (songIndex = null) => {
  609. if (songIndex && songIndex > -1) {
  610. filteredItems.value[songIndex].flagged =
  611. !filteredItems.value[songIndex].flagged;
  612. new Toast(
  613. `Successfully ${
  614. filteredItems.value[songIndex].flagged ? "flagged" : "unflagged"
  615. } song.`
  616. );
  617. } else if (!songIndex && editingItemIndex.value > -1) {
  618. items.value[editingItemIndex.value].flagged =
  619. !items.value[editingItemIndex.value].flagged;
  620. new Toast(
  621. `Successfully ${
  622. items.value[editingItemIndex.value].flagged
  623. ? "flagged"
  624. : "unflagged"
  625. } song.`
  626. );
  627. }
  628. };
  629. const onThumbnailLoad = () => {
  630. if (thumbnailElement.value) {
  631. const height = thumbnailElement.value.naturalHeight;
  632. const width = thumbnailElement.value.naturalWidth;
  633. thumbnailNotSquare.value = height !== width;
  634. thumbnailHeight.value = height;
  635. thumbnailWidth.value = width;
  636. } else {
  637. thumbnailNotSquare.value = false;
  638. thumbnailHeight.value = null;
  639. thumbnailWidth.value = null;
  640. }
  641. };
  642. const onThumbnailLoadError = error => {
  643. thumbnailLoadError.value = error !== 0;
  644. };
  645. const isYoutubeThumbnail = computed(
  646. () =>
  647. songDataLoaded.value &&
  648. inputs.value.mediaSource.value &&
  649. inputs.value.mediaSource.value.startsWith("youtube:") &&
  650. inputs.value.thumbnail.value &&
  651. (inputs.value.thumbnail.value.lastIndexOf("i.ytimg.com") !== -1 ||
  652. inputs.value.thumbnail.value.lastIndexOf("img.youtube.com") !== -1)
  653. );
  654. const drawCanvas = async () => {
  655. if (!songDataLoaded.value || !canvasElement.value) return;
  656. const ctx = canvasElement.value.getContext("2d");
  657. const videoDuration = Number(youtubeVideoDuration.value);
  658. const skipDuration = Number(inputs.value.skipDuration.value);
  659. const duration = Number(inputs.value.duration.value);
  660. const afterDuration = videoDuration - (skipDuration + duration);
  661. const width = 530;
  662. const currentTime = await getCurrentPlayerTime();
  663. const widthSkipDuration = (skipDuration / videoDuration) * width;
  664. const widthDuration = (duration / videoDuration) * width;
  665. const widthAfterDuration = (afterDuration / videoDuration) * width;
  666. const widthCurrentTime = (currentTime / videoDuration) * width;
  667. const skipDurationColor = "#F42003";
  668. const durationColor = configStore.primaryColor;
  669. const afterDurationColor = "#41E841";
  670. const currentDurationColor = "#3b25e8";
  671. ctx.fillStyle = skipDurationColor;
  672. ctx.fillRect(0, 0, widthSkipDuration, 20);
  673. ctx.fillStyle = durationColor;
  674. ctx.fillRect(widthSkipDuration, 0, widthDuration, 20);
  675. ctx.fillStyle = afterDurationColor;
  676. ctx.fillRect(widthSkipDuration + widthDuration, 0, widthAfterDuration, 20);
  677. ctx.fillStyle = currentDurationColor;
  678. ctx.fillRect(widthCurrentTime, 0, 1, 20);
  679. };
  680. const playerPlay = () => {
  681. if (currentSongMediaType.value === "youtube") {
  682. soundcloudPause();
  683. if (
  684. youtubePlayerReady.value &&
  685. video.value.player &&
  686. video.value.player.playVideo
  687. )
  688. video.value.player.playVideo();
  689. } else if (currentSongMediaType.value === "soundcloud") {
  690. if (
  691. youtubePlayerReady.value &&
  692. video.value.player &&
  693. video.value.player.pauseVideo
  694. )
  695. video.value.player.pauseVideo();
  696. soundcloudPlay();
  697. }
  698. };
  699. const seekTo = (position, play = true) => {
  700. if (currentSongMediaType.value === "youtube") {
  701. if (play) {
  702. video.value.player.seekTo(position);
  703. pauseVideo(false);
  704. playerPlay();
  705. }
  706. }
  707. if (currentSongMediaType.value === "soundcloud") {
  708. soundcloudSeekTo(position * 1000);
  709. if (play) {
  710. soundcloudPlay();
  711. }
  712. }
  713. };
  714. const getAlbumData = type => {
  715. if (!inputs.value.discogs.value) return;
  716. if (type === "title")
  717. setValue({ title: inputs.value.discogs.value.track.title });
  718. if (type === "albumArt")
  719. setValue({ thumbnail: inputs.value.discogs.value.album.albumArt });
  720. if (type === "genres")
  721. setValue({
  722. genres: JSON.parse(
  723. JSON.stringify(inputs.value.discogs.value.album.genres)
  724. )
  725. });
  726. if (type === "artists")
  727. setValue({
  728. artists: JSON.parse(
  729. JSON.stringify(inputs.value.discogs.value.album.artists)
  730. )
  731. });
  732. };
  733. const getYouTubeData = type => {
  734. if (type === "title") {
  735. try {
  736. const { title } = video.value.player.getVideoData();
  737. if (title) setValue({ title });
  738. else throw new Error("No title found");
  739. } catch (e) {
  740. new Toast(
  741. "Unable to fetch YouTube video title. Try starting the video."
  742. );
  743. }
  744. }
  745. if (type === "thumbnail")
  746. setValue({
  747. thumbnail: `https://img.youtube.com/vi/${
  748. inputs.value.mediaSource.value.split(":")[1]
  749. }/mqdefault.jpg`
  750. });
  751. if (type === "author") {
  752. try {
  753. const { author } = video.value.player.getVideoData();
  754. if (author) setValue({ addArtist: author });
  755. else throw new Error("No video author found");
  756. } catch (e) {
  757. new Toast(
  758. "Unable to fetch YouTube video author. Try starting the video."
  759. );
  760. }
  761. }
  762. };
  763. const getSoundCloudData = type => {
  764. if (type === "title") {
  765. try {
  766. soundcloudGetCurrentSound(soundcloudCurrentSound => {
  767. const { title } = soundcloudCurrentSound;
  768. if (title) setValue({ title });
  769. else throw new Error("No title found");
  770. });
  771. } catch (e) {
  772. new Toast("Unable to fetch SoundCloud track title.");
  773. }
  774. }
  775. if (type === "thumbnail") {
  776. setValue({
  777. thumbnail: `https://img.youtube.com/vi/${
  778. inputs.value.mediaSource.value.split(":")[1]
  779. }/mqdefault.jpg`
  780. });
  781. try {
  782. soundcloudGetCurrentSound(soundcloudCurrentSound => {
  783. const { artwork_url: artworkUrl } = soundcloudCurrentSound;
  784. if (artworkUrl) setValue({ thumbnail: artworkUrl });
  785. else throw new Error("No thumbnail found");
  786. });
  787. } catch (e) {
  788. new Toast("Unable to fetch SoundCloud track artwork.");
  789. }
  790. }
  791. if (type === "author") {
  792. try {
  793. soundcloudGetCurrentSound(soundcloudCurrentSound => {
  794. const { user } = soundcloudCurrentSound;
  795. if (user) setValue({ addArtist: user.username });
  796. else throw new Error("No artist found");
  797. });
  798. } catch (e) {
  799. new Toast("Unable to fetch SoundCloud track artist.");
  800. }
  801. }
  802. };
  803. const fillDuration = () => {
  804. if (currentSongMediaType.value === "youtube")
  805. setValue({
  806. duration:
  807. Number.parseFloat(youtubeVideoDuration.value) -
  808. inputs.value.skipDuration.value
  809. });
  810. else if (currentSongMediaType.value === "soundcloud") {
  811. soundcloudGetDuration(duration => {
  812. setValue({
  813. duration:
  814. Number.parseFloat(duration) / 1000 -
  815. inputs.value.skipDuration.value
  816. });
  817. });
  818. }
  819. };
  820. const playerPause = () => {
  821. if (
  822. youtubePlayerReady.value &&
  823. video.value.player &&
  824. video.value.player.pauseVideo
  825. )
  826. video.value.player.pauseVideo();
  827. soundcloudPause();
  828. };
  829. const settings = type => {
  830. switch (type) {
  831. case "stop":
  832. stopVideo();
  833. playerPause();
  834. pauseVideo(true);
  835. break;
  836. case "hardStop":
  837. playerHardStop();
  838. pauseVideo(true);
  839. break;
  840. case "pause":
  841. playerPause();
  842. pauseVideo(true);
  843. break;
  844. case "play":
  845. playerPlay();
  846. pauseVideo(false);
  847. break;
  848. case "skipToLast10Secs":
  849. seekTo(
  850. inputs.value.duration.value -
  851. 10 +
  852. inputs.value.skipDuration.value
  853. );
  854. break;
  855. default:
  856. break;
  857. }
  858. };
  859. const play = () => {
  860. if (
  861. currentSongMediaType.value === "youtube" &&
  862. inputs.value.mediaSource.value !==
  863. `youtube:${video.value.player.getVideoData().video_id}`
  864. ) {
  865. setValue({ duration: -1 });
  866. loadVideoById(
  867. inputs.value.mediaSource.value.split(":")[1],
  868. inputs.value.skipDuration.value
  869. );
  870. }
  871. console.log(
  872. `|${
  873. inputs.value.mediaSource.value
  874. }|--|soundcloud:${soundcloudGetTrackId()}|`
  875. );
  876. if (
  877. currentSongMediaType.value === "soundcloud" &&
  878. `${inputs.value.mediaSource.value}` !==
  879. `soundcloud:${soundcloudGetTrackId()}`
  880. ) {
  881. setValue({ duration: -1 });
  882. console.log(
  883. "ON PLAY LOAD SC",
  884. currentSongMediaValue.value,
  885. Math.max(Number(inputs.value.skipDuration.value), 0),
  886. true
  887. );
  888. soundcloudLoadTrack(
  889. currentSongMediaValue.value,
  890. Math.max(Number(inputs.value.skipDuration.value), 0),
  891. true
  892. );
  893. }
  894. settings("play");
  895. };
  896. const changeSoundcloudPlayerVolume = () => {
  897. if (muted.value) soundcloudSetVolume(0);
  898. else soundcloudSetVolume(volumeSliderValue.value);
  899. };
  900. const changePlayerVolume = () => {
  901. if (youtubePlayerReady.value) {
  902. video.value.player.setVolume(volumeSliderValue.value);
  903. if (muted.value) video.value.player.mute();
  904. else video.value.player.unMute();
  905. }
  906. changeSoundcloudPlayerVolume();
  907. };
  908. const changeVolume = () => {
  909. const volume = volumeSliderValue.value;
  910. localStorage.setItem("volume", `${volume}`);
  911. muted.value = volume <= 0;
  912. localStorage.setItem("muted", `${muted.value}`);
  913. changePlayerVolume();
  914. };
  915. const toggleMute = () => {
  916. muted.value = !muted.value;
  917. changePlayerVolume();
  918. };
  919. const addTag = (type, value?) => {
  920. if (type === "genres") {
  921. const genre = value || inputs.value.addGenre.value.trim();
  922. if (
  923. inputs.value.genres.value
  924. .map(genre => genre.toLowerCase())
  925. .indexOf(genre.toLowerCase()) !== -1
  926. )
  927. return new Toast("Genre already exists");
  928. if (genre) {
  929. inputs.value.genres.value.push(genre);
  930. setValue({ addGenre: "" });
  931. return false;
  932. }
  933. return new Toast("Genre cannot be empty");
  934. }
  935. if (type === "artists") {
  936. const artist = value || inputs.value.addArtist.value.trim();
  937. if (inputs.value.artists.value.indexOf(artist) !== -1)
  938. return new Toast("Artist already exists");
  939. if (artist !== "") {
  940. inputs.value.artists.value.push(artist);
  941. setValue({ addArtist: "" });
  942. return false;
  943. }
  944. return new Toast("Artist cannot be empty");
  945. }
  946. if (type === "tags") {
  947. const tag = value || inputs.value.addTag.value.trim();
  948. if (inputs.value.tags.value.indexOf(tag) !== -1)
  949. return new Toast("Tag already exists");
  950. if (tag !== "") {
  951. inputs.value.tags.value.push(tag);
  952. setValue({ addTag: "" });
  953. return false;
  954. }
  955. return new Toast("Tag cannot be empty");
  956. }
  957. return false;
  958. };
  959. const removeTag = (type, value) => {
  960. if (type === "genres")
  961. inputs.value.genres.value.splice(
  962. inputs.value.genres.value.indexOf(value),
  963. 1
  964. );
  965. else if (type === "artists")
  966. inputs.value.artists.value.splice(
  967. inputs.value.artists.value.indexOf(value),
  968. 1
  969. );
  970. else if (type === "tags")
  971. inputs.value.tags.value.splice(
  972. inputs.value.tags.value.indexOf(value),
  973. 1
  974. );
  975. };
  976. const setTrackPosition = async event => {
  977. const clickPosition =
  978. (event.pageX - event.target.getBoundingClientRect().left) / 530;
  979. if (currentSongMediaType.value === "youtube" && youtubePlayerReady.value) {
  980. seekTo(
  981. Number(Number(video.value.player.getDuration()) * clickPosition)
  982. );
  983. }
  984. if (currentSongMediaType.value === "soundcloud") {
  985. const duration = await getPlayerDuration();
  986. seekTo(Number(Number(duration) * clickPosition));
  987. }
  988. };
  989. const toggleGenreHelper = () => {
  990. genreHelper.value.toggleBox();
  991. };
  992. const resetGenreHelper = () => {
  993. genreHelper.value.resetBox();
  994. };
  995. const sendActivityWatchMediaData = () => {
  996. // TODO have this support soundcloud
  997. if (
  998. !video.value.paused &&
  999. (currentSongMediaType.value !== "youtube" ||
  1000. video.value.player.getPlayerState() ===
  1001. window.YT.PlayerState.PLAYING)
  1002. ) {
  1003. if (activityWatchMediaLastStatus.value !== "playing") {
  1004. activityWatchMediaLastStatus.value = "playing";
  1005. if (
  1006. inputs.value.skipDuration.value > 0 &&
  1007. Number(youtubeVideoCurrentTime.value) === 0
  1008. ) {
  1009. activityWatchMediaLastStartDuration.value = Math.floor(
  1010. inputs.value.skipDuration.value +
  1011. Number(youtubeVideoCurrentTime.value)
  1012. );
  1013. } else {
  1014. activityWatchMediaLastStartDuration.value = Math.floor(
  1015. Number(youtubeVideoCurrentTime.value)
  1016. );
  1017. }
  1018. }
  1019. const videoData = {
  1020. title: inputs.value.title.value,
  1021. artists: inputs.value.artists.value
  1022. ? inputs.value.artists.value.join(", ")
  1023. : null,
  1024. mediaSource: inputs.value.mediaSource.value,
  1025. muted: muted.value,
  1026. volume: volumeSliderValue.value,
  1027. startedDuration:
  1028. activityWatchMediaLastStartDuration.value <= 0
  1029. ? 0
  1030. : activityWatchMediaLastStartDuration.value,
  1031. source: `editSong#${inputs.value.mediaSource.value}`,
  1032. hostname: window.location.hostname,
  1033. playerState: Object.keys(window.YT.PlayerState).find(
  1034. key =>
  1035. window.YT.PlayerState[key] ===
  1036. video.value.player.getPlayerState()
  1037. ),
  1038. playbackRate: video.value.playbackRate
  1039. };
  1040. aw.sendMediaData(videoData);
  1041. } else {
  1042. activityWatchMediaLastStatus.value = "not_playing";
  1043. }
  1044. };
  1045. const remove = id => {
  1046. socket.dispatch("songs.remove", id, res => {
  1047. new Toast(res.message);
  1048. });
  1049. };
  1050. watch(
  1051. [() => inputs.value.duration.value, () => inputs.value.skipDuration.value],
  1052. () => drawCanvas()
  1053. );
  1054. watch(mediaSource, (_mediaSource, _oldMediaSource) => {
  1055. if (_oldMediaSource) unloadSong(_oldMediaSource);
  1056. if (_mediaSource) loadSong(_mediaSource, true);
  1057. });
  1058. watch(
  1059. () => inputs.value.mediaSource.value,
  1060. value => {
  1061. if (
  1062. value.split(":")[0] === "youtube" &&
  1063. video.value.player &&
  1064. video.value.player.cueVideoById
  1065. ) {
  1066. soundcloudUnload();
  1067. video.value.player.cueVideoById(
  1068. value.split(":")[1],
  1069. inputs.value.skipDuration.value
  1070. );
  1071. }
  1072. if (value.split(":")[0] === "soundcloud") {
  1073. playerPause();
  1074. console.log(
  1075. "ON WATCH LOAD SC",
  1076. value.split(":")[1],
  1077. Number(inputs.value.skipDuration.value),
  1078. true
  1079. );
  1080. soundcloudLoadTrack(
  1081. value.split(":")[1],
  1082. Number(inputs.value.skipDuration.value),
  1083. true
  1084. );
  1085. }
  1086. }
  1087. );
  1088. watch(
  1089. () => hasPermission("songs.update"),
  1090. value => {
  1091. if (!value) closeCurrentModal(true);
  1092. }
  1093. );
  1094. watch(
  1095. () => discogsEnabled.value || inputs.value.discogs.value,
  1096. value => {
  1097. if (!value && tab.value === "discogs") showTab("musare-songs");
  1098. }
  1099. );
  1100. onMounted(async () => {
  1101. editSongStore.init({ song: props.song, songs: props.songs });
  1102. if (!(discogsEnabled.value || inputs.value.discogs.value))
  1103. showTab("musare-songs");
  1104. editSongStore.form = {
  1105. inputs,
  1106. unsavedChanges,
  1107. save,
  1108. setValue,
  1109. setOriginalValue
  1110. };
  1111. preventCloseCbs[props.modalUuid] = onCloseOrNext;
  1112. activityWatchMediaDataInterval.value = setInterval(() => {
  1113. sendActivityWatchMediaData();
  1114. }, 1000);
  1115. socket.onConnect(() => {
  1116. if (newSong.value && !mediaSource.value && !bulk.value) {
  1117. setSong({
  1118. mediaSource: "",
  1119. title: "",
  1120. artists: [],
  1121. genres: [],
  1122. tags: [],
  1123. duration: 0,
  1124. skipDuration: 0,
  1125. thumbnail: "",
  1126. verified: false
  1127. });
  1128. songDataLoaded.value = true;
  1129. showTab("youtube");
  1130. } else if (mediaSource.value) loadSong(mediaSource.value);
  1131. else if (!bulk.value) {
  1132. new Toast("You can't open EditSong without editing a song");
  1133. return closeCurrentModal();
  1134. }
  1135. interval.value = setInterval(async () => {
  1136. const currentPlayerTime = await getCurrentPlayerTime();
  1137. const playerDuration = await getPlayerDuration();
  1138. if (
  1139. inputs.value.duration.value !== -1 &&
  1140. video.value.paused === false
  1141. ) {
  1142. if (
  1143. (currentSongMediaType.value === "youtube" &&
  1144. youtubePlayerReady.value) ||
  1145. currentSongMediaType.value === "soundcloud"
  1146. ) {
  1147. if (
  1148. currentPlayerTime - inputs.value.skipDuration.value >
  1149. inputs.value.duration.value ||
  1150. (currentPlayerTime > 0 &&
  1151. currentPlayerTime >= playerDuration)
  1152. ) {
  1153. pauseVideo(true);
  1154. playerPause();
  1155. seekTo(0, false);
  1156. drawCanvas();
  1157. }
  1158. }
  1159. }
  1160. if (
  1161. currentSongMediaType.value === "youtube" &&
  1162. youtubePlayerReady.value &&
  1163. video.value.player.getVideoData &&
  1164. video.value.player.getVideoData() &&
  1165. `youtube:${video.value.player.getVideoData().video_id}` ===
  1166. inputs.value.mediaSource.value
  1167. ) {
  1168. const currentTime = video.value.player.getCurrentTime();
  1169. if (currentTime !== undefined)
  1170. youtubeVideoCurrentTime.value = currentTime.toFixed(3);
  1171. if (youtubeVideoDuration.value.indexOf(".000") !== -1) {
  1172. const duration = video.value.player.getDuration();
  1173. if (duration !== undefined) {
  1174. if (
  1175. `${youtubeVideoDuration.value}` ===
  1176. `${Number(inputs.value.duration.value).toFixed(3)}`
  1177. )
  1178. setValue({ duration: duration.toFixed(3) });
  1179. youtubeVideoDuration.value = duration.toFixed(3);
  1180. if (youtubeVideoDuration.value.indexOf(".000") !== -1)
  1181. youtubeVideoNote.value = "(~)";
  1182. else youtubeVideoNote.value = "";
  1183. drawCanvas();
  1184. }
  1185. }
  1186. }
  1187. if (currentSongMediaType.value === "soundcloud") {
  1188. console.log(
  1189. "INTERVAL SOUNDCLOUD",
  1190. currentPlayerTime,
  1191. playerDuration,
  1192. youtubeVideoCurrentTime.value,
  1193. youtubeVideoDuration.value,
  1194. inputs.value.duration.value
  1195. );
  1196. if (currentPlayerTime)
  1197. youtubeVideoCurrentTime.value =
  1198. Number(currentPlayerTime).toFixed(3);
  1199. if (youtubeVideoDuration.value === "0.000") {
  1200. if (playerDuration) {
  1201. youtubeVideoDuration.value =
  1202. Number(playerDuration).toFixed(3);
  1203. if (youtubeVideoDuration.value.indexOf(".000") !== -1)
  1204. youtubeVideoNote.value = "(~)";
  1205. else youtubeVideoNote.value = "";
  1206. }
  1207. if (
  1208. !inputs.value.duration.value ||
  1209. (Number(inputs.value.duration.value) <= 0 &&
  1210. playerDuration &&
  1211. Number(playerDuration) > 0)
  1212. ) {
  1213. setValue({ duration: playerDuration.toFixed(3) });
  1214. }
  1215. drawCanvas();
  1216. }
  1217. }
  1218. if (video.value.paused === false) drawCanvas();
  1219. }, 200);
  1220. if (window.YT && window.YT.Player) {
  1221. video.value.player = new window.YT.Player(
  1222. `editSongPlayerYouTube-${props.modalUuid}`,
  1223. {
  1224. height: 298,
  1225. width: 530,
  1226. videoId: null,
  1227. host: "https://www.youtube-nocookie.com",
  1228. playerVars: {
  1229. controls: 0,
  1230. iv_load_policy: 3,
  1231. rel: 0,
  1232. showinfo: 0,
  1233. autoplay: 0
  1234. },
  1235. startSeconds: inputs.value.skipDuration.value,
  1236. events: {
  1237. onReady: () => {
  1238. changePlayerVolume();
  1239. youtubePlayerReady.value = true;
  1240. if (
  1241. inputs.value.mediaSource.value &&
  1242. inputs.value.mediaSource.value.startsWith(
  1243. "youtube:"
  1244. )
  1245. )
  1246. video.value.player.cueVideoById(
  1247. inputs.value.mediaSource.value.split(
  1248. ":"
  1249. )[1],
  1250. inputs.value.skipDuration.value
  1251. );
  1252. setPlaybackRate(null);
  1253. drawCanvas();
  1254. },
  1255. onStateChange: event => {
  1256. drawCanvas();
  1257. if (event.data === 1) {
  1258. video.value.paused = false;
  1259. updateMediaModalPlayingAudio(true);
  1260. let youtubeDuration =
  1261. video.value.player.getDuration();
  1262. const newYoutubeVideoDuration =
  1263. youtubeDuration.toFixed(3);
  1264. if (
  1265. youtubeVideoDuration.value.indexOf(
  1266. ".000"
  1267. ) !== -1 &&
  1268. `${youtubeVideoDuration.value}` !==
  1269. `${newYoutubeVideoDuration}`
  1270. ) {
  1271. const songDurationNumber = Number(
  1272. inputs.value.duration.value
  1273. );
  1274. const songDurationNumber2 =
  1275. Number(inputs.value.duration.value) + 1;
  1276. const songDurationNumber3 =
  1277. Number(inputs.value.duration.value) - 1;
  1278. const fixedSongDuration =
  1279. songDurationNumber.toFixed(3);
  1280. const fixedSongDuration2 =
  1281. songDurationNumber2.toFixed(3);
  1282. const fixedSongDuration3 =
  1283. songDurationNumber3.toFixed(3);
  1284. if (
  1285. `${youtubeVideoDuration.value}` ===
  1286. `${Number(
  1287. inputs.value.duration.value
  1288. ).toFixed(3)}` &&
  1289. (fixedSongDuration ===
  1290. youtubeVideoDuration.value ||
  1291. fixedSongDuration2 ===
  1292. youtubeVideoDuration.value ||
  1293. fixedSongDuration3 ===
  1294. youtubeVideoDuration.value)
  1295. )
  1296. setValue({
  1297. duration: newYoutubeVideoDuration
  1298. });
  1299. youtubeVideoDuration.value =
  1300. newYoutubeVideoDuration;
  1301. if (
  1302. youtubeVideoDuration.value.indexOf(
  1303. ".000"
  1304. ) !== -1
  1305. )
  1306. youtubeVideoNote.value = "(~)";
  1307. else youtubeVideoNote.value = "";
  1308. }
  1309. if (inputs.value.duration.value === -1)
  1310. setValue({
  1311. duration: Number.parseFloat(
  1312. youtubeVideoDuration.value
  1313. )
  1314. });
  1315. youtubeDuration -=
  1316. inputs.value.skipDuration.value;
  1317. if (
  1318. inputs.value.duration.value >
  1319. youtubeDuration + 1
  1320. ) {
  1321. pauseVideo(true);
  1322. playerPause();
  1323. seekTo(0, false);
  1324. return new Toast(
  1325. "Video can't play. Specified duration is bigger than the YouTube song duration."
  1326. );
  1327. }
  1328. if (inputs.value.duration.value <= 0) {
  1329. pauseVideo(true);
  1330. playerPause();
  1331. seekTo(0, false);
  1332. return new Toast(
  1333. "Video can't play. Specified duration has to be more than 0 seconds."
  1334. );
  1335. }
  1336. if (
  1337. video.value.player.getCurrentTime() <
  1338. inputs.value.skipDuration.value
  1339. ) {
  1340. return seekTo(
  1341. inputs.value.skipDuration.value
  1342. );
  1343. }
  1344. setPlaybackRate(null);
  1345. } else if (event.data === 2) {
  1346. video.value.paused = true;
  1347. updateMediaModalPlayingAudio(false);
  1348. }
  1349. return false;
  1350. }
  1351. }
  1352. }
  1353. );
  1354. } else {
  1355. youtubeError.value = true;
  1356. youtubeErrorMessage.value = "Player could not be loaded.";
  1357. }
  1358. ["artists", "genres", "tags"].forEach(type => {
  1359. socket.dispatch(
  1360. `songs.get${type.charAt(0).toUpperCase()}${type.slice(1)}`,
  1361. res => {
  1362. if (res.status === "success") {
  1363. const { items } = res.data;
  1364. if (type === "genres")
  1365. autosuggest.value.allItems[type] = Array.from(
  1366. new Set([...recommendedGenres.value, ...items])
  1367. );
  1368. else autosuggest.value.allItems[type] = items;
  1369. } else {
  1370. new Toast(res.message);
  1371. }
  1372. }
  1373. );
  1374. });
  1375. if (bulk.value) {
  1376. socket.dispatch("apis.joinRoom", "edit-songs");
  1377. console.log(68768, mediaSources.value);
  1378. socket.dispatch(
  1379. "songs.getSongsFromMediaSources",
  1380. mediaSources.value,
  1381. res => {
  1382. if (res.data.songs.length === 0) {
  1383. closeCurrentModal();
  1384. new Toast("You can't edit 0 songs.");
  1385. } else {
  1386. items.value = res.data.songs.map(song => ({
  1387. status: "todo",
  1388. flagged: false,
  1389. song
  1390. }));
  1391. editNextSong();
  1392. }
  1393. }
  1394. );
  1395. }
  1396. return null;
  1397. });
  1398. socket.on(
  1399. `event:admin.song.updated`,
  1400. res => {
  1401. if (song.value._id === res.data.song._id)
  1402. setOriginalValue({
  1403. title: res.data.song.title,
  1404. duration: res.data.song.duration,
  1405. skipDuration: res.data.song.skipDuration,
  1406. thumbnail: res.data.song.thumbnail,
  1407. mediaSource: res.data.song.mediaSource,
  1408. verified: res.data.song.verified,
  1409. artists: res.data.song.artists,
  1410. genres: res.data.song.genres,
  1411. tags: res.data.song.tags,
  1412. discogs: res.data.song.discogs
  1413. });
  1414. if (bulk.value) {
  1415. const index = items.value
  1416. .map(item => item.song.mediaSource)
  1417. .indexOf(res.data.song.mediaSource);
  1418. if (index >= 0)
  1419. items.value[index].song = {
  1420. ...items.value[index].song,
  1421. ...res.data.song,
  1422. updated: true
  1423. };
  1424. }
  1425. },
  1426. { modalUuid: props.modalUuid }
  1427. );
  1428. socket.on(
  1429. "event:admin.song.removed",
  1430. res => {
  1431. if (res.data.songId === song.value._id) {
  1432. songDeleted.value = true;
  1433. if (!bulk.value) closeCurrentModal(true);
  1434. }
  1435. },
  1436. { modalUuid: props.modalUuid }
  1437. );
  1438. if (bulk.value) {
  1439. socket.on(
  1440. `event:admin.song.created`,
  1441. res => {
  1442. const index = items.value
  1443. .map(item => item.song.mediaSource)
  1444. .indexOf(res.data.song.mediaSource);
  1445. if (index >= 0)
  1446. items.value[index].song = {
  1447. ...items.value[index].song,
  1448. ...res.data.song,
  1449. created: true
  1450. };
  1451. },
  1452. { modalUuid: props.modalUuid }
  1453. );
  1454. socket.on(
  1455. `event:admin.song.removed`,
  1456. res => {
  1457. const index = items.value
  1458. .map(item => item.song._id)
  1459. .indexOf(res.data.songId);
  1460. if (index >= 0) items.value[index].song.removed = true;
  1461. },
  1462. { modalUuid: props.modalUuid }
  1463. );
  1464. socket.on(
  1465. `event:admin.youtubeVideo.removed`,
  1466. res => {
  1467. const index = items.value
  1468. .map(item => item.song.youtubeVideoId)
  1469. .indexOf(res.videoId);
  1470. if (index >= 0) items.value[index].song.removed = true;
  1471. },
  1472. { modalUuid: props.modalUuid }
  1473. );
  1474. }
  1475. let volume = parseFloat(localStorage.getItem("volume"));
  1476. volume = typeof volume === "number" && !Number.isNaN(volume) ? volume : 20;
  1477. localStorage.setItem("volume", `${volume}`);
  1478. volumeSliderValue.value = volume;
  1479. keyboardShortcuts.registerShortcut("editSong.pauseResumeVideo", {
  1480. keyCode: 101,
  1481. preventDefault: true,
  1482. handler: () => {
  1483. if (video.value.paused) play();
  1484. else settings("pause");
  1485. }
  1486. });
  1487. keyboardShortcuts.registerShortcut("editSong.stopVideo", {
  1488. keyCode: 101,
  1489. ctrl: true,
  1490. preventDefault: true,
  1491. handler: () => {
  1492. settings("stop");
  1493. }
  1494. });
  1495. keyboardShortcuts.registerShortcut("editSong.hardStopVideo", {
  1496. keyCode: 101,
  1497. ctrl: true,
  1498. shift: true,
  1499. preventDefault: true,
  1500. handler: () => {
  1501. settings("hardStop");
  1502. }
  1503. });
  1504. keyboardShortcuts.registerShortcut("editSong.skipToLast10Secs", {
  1505. keyCode: 102,
  1506. preventDefault: true,
  1507. handler: () => {
  1508. settings("skipToLast10Secs");
  1509. }
  1510. });
  1511. keyboardShortcuts.registerShortcut("editSong.lowerVolumeLarge", {
  1512. keyCode: 98,
  1513. preventDefault: true,
  1514. handler: () => {
  1515. volumeSliderValue.value = Math.max(0, volumeSliderValue.value - 10);
  1516. changeVolume();
  1517. }
  1518. });
  1519. keyboardShortcuts.registerShortcut("editSong.lowerVolumeSmall", {
  1520. keyCode: 98,
  1521. ctrl: true,
  1522. preventDefault: true,
  1523. handler: () => {
  1524. volumeSliderValue.value = Math.max(0, volumeSliderValue.value - 1);
  1525. changeVolume();
  1526. }
  1527. });
  1528. keyboardShortcuts.registerShortcut("editSong.increaseVolumeLarge", {
  1529. keyCode: 104,
  1530. preventDefault: true,
  1531. handler: () => {
  1532. volumeSliderValue.value = Math.min(
  1533. 100,
  1534. volumeSliderValue.value + 10
  1535. );
  1536. changeVolume();
  1537. }
  1538. });
  1539. keyboardShortcuts.registerShortcut("editSong.increaseVolumeSmall", {
  1540. keyCode: 104,
  1541. ctrl: true,
  1542. preventDefault: true,
  1543. handler: () => {
  1544. volumeSliderValue.value = Math.min(
  1545. 100,
  1546. volumeSliderValue.value + 1
  1547. );
  1548. changeVolume();
  1549. }
  1550. });
  1551. keyboardShortcuts.registerShortcut("editSong.save", {
  1552. keyCode: 83,
  1553. ctrl: true,
  1554. preventDefault: true,
  1555. handler: () => {
  1556. saveSong("saveButton");
  1557. }
  1558. });
  1559. keyboardShortcuts.registerShortcut("editSong.saveClose", {
  1560. keyCode: 83,
  1561. ctrl: true,
  1562. alt: true,
  1563. preventDefault: true,
  1564. handler: () => {
  1565. saveSong("saveAndCloseButton", true);
  1566. }
  1567. });
  1568. keyboardShortcuts.registerShortcut("editSong.focusTitle", {
  1569. keyCode: 36,
  1570. preventDefault: true,
  1571. handler: () => {
  1572. inputs.value["title-input"].focus();
  1573. }
  1574. });
  1575. keyboardShortcuts.registerShortcut("editSong.useAllDiscogs", {
  1576. keyCode: 68,
  1577. alt: true,
  1578. ctrl: true,
  1579. preventDefault: true,
  1580. handler: () => {
  1581. getAlbumData("title");
  1582. getAlbumData("albumArt");
  1583. getAlbumData("artists");
  1584. getAlbumData("genres");
  1585. }
  1586. });
  1587. /*
  1588. editSong.pauseResume - Num 5 - Pause/resume song
  1589. editSong.stopVideo - Ctrl - Num 5 - Stop
  1590. editSong.hardStopVideo - Shift - Ctrl - Num 5 - Stop
  1591. editSong.skipToLast10Secs - Num 6 - Skip to last 10 seconds
  1592. editSong.lowerVolumeLarge - Num 2 - Volume down by 10
  1593. editSong.lowerVolumeSmall - Ctrl - Num 2 - Volume down by 1
  1594. editSong.increaseVolumeLarge - Num 8 - Volume up by 10
  1595. editSong.increaseVolumeSmall - Ctrl - Num 8 - Volume up by 1
  1596. editSong.focusTitle - Home - Focus the title input
  1597. editSong.focusDicogs - End - Focus the discogs input
  1598. editSong.save - Ctrl - S - Saves song
  1599. editSong.save - Ctrl - Alt - S - Saves song and closes the modal
  1600. editSong.save - Ctrl - Alt - V - Saves song, verifies songs and then closes the modal
  1601. editSong.close - F4 - Closes modal without saving
  1602. editSong.useAllDiscogs - Ctrl - Alt - D - Sets all fields to the Discogs data
  1603. Inside Discogs inputs: Ctrl - D - Sets this field to the Discogs data
  1604. */
  1605. soundcloudBindListener("seek", () => {
  1606. console.debug(TAG, "Bind on seek");
  1607. // if (seeking.value) seeking.value = false;
  1608. });
  1609. soundcloudBindListener("error", value => {
  1610. console.debug(TAG, "Bind on error", value);
  1611. });
  1612. });
  1613. onBeforeUnmount(() => {
  1614. if (bulk.value) {
  1615. socket.dispatch("apis.leaveRoom", "edit-songs");
  1616. }
  1617. unloadSong(mediaSource.value, song.value._id);
  1618. updateMediaModalPlayingAudio(false);
  1619. youtubePlayerReady.value = false;
  1620. clearInterval(interval.value);
  1621. clearInterval(activityWatchMediaDataInterval.value);
  1622. const shortcutNames = [
  1623. "editSong.pauseResume",
  1624. "editSong.stopVideo",
  1625. "editSong.hardStopVideo",
  1626. "editSong.skipToLast10Secs",
  1627. "editSong.lowerVolumeLarge",
  1628. "editSong.lowerVolumeSmall",
  1629. "editSong.increaseVolumeLarge",
  1630. "editSong.increaseVolumeSmall",
  1631. "editSong.focusTitle",
  1632. "editSong.focusDicogs",
  1633. "editSong.save",
  1634. "editSong.saveClose",
  1635. "editSong.useAllDiscogs",
  1636. "editSong.closeModal"
  1637. ];
  1638. shortcutNames.forEach(shortcutName => {
  1639. keyboardShortcuts.unregisterShortcut(shortcutName);
  1640. });
  1641. delete preventCloseCbs[props.modalUuid];
  1642. // Delete the Pinia store that was created for this modal, after all other cleanup tasks are performed
  1643. editSongStore.$dispose();
  1644. });
  1645. </script>
  1646. <template>
  1647. <div>
  1648. <modal
  1649. :title="`${newSong ? 'Create' : 'Edit'} Song`"
  1650. class="song-modal"
  1651. :size="'wide'"
  1652. :split="true"
  1653. >
  1654. <template #toggleMobileSidebar v-if="bulk">
  1655. <i
  1656. class="material-icons toggle-sidebar-icon"
  1657. :content="`${
  1658. sidebarMobileActive ? 'Close' : 'Open'
  1659. } Edit Queue`"
  1660. v-tippy
  1661. @click="toggleMobileSidebar()"
  1662. >expand_circle_down</i
  1663. >
  1664. </template>
  1665. <template #sidebar v-if="bulk">
  1666. <div class="sidebar" :class="{ active: sidebarMobileActive }">
  1667. <header class="sidebar-head">
  1668. <h2 class="sidebar-title is-marginless">Edit Queue</h2>
  1669. <i
  1670. class="material-icons toggle-sidebar-icon"
  1671. :content="`${
  1672. sidebarMobileActive ? 'Close' : 'Open'
  1673. } Edit Queue`"
  1674. v-tippy
  1675. @click="toggleMobileSidebar()"
  1676. >expand_circle_down</i
  1677. >
  1678. </header>
  1679. <section class="sidebar-body">
  1680. <div
  1681. v-show="filteredItems.length > 0"
  1682. class="edit-songs-items"
  1683. >
  1684. <div
  1685. class="item"
  1686. v-for="(data, index) in filteredItems"
  1687. :key="`edit-songs-item-${index}`"
  1688. :ref="
  1689. el =>
  1690. (songItems[
  1691. `edit-songs-item-${data.song.mediaSource}`
  1692. ] = el)
  1693. "
  1694. >
  1695. <media-item
  1696. :song="data.song"
  1697. :thumbnail="false"
  1698. :duration="false"
  1699. :disabled-actions="
  1700. data.song.removed
  1701. ? ['all']
  1702. : ['report', 'edit']
  1703. "
  1704. :class="{
  1705. updated: data.song.updated,
  1706. removed: data.song.removed
  1707. }"
  1708. >
  1709. <template #leftIcon>
  1710. <i
  1711. v-if="
  1712. currentSong.mediaSource ===
  1713. data.song.mediaSource &&
  1714. !data.song.removed
  1715. "
  1716. class="material-icons item-icon editing-icon"
  1717. content="Currently editing song"
  1718. v-tippy="{ theme: 'info' }"
  1719. @click="toggleDone(index)"
  1720. >edit</i
  1721. >
  1722. <i
  1723. v-else-if="data.song.removed"
  1724. class="material-icons item-icon removed-icon"
  1725. content="Song removed"
  1726. v-tippy="{ theme: 'info' }"
  1727. >delete_forever</i
  1728. >
  1729. <i
  1730. v-else-if="data.status === 'error'"
  1731. class="material-icons item-icon error-icon"
  1732. content="Error saving song"
  1733. v-tippy="{ theme: 'info' }"
  1734. @click="toggleDone(index)"
  1735. >error</i
  1736. >
  1737. <i
  1738. v-else-if="data.status === 'saving'"
  1739. class="material-icons item-icon saving-icon"
  1740. content="Currently saving song"
  1741. v-tippy="{ theme: 'info' }"
  1742. >pending</i
  1743. >
  1744. <i
  1745. v-else-if="data.flagged"
  1746. class="material-icons item-icon flag-icon"
  1747. content="Song flagged"
  1748. v-tippy="{ theme: 'info' }"
  1749. @click="toggleDone(index)"
  1750. >flag_circle</i
  1751. >
  1752. <i
  1753. v-else-if="data.status === 'done'"
  1754. class="material-icons item-icon done-icon"
  1755. content="Song marked complete"
  1756. v-tippy="{ theme: 'info' }"
  1757. @click="toggleDone(index)"
  1758. >check_circle</i
  1759. >
  1760. <i
  1761. v-else-if="data.status === 'todo'"
  1762. class="material-icons item-icon todo-icon"
  1763. content="Song marked todo"
  1764. v-tippy="{ theme: 'info' }"
  1765. @click="toggleDone(index)"
  1766. >cancel</i
  1767. >
  1768. </template>
  1769. <template
  1770. v-if="!data.song.removed"
  1771. #actions
  1772. >
  1773. <i
  1774. class="material-icons edit-icon"
  1775. content="Edit Song"
  1776. v-tippy
  1777. @click="pickSong(data.song)"
  1778. >
  1779. edit
  1780. </i>
  1781. </template>
  1782. <template #tippyActions>
  1783. <i
  1784. class="material-icons flag-icon"
  1785. :class="{
  1786. flagged: data.flagged
  1787. }"
  1788. content="Toggle Flag"
  1789. v-tippy
  1790. @click="toggleFlag(index)"
  1791. >
  1792. flag_circle
  1793. </i>
  1794. </template>
  1795. </media-item>
  1796. </div>
  1797. </div>
  1798. <p v-if="filteredItems.length === 0" class="no-items">
  1799. {{
  1800. flagFilter
  1801. ? "No flagged songs queued"
  1802. : "No songs queued"
  1803. }}
  1804. </p>
  1805. </section>
  1806. <footer class="sidebar-foot">
  1807. <button
  1808. @click="toggleFlagFilter()"
  1809. class="button is-primary"
  1810. >
  1811. {{
  1812. flagFilter
  1813. ? "Show All Songs"
  1814. : "Show Only Flagged Songs"
  1815. }}
  1816. </button>
  1817. </footer>
  1818. </div>
  1819. <div
  1820. v-if="sidebarMobileActive"
  1821. class="sidebar-overlay"
  1822. @click="toggleMobileSidebar()"
  1823. ></div>
  1824. </template>
  1825. <template #body>
  1826. <div v-if="!mediaSource && !newSong" class="notice-container">
  1827. <h4>No song has been selected</h4>
  1828. </div>
  1829. <div v-if="songDeleted" class="notice-container">
  1830. <h4>The song you were editing has been deleted</h4>
  1831. </div>
  1832. <div
  1833. v-if="
  1834. mediaSource &&
  1835. !songDataLoaded &&
  1836. !songNotFound &&
  1837. !newSong
  1838. "
  1839. class="notice-container"
  1840. >
  1841. <h4>Song hasn't loaded yet</h4>
  1842. </div>
  1843. <div
  1844. v-if="mediaSource && songNotFound && !newSong"
  1845. class="notice-container"
  1846. >
  1847. <h4>Song was not found</h4>
  1848. </div>
  1849. <div
  1850. class="left-section"
  1851. v-show="songDataLoaded && !songDeleted"
  1852. >
  1853. <div class="top-section">
  1854. <div class="player-section">
  1855. <div
  1856. v-show="currentSongMediaType === 'youtube'"
  1857. class="youtube-player-wrapper"
  1858. >
  1859. <div
  1860. :id="`editSongPlayerYouTube-${modalUuid}`"
  1861. ></div>
  1862. </div>
  1863. <iframe
  1864. v-if="experimental.soundcloud"
  1865. :id="`editSongPlayerSoundCloud-${modalUuid}`"
  1866. v-show="currentSongMediaType === 'soundcloud'"
  1867. ref="soundcloudIframeElement"
  1868. style="
  1869. width: 100%;
  1870. height: 100%;
  1871. min-height: 200px;
  1872. "
  1873. scrolling="no"
  1874. frameborder="no"
  1875. allow="autoplay"
  1876. ></iframe>
  1877. <div
  1878. class="player-message"
  1879. v-show="
  1880. currentSongMediaType === 'soundcloud' &&
  1881. !experimental.soundcloud
  1882. "
  1883. >
  1884. <h2>SoundCloud is not enabled</h2>
  1885. </div>
  1886. <div
  1887. class="player-message"
  1888. v-show="
  1889. currentSongMediaType !== 'youtube' &&
  1890. currentSongMediaType !== 'soundcloud'
  1891. "
  1892. >
  1893. <h2>No media source specified</h2>
  1894. </div>
  1895. <div v-show="youtubeError" class="player-error">
  1896. <h2>{{ youtubeErrorMessage }}</h2>
  1897. </div>
  1898. <canvas
  1899. ref="canvasElement"
  1900. class="duration-canvas"
  1901. v-show="!youtubeError"
  1902. height="20"
  1903. width="530"
  1904. @click="setTrackPosition($event)"
  1905. />
  1906. <div class="player-footer">
  1907. <div class="player-footer-left">
  1908. <button
  1909. class="button is-primary"
  1910. @click="play()"
  1911. @keyup.enter="play()"
  1912. v-if="video.paused"
  1913. content="Resume Playback"
  1914. v-tippy
  1915. >
  1916. <i class="material-icons">play_arrow</i>
  1917. </button>
  1918. <button
  1919. class="button is-primary"
  1920. @click="settings('pause')"
  1921. @keyup.enter="settings('pause')"
  1922. v-else
  1923. content="Pause Playback"
  1924. v-tippy
  1925. >
  1926. <i class="material-icons">pause</i>
  1927. </button>
  1928. <button
  1929. class="button is-danger"
  1930. @click.exact="settings('stop')"
  1931. @click.shift="settings('hardStop')"
  1932. @keyup.enter.exact="settings('stop')"
  1933. @keyup.shift.enter="
  1934. settings('hardStop')
  1935. "
  1936. content="Stop Playback"
  1937. v-tippy
  1938. >
  1939. <i class="material-icons">stop</i>
  1940. </button>
  1941. <tippy
  1942. class="playerRateDropdown"
  1943. :touch="true"
  1944. :interactive="true"
  1945. placement="bottom"
  1946. theme="dropdown"
  1947. ref="dropdown"
  1948. trigger="click"
  1949. append-to="parent"
  1950. @show="
  1951. () => {
  1952. showRateDropdown = true;
  1953. }
  1954. "
  1955. @hide="
  1956. () => {
  1957. showRateDropdown = false;
  1958. }
  1959. "
  1960. >
  1961. <div
  1962. ref="trigger"
  1963. class="control has-addons"
  1964. content="Set Playback Rate"
  1965. v-tippy
  1966. >
  1967. <button class="button is-primary">
  1968. <i class="material-icons"
  1969. >fast_forward</i
  1970. >
  1971. </button>
  1972. <button
  1973. class="button dropdown-toggle"
  1974. >
  1975. <i class="material-icons">
  1976. {{
  1977. showRateDropdown
  1978. ? "expand_more"
  1979. : "expand_less"
  1980. }}
  1981. </i>
  1982. </button>
  1983. </div>
  1984. <template #content>
  1985. <div class="nav-dropdown-items">
  1986. <button
  1987. class="nav-item button"
  1988. :class="{
  1989. active:
  1990. video.playbackRate ===
  1991. 0.5
  1992. }"
  1993. title="0.5x"
  1994. @click="
  1995. setPlaybackRate(0.5)
  1996. "
  1997. >
  1998. <p>0.5x</p>
  1999. </button>
  2000. <button
  2001. class="nav-item button"
  2002. :class="{
  2003. active:
  2004. video.playbackRate ===
  2005. 1
  2006. }"
  2007. title="1x"
  2008. @click="setPlaybackRate(1)"
  2009. >
  2010. <p>1x</p>
  2011. </button>
  2012. <button
  2013. class="nav-item button"
  2014. :class="{
  2015. active:
  2016. video.playbackRate ===
  2017. 2
  2018. }"
  2019. title="2x"
  2020. @click="setPlaybackRate(2)"
  2021. >
  2022. <p>2x</p>
  2023. </button>
  2024. </div>
  2025. </template>
  2026. </tippy>
  2027. </div>
  2028. <div class="player-footer-center">
  2029. <span>
  2030. <span>
  2031. {{ youtubeVideoCurrentTime }}
  2032. </span>
  2033. /
  2034. <span>
  2035. {{ youtubeVideoDuration }}
  2036. {{ youtubeVideoNote }}
  2037. </span>
  2038. </span>
  2039. </div>
  2040. <div class="player-footer-right">
  2041. <p id="volume-control">
  2042. <i
  2043. class="material-icons"
  2044. @click="toggleMute()"
  2045. :content="`${
  2046. muted ? 'Unmute' : 'Mute'
  2047. }`"
  2048. v-tippy
  2049. >{{
  2050. muted
  2051. ? "volume_mute"
  2052. : volumeSliderValue >= 50
  2053. ? "volume_up"
  2054. : "volume_down"
  2055. }}</i
  2056. >
  2057. <input
  2058. v-model="volumeSliderValue"
  2059. type="range"
  2060. min="0"
  2061. max="100"
  2062. class="volume-slider active"
  2063. @change="changeVolume()"
  2064. @input="changeVolume()"
  2065. />
  2066. </p>
  2067. </div>
  2068. </div>
  2069. </div>
  2070. <song-thumbnail
  2071. v-if="songDataLoaded && !songDeleted"
  2072. :song="{
  2073. mediaSource: inputs['mediaSource'].value,
  2074. thumbnail: inputs['thumbnail'].value
  2075. }"
  2076. :fallback="false"
  2077. class="thumbnail-preview"
  2078. @load-error="onThumbnailLoadError"
  2079. />
  2080. <img
  2081. v-if="
  2082. !isYoutubeThumbnail &&
  2083. songDataLoaded &&
  2084. !songDeleted
  2085. "
  2086. class="thumbnail-dummy"
  2087. :src="inputs['thumbnail'].value"
  2088. ref="thumbnailElement"
  2089. @load="onThumbnailLoad"
  2090. />
  2091. </div>
  2092. <div
  2093. class="edit-section"
  2094. v-if="songDataLoaded && !songDeleted"
  2095. >
  2096. <div class="control is-grouped">
  2097. <div class="title-container">
  2098. <label class="label">Title</label>
  2099. <p class="control has-addons">
  2100. <input
  2101. class="input"
  2102. type="text"
  2103. :ref="el => (inputs['title'].ref = el)"
  2104. v-model="inputs['title'].value"
  2105. placeholder="Enter song title..."
  2106. @keyup.shift.enter="
  2107. getAlbumData('title')
  2108. "
  2109. />
  2110. <button
  2111. v-if="
  2112. currentSongMediaType ===
  2113. 'soundcloud' &&
  2114. experimental.soundcloud
  2115. "
  2116. class="button soundcloud-get-button"
  2117. @click="getSoundCloudData('title')"
  2118. >
  2119. <div
  2120. class="soundcloud-icon"
  2121. v-tippy
  2122. content="Fill from SoundCloud"
  2123. ></div>
  2124. </button>
  2125. <button
  2126. v-if="
  2127. currentSongMediaType ===
  2128. 'youtube' && youtubePlayerReady
  2129. "
  2130. class="button youtube-get-button"
  2131. @click="getYouTubeData('title')"
  2132. >
  2133. <div
  2134. class="youtube-icon"
  2135. v-tippy
  2136. content="Fill from YouTube"
  2137. ></div>
  2138. </button>
  2139. <button
  2140. v-if="inputs.discogs.value"
  2141. class="button album-get-button"
  2142. @click="getAlbumData('title')"
  2143. >
  2144. <i
  2145. class="material-icons"
  2146. v-tippy
  2147. content="Fill from Discogs"
  2148. >album</i
  2149. >
  2150. </button>
  2151. </p>
  2152. </div>
  2153. <div class="duration-container">
  2154. <label class="label">Duration</label>
  2155. <p class="control has-addons">
  2156. <input
  2157. class="input"
  2158. type="text"
  2159. placeholder="Enter song duration..."
  2160. v-model.number="
  2161. inputs['duration'].value
  2162. "
  2163. @keyup.shift.enter="fillDuration()"
  2164. />
  2165. <button
  2166. class="button duration-fill-button"
  2167. @click="fillDuration()"
  2168. >
  2169. <i
  2170. class="material-icons"
  2171. v-tippy
  2172. content="Sync duration with player"
  2173. >sync</i
  2174. >
  2175. </button>
  2176. </p>
  2177. </div>
  2178. <div class="skip-duration-container">
  2179. <label class="label">Skip duration</label>
  2180. <p class="control">
  2181. <input
  2182. class="input"
  2183. type="text"
  2184. placeholder="Enter skip duration..."
  2185. v-model.number="
  2186. inputs['skipDuration'].value
  2187. "
  2188. />
  2189. </p>
  2190. </div>
  2191. </div>
  2192. <div class="control is-grouped">
  2193. <div class="album-art-container">
  2194. <label class="label">
  2195. Thumbnail
  2196. <i
  2197. v-if="
  2198. thumbnailNotSquare &&
  2199. !isYoutubeThumbnail
  2200. "
  2201. class="material-icons thumbnail-warning"
  2202. content="Thumbnail not square, it will be stretched"
  2203. v-tippy="{ theme: 'info' }"
  2204. >
  2205. warning
  2206. </i>
  2207. <i
  2208. v-if="
  2209. thumbnailLoadError &&
  2210. !isYoutubeThumbnail
  2211. "
  2212. class="material-icons thumbnail-warning"
  2213. content="Error loading thumbnail"
  2214. v-tippy="{ theme: 'info' }"
  2215. >
  2216. warning
  2217. </i>
  2218. </label>
  2219. <p class="control has-addons">
  2220. <input
  2221. class="input"
  2222. type="text"
  2223. v-model="inputs['thumbnail'].value"
  2224. placeholder="Enter link to thumbnail..."
  2225. @keyup.shift.enter="
  2226. getAlbumData('albumArt')
  2227. "
  2228. />
  2229. <button
  2230. v-if="
  2231. currentSongMediaType ===
  2232. 'soundcloud' &&
  2233. experimental.soundcloud
  2234. "
  2235. class="button soundcloud-get-button"
  2236. @click="getSoundCloudData('thumbnail')"
  2237. >
  2238. <div
  2239. class="soundcloud-icon"
  2240. v-tippy
  2241. content="Fill from SoundCloud"
  2242. ></div>
  2243. </button>
  2244. <button
  2245. v-if="
  2246. currentSongMediaType ===
  2247. 'youtube' && youtubePlayerReady
  2248. "
  2249. class="button youtube-get-button"
  2250. @click="getYouTubeData('thumbnail')"
  2251. >
  2252. <div
  2253. class="youtube-icon"
  2254. v-tippy
  2255. content="Fill from YouTube"
  2256. ></div>
  2257. </button>
  2258. <button
  2259. v-if="inputs.discogs.value"
  2260. class="button album-get-button"
  2261. @click="getAlbumData('albumArt')"
  2262. >
  2263. <i
  2264. class="material-icons"
  2265. v-tippy
  2266. content="Fill from Discogs"
  2267. >album</i
  2268. >
  2269. </button>
  2270. </p>
  2271. </div>
  2272. <div class="youtube-id-container">
  2273. <label class="label">Media source</label>
  2274. <p class="control">
  2275. <input
  2276. class="input"
  2277. type="text"
  2278. placeholder="Enter media source..."
  2279. v-model="inputs['mediaSource'].value"
  2280. />
  2281. </p>
  2282. </div>
  2283. <div class="verified-container">
  2284. <label class="label">Verified</label>
  2285. <p class="is-expanded checkbox-control">
  2286. <label class="switch">
  2287. <input
  2288. type="checkbox"
  2289. id="verified"
  2290. v-model="inputs['verified'].value"
  2291. />
  2292. <span class="slider round"></span>
  2293. </label>
  2294. </p>
  2295. </div>
  2296. </div>
  2297. <div class="control is-grouped">
  2298. <div class="artists-container">
  2299. <label class="label">Artists</label>
  2300. <p class="control has-addons">
  2301. <auto-suggest
  2302. v-model="inputs['addArtist'].value"
  2303. ref="new-artist"
  2304. placeholder="Add artist..."
  2305. :all-items="
  2306. autosuggest.allItems.artists
  2307. "
  2308. @submitted="addTag('artists')"
  2309. @keyup.shift.enter="
  2310. getAlbumData('artists')
  2311. "
  2312. />
  2313. <button
  2314. v-if="
  2315. currentSongMediaType ===
  2316. 'soundcloud' &&
  2317. experimental.soundcloud
  2318. "
  2319. class="button soundcloud-get-button"
  2320. @click="getSoundCloudData('author')"
  2321. >
  2322. <div
  2323. class="soundcloud-icon"
  2324. v-tippy
  2325. content="Fill from SoundCloud"
  2326. ></div>
  2327. </button>
  2328. <button
  2329. v-if="
  2330. currentSongMediaType ===
  2331. 'youtube' && youtubePlayerReady
  2332. "
  2333. class="button youtube-get-button"
  2334. @click="getYouTubeData('author')"
  2335. >
  2336. <div
  2337. class="youtube-icon"
  2338. v-tippy
  2339. content="Fill from YouTube"
  2340. ></div>
  2341. </button>
  2342. <button
  2343. v-if="inputs.discogs.value"
  2344. class="button album-get-button"
  2345. @click="getAlbumData('artists')"
  2346. >
  2347. <i
  2348. class="material-icons"
  2349. v-tippy
  2350. content="Fill from Discogs"
  2351. >album</i
  2352. >
  2353. </button>
  2354. <button
  2355. class="button is-info add-button"
  2356. @click="addTag('artists')"
  2357. >
  2358. <i class="material-icons">add</i>
  2359. </button>
  2360. </p>
  2361. <div class="list-container">
  2362. <div
  2363. class="list-item"
  2364. v-for="artist in inputs['artists']
  2365. .value"
  2366. :key="artist"
  2367. >
  2368. <div
  2369. class="list-item-circle"
  2370. @click="
  2371. removeTag('artists', artist)
  2372. "
  2373. >
  2374. <i class="material-icons">close</i>
  2375. </div>
  2376. <p>{{ artist }}</p>
  2377. </div>
  2378. </div>
  2379. </div>
  2380. <div class="genres-container">
  2381. <label class="label">
  2382. <span>Genres</span>
  2383. <i
  2384. class="material-icons"
  2385. @click="toggleGenreHelper"
  2386. @dblclick="resetGenreHelper"
  2387. v-tippy
  2388. content="View list of genres"
  2389. >info</i
  2390. >
  2391. </label>
  2392. <p class="control has-addons">
  2393. <auto-suggest
  2394. v-model="inputs['addGenre'].value"
  2395. ref="new-genre"
  2396. placeholder="Add genre..."
  2397. :all-items="autosuggest.allItems.genres"
  2398. @submitted="addTag('genres')"
  2399. @keyup.shift.enter="
  2400. getAlbumData('genres')
  2401. "
  2402. />
  2403. <button
  2404. v-if="inputs.discogs.value"
  2405. class="button album-get-button"
  2406. @click="getAlbumData('genres')"
  2407. >
  2408. <i
  2409. class="material-icons"
  2410. v-tippy
  2411. content="Fill from Discogs"
  2412. >album</i
  2413. >
  2414. </button>
  2415. <button
  2416. class="button is-info add-button"
  2417. @click="addTag('genres')"
  2418. >
  2419. <i class="material-icons">add</i>
  2420. </button>
  2421. </p>
  2422. <div class="list-container">
  2423. <div
  2424. class="list-item"
  2425. v-for="genre in inputs['genres'].value"
  2426. :key="genre"
  2427. >
  2428. <div
  2429. class="list-item-circle"
  2430. @click="removeTag('genres', genre)"
  2431. >
  2432. <i class="material-icons">close</i>
  2433. </div>
  2434. <p>{{ genre }}</p>
  2435. </div>
  2436. </div>
  2437. </div>
  2438. <div class="tags-container">
  2439. <label class="label">Tags</label>
  2440. <p class="control has-addons">
  2441. <auto-suggest
  2442. v-model="inputs['addTag'].value"
  2443. ref="new-tag"
  2444. placeholder="Add tag..."
  2445. :all-items="autosuggest.allItems.tags"
  2446. @submitted="addTag('tags')"
  2447. />
  2448. <button
  2449. class="button is-info add-button"
  2450. @click="addTag('tags')"
  2451. >
  2452. <i class="material-icons">add</i>
  2453. </button>
  2454. </p>
  2455. <div class="list-container">
  2456. <div
  2457. class="list-item"
  2458. v-for="tag in inputs['tags'].value"
  2459. :key="tag"
  2460. >
  2461. <div
  2462. class="list-item-circle"
  2463. @click="removeTag('tags', tag)"
  2464. >
  2465. <i class="material-icons">close</i>
  2466. </div>
  2467. <p>{{ tag }}</p>
  2468. </div>
  2469. </div>
  2470. </div>
  2471. </div>
  2472. </div>
  2473. </div>
  2474. <div
  2475. class="right-section"
  2476. v-if="songDataLoaded && !songDeleted"
  2477. >
  2478. <div id="tabs-container">
  2479. <div id="tab-selection">
  2480. <button
  2481. v-if="discogsEnabled || inputs.discogs.value"
  2482. class="button is-default"
  2483. :class="{ selected: tab === 'discogs' }"
  2484. :ref="el => (tabs['discogs-tab'] = el)"
  2485. @click="showTab('discogs')"
  2486. >
  2487. Discogs
  2488. </button>
  2489. <button
  2490. v-if="!newSong"
  2491. class="button is-default"
  2492. :class="{ selected: tab === 'reports' }"
  2493. :ref="el => (tabs['reports-tab'] = el)"
  2494. @click="showTab('reports')"
  2495. >
  2496. Reports ({{ reports.length }})
  2497. </button>
  2498. <button
  2499. class="button is-default"
  2500. :class="{ selected: tab === 'youtube' }"
  2501. :ref="el => (tabs['youtube-tab'] = el)"
  2502. @click="showTab('youtube')"
  2503. >
  2504. YouTube
  2505. </button>
  2506. <button
  2507. class="button is-default"
  2508. :class="{ selected: tab === 'musare-songs' }"
  2509. :ref="el => (tabs['musare-songs-tab'] = el)"
  2510. @click="showTab('musare-songs')"
  2511. >
  2512. Songs
  2513. </button>
  2514. </div>
  2515. <discogs
  2516. v-if="discogsEnabled || inputs.discogs.value"
  2517. class="tab"
  2518. v-show="tab === 'discogs'"
  2519. :bulk="bulk"
  2520. :modal-uuid="modalUuid"
  2521. :modal-module-path="modalModulePath"
  2522. />
  2523. <reports-tab
  2524. v-if="!newSong"
  2525. class="tab"
  2526. v-show="tab === 'reports'"
  2527. :modal-uuid="modalUuid"
  2528. :modal-module-path="modalModulePath"
  2529. />
  2530. <youtube
  2531. class="tab"
  2532. v-show="tab === 'youtube'"
  2533. :modal-uuid="modalUuid"
  2534. :modal-module-path="modalModulePath"
  2535. />
  2536. <musare-songs
  2537. class="tab"
  2538. v-show="tab === 'musare-songs'"
  2539. :modal-uuid="modalUuid"
  2540. :modal-module-path="modalModulePath"
  2541. />
  2542. </div>
  2543. </div>
  2544. </template>
  2545. <template #footer>
  2546. <div v-if="bulk">
  2547. <button class="button is-primary" @click="editNextSong()">
  2548. Next
  2549. </button>
  2550. <button
  2551. class="button is-primary"
  2552. @click="toggleFlag()"
  2553. v-if="mediaSource && !songDeleted"
  2554. >
  2555. {{ currentSongFlagged ? "Unflag" : "Flag" }}
  2556. </button>
  2557. </div>
  2558. <div v-if="!newSong && !songDeleted">
  2559. <save-button
  2560. :ref="el => (saveButtonRefs['saveButton'] = el)"
  2561. @clicked="saveSong('saveButton')"
  2562. />
  2563. <save-button
  2564. :ref="el => (saveButtonRefs['saveAndCloseButton'] = el)"
  2565. :default-message="
  2566. bulk ? `Save and next` : `Save and close`
  2567. "
  2568. @clicked="saveSong('saveAndCloseButton', true)"
  2569. />
  2570. <div class="right">
  2571. <button
  2572. v-if="hasPermission('songs.remove')"
  2573. class="button is-danger icon-with-button material-icons"
  2574. @click.prevent="
  2575. openModal({
  2576. modal: 'confirm',
  2577. props: {
  2578. message:
  2579. 'Removing this song will remove it from all playlists and cause a ratings recalculation.',
  2580. onCompleted: () => remove(song._id)
  2581. }
  2582. })
  2583. "
  2584. content="Delete Song"
  2585. v-tippy
  2586. >
  2587. delete_forever
  2588. </button>
  2589. </div>
  2590. </div>
  2591. <div v-else-if="newSong">
  2592. <save-button
  2593. :ref="el => (saveButtonRefs['createButton'] = el)"
  2594. default-message="Create Song"
  2595. @clicked="saveSong('createButton')"
  2596. />
  2597. <save-button
  2598. :ref="
  2599. el => (saveButtonRefs['createAndCloseButton'] = el)
  2600. "
  2601. :default-message="
  2602. bulk ? `Create and next` : `Create and close`
  2603. "
  2604. @clicked="saveSong('createAndCloseButton', true)"
  2605. />
  2606. </div>
  2607. </template>
  2608. </modal>
  2609. <floating-box
  2610. id="genreHelper"
  2611. ref="genreHelper"
  2612. :column="false"
  2613. title="Song Genres List"
  2614. >
  2615. <template #body>
  2616. <span
  2617. v-for="item in autosuggest.allItems.genres"
  2618. :key="`genre-helper-${item}`"
  2619. >
  2620. {{ item }}
  2621. </span>
  2622. </template>
  2623. </floating-box>
  2624. </div>
  2625. </template>
  2626. <style lang="less" scoped>
  2627. .night-mode {
  2628. .edit-section,
  2629. .player-section,
  2630. #tabs-container {
  2631. background-color: var(--dark-grey-3) !important;
  2632. border: 0 !important;
  2633. .tab {
  2634. border: 0 !important;
  2635. }
  2636. }
  2637. #tabs-container #tab-selection .button {
  2638. background: var(--dark-grey) !important;
  2639. color: var(--white) !important;
  2640. }
  2641. .left-section {
  2642. .edit-section {
  2643. .album-get-button,
  2644. .duration-fill-button,
  2645. .youtube-get-button,
  2646. .soundcloud-get-button,
  2647. .add-button {
  2648. &:focus,
  2649. &:hover {
  2650. border: none !important;
  2651. }
  2652. }
  2653. }
  2654. }
  2655. .duration-canvas {
  2656. background-color: var(--dark-grey-2) !important;
  2657. }
  2658. .sidebar {
  2659. .sidebar-head,
  2660. .sidebar-foot {
  2661. background-color: var(--dark-grey-3);
  2662. border: none;
  2663. }
  2664. .sidebar-body {
  2665. background-color: var(--dark-grey-4) !important;
  2666. }
  2667. .sidebar-head .toggle-sidebar-icon.material-icons,
  2668. .sidebar-title {
  2669. color: var(--white);
  2670. }
  2671. p,
  2672. label,
  2673. td,
  2674. th {
  2675. color: var(--light-grey-2) !important;
  2676. }
  2677. h1,
  2678. h2,
  2679. h3,
  2680. h4,
  2681. h5,
  2682. h6 {
  2683. color: var(--white) !important;
  2684. }
  2685. }
  2686. }
  2687. .modal-card-body {
  2688. display: flex;
  2689. }
  2690. .notice-container {
  2691. display: flex;
  2692. flex: 1;
  2693. justify-content: center;
  2694. h4 {
  2695. margin: auto;
  2696. }
  2697. }
  2698. .left-section {
  2699. height: 100%;
  2700. display: flex;
  2701. flex-direction: column;
  2702. margin-right: 16px;
  2703. .top-section {
  2704. display: flex;
  2705. .player-section {
  2706. width: 530px;
  2707. display: flex;
  2708. flex-direction: column;
  2709. border: 1px solid var(--light-grey-3);
  2710. border-radius: @border-radius;
  2711. overflow: hidden;
  2712. .youtube-player-wrapper {
  2713. display: flex;
  2714. > * {
  2715. flex: 1;
  2716. }
  2717. }
  2718. .duration-canvas {
  2719. background-color: var(--light-grey-2);
  2720. }
  2721. .player-error,
  2722. .player-message {
  2723. display: flex;
  2724. height: 318px;
  2725. width: 530px;
  2726. align-items: center;
  2727. * {
  2728. margin: 0;
  2729. flex: 1;
  2730. font-size: 30px;
  2731. text-align: center;
  2732. }
  2733. }
  2734. .player-footer {
  2735. display: flex;
  2736. justify-content: space-between;
  2737. height: 54px;
  2738. padding-left: 10px;
  2739. padding-right: 10px;
  2740. > * {
  2741. width: 33.3%;
  2742. display: flex;
  2743. align-items: center;
  2744. }
  2745. .player-footer-left {
  2746. flex: 1;
  2747. & > .button:not(:first-child) {
  2748. margin-left: 5px;
  2749. }
  2750. :deep(& > .playerRateDropdown) {
  2751. margin-left: 5px;
  2752. margin-bottom: unset !important;
  2753. .control.has-addons {
  2754. margin-bottom: unset !important;
  2755. & > .button {
  2756. font-size: 24px;
  2757. }
  2758. }
  2759. }
  2760. :deep(.tippy-box[data-theme~="dropdown"]) {
  2761. max-width: 100px !important;
  2762. .nav-dropdown-items .nav-item {
  2763. justify-content: center !important;
  2764. border-radius: @border-radius !important;
  2765. &.active {
  2766. background-color: var(--primary-color);
  2767. color: var(--white);
  2768. }
  2769. }
  2770. }
  2771. }
  2772. .player-footer-center {
  2773. justify-content: center;
  2774. align-items: center;
  2775. flex: 2;
  2776. font-size: 18px;
  2777. font-weight: 400;
  2778. width: 200px;
  2779. margin: 0 5px;
  2780. img {
  2781. height: 21px;
  2782. margin-right: 12px;
  2783. filter: invert(26%) sepia(54%) saturate(6317%)
  2784. hue-rotate(2deg) brightness(92%) contrast(115%);
  2785. }
  2786. }
  2787. .player-footer-right {
  2788. justify-content: right;
  2789. flex: 1;
  2790. #volume-control {
  2791. margin: 3px;
  2792. margin-top: 0;
  2793. display: flex;
  2794. align-items: center;
  2795. cursor: pointer;
  2796. .volume-slider {
  2797. width: 100%;
  2798. padding: 0 15px;
  2799. background: transparent;
  2800. min-width: 100px;
  2801. }
  2802. input[type="range"] {
  2803. -webkit-appearance: none;
  2804. margin: 7.3px 0;
  2805. }
  2806. input[type="range"]:focus {
  2807. outline: none;
  2808. }
  2809. input[type="range"]::-webkit-slider-runnable-track {
  2810. width: 100%;
  2811. height: 5.2px;
  2812. cursor: pointer;
  2813. box-shadow: 0;
  2814. background: var(--light-grey-3);
  2815. border-radius: @border-radius;
  2816. border: 0;
  2817. }
  2818. input[type="range"]::-webkit-slider-thumb {
  2819. box-shadow: 0;
  2820. border: 0;
  2821. height: 19px;
  2822. width: 19px;
  2823. border-radius: 100%;
  2824. background: var(--primary-color);
  2825. cursor: pointer;
  2826. -webkit-appearance: none;
  2827. margin-top: -6.5px;
  2828. }
  2829. input[type="range"]::-moz-range-track {
  2830. width: 100%;
  2831. height: 5.2px;
  2832. cursor: pointer;
  2833. box-shadow: 0;
  2834. background: var(--light-grey-3);
  2835. border-radius: @border-radius;
  2836. border: 0;
  2837. }
  2838. input[type="range"]::-moz-range-thumb {
  2839. box-shadow: 0;
  2840. border: 0;
  2841. height: 19px;
  2842. width: 19px;
  2843. border-radius: 100%;
  2844. background: var(--primary-color);
  2845. cursor: pointer;
  2846. -webkit-appearance: none;
  2847. margin-top: -6.5px;
  2848. }
  2849. input[type="range"]::-ms-track {
  2850. width: 100%;
  2851. height: 5.2px;
  2852. cursor: pointer;
  2853. box-shadow: 0;
  2854. background: var(--light-grey-3);
  2855. border-radius: @border-radius;
  2856. }
  2857. input[type="range"]::-ms-fill-lower {
  2858. background: var(--light-grey-3);
  2859. border: 0;
  2860. border-radius: 0;
  2861. box-shadow: 0;
  2862. }
  2863. input[type="range"]::-ms-fill-upper {
  2864. background: var(--light-grey-3);
  2865. border: 0;
  2866. border-radius: 0;
  2867. box-shadow: 0;
  2868. }
  2869. input[type="range"]::-ms-thumb {
  2870. box-shadow: 0;
  2871. border: 0;
  2872. height: 15px;
  2873. width: 15px;
  2874. border-radius: 100%;
  2875. background: var(--primary-color);
  2876. cursor: pointer;
  2877. -webkit-appearance: none;
  2878. margin-top: 1.5px;
  2879. }
  2880. }
  2881. }
  2882. }
  2883. }
  2884. :deep(.thumbnail-preview) {
  2885. width: 189px;
  2886. height: 189px;
  2887. margin-left: 16px;
  2888. }
  2889. .thumbnail-dummy {
  2890. opacity: 0;
  2891. height: 10px;
  2892. width: 10px;
  2893. }
  2894. }
  2895. .edit-section {
  2896. display: flex;
  2897. flex-wrap: wrap;
  2898. flex-grow: 1;
  2899. border: 1px solid var(--light-grey-3);
  2900. margin-top: 16px;
  2901. border-radius: @border-radius;
  2902. .album-get-button {
  2903. background-color: var(--purple);
  2904. color: var(--white);
  2905. width: 32px;
  2906. text-align: center;
  2907. border-width: 0;
  2908. }
  2909. .duration-fill-button,
  2910. .youtube-get-button {
  2911. background-color: var(--dark-red);
  2912. color: var(--white);
  2913. width: 32px;
  2914. text-align: center;
  2915. border-width: 0;
  2916. }
  2917. .soundcloud-get-button {
  2918. background-color: var(--orange);
  2919. color: var(--white);
  2920. width: 32px;
  2921. text-align: center;
  2922. border-width: 0;
  2923. }
  2924. .add-button {
  2925. background-color: var(--primary-color) !important;
  2926. width: 32px;
  2927. i {
  2928. font-size: 32px;
  2929. }
  2930. }
  2931. .album-get-button,
  2932. .duration-fill-button,
  2933. .youtube-get-button,
  2934. .add-button {
  2935. &:focus,
  2936. &:hover {
  2937. filter: contrast(0.75);
  2938. border: 1px solid var(--black) !important;
  2939. }
  2940. }
  2941. .youtube-get-button,
  2942. .soundcloud-get-button {
  2943. padding-left: 4px;
  2944. padding-right: 4px;
  2945. .youtube-icon,
  2946. .soundcloud-icon,
  2947. .spotify-icon {
  2948. background: var(--white);
  2949. }
  2950. }
  2951. > div {
  2952. margin: 16px !important;
  2953. width: 100%;
  2954. }
  2955. input {
  2956. width: 100%;
  2957. }
  2958. .title-container {
  2959. width: calc((100% - 32px) / 2);
  2960. }
  2961. .duration-container {
  2962. margin-right: 16px;
  2963. margin-left: 16px;
  2964. width: calc((100% - 32px) / 4);
  2965. }
  2966. .skip-duration-container {
  2967. width: calc((100% - 32px) / 4);
  2968. }
  2969. .album-art-container {
  2970. margin-right: 16px;
  2971. width: 100%;
  2972. }
  2973. .youtube-id-container {
  2974. margin-right: 16px;
  2975. width: calc((100% - 16px) / 8 * 3);
  2976. }
  2977. .verified-container {
  2978. width: calc((100% - 16px) / 8);
  2979. .checkbox-control {
  2980. margin-top: 10px;
  2981. }
  2982. }
  2983. .artists-container {
  2984. width: calc((100% - 32px) / 3);
  2985. position: relative;
  2986. }
  2987. .genres-container {
  2988. width: calc((100% - 32px) / 3);
  2989. margin-left: 16px;
  2990. margin-right: 16px;
  2991. position: relative;
  2992. label {
  2993. display: flex;
  2994. i {
  2995. font-size: 15px;
  2996. align-self: center;
  2997. margin-left: 5px;
  2998. color: var(--primary-color);
  2999. cursor: pointer;
  3000. -webkit-user-select: none;
  3001. -moz-user-select: none;
  3002. -ms-user-select: none;
  3003. user-select: none;
  3004. }
  3005. }
  3006. }
  3007. .tags-container {
  3008. width: calc((100% - 32px) / 3);
  3009. position: relative;
  3010. }
  3011. .list-item-circle {
  3012. background-color: var(--primary-color);
  3013. width: 16px;
  3014. height: 16px;
  3015. border-radius: 8px;
  3016. cursor: pointer;
  3017. margin-right: 8px;
  3018. float: left;
  3019. -webkit-touch-callout: none;
  3020. -webkit-user-select: none;
  3021. -khtml-user-select: none;
  3022. -moz-user-select: none;
  3023. -ms-user-select: none;
  3024. user-select: none;
  3025. i {
  3026. color: var(--primary-color);
  3027. font-size: 14px;
  3028. margin-left: 1px;
  3029. position: relative;
  3030. top: -1px;
  3031. }
  3032. }
  3033. .list-item-circle:hover,
  3034. .list-item-circle:focus {
  3035. i {
  3036. color: var(--white);
  3037. }
  3038. }
  3039. .list-item > p {
  3040. line-height: 16px;
  3041. word-wrap: break-word;
  3042. width: calc(100% - 24px);
  3043. left: 24px;
  3044. float: left;
  3045. margin-bottom: 8px;
  3046. }
  3047. .list-item:last-child > p {
  3048. margin-bottom: 0;
  3049. }
  3050. .thumbnail-warning {
  3051. color: var(--red);
  3052. font-size: 18px;
  3053. margin: auto 0 auto 5px;
  3054. }
  3055. }
  3056. }
  3057. .right-section {
  3058. flex-basis: unset !important;
  3059. flex-grow: 0 !important;
  3060. display: flex;
  3061. height: 100%;
  3062. #tabs-container {
  3063. width: 376px;
  3064. #tab-selection {
  3065. display: flex;
  3066. overflow-x: auto;
  3067. .button {
  3068. border-radius: @border-radius @border-radius 0 0;
  3069. border: 0;
  3070. text-transform: uppercase;
  3071. font-size: 14px;
  3072. color: var(--dark-grey-3);
  3073. background-color: var(--light-grey-2);
  3074. flex-grow: 1;
  3075. height: 32px;
  3076. &:not(:first-of-type) {
  3077. margin-left: 5px;
  3078. }
  3079. }
  3080. .selected {
  3081. background-color: var(--primary-color) !important;
  3082. color: var(--white) !important;
  3083. font-weight: 600;
  3084. }
  3085. }
  3086. .tab {
  3087. border: 1px solid var(--light-grey-3);
  3088. border-radius: 0 0 @border-radius @border-radius;
  3089. padding: 15px;
  3090. height: calc(100% - 32px);
  3091. overflow: auto;
  3092. }
  3093. }
  3094. }
  3095. @media screen and (max-width: 1100px) {
  3096. .left-section,
  3097. .right-section {
  3098. height: unset;
  3099. max-height: unset;
  3100. }
  3101. .left-section {
  3102. margin-right: 0;
  3103. }
  3104. .right-section {
  3105. flex-basis: 100% !important;
  3106. #tabs-container {
  3107. width: 100%;
  3108. }
  3109. }
  3110. }
  3111. .modal-card-foot .is-primary {
  3112. width: 200px;
  3113. }
  3114. :deep(.autosuggest-container) {
  3115. top: unset;
  3116. }
  3117. .toggle-sidebar-icon {
  3118. display: none;
  3119. }
  3120. .sidebar {
  3121. width: 100%;
  3122. max-width: 350px;
  3123. z-index: 2000;
  3124. display: flex;
  3125. flex-direction: column;
  3126. position: relative;
  3127. height: 100%;
  3128. max-height: calc(100vh - 40px);
  3129. overflow: auto;
  3130. margin-right: 8px;
  3131. border-radius: @border-radius;
  3132. .sidebar-head,
  3133. .sidebar-foot {
  3134. display: flex;
  3135. flex-shrink: 0;
  3136. position: relative;
  3137. justify-content: flex-start;
  3138. align-items: center;
  3139. padding: 20px;
  3140. background-color: var(--light-grey);
  3141. }
  3142. .sidebar-head {
  3143. border-bottom: 1px solid var(--light-grey-2);
  3144. border-radius: @border-radius @border-radius 0 0;
  3145. .sidebar-title {
  3146. display: flex;
  3147. flex: 1;
  3148. margin: 0;
  3149. font-size: 26px;
  3150. font-weight: 600;
  3151. }
  3152. }
  3153. .sidebar-body {
  3154. background-color: var(--white);
  3155. display: flex;
  3156. flex-direction: column;
  3157. row-gap: 8px;
  3158. flex: 1;
  3159. overflow: auto;
  3160. padding: 10px;
  3161. .edit-songs-items {
  3162. display: flex;
  3163. flex-direction: column;
  3164. row-gap: 8px;
  3165. .item {
  3166. display: flex;
  3167. flex-direction: row;
  3168. align-items: center;
  3169. column-gap: 8px;
  3170. :deep(.song-item) {
  3171. .item-icon {
  3172. margin-right: 10px;
  3173. cursor: pointer;
  3174. }
  3175. .removed-icon,
  3176. .error-icon {
  3177. color: var(--red);
  3178. }
  3179. .saving-icon,
  3180. .todo-icon,
  3181. .editing-icon {
  3182. color: var(--primary-color);
  3183. }
  3184. .done-icon {
  3185. color: var(--green);
  3186. }
  3187. .flag-icon {
  3188. color: var(--orange);
  3189. &.flagged {
  3190. color: var(--grey);
  3191. }
  3192. }
  3193. &.removed {
  3194. filter: grayscale(100%);
  3195. cursor: not-allowed;
  3196. user-select: none;
  3197. }
  3198. }
  3199. }
  3200. }
  3201. .no-items {
  3202. text-align: center;
  3203. font-size: 18px;
  3204. }
  3205. }
  3206. .sidebar-foot {
  3207. border-top: 1px solid var(--light-grey-2);
  3208. border-radius: 0 0 @border-radius @border-radius;
  3209. .button {
  3210. flex: 1;
  3211. }
  3212. }
  3213. .sidebar-overlay {
  3214. display: none;
  3215. }
  3216. }
  3217. @media only screen and (max-width: 1580px) {
  3218. .toggle-sidebar-icon {
  3219. display: flex;
  3220. margin-right: 5px;
  3221. transform: rotate(90deg);
  3222. cursor: pointer;
  3223. }
  3224. .sidebar {
  3225. display: none;
  3226. &.active {
  3227. display: flex;
  3228. position: absolute;
  3229. z-index: 2010;
  3230. top: 20px;
  3231. left: 20px;
  3232. .sidebar-head .toggle-sidebar-icon {
  3233. display: flex;
  3234. margin-left: 5px;
  3235. transform: rotate(-90deg);
  3236. }
  3237. }
  3238. }
  3239. .sidebar-overlay {
  3240. display: flex;
  3241. position: absolute;
  3242. z-index: 2009;
  3243. top: 0;
  3244. left: 0;
  3245. right: 0;
  3246. bottom: 0;
  3247. background-color: rgba(10, 10, 10, 0.85);
  3248. }
  3249. }
  3250. </style>