Skip to content

Commit

Permalink
add auto-refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticroentgen committed Jul 30, 2024
1 parent 0e542cd commit e9224bf
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 4 deletions.
31 changes: 29 additions & 2 deletions src/components/Jobs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
<n-form-item>
<n-button @click="fetchJobs">Refresh</n-button>
</n-form-item>
<n-form-item>
<n-switch v-model:value="autoRefresh">
<template #checked>
Auto-update enabled
</template>
<template #unchecked>
Auto-update disabled
</template>
</n-switch>
</n-form-item>
</n-form>
<n-table striped>
<thead>
Expand Down Expand Up @@ -42,11 +52,28 @@
import axios from 'axios';
import {parseJobState} from '../common'
export default {
name: 'RunnersView',
name: 'JobsView',
watch: {
autoRefresh(newVal) {
if (newVal) {
// Start auto-refreshing
this.interval = setInterval(this.fetchJobs, 2000); // Fetch jobs every 2000 milliseconds (2 seconds)
} else {
// Stop auto-refreshing
clearInterval(this.interval);
}
}
},
beforeUnmount() {
if (this.interval) {
clearInterval(this.interval);
}
},
data() {
return {
jobs: [],
hideComplete: false
hideComplete: false,
autoRefresh: false
};
},
mounted() {
Expand Down
30 changes: 28 additions & 2 deletions src/components/Runners.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
<n-form-item>
<n-button @click="fetchrunners">Refresh</n-button>
</n-form-item>
<n-form-item>
<n-switch v-model:value="autoRefresh">
<template #checked>
Auto-update enabled
</template>
<template #unchecked>
Auto-update disabled
</template>
</n-switch>
</n-form-item>
</n-form>
<n-drawer v-model:show="show" :width="'60%'">
<n-drawer-content :title="'Runner Details for ' + this.selectedRunner.hostname" closable>
Expand Down Expand Up @@ -68,13 +78,30 @@ export default {
components: {
RunnerDetails
},
watch: {
autoRefresh(newVal) {
if (newVal) {
// Start auto-refreshing
this.interval = setInterval(this.fetchRunners, 2000); // Fetch jobs every 2000 milliseconds (2 seconds)
} else {
// Stop auto-refreshing
clearInterval(this.interval);
}
}
},
beforeUnmount() {
if (this.interval) {
clearInterval(this.interval);
}
},
data() {
return {
runners: [],
jobs: [],
searchRunner: "",
searchOnlyOnline: false,
selectedRunner: {}
selectedRunner: {},
autoRefresh: false,
};
},
setup() {
Expand All @@ -84,7 +111,6 @@ export default {
},
mounted() {
this.fetchRunners();
setInterval(this.fetchRunners, 10000);
},
computed: {
sortedRunners() {
Expand Down

0 comments on commit e9224bf

Please sign in to comment.