snackbars added to change and scan

This commit is contained in:
zurdi zurdo
2023-03-24 12:49:17 +01:00
parent 8886922e5d
commit 59b71c6713
18 changed files with 45 additions and 26 deletions

View File

View File

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

@@ -6,10 +6,18 @@ import Navigation from '@/components/Navigation.vue'
// Props
useTheme().global.name.value = localStorage.getItem('theme') || 'dark'
const refresh = ref(false)
const refreshRoms = ref(false)
const snackbarShow = ref(false)
const snackbarStatus = ref({})
// Event listeners bus
const emitter = inject('emitter')
emitter.on('scanning', () => { refresh.value = !refresh.value })
emitter.on('refresh', () => { refresh.value = !refresh.value })
emitter.on('refreshRoms', () => { refreshRoms.value = !refreshRoms.value })
emitter.on('snackbarScan', (snackbar) => {
snackbarShow.value = true
snackbarStatus.value = snackbar
})
</script>
<template>
@@ -19,10 +27,18 @@ emitter.on('scanning', () => { refresh.value = !refresh.value })
<v-main>
<v-container fluid>
<router-view :key="refresh"/>
<router-view :key="refreshRoms"/>
</v-container>
</v-main>
<v-snackbar v-model="snackbarShow" :timeout="3000">
<v-icon :icon="snackbarStatus.icon" :color="snackbarStatus.color" class="ml-2 mr-2"/>
{{ snackbarStatus.msg }}
<template v-slot:actions>
<v-btn variant="text" @click="snackbarShow = false"><v-icon icon="mdi-close"/></v-btn>
</template>
</v-snackbar>
</v-app>
</template>

View File

@@ -67,9 +67,13 @@ async function scan() {
await axios.get('/api/scan?overwrite='+scanOverwrite.value).then((response) => {
console.log("scan completed")
console.log(response.data)
}).catch((error) => {console.log(error)})
emitter.emit('snackbarScan', {'msg': 'Scan completed successfully!', 'icon': 'mdi-check-bold', 'color': 'green'})
}).catch((error) => {
console.log(error)
emitter.emit('snackbarScan', {'msg': "Couldn't complete scan. Something went wrong...", 'icon': 'mdi-close-circle', 'color': 'red'})
})
scanning.value = false
emitter.emit('scanning')
emitter.emit('refresh')
}
else{
platforms.forEach(async p => {
@@ -80,9 +84,13 @@ async function scan() {
}).then((response) => {
console.log("scan "+p.name+" completed")
console.log(response.data)
}).catch((error) => {console.log(error)})
emitter.emit('snackbarScan', {'msg': p.name+' scan completed successfully!', 'icon': 'mdi-check-bold', 'color': 'green'})
}).catch((error) => {
console.log(error)
emitter.emit('snackbarScan', {'msg': "Couldn't complete "+p.name+" scan. Something went wrong...", 'icon': 'mdi-close-circle', 'color': 'red'})
})
scanning.value = false
emitter.emit('scanning')
emitter.emit('refreshRoms')
});
}
}

View File

@@ -8,10 +8,8 @@ const searching = ref(false)
const matchedRoms = ref([])
const changing = ref(false)
const romNewName = ref(rom.value.filename)
const submitted = ref(false)
const snackbarOK = ref(false)
const snackbarKO = ref(false)
const snackbarShow = ref(false)
const snackbarStatus = ref({})
// Event listeners bus
const emitter = inject('emitter')
emitter.on('currentRom', (currentRom) => { rom.value = currentRom })
@@ -48,27 +46,28 @@ async function changeRom(newRomRaw) {
}).then((response) => {
console.log("update "+rom.value.filename+" completed")
localStorage.setItem('currentRom', JSON.stringify(response.data.data))
snackbarStatus.value = {'msg': rom.value.filename+" changed successfully!", 'icon': 'mdi-check-bold', 'color': 'green'}
rom.value = response.data.data
snackbarOK.value = true
}).catch((error) => {
console.log(error)
snackbarKO.value = true
snackbarStatus.value = {'msg': "Couldn't change "+rom.value.filename+". Something went wrong...", 'icon': 'mdi-close-circle', 'color': 'red'}
})
snackbarShow.value = true
changing.value = false
}
async function editRom() {
submitted.value = true
await axios.patch('/api/platforms/'+rom.value.p_slug+'/roms/'+rom.value.filename, {
filename: romNewName.value
}).then((response) => {
console.log("update "+rom.value.filename+" to "+romNewName.value)
rom.value.filename = romNewName.value
snackbarOK.value = true
snackbarStatus.value = {'msg': romNewName.value+" edited successfully!", 'icon': 'mdi-check-bold', 'color': 'green'}
}).catch((error) => {
console.log(error)
snackbarKO.value = true
snackbarStatus.value = {'msg': "Couldn't edit "+rom.value.filename+". Something went wrong...", 'icon': 'mdi-close-circle', 'color': 'red'}
})
snackbarShow.value = true
}
</script>
@@ -163,19 +162,15 @@ async function editRom() {
</v-container>
</v-col>
</v-row>
<v-divider class="mt-10 mb-10 border-opacity-75"/>
<v-snackbar v-model="snackbarOK" :timeout="3000">
<v-icon v-if="submitted" icon="mdi-check-bold" color="green" class="ml-2 mr-2"/>
{{ rom.filename }} edited successfully!
<v-snackbar v-model="snackbarShow" :timeout="3000">
<v-icon :icon="snackbarStatus.icon" :color="snackbarStatus.color" class="ml-2 mr-2"/>
{{ snackbarStatus.msg }}
<template v-slot:actions>
<v-btn variant="text" @click="snackbarOK = false"><v-icon icon="mdi-close"/></v-btn>
</template>
</v-snackbar>
<v-snackbar v-model="snackbarKO" :timeout="3000">
<v-icon v-if="submitted" icon="mdi-close-circle" color="red" class="ml-2 mr-2"/>
Couldn't edit {{ rom.filename }}. Something went wrong...
<template v-slot:actions>
<v-btn variant="text" @click="snackbarKO = false"><v-icon icon="mdi-close"/></v-btn>
<v-btn variant="text" @click="snackbarShow = false"><v-icon icon="mdi-close"/></v-btn>
</template>
</v-snackbar>
</template>