104
104
<script lang="ts">
105
105
import { type FarmInfo , Features , type FilterOptions , type NodeInfo } from " @threefold/grid_client" ;
106
106
import { noop } from " lodash" ;
107
- import { computed , getCurrentInstance , nextTick , onUnmounted , type PropType , ref , watch } from " vue" ;
108
- import { onMounted } from " vue" ;
109
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
110
- import type { VInput } from " vuetify/components/VInput" ;
107
+ import { computed , getCurrentInstance , nextTick , onMounted , onUnmounted , type PropType , ref , watch } from " vue" ;
111
108
112
109
import { type InputValidatorService , useInputRef } from " @/hooks/input_validator" ;
113
110
114
- import { useAsync , usePagination , useWatchDeep } from " ../../hooks" ;
111
+ import { useAsync , usePagination } from " ../../hooks" ;
115
112
import { useForm , useFormRef , ValidatorStatus } from " ../../hooks/form_validator" ;
116
113
import { useGrid } from " ../../stores" ;
117
114
import type { DomainInfo , NetworkFeatures , SelectionDetailsFilters } from " ../../types/nodeSelector" ;
@@ -157,9 +154,10 @@ export default {
157
154
const pagination = usePagination ();
158
155
159
156
const enableCustomDomain = ref (false );
157
+ const size = ref (window .env .PAGE_SIZE );
160
158
const filters = computed <FilterOptions >(() => ({
161
159
gateway: true ,
162
- size: window . env . PAGE_SIZE ,
160
+ size: size . value ,
163
161
page: Math .max (1 , pagination .value .page ),
164
162
farmId: enableCustomDomain .value ? props .farm ?.farmId : undefined ,
165
163
availableFor: gridStore .client ?.twinId ,
@@ -170,47 +168,52 @@ export default {
170
168
const loadDomains = () => domainsTask .value .run (gridStore , filters .value );
171
169
172
170
const domainInput = useInputRef ();
173
- const reloadDomains = async (_filters : FilterOptions = filters . value ) => {
171
+ const reloadDomains = async () => {
174
172
domainInput .value ?.reset ();
175
173
if (selectedDomain .value ) {
176
174
selectedDomain .value = null ;
177
175
bindModelValue ();
178
176
}
179
- await pageCountTask .value .run (gridStore , _filters );
177
+ await pageCountTask .value .run (gridStore , filters . value );
180
178
pagination .value .reset (pageCountTask .value .data as number );
181
- await nextTick ();
182
179
loadedDomains .value = [];
180
+ await nextTick ();
183
181
return loadDomains ();
184
182
};
185
- let previousFilters = JSON .stringify (filters .value );
186
- useWatchDeep (
187
- filters ,
188
- newFilters => {
189
- const currentFilters = JSON .stringify (newFilters );
190
- if (currentFilters !== previousFilters ) {
191
- reloadDomains ();
192
- previousFilters = currentFilters ;
193
- }
183
+
184
+ watch (
185
+ [() => props .farm ?.farmId , () => gridStore .client ?.twinId , () => props .interfaces ],
186
+ () => {
187
+ reloadDomains ();
194
188
},
195
- { immediate: true , deep: true , ignoreFields: [ " page " ] },
189
+ { deep: true },
196
190
);
191
+
192
+ onMounted (() => {
193
+ loadDomains ();
194
+ });
195
+
197
196
const customDomain = ref (" " );
198
197
const domainFormRef = useFormRef ();
199
198
200
199
const disableSelectedDomain = computed (() => enableCustomDomain .value && props .filters .ipv4 === true );
201
200
const useFQDN = computed (() => enableCustomDomain .value && (props .useFqdn || props .filters .ipv4 === false ));
202
201
203
- const domain = computed <DomainInfo >(() => {
204
- return {
205
- selectedDomain: disableSelectedDomain .value ? null : selectedDomain .value ,
206
- enableSelectedDomain: ! disableSelectedDomain .value ,
207
- enabledCustomDomain: enableCustomDomain .value ,
208
- customDomain: enableCustomDomain .value ? customDomain .value : " " ,
209
- useFQDN: useFQDN .value ,
210
- };
211
- });
202
+ const domain = computed <DomainInfo >(() => ({
203
+ selectedDomain: disableSelectedDomain .value ? null : selectedDomain .value ,
204
+ enableSelectedDomain: ! disableSelectedDomain .value ,
205
+ enabledCustomDomain: enableCustomDomain .value ,
206
+ customDomain: enableCustomDomain .value ? customDomain .value : " " ,
207
+ useFQDN: useFQDN .value ,
208
+ }));
212
209
213
- useWatchDeep (domain , bindModelValue , { immediate: true , deep: true });
210
+ watch (
211
+ domain ,
212
+ newDomain => {
213
+ bindModelValue (newDomain );
214
+ },
215
+ { immediate: true },
216
+ );
214
217
215
218
onUnmounted (() => {
216
219
bindModelValue ();
@@ -278,6 +281,7 @@ export default {
278
281
selectedDomain ,
279
282
loadDomains ,
280
283
reloadDomains ,
284
+ size ,
281
285
282
286
domainFormRef ,
283
287
domainInput ,
0 commit comments