outbound tag validation #1286

This commit is contained in:
Alireza Ahmadi 2023-12-05 23:03:38 +01:00
parent 1bbef6d612
commit aa19637288
10 changed files with 18 additions and 8 deletions

View File

@ -747,7 +747,8 @@
} }
outModal.close(); outModal.close();
}, },
isEdit: false isEdit: false,
tags: this.templateSettings.outbounds.map(obj => obj.tag)
}); });
}, },
editOutbound(index){ editOutbound(index){
@ -760,7 +761,8 @@
this.outboundSettings = JSON.stringify(this.templateSettings.outbounds); this.outboundSettings = JSON.stringify(this.templateSettings.outbounds);
outModal.close(); outModal.close();
}, },
isEdit: true isEdit: true,
tags: this.outboundData.filter((o) => o.key != index ).map(obj => obj.tag)
}); });
}, },
deleteOutbound(index){ deleteOutbound(index){

View File

@ -21,10 +21,11 @@
duplicateTag: false, duplicateTag: false,
isValid: true, isValid: true,
activeKey: '1', activeKey: '1',
tags: [],
ok() { ok() {
ObjectUtil.execute(outModal.confirm, outModal.outbound.toJson()); ObjectUtil.execute(outModal.confirm, outModal.outbound.toJson());
}, },
show({ title='', okText='{{ i18n "sure" }}', outbound, confirm=(outbound)=>{}, isEdit=false }) { show({ title='', okText='{{ i18n "sure" }}', outbound, confirm=(outbound)=>{}, isEdit=false, tags=[] }) {
this.title = title; this.title = title;
this.okText = okText; this.okText = okText;
this.confirm = confirm; this.confirm = confirm;
@ -34,6 +35,7 @@
this.visible = true; this.visible = true;
this.outbound = isEdit ? Outbound.fromJson(outbound) : new Outbound(); this.outbound = isEdit ? Outbound.fromJson(outbound) : new Outbound();
this.isEdit = isEdit; this.isEdit = isEdit;
this.tags = tags;
this.check() this.check()
}, },
close() { close() {
@ -44,7 +46,7 @@
outModal.confirmLoading = loading; outModal.confirmLoading = loading;
}, },
check(){ check(){
if(outModal.outbound.tag == ''){ if(outModal.outbound.tag == '' || outModal.tags.includes(outModal.outbound.tag)){
this.duplicateTag = true; this.duplicateTag = true;
this.isValid = false; this.isValid = false;
} else { } else {

View File

@ -111,9 +111,9 @@
] ]
} }
this.isEdit = isEdit; this.isEdit = isEdit;
this.inboundTags = app.templateSettings.inbounds.map(obj => obj.tag); this.inboundTags = app.templateSettings.inbounds.filter((i) => !ObjectUtil.isEmpty(i.tag)).map(obj => obj.tag);
this.inboundTags.push(...app.inboundTags); this.inboundTags.push(...app.inboundTags);
this.outboundTags = app.templateSettings.outbounds.map(obj => obj.tag); this.outboundTags = app.templateSettings.outbounds.filter((o) => !ObjectUtil.isEmpty(o.tag)).map(obj => obj.tag);
}, },
close() { close() {
reverseModal.visible = false; reverseModal.visible = false;

View File

@ -152,9 +152,9 @@
} }
} }
this.isEdit = isEdit; this.isEdit = isEdit;
this.inboundTags = app.templateSettings.inbounds.map(obj => obj.tag); this.inboundTags = app.templateSettings.inbounds.filter((i) => !ObjectUtil.isEmpty(i.tag)).map(obj => obj.tag);
this.inboundTags.push(...app.inboundTags); this.inboundTags.push(...app.inboundTags);
this.outboundTags = app.templateSettings.outbounds.map(obj => obj.tag); this.outboundTags = app.templateSettings.outbounds.filter((o) => !ObjectUtil.isEmpty(o.tag)).map(obj => obj.tag);
if(app.templateSettings.reverse){ if(app.templateSettings.reverse){
if(app.templateSettings.reverse.bridges) { if(app.templateSettings.reverse.bridges) {
this.inboundTags.push(...app.templateSettings.reverse.bridges.map(b => b.tag)); this.inboundTags.push(...app.templateSettings.reverse.bridges.map(b => b.tag));

View File

@ -390,6 +390,7 @@
"editOutbound" = "Edit outbound" "editOutbound" = "Edit outbound"
"editReverse" = "Edit reverse" "editReverse" = "Edit reverse"
"tag" = "Tag" "tag" = "Tag"
"tagDesc" = "Unique tag"
"address" = "Address" "address" = "Address"
"reverse" = "Reverse" "reverse" = "Reverse"
"domain" = "Domain" "domain" = "Domain"

View File

@ -390,6 +390,7 @@
"editOutbound" = "Editar salida" "editOutbound" = "Editar salida"
"editReverse" = "Editar reverso" "editReverse" = "Editar reverso"
"tag" = "Etiqueta" "tag" = "Etiqueta"
"tagDesc" = "etiqueta única"
"address" = "Dirección" "address" = "Dirección"
"reverse" = "Reverso" "reverse" = "Reverso"
"domain" = "Dominio" "domain" = "Dominio"

View File

@ -390,6 +390,7 @@
"editOutbound" = "ویرایش خروجی" "editOutbound" = "ویرایش خروجی"
"editReverse" = "ویرایش معکوس" "editReverse" = "ویرایش معکوس"
"tag" = "برچسب" "tag" = "برچسب"
"tagDesc" = "برچسب یگانه"
"address" = "آدرس" "address" = "آدرس"
"reverse" = "معکوس" "reverse" = "معکوس"
"domain" = "دامنه" "domain" = "دامنه"

View File

@ -390,6 +390,7 @@
"editOutbound" = "Изменить исходящий" "editOutbound" = "Изменить исходящий"
"editReverse" = "Редактировать реверс" "editReverse" = "Редактировать реверс"
"tag" = "Тег" "tag" = "Тег"
"tagDesc" = "уникальный тег"
"address" = "Адрес" "address" = "Адрес"
"reverse" = "Обратный" "reverse" = "Обратный"
"domain" = "Домен" "domain" = "Домен"

View File

@ -390,6 +390,7 @@
"editOutbound" = "Chỉnh sửa gửi đi" "editOutbound" = "Chỉnh sửa gửi đi"
"editReverse" = "Chỉnh sửa ngược lại" "editReverse" = "Chỉnh sửa ngược lại"
"tag" = "Thẻ" "tag" = "Thẻ"
"tagDesc" = "thẻ duy nhất"
"address" = "Địa chỉ" "address" = "Địa chỉ"
"reverse" = "Đảo ngược" "reverse" = "Đảo ngược"
"domain" = "Miền" "domain" = "Miền"

View File

@ -390,6 +390,7 @@
"editOutbound" = "编辑出站" "editOutbound" = "编辑出站"
"editReverse" = "编辑反向" "editReverse" = "编辑反向"
"tag" = "标签" "tag" = "标签"
"tagDesc" = "独特的标签"
"address" = "地址" "address" = "地址"
"rreverse" = "反转" "rreverse" = "反转"
"domain" = "域名" "domain" = "域名"