fallback outbound in balancer

Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
This commit is contained in:
mhsanaei 2024-07-15 00:09:31 +02:00
parent 0a95b0c7b2
commit 816adfc3ea
2 changed files with 21 additions and 9 deletions

View File

@ -1268,7 +1268,8 @@
balancer: { balancer: {
tag: '', tag: '',
strategy: 'random', strategy: 'random',
selector: [] selector: [],
fallbackTag: ''
}, },
confirm: (balancer) => { confirm: (balancer) => {
balancerModal.loading(); balancerModal.loading();
@ -1278,7 +1279,8 @@
} }
let tmpBalancer = { let tmpBalancer = {
'tag': balancer.tag, 'tag': balancer.tag,
'selector': balancer.selector 'selector': balancer.selector,
'fallbackTag': balancer.fallbackTag
}; };
if (balancer.strategy && balancer.strategy != 'random') { if (balancer.strategy && balancer.strategy != 'random') {
tmpBalancer.strategy = { tmpBalancer.strategy = {
@ -1308,7 +1310,8 @@
let tmpBalancer = { let tmpBalancer = {
'tag': balancer.tag, 'tag': balancer.tag,
'selector': balancer.selector 'selector': balancer.selector,
'fallbackTag': balancer.fallbackTag
}; };
// Remove old tag // Remove old tag
@ -1377,7 +1380,7 @@
this.changeObsCode(); this.changeObsCode();
}, },
deleteBalancer(index) { deleteBalancer(index) {
let newTemplateSettings = { ...this.templateSettings }; newTemplateSettings = this.templateSettings;
// Remove from balancers // Remove from balancers
const removedBalancer = this.balancersData.splice(index, 1)[0]; const removedBalancer = this.balancersData.splice(index, 1)[0];
@ -1623,7 +1626,8 @@
'key': index, 'key': index,
'tag': o.tag ? o.tag : "", 'tag': o.tag ? o.tag : "",
'strategy': o.strategy?.type ?? "random", 'strategy': o.strategy?.type ?? "random",
'selector': o.selector ? o.selector : [] 'selector': o.selector ? o.selector : [],
'fallbackTag': o.fallbackTag?? '',
}); });
}); });
} }

View File

@ -32,6 +32,12 @@
<a-select-option v-for="tag in balancerModal.outboundTags" :value="tag">[[ tag ]]</a-select-option> <a-select-option v-for="tag in balancerModal.outboundTags" :value="tag">[[ tag ]]</a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
<a-form-item label="Fallback">
<a-select v-model="balancerModal.balancer.fallbackTag" clearable
:dropdown-class-name="themeSwitcher.currentTheme">
<a-select-option v-for="tag in [ '', ...balancerModal.outboundTags]" :value="tag">[[ tag ]]</a-select-option>
</a-select>
</a-form-item>
</table> </table>
</a-form> </a-form>
</a-modal> </a-modal>
@ -48,7 +54,8 @@
balancer: { balancer: {
tag: '', tag: '',
strategy: 'random', strategy: 'random',
selector: [] selector: [],
fallbackTag: ''
}, },
outboundTags: [], outboundTags: [],
balancerTags:[], balancerTags:[],
@ -71,7 +78,8 @@
balancerModal.balancer = { balancerModal.balancer = {
tag: '', tag: '',
strategy: 'random', strategy: 'random',
selector: [] selector: [],
fallbackTag: ''
}; };
} }
this.balancerTags = balancerTags.filter((tag) => tag != balancer.tag); this.balancerTags = balancerTags.filter((tag) => tag != balancer.tag);