Commit be080e89 authored by Wen Wei Li's avatar Wen Wei Li

update agent view

parent bb3afdd2
...@@ -6,16 +6,26 @@ ...@@ -6,16 +6,26 @@
<CTable hover> <CTable hover>
<CTableHead> <CTableHead>
<CTableRow> <CTableRow>
<CTableHeaderCell scope="col">#</CTableHeaderCell> <CTableHeaderCell scope="col">#</CTableHeaderCell>
<CTableHeaderCell scope="col">Name</CTableHeaderCell> <CTableHeaderCell scope="col">Name</CTableHeaderCell>
<CTableHeaderCell scope="col">OS</CTableHeaderCell>
<CTableHeaderCell scope="col">Status</CTableHeaderCell>
<CTableHeaderCell scope="col">SCA Score</CTableHeaderCell>
<CTableHeaderCell scope="col">Healthy Check</CTableHeaderCell>
</CTableRow> </CTableRow>
</CTableHead> </CTableHead>
<CTableBody> <CTableBody>
<CTableRow v-for="(data, index) in agent_data" :key="index"> <CTableRow v-for="(data, index) in agent_data" :key="index">
<CTableDataCell>{{ data.id }}</CTableDataCell> <CTableDataCell>{{ data.id }}</CTableDataCell>
<CTableDataCell>{{ data.name }}</CTableDataCell> <CTableDataCell>{{ data.node_name }}</CTableDataCell>
<CTableDataCell>{{ data.OS }}</CTableDataCell>
<CTableDataCell>{{ data.status }}</CTableDataCell>
<CTableDataCell>{{ data.sca_score }}</CTableDataCell>
<CTableDataCell v-if="healthy === 'true'">
<CIcon icon="cilCheckAlt" /></CTableDataCell>
<CTableDataCell v-else>
<CIcon icon="cilX" /></CTableDataCell>
</CTableRow> </CTableRow>
</CTableBody> </CTableBody>
</CTable> </CTable>
...@@ -25,14 +35,16 @@ ...@@ -25,14 +35,16 @@
</template> </template>
<script> <script>
import { onMounted } from 'vue'; import { onMounted } from 'vue';
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
export default { export default {
name:"AgentDetail", name:"AgentDetail",
data() { data() {
return { return {
agentId: "000", agentId: "000",
agent_data: [] agent_data: [],
healthy: 'true'
}; };
}, },
mounted() { mounted() {
...@@ -41,18 +53,18 @@ import { useRoute } from 'vue-router' ...@@ -41,18 +53,18 @@ import { useRoute } from 'vue-router'
methods: { methods: {
async fetchAgentData() { async fetchAgentData() {
this.agent_data = [{"id":this.$route.params.id,"name":"test"}] this.agent_data = [{"id":this.$route.params.id,"name":"test"}]
this.agentId = this.$route.params.id this.agentId = this.$route.params.id
/*
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();
this.healthy = this.agent_data[0].healthy
console.log(this.agent_data); console.log(this.agent_data);
} catch (error) { } catch (error) {
console.error('Error fetching products:', error); console.error('Error fetching products:', error);
} }
*/
} }
}, },
......
...@@ -37,6 +37,7 @@ export default { ...@@ -37,6 +37,7 @@ export default {
methods:{ methods:{
updateParent() { updateParent() {
this.$emit('update-data', { attribute: this.attribute, threshold: this.threshold }); this.$emit('update-data', { attribute: this.attribute, threshold: this.threshold });
console.log(this.threshold)
} }
} }
......
...@@ -37,7 +37,16 @@ export default { ...@@ -37,7 +37,16 @@ export default {
}, },
methods: { methods: {
async fetchAgentsData() { async fetchAgentsData() {
this.rules = [{"attribute": "SCA", "threshold":"60"}] //this.rules = [{"attribute": "SCA", "threshold":"60"}]
try {
const response = await fetch("http://192.168.88.238:8080/api/v1/rules");
if (!response.ok) throw new Error('Failed to fetch');
this.rules = await response.json();
console.log(this.rules);
} catch (error) {
console.error('Error fetching products:', error);
}
} }
} }
} }
......
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