@@ -13,6 +13,54 @@ const loadingFromSettings = ref(false)
1313const loadingReload = ref (false )
1414const loadingRestart = ref (false )
1515
16+ // Auto refresh logic
17+ const isAutoRefresh = ref (true )
18+ const autoRefreshInterval = ref (5 ) // seconds
19+ const autoRefreshTimer = ref <NodeJS .Timeout | null >(null )
20+
21+ function startAutoRefresh() {
22+ if (autoRefreshTimer .value ) {
23+ clearInterval (autoRefreshTimer .value )
24+ }
25+
26+ autoRefreshTimer .value = setInterval (() => {
27+ if (curd .value ) {
28+ curd .value .refresh ()
29+ }
30+ }, autoRefreshInterval .value * 1000 )
31+ }
32+
33+ function stopAutoRefresh() {
34+ if (autoRefreshTimer .value ) {
35+ clearInterval (autoRefreshTimer .value )
36+ autoRefreshTimer .value = null
37+ }
38+ }
39+
40+ // Watch for auto refresh state changes
41+ watch (isAutoRefresh , newValue => {
42+ if (newValue ) {
43+ startAutoRefresh ()
44+ message .success ($gettext (' Auto refresh enabled' ))
45+ }
46+ else {
47+ stopAutoRefresh ()
48+ message .success ($gettext (' Auto refresh disabled' ))
49+ }
50+ })
51+
52+ // Initialize auto refresh on mount if enabled
53+ onMounted (() => {
54+ if (isAutoRefresh .value ) {
55+ startAutoRefresh ()
56+ }
57+ })
58+
59+ // Clean up timer on component unmount
60+ onBeforeUnmount (() => {
61+ stopAutoRefresh ()
62+ })
63+
1664function loadFromSettings() {
1765 loadingFromSettings .value = true
1866 environment .load_from_settings ().then (() => {
@@ -78,6 +126,7 @@ const inTrash = computed(() => {
78126 disabled: !record.status,
79127 }),
80128 },
129+ pagination: false,
81130 }"
82131 :title =" $gettext('Environments')"
83132 :api =" environment"
@@ -89,6 +138,37 @@ const inTrash = computed(() => {
89138 {{ $gettext('Load from settings') }}
90139 </AButton >
91140 </template >
141+
142+ <template #afterListActions >
143+ <div class =" flex items-center gap-2" >
144+ <ASelect
145+ v-model:value =" autoRefreshInterval"
146+ size =" small"
147+ class =" w-16"
148+ :disabled =" isAutoRefresh"
149+ @change =" isAutoRefresh && startAutoRefresh()"
150+ >
151+ <ASelectOption :value =" 5" >
152+ 5s
153+ </ASelectOption >
154+ <ASelectOption :value =" 10" >
155+ 10s
156+ </ASelectOption >
157+ <ASelectOption :value =" 30" >
158+ 30s
159+ </ASelectOption >
160+ <ASelectOption :value =" 60" >
161+ 60s
162+ </ASelectOption >
163+ </ASelect >
164+
165+ <span >{{ $gettext('Auto Refresh') }}</span >
166+ <ASwitch
167+ v-model:checked =" isAutoRefresh"
168+ size =" small"
169+ />
170+ </div >
171+ </template >
92172 </StdCurd >
93173
94174 <BatchUpgrader ref =" refUpgrader" @success =" curd.refresh()" />
0 commit comments