index.vue 82 KB

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