From 668488cd1ae9ffcb0fc0219b1c60bb0ee378aab4 Mon Sep 17 00:00:00 2001 From: zurdi zurdo Date: Wed, 12 Apr 2023 10:43:46 +0200 Subject: [PATCH] app bar component refactor --- frontend/src/App.vue | 41 ++-- frontend/src/components/AppBar/Base.vue | 43 ++++ frontend/src/components/AppBar/HomeBtn.vue | 11 + .../src/components/AppBar/PlatformsBtn.vue | 21 ++ frontend/src/components/AppBar/SearchBar.vue | 23 ++ .../src/components/AppBar/SettingsBtn.vue | 16 ++ frontend/src/components/AppBar/UploadBtn.vue | 19 ++ frontend/src/components/Navigation.vue | 198 ------------------ frontend/src/components/Notification.vue | 24 +++ frontend/src/components/PlatformsDrawer.vue | 81 +++++++ frontend/src/components/SettingsDrawer.vue | 83 ++++++++ frontend/src/router/index.js | 4 +- frontend/src/utils/utils.js | 18 +- .../RomDetails.vue => views/Details.vue} | 6 - .../RomsGallery.vue => views/Gallery.vue} | 10 +- 15 files changed, 346 insertions(+), 252 deletions(-) create mode 100644 frontend/src/components/AppBar/Base.vue create mode 100644 frontend/src/components/AppBar/HomeBtn.vue create mode 100644 frontend/src/components/AppBar/PlatformsBtn.vue create mode 100644 frontend/src/components/AppBar/SearchBar.vue create mode 100644 frontend/src/components/AppBar/SettingsBtn.vue create mode 100644 frontend/src/components/AppBar/UploadBtn.vue delete mode 100644 frontend/src/components/Navigation.vue create mode 100644 frontend/src/components/Notification.vue create mode 100644 frontend/src/components/PlatformsDrawer.vue create mode 100644 frontend/src/components/SettingsDrawer.vue rename frontend/src/{components/RomDetails.vue => views/Details.vue} (97%) rename frontend/src/{components/RomsGallery.vue => views/Gallery.vue} (91%) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 311fc8da4..f49f3257e 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -1,47 +1,36 @@ diff --git a/frontend/src/components/AppBar/Base.vue b/frontend/src/components/AppBar/Base.vue new file mode 100644 index 000000000..196f74ebf --- /dev/null +++ b/frontend/src/components/AppBar/Base.vue @@ -0,0 +1,43 @@ + + + diff --git a/frontend/src/components/AppBar/HomeBtn.vue b/frontend/src/components/AppBar/HomeBtn.vue new file mode 100644 index 000000000..2b7666968 --- /dev/null +++ b/frontend/src/components/AppBar/HomeBtn.vue @@ -0,0 +1,11 @@ + diff --git a/frontend/src/components/AppBar/PlatformsBtn.vue b/frontend/src/components/AppBar/PlatformsBtn.vue new file mode 100644 index 000000000..20c043825 --- /dev/null +++ b/frontend/src/components/AppBar/PlatformsBtn.vue @@ -0,0 +1,21 @@ + + + \ No newline at end of file diff --git a/frontend/src/components/AppBar/SearchBar.vue b/frontend/src/components/AppBar/SearchBar.vue new file mode 100644 index 000000000..f16c45cc9 --- /dev/null +++ b/frontend/src/components/AppBar/SearchBar.vue @@ -0,0 +1,23 @@ + + + diff --git a/frontend/src/components/AppBar/SettingsBtn.vue b/frontend/src/components/AppBar/SettingsBtn.vue new file mode 100644 index 000000000..02e35e2b2 --- /dev/null +++ b/frontend/src/components/AppBar/SettingsBtn.vue @@ -0,0 +1,16 @@ + + + \ No newline at end of file diff --git a/frontend/src/components/AppBar/UploadBtn.vue b/frontend/src/components/AppBar/UploadBtn.vue new file mode 100644 index 000000000..750e80fbc --- /dev/null +++ b/frontend/src/components/AppBar/UploadBtn.vue @@ -0,0 +1,19 @@ + + + \ No newline at end of file diff --git a/frontend/src/components/Navigation.vue b/frontend/src/components/Navigation.vue deleted file mode 100644 index 55abd72e7..000000000 --- a/frontend/src/components/Navigation.vue +++ /dev/null @@ -1,198 +0,0 @@ - - - - - \ No newline at end of file diff --git a/frontend/src/components/Notification.vue b/frontend/src/components/Notification.vue new file mode 100644 index 000000000..50d19b310 --- /dev/null +++ b/frontend/src/components/Notification.vue @@ -0,0 +1,24 @@ + + + \ No newline at end of file diff --git a/frontend/src/components/PlatformsDrawer.vue b/frontend/src/components/PlatformsDrawer.vue new file mode 100644 index 000000000..1927ae490 --- /dev/null +++ b/frontend/src/components/PlatformsDrawer.vue @@ -0,0 +1,81 @@ + + + + + diff --git a/frontend/src/components/SettingsDrawer.vue b/frontend/src/components/SettingsDrawer.vue new file mode 100644 index 000000000..dd1d50c35 --- /dev/null +++ b/frontend/src/components/SettingsDrawer.vue @@ -0,0 +1,83 @@ + + + diff --git a/frontend/src/router/index.js b/frontend/src/router/index.js index 0f255f8d3..fae2377e8 100644 --- a/frontend/src/router/index.js +++ b/frontend/src/router/index.js @@ -4,11 +4,11 @@ import { createRouter, createWebHistory } from 'vue-router' const routes = [ { path: '/', - component: () => import('@/components/RomsGallery.vue') + component: () => import('@/views/Gallery.vue') }, { path: '/details', - component: () => import('@/components/RomDetails.vue') + component: () => import('@/views/Details.vue') } ] diff --git a/frontend/src/utils/utils.js b/frontend/src/utils/utils.js index 81a2a0c51..bba7b92e9 100644 --- a/frontend/src/utils/utils.js +++ b/frontend/src/utils/utils.js @@ -4,28 +4,22 @@ import { saveAs } from 'file-saver' export async function downloadRom(rom, emitter, filesToDownload=[]) { - console.log("Downloading "+rom.file_name) emitter.emit('snackbarScan', {'msg': "Downloading "+rom.file_name+"...", 'icon': 'mdi-download', 'color': 'green'}) if(rom.multi){ + const zip = new JSZip() + var zipFilename = rom.file_name+".zip" var files = [] toRaw(filesToDownload).forEach(f => {files.push(toRaw(f))}) - var zipFilename = rom.file_name+".zip" - const zip = new JSZip() - var count = 0 if (files.length == 0){ files = rom.files } + var count = 0 files.forEach(async function (file_part) { var file_full_path = "/assets"+rom.file_path+"/"+rom.file_name+"/"+file_part - console.log("downloading part: "+file_full_path) var file = await fetch(file_full_path) var fileBlob = await file.blob() var f = zip.folder(rom.file_name); f.file(file_part, fileBlob, { binary: true }); count ++ - if (count == files.length) { - zip.generateAsync({ type: 'blob' }).then(function (content) { - saveAs(content, zipFilename); - }); - } + if (count == files.length) { zip.generateAsync({ type: 'blob' }).then(function (content) { saveAs(content, zipFilename); }); } }) } else{ @@ -36,6 +30,4 @@ export async function downloadRom(rom, emitter, filesToDownload=[]) { } } -export async function downloadSave(rom, emitter) { - console.log("Downloading "+rom.file_name+" save file") -} +export async function downloadSave(rom, emitter) { console.log("Downloading "+rom.file_name+" save file") } diff --git a/frontend/src/components/RomDetails.vue b/frontend/src/views/Details.vue similarity index 97% rename from frontend/src/components/RomDetails.vue rename to frontend/src/views/Details.vue index 3353d49a2..8c49a6ab5 100644 --- a/frontend/src/components/RomDetails.vue +++ b/frontend/src/views/Details.vue @@ -27,11 +27,9 @@ emitter.on('currentRom', (currentRom) => { rom.value = currentRom }) async function searchRomIGDB() { searching.value = true dialogSearchRom.value = true - console.log("searching for rom... "+rom.value.file_name) await axios.put('/api/search/roms/igdb', { rom: rom.value }).then((response) => { - console.log(response.data.data) matchedRoms.value = response.data.data }).catch((error) => {console.log(error)}) searching.value = false @@ -48,12 +46,10 @@ async function updateRom(updatedRom=Object.assign({},rom.value), newName=rom.val else{ updatedRom.file_name = newName } - console.log(rom.value) await axios.patch('/api/platforms/'+rom.value.p_slug+'/roms', { rom: rom.value, updatedRom: updatedRom }).then((response) => { - console.log('updated rom: '+JSON.stringify(rom.value)) localStorage.setItem('currentRom', JSON.stringify(response.data.data)) emitter.emit('snackbarScan', {'msg': rom.value.file_name+" updated successfully!", 'icon': 'mdi-check-bold', 'color': 'green'}) rom.value = response.data.data @@ -66,10 +62,8 @@ async function updateRom(updatedRom=Object.assign({},rom.value), newName=rom.val } async function deleteRom() { - console.log('deleting rom '+ rom.value.file_name) await axios.delete('/api/platforms/'+rom.value.p_slug+'/roms/'+rom.value.file_name+'?filesystem='+deleteFromFs.value) .then((response) => { - console.log(response) emitter.emit('snackbarScan', {'msg': rom.value.file_name+" deleted successfully!", 'icon': 'mdi-check-bold', 'color': 'green'}) router.push(import.meta.env.BASE_URL) }).catch((error) => { diff --git a/frontend/src/components/RomsGallery.vue b/frontend/src/views/Gallery.vue similarity index 91% rename from frontend/src/components/RomsGallery.vue rename to frontend/src/views/Gallery.vue index 17e262700..6b95aa461 100644 --- a/frontend/src/components/RomsGallery.vue +++ b/frontend/src/views/Gallery.vue @@ -16,18 +16,15 @@ const saveFiles = ref(false) // Event listeners bus const emitter = inject('emitter') -emitter.on('currentPlatform', (platform) => { getRoms(platform.slug) }) -emitter.on('romsFilter', (filter) => { setFilter(filter) }) +emitter.on('selectedPlatform', (platform) => { getRoms(platform.slug) }) +emitter.on('filter', (filter) => { setFilter(filter) }) // Functions async function getRoms(platform) { noRoms.value = false - console.log("Getting roms...") emitter.emit('gettingRoms', true) gettingRoms.value = true await axios.get('/api/platforms/'+platform+'/roms').then((response) => { - console.log("Roms loaded!") - console.log(response.data.data) roms.value = response.data.data setFilter(currentFilter.value) }).catch((error) => {console.log(error)}) @@ -37,7 +34,6 @@ async function getRoms(platform) { } async function selectRom(rom) { - console.log("Selected rom "+rom.name) localStorage.setItem('currentRom', JSON.stringify(rom)) await router.push(import.meta.env.BASE_URL+'details') emitter.emit('currentRom', rom) @@ -54,7 +50,7 @@ function setFilter(filter) { }) } -onMounted(() => { if(localStorage.getItem('currentPlatform')){ getRoms(JSON.parse(localStorage.getItem('currentPlatform')).slug) } }) +onMounted(() => { if(localStorage.getItem('selectedPlatform')){ getRoms(JSON.parse(localStorage.getItem('selectedPlatform')).slug) } })