Commit 8cd6c43a authored by Wen Wei Li's avatar Wen Wei Li

add single agent view

parent be38f193
<template> <template>
<CContainer> <CContainer>
<div> <div>
<h2>Agent Lists</h2> <h2>{{ agentId }}</h2>
<CContainer> <CContainer>
<CTable hover> <CTable hover>
<CTableHead> <CTableHead>
...@@ -42,8 +42,8 @@ ...@@ -42,8 +42,8 @@
methods: { methods: {
async fetchAgentsData() { async fetchAgentsData() {
try { try {
console.log("`http://192.168.88.238:8080/api/v1/agent/${this.agentID}`"); console.log("`http://192.168.88.238:8080/api/v1/agent/${this.agentId}`");
const response = await fetch("`http://192.168.88.238:8080/api/v1/agent/${this.agentID}`"); const response = await fetch("`http://192.168.88.238:8080/api/v1/agent/${this.agentId}`");
if (!response.ok) throw new Error('Failed to fetch'); if (!response.ok) throw new Error('Failed to fetch');
this.agent_data = await response.json(); this.agent_data = await response.json();
console.log(this.agent_data); console.log(this.agent_data);
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
watch: { watch: {
'$route'(to, from) { '$route'(to, from) {
// React to route changes and update the productId // React to route changes and update the productId
this.agentID = to.params.agentID; this.agentId = to.params.agentId;
} }
} }
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<CTableBody> <CTableBody>
<CTableRow v-for="(agent, index) in agents" :key="agent.id"> <CTableRow v-for="(agent, index) in agents" :key="agent.id">
<CTableDataCell> <CTableDataCell>
<router-link :to="`/agent/${agent.id}`" > <router-link :to="`/agents/${agent.id}`" >
{{ agent.id }} {{ agent.id }}
</router-link> </router-link>
</CTableDataCell> </CTableDataCell>
......
...@@ -14,8 +14,16 @@ const router = createRouter({ ...@@ -14,8 +14,16 @@ const router = createRouter({
history: createWebHistory(), history: createWebHistory(),
routes: [ routes: [
{ path: '/', component: Criteria }, { path: '/', component: Criteria },
{ path: '/agents', component: Agents }, { path: '/agents', component: Agents,
{ path: '/agent/:agentID', component: Agent } children: [
{
path: ':agentId',
name: 'agentId',
props: true,
component: Agent
}
]
},
] ]
}); });
export default router; export default router;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment