mirror of
https://github.com/rommapp/romm.git
synced 2026-11-29 10:01:00 +01:00
snackbar added to gathering and download rom
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script setup>
|
||||
import axios from 'axios'
|
||||
import { ref, inject, toRaw } from 'vue'
|
||||
import { ref, inject } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { downloadRom, downloadSave } from '@/utils/utils.js'
|
||||
|
||||
@@ -23,16 +23,6 @@ const emitter = inject('emitter')
|
||||
emitter.on('currentRom', (currentRom) => { rom.value = currentRom })
|
||||
|
||||
// Functions
|
||||
function downloadingRom(rom) {
|
||||
emitter.emit('snackbarScan', {'msg': "Downloading "+rom.file_name, 'icon': 'mdi-download', 'color': 'green'})
|
||||
downloadRom(rom)
|
||||
}
|
||||
|
||||
function downloadingSave() {
|
||||
emitter.emit('snackbarScan', {'msg': "Downloading "+rom.file_name+" savefile", 'icon': 'mdi-download', 'color': 'green'})
|
||||
downloadSave()
|
||||
}
|
||||
|
||||
async function searchRomIGDB() {
|
||||
searching.value = true
|
||||
dialogSearchRom.value = true
|
||||
@@ -110,10 +100,10 @@ async function deleteRom() {
|
||||
<v-container>
|
||||
<v-row>
|
||||
<v-col class="pa-1">
|
||||
<v-btn @click="downloadingRom(rom)" rounded="0" block><v-icon icon="mdi-download" size="large"/></v-btn>
|
||||
<v-btn @click="downloadRom(rom, emitter)" rounded="0" block><v-icon icon="mdi-download" size="large"/></v-btn>
|
||||
</v-col>
|
||||
<v-col class="pa-1">
|
||||
<v-btn @click="downloadingSave()" rounded="0" block :disabled="!saveFiles"><v-icon icon="mdi-content-save-all" size="large"/></v-btn>
|
||||
<v-btn @click="downloadSave(rom, emitter)" rounded="0" block :disabled="!saveFiles"><v-icon icon="mdi-content-save-all" size="large"/></v-btn>
|
||||
</v-col>
|
||||
<v-col class="pa-1">
|
||||
<v-menu location="bottom">
|
||||
|
||||
@@ -53,15 +53,6 @@ function setFilter(filter) {
|
||||
return normalizeString(rom.file_name).includes(currentFilter.value)
|
||||
})
|
||||
}
|
||||
function downloadingRom(rom) {
|
||||
emitter.emit('snackbarScan', {'msg': "Downloading "+rom.file_name, 'icon': 'mdi-download', 'color': 'green'})
|
||||
downloadRom(rom)
|
||||
}
|
||||
|
||||
function downloadingSave() {
|
||||
// emitter.emit('snackbarScan', {'msg': "Downloading "+rom.file_name+" savefile", 'icon': 'mdi-download', 'color': 'green'})
|
||||
downloadSave()
|
||||
}
|
||||
|
||||
onMounted(() => { if(localStorage.getItem('currentPlatform')){ getRoms(JSON.parse(localStorage.getItem('currentPlatform')).slug) } })
|
||||
</script>
|
||||
@@ -92,8 +83,8 @@ onMounted(() => { if(localStorage.getItem('currentPlatform')){ getRoms(JSON.pars
|
||||
<v-card-text>
|
||||
<v-row>
|
||||
<v-col class="pa-0">
|
||||
<v-btn @click="downloadingRom(rom)" icon="mdi-download" size="small" variant="text"/>
|
||||
<v-btn @click="downloadingSave()" icon="mdi-content-save-all" size="small" variant="text" :disabled="!saveFiles"/>
|
||||
<v-btn @click="downloadRom(rom, emitter)" icon="mdi-download" size="small" variant="text"/>
|
||||
<v-btn @click="downloadSave(rom, emitter)" icon="mdi-content-save-all" size="small" variant="text" :disabled="!saveFiles"/>
|
||||
</v-col>
|
||||
<v-btn @click="" icon="mdi-dots-vertical" size="small" variant="text" :disabled="!saveFiles"/>
|
||||
</v-row>
|
||||
|
||||
@@ -2,13 +2,21 @@ import axios from 'axios'
|
||||
import { saveAs } from 'file-saver'
|
||||
|
||||
|
||||
export function downloadRom(rom) {
|
||||
export function downloadRom(rom, emitter) {
|
||||
console.log("Downloading "+rom.file_name)
|
||||
emitter.emit('snackbarScan', {'msg': "Gathering "+rom.file_name+"...", 'icon': 'mdi-download', 'color': 'green'})
|
||||
emitter.emit('downloadingRom', true)
|
||||
axios.get('/assets'+rom.file_path+'/'+rom.file_name, { responseType: 'blob' }).then(response => {
|
||||
emitter.emit('downloadingRom', false, rom.file_name)
|
||||
emitter.emit('snackbarScan', {'msg': "Downloading "+rom.file_name, 'icon': 'mdi-download', 'color': 'green'})
|
||||
saveAs(new Blob([response.data], { type: 'application/file' }), rom.file_name)
|
||||
}).catch((error) => {console.log(error)})
|
||||
}).catch((error) => {
|
||||
emitter.emit('downloadingRom', false)
|
||||
console.log(error)
|
||||
emitter.emit('snackbarScan', {'msg': "Couldn't download "+rom.file_name+". Something went wrong...", 'icon': 'mdi-close-circle', 'color': 'red'})
|
||||
})
|
||||
}
|
||||
|
||||
export function downloadSave(rom) {
|
||||
export function downloadSave(rom, emitter) {
|
||||
console.log("Downloading "+rom.file_name+" save file")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user