mirror of
https://github.com/rommapp/romm.git
synced 2026-12-05 05:07:31 +01:00
added global search api call
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, inject } from "vue";
|
||||
import { useDisplay } from "vuetify";
|
||||
import type { Emitter } from "mitt";
|
||||
import type { Events } from "@/types/emitter";
|
||||
import { debounce } from "lodash";
|
||||
import type { Emitter } from "mitt";
|
||||
import { inject, ref, onMounted } from "vue";
|
||||
import { useDisplay } from "vuetify";
|
||||
import api_rom from "@/services/api_rom";
|
||||
|
||||
import storePlatforms from "@/stores/platforms";
|
||||
import storeAuth from "@/stores/auth";
|
||||
import RailFooter from "@/components/Drawer/Footer.vue";
|
||||
import DrawerHeader from "@/components/Drawer/Header.vue";
|
||||
import PlatformListItem from "@/components/Platform/PlatformListItem.vue";
|
||||
import RailFooter from "@/components/Drawer/Footer.vue";
|
||||
import storeAuth from "@/stores/auth";
|
||||
import storePlatforms from "@/stores/platforms";
|
||||
|
||||
// Props
|
||||
const { lgAndUp } = useDisplay();
|
||||
@@ -17,6 +19,7 @@ const auth = storeAuth();
|
||||
const drawer = ref(!!lgAndUp.value);
|
||||
const open = ref(["Platforms", "Library", "Settings"]);
|
||||
const rail = ref(localStorage.getItem("rail") == "true");
|
||||
const searchedRoms = ref()
|
||||
|
||||
// Event listeners bus
|
||||
const emitter = inject<Emitter<Events>>("emitter");
|
||||
@@ -27,6 +30,19 @@ emitter?.on("toggleDrawerRail", () => {
|
||||
rail.value = !rail.value;
|
||||
localStorage.setItem("rail", rail.value.toString());
|
||||
});
|
||||
|
||||
const searchValue = ref("");
|
||||
|
||||
function clearFilter() {
|
||||
searchValue.value = "";
|
||||
}
|
||||
|
||||
async function searchRoms() {
|
||||
searchedRoms.value = await api_rom.getRoms({searchTerm: searchValue.value})
|
||||
console.log(searchedRoms.value)
|
||||
};
|
||||
|
||||
onMounted(() => {});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -42,6 +58,46 @@ emitter?.on("toggleDrawerRail", () => {
|
||||
<v-divider />
|
||||
</template>
|
||||
<v-list v-model:opened="open" class="pa-0">
|
||||
<v-toolbar density="compact" class="bg-primary">
|
||||
<v-row class="align-center" no-gutters>
|
||||
<v-col cols="7" xs="7" sm="8" md="8" lg="9">
|
||||
<v-text-field
|
||||
@keyup.enter="searchRoms"
|
||||
@click:clear="clearFilter"
|
||||
v-model="searchValue"
|
||||
label="Search in RomM"
|
||||
hide-details
|
||||
class="bg-terciary"
|
||||
clearable
|
||||
/>
|
||||
</v-col>
|
||||
<v-col>
|
||||
<v-btn
|
||||
class="bg-terciary"
|
||||
type="submit"
|
||||
@click="searchRoms"
|
||||
rounded="0"
|
||||
variant="text"
|
||||
icon="mdi-magnify"
|
||||
block
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-toolbar>
|
||||
<!-- <v-row no-gutters>
|
||||
<v-text-field
|
||||
density="compact"
|
||||
@click:clear="clearFilter"
|
||||
@keyup.enter="searchRoms"
|
||||
v-model="searchValue"
|
||||
prepend-inner-icon="mdi-magnify"
|
||||
label="Search in RomM"
|
||||
rounded="0"
|
||||
hide-details
|
||||
clearable
|
||||
/>
|
||||
<v-btn @click="searchRoms">S</v-btn>
|
||||
</v-row> -->
|
||||
<v-list-group value="Platforms" fluid>
|
||||
<template v-slot:activator="{ props }">
|
||||
<v-list-item v-bind="props">
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { inject, ref, onMounted } from "vue";
|
||||
import type { Events } from "@/types/emitter";
|
||||
import { debounce } from "lodash";
|
||||
import type { Emitter } from "mitt";
|
||||
import type { Events } from "@/types/emitter";
|
||||
import { inject, onMounted, ref } from "vue";
|
||||
|
||||
import storeGalleryFilter from "@/stores/galleryFilter";
|
||||
|
||||
@@ -12,9 +12,6 @@ const filterValue = ref("");
|
||||
|
||||
// Event listeners bus
|
||||
const emitter = inject<Emitter<Events>>("emitter");
|
||||
onMounted(() => {
|
||||
filterValue.value = galleryFilter.filter;
|
||||
});
|
||||
|
||||
function clearFilter() {
|
||||
galleryFilter.set("");
|
||||
@@ -25,6 +22,10 @@ const filterRoms = debounce(() => {
|
||||
galleryFilter.set(filterValue.value);
|
||||
emitter?.emit("filter", null);
|
||||
}, 500);
|
||||
|
||||
onMounted(() => {
|
||||
filterValue.value = galleryFilter.filter;
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -32,8 +33,8 @@ const filterRoms = debounce(() => {
|
||||
@click:clear="clearFilter"
|
||||
@keyup="filterRoms"
|
||||
v-model="filterValue"
|
||||
prepend-inner-icon="mdi-magnify"
|
||||
label="Search"
|
||||
prepend-inner-icon="mdi-filter-variant"
|
||||
label="Filter"
|
||||
rounded="0"
|
||||
hide-details
|
||||
clearable
|
||||
|
||||
@@ -32,19 +32,19 @@ async function uploadRoms({
|
||||
}
|
||||
|
||||
async function getRoms({
|
||||
platformId,
|
||||
platformId = null,
|
||||
size = 60,
|
||||
cursor = "",
|
||||
searchTerm = "",
|
||||
orderBy = "name",
|
||||
orderDir = "asc",
|
||||
}: {
|
||||
platformId: number;
|
||||
size?: number;
|
||||
platformId?: number | null;
|
||||
size?: number | null;
|
||||
cursor?: string | null;
|
||||
searchTerm?: string;
|
||||
orderBy?: string;
|
||||
orderDir?: string;
|
||||
searchTerm?: string | null;
|
||||
orderBy?: string | null;
|
||||
orderDir?: string | null;
|
||||
}): Promise<{ data: CursorPage_RomSchema_ }> {
|
||||
return api.get(`/roms`, {
|
||||
params: {
|
||||
|
||||
Reference in New Issue
Block a user