index.vue 71 KB

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