index.vue 71 KB

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