mirror of
https://github.com/rommapp/romm.git
synced 2026-12-06 07:54:18 +01:00
roms filter code improved
This commit is contained in:
1 parent
9348acdd59
commit
afef3a67f6
3 files changed
+20
-10
No files matched your search
@@ -1,7 +1,11 @@
|
||||
**/node_modules
|
||||
node_modules/
|
||||
|
||||
**/venv
|
||||
venv/
|
||||
|
||||
**/__pycache__
|
||||
__pycache__/
|
||||
|
||||
**/assets/emulation
|
||||
**/assets/emulation
|
||||
../frontend/assets/emulation/
|
||||
+3
-1
@@ -7,16 +7,18 @@ RUN apt update -y && apt install libmariadb3 libmariadb-dev python3 python3-pip
|
||||
|
||||
# Copy backend and install pip requirements
|
||||
COPY backend /backend
|
||||
RUN rm -rf /backend/venv
|
||||
RUN pip install -r /backend/requirements.txt
|
||||
EXPOSE 5000
|
||||
|
||||
# Copy frontend and install npm packages
|
||||
COPY frontend /frontend
|
||||
COPY frontend/package.json /frontend/package.json
|
||||
RUN rm -rf /frontend/node_modules
|
||||
RUN rm -rf /frontend/assets/emulation
|
||||
RUN ln -s /emulation /frontend/assets/emulation
|
||||
WORKDIR /frontend
|
||||
RUN npm install
|
||||
EXPOSE 5173
|
||||
|
||||
CMD ["/bin/bash", "-c", "python3 /backend/src/main.py & cd /frontend && npm run dev"]
|
||||
CMD ["/bin/bash", "-c", "cd /frontend && npm run dev & python3 /backend/src/main.py"]
|
||||
@@ -19,6 +19,17 @@ emitter.on('currentPlatform', (platform) => { getRoms(platform) })
|
||||
emitter.on('romsFilter', (filter) => { setFilter(filter) })
|
||||
|
||||
// Functions
|
||||
function normalizeString(s) {
|
||||
return s.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g,"")
|
||||
}
|
||||
|
||||
function setFilter(filter) {
|
||||
currentFilter.value = normalizeString(filter)
|
||||
romsFiltered.value = roms.value.filter(rom => {
|
||||
return normalizeString(rom.name).includes(currentFilter.value)
|
||||
})
|
||||
}
|
||||
|
||||
async function getRoms(platform) {
|
||||
currentPlatformSlug = platform
|
||||
console.log("Getting roms...")
|
||||
@@ -27,7 +38,7 @@ async function getRoms(platform) {
|
||||
console.log("Roms loaded!")
|
||||
console.log(response.data.data)
|
||||
roms.value = response.data.data
|
||||
romsFiltered.value = response.data.data.filter(rom => { return rom.name.toLowerCase().includes(currentFilter.value.toLowerCase()) })
|
||||
setFilter(currentFilter.value)
|
||||
if (roms.value.length == 0){ noRoms.value = true }else{ noRoms.value = false }
|
||||
}).catch((error) => {console.log(error)})
|
||||
emitter.emit('gettingRoms', false)
|
||||
@@ -50,13 +61,6 @@ async function selectRom(rom) {
|
||||
emitter.emit('currentRom', rom)
|
||||
}
|
||||
|
||||
function setFilter(filter) {
|
||||
currentFilter.value = filter
|
||||
romsFiltered.value = roms.value.filter(rom => {
|
||||
return rom.name.toLowerCase().includes(filter.toLowerCase())
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => { if(currentPlatformSlug){ getRoms(currentPlatformSlug) } })
|
||||
</script>
|
||||
|
||||
|
||||
Reference in new issue
Block a user