Skip to content

Commit

Permalink
Refrsh agent connections.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhsamuel committed Dec 28, 2023
1 parent 8f5d33c commit f4c35f9
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions vue/src/views/AgentsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ div
div(v-if="groups")
h1 Groups
div.controls
input(type="checkbox" v-model="showDisconnected")
label Show disconnected
button(@click="fetchGroups()") Refresh

div
input(type="checkbox" v-model="showDisconnected")
label Show disconnected

div.groups
div.group(v-for="(conns, group_id) in filteredGroups" :key="group_id")
Expand Down Expand Up @@ -44,6 +47,7 @@ export default {
return {
store,
groups: undefined,
timerId: undefined,
showDisconnected: true,
}
},
Expand All @@ -54,18 +58,23 @@ export default {
methods: {
fetchGroups() {
if (self.timerId)
clearTimeout(self.timerId)
const url = '/api/procstar/groups'
fetch(url).then(async (rsp) => {
if (rsp.ok)
this.groups = await rsp.json()
// FIXME: Handle error, e.g. no procstar server.
})
// Load again in a minute.
self.timerId = setTimeout(this.fetchGroups, 60 * 1000)
},
},
computed: {
filteredGroups() {
console.log('filteredGroups', this.showDisconnected)
let groups = this.groups
if (groups)
if (!this.showDisconnected)
Expand All @@ -80,7 +89,15 @@ export default {
@import 'src/styles/vars.scss';
.controls {
margin-bottom: 24px;
margin-bottom: 32px;
display: flex;
align-items: center;
column-gap: 24px;
button {
height: 28px;
}
}
groups {
Expand Down

0 comments on commit f4c35f9

Please sign in to comment.