table in progress
This commit is contained in:
parent
9f96d20cac
commit
44d5a52499
@ -54,7 +54,7 @@
|
|||||||
*::before,
|
*::before,
|
||||||
*::after {
|
*::after {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
margin: 0;
|
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,23 +1,115 @@
|
|||||||
<template>
|
<template>
|
||||||
|
|
||||||
<div class="card bg-red-100 w-[300px]">
|
<div class="card bg-[#081f6e] text-[#FFF] w-[30%] p-6">
|
||||||
<p>hello world</p>
|
|
||||||
|
<div>
|
||||||
<div class="mt-6">
|
<label for="userInput" class="block text-sm !font-bold mb-2">Query</label>
|
||||||
<span class="block font-bold mb-2">Search Type:</span>
|
<input
|
||||||
<div class="flex space-x-4">
|
id="userInput"
|
||||||
<label v-for="type in searchTypes" :key="type" class="flex items-center space-x-1">
|
v-model="searchQuery"
|
||||||
<input type="radio" v-model="selectedSearchType" :value="type" class="radio radio-primary" />
|
type="text"
|
||||||
<span>{{ type }}</span>
|
class="w-full p-3 border border-gray-300 bg-[#1a1a1a] rounded-md focus:border-blue-500 focus:ring focus:ring-blue-200"
|
||||||
</label>
|
/>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-[20px]">
|
||||||
|
<label for="searchType" class="block text-sm !font-bold">Search Type</label>
|
||||||
|
<select v-model="selectedSearchType" id="searchType" class="mt-4 p-[10px] block w-full bg-[#1a1a1a] rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring focus:ring-blue-200">
|
||||||
|
<option v-for="option in searchTypes" :key="option" :value="option">
|
||||||
|
{{ option }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-[20px]">
|
||||||
|
<label for="pageNumber" class="block text-sm !font-bold ">Page Number</label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
id="pageNumber"
|
||||||
|
v-model.number="pageNumber"
|
||||||
|
class="input input-bordered border-white bg-[#1a1a1a] w-full mt-4"
|
||||||
|
min="1"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-[20px]">
|
||||||
|
<label for="pageSize" class="block text-sm !font-bold">Page Size</label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
id="pageSize"
|
||||||
|
v-model.number="pageSize"
|
||||||
|
class="input input-bordered border-white bg-[#1a1a1a] w-full mt-4"
|
||||||
|
min="1"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button @click="sendRequest" class="btn mt-[40px]">Send Request</button>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {ref} from "vue";
|
import {ref} from "vue";
|
||||||
|
import { useSearchStore } from "@/stores/searchStore";
|
||||||
|
import { useRouter } from "vue-router";
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
|
||||||
const selectedSearchType= ref("precise")
|
const selectedSearchType= ref("precise")
|
||||||
const searchTypes = []
|
const searchTypes = ref(["precise","associative","proximity","semantic"])
|
||||||
|
const searchQuery = ref("")
|
||||||
|
const pageNumber = ref()
|
||||||
|
const pageSize = ref()
|
||||||
|
|
||||||
|
const data = ref(null);
|
||||||
|
|
||||||
|
const responseData = ref(null);
|
||||||
|
let error=ref(null)
|
||||||
|
const fetchData = async () => {
|
||||||
|
try {
|
||||||
|
console.log("fetchData called ")
|
||||||
|
const response = await fetch("/search", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Authorization": "ApiKey NS00TXlKUUIweUhWaGFuUUpUVTk6bWNVWXI1VXRSN2VWcFRtaEZ6NmdCUQ=="
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
query: "China",
|
||||||
|
search_type: "precise",
|
||||||
|
page_num: "2",
|
||||||
|
page_size: "2"
|
||||||
|
}),
|
||||||
|
mode: "cors"
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
console.log("response:", response.ok)
|
||||||
|
throw new Error(`HTTP error! Status: ${response.status}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
responseData.value = await response.json();
|
||||||
|
console.log("Response:", responseData.value);
|
||||||
|
} catch (err) {
|
||||||
|
|
||||||
|
console.error("Fetch error:", err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const searchStore = useSearchStore();
|
||||||
|
|
||||||
|
const sendRequest = async()=>{
|
||||||
|
|
||||||
|
console.log("calling fetchData")
|
||||||
|
fetchData()
|
||||||
|
searchStore.searchParams = {
|
||||||
|
query: searchQuery.value,
|
||||||
|
searchType: selectedSearchType.value,
|
||||||
|
pageNumber: pageNumber.value,
|
||||||
|
pageSize: pageSize.value
|
||||||
|
};
|
||||||
|
console.log("searchStore: ", searchStore.searchParams)
|
||||||
|
router.push("/table");
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
17
src/components/TableComp.vue
Normal file
17
src/components/TableComp.vue
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<h3>Search Parameters</h3>
|
||||||
|
<pre>{{ searchStore.searchParams }}</pre> <!-- ✅ Displays as JSON -->
|
||||||
|
|
||||||
|
<p>Query: {{ searchStore.searchParams.query }}</p>
|
||||||
|
<p>Search Type: {{ searchStore.searchParams.searchType }}</p>
|
||||||
|
<p>Page Number: {{ searchStore.searchParams.pageNumber }}</p>
|
||||||
|
<p>Page Size: {{ searchStore.searchParams.pageSize }}</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
import {ref} from "vue";
|
||||||
|
import { useSearchStore } from "@/stores/searchStore";
|
||||||
|
const searchStore = useSearchStore();
|
||||||
|
</script>
|
||||||
@ -1,87 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="item">
|
|
||||||
<i>
|
|
||||||
<slot name="icon"></slot>
|
|
||||||
</i>
|
|
||||||
<div class="details">
|
|
||||||
<h3>
|
|
||||||
<slot name="heading"></slot>
|
|
||||||
</h3>
|
|
||||||
<slot></slot>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.item {
|
|
||||||
margin-top: 2rem;
|
|
||||||
display: flex;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.details {
|
|
||||||
flex: 1;
|
|
||||||
margin-left: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
i {
|
|
||||||
display: flex;
|
|
||||||
place-items: center;
|
|
||||||
place-content: center;
|
|
||||||
width: 32px;
|
|
||||||
height: 32px;
|
|
||||||
|
|
||||||
color: var(--color-text);
|
|
||||||
}
|
|
||||||
|
|
||||||
h3 {
|
|
||||||
font-size: 1.2rem;
|
|
||||||
font-weight: 500;
|
|
||||||
margin-bottom: 0.4rem;
|
|
||||||
color: var(--color-heading);
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 1024px) {
|
|
||||||
.item {
|
|
||||||
margin-top: 0;
|
|
||||||
padding: 0.4rem 0 1rem calc(var(--section-gap) / 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
i {
|
|
||||||
top: calc(50% - 25px);
|
|
||||||
left: -26px;
|
|
||||||
position: absolute;
|
|
||||||
border: 1px solid var(--color-border);
|
|
||||||
background: var(--color-background);
|
|
||||||
border-radius: 8px;
|
|
||||||
width: 50px;
|
|
||||||
height: 50px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.item:before {
|
|
||||||
content: ' ';
|
|
||||||
border-left: 1px solid var(--color-border);
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
bottom: calc(50% + 25px);
|
|
||||||
height: calc(50% - 25px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.item:after {
|
|
||||||
content: ' ';
|
|
||||||
border-left: 1px solid var(--color-border);
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
top: calc(50% + 25px);
|
|
||||||
height: calc(50% - 25px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.item:first-of-type:before {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.item:last-of-type:after {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@ -17,6 +17,14 @@ const router = createRouter({
|
|||||||
// which is lazy-loaded when the route is visited.
|
// which is lazy-loaded when the route is visited.
|
||||||
component: () => import('../views/AboutView.vue'),
|
component: () => import('../views/AboutView.vue'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/table',
|
||||||
|
name: 'table',
|
||||||
|
// route level code-splitting
|
||||||
|
// this generates a separate chunk (About.[hash].js) for this route
|
||||||
|
// which is lazy-loaded when the route is visited.
|
||||||
|
component: () => import('../views/ResponseView.vue'),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
8
src/stores/searchStore.ts
Normal file
8
src/stores/searchStore.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { ref, computed } from 'vue'
|
||||||
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
|
export const useSearchStore = defineStore('search', () => {
|
||||||
|
const searchParams = ref({})
|
||||||
|
|
||||||
|
return { searchParams }
|
||||||
|
})
|
||||||
32
src/utils/api.js
Normal file
32
src/utils/api.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
export const fetchData = async(endpoints="", requestType="GET", requestBody=null)=>{
|
||||||
|
console.log("requestBody:", requestBody)
|
||||||
|
console.log("requestType:", requestType)
|
||||||
|
console.log("endpoints:", `https://192.168.99.121/${endpoints}`)
|
||||||
|
try{
|
||||||
|
const options={
|
||||||
|
method:requestType,
|
||||||
|
headers:{
|
||||||
|
"Content-Type":"application/json",
|
||||||
|
"Authorization": "ApiKey NS00TXlKUUIweUhWaGFuUUpUVTk6bWNVWXI1VXRSN2VWcFRtaEZ6NmdCUQ=="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requestType !=="GET" && requestBody){
|
||||||
|
options.body = JSON.stringify(requestBody)
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch(`http://192.168.99.121/${endpoints}`, options)
|
||||||
|
console.log("response butrte: ", response)
|
||||||
|
if (!response.ok){
|
||||||
|
throw new Error(`HTTP error! Status: ${response.status}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
return await response.json()
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(error){
|
||||||
|
console.log("Fetch error:", error)
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -3,8 +3,7 @@ import InputFieldCard from '@/components/InputFieldCard.vue'
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<main>
|
<main class="flex place-content-center p-4 h-[100%]">
|
||||||
<p>home page</p>
|
|
||||||
<InputFieldCard/>
|
<InputFieldCard/>
|
||||||
</main>
|
</main>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
9
src/views/ResponseView.vue
Normal file
9
src/views/ResponseView.vue
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<template>
|
||||||
|
<main class="flex place-content-center p-4 h-[100%]">
|
||||||
|
<TableComp />
|
||||||
|
</main>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
import TableComp from "@/components/TableComp.vue"
|
||||||
|
</script>
|
||||||
@ -6,6 +6,15 @@ import vueDevTools from 'vite-plugin-vue-devtools'
|
|||||||
import tailwindcss from '@tailwindcss/vite'
|
import tailwindcss from '@tailwindcss/vite'
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
|
server: {
|
||||||
|
proxy: {
|
||||||
|
"/search": {
|
||||||
|
target: "https://192.168.99.121",
|
||||||
|
changeOrigin: true,
|
||||||
|
secure: false, // Ignores SSL certificate issues
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
vue(),
|
vue(),
|
||||||
vueDevTools(),
|
vueDevTools(),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user