|
@@ -1054,12 +1054,13 @@
|
|
});
|
|
});
|
|
},
|
|
},
|
|
changeObsCode() {
|
|
changeObsCode() {
|
|
- if (this.obsSettings == ''){
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
if(this.cm != null) {
|
|
if(this.cm != null) {
|
|
this.cm.toTextArea();
|
|
this.cm.toTextArea();
|
|
}
|
|
}
|
|
|
|
+ if (this.obsSettings == ''){
|
|
|
|
+ this.cm = null;
|
|
|
|
+ return
|
|
|
|
+ }
|
|
textAreaObj = document.getElementById('obsSetting');
|
|
textAreaObj = document.getElementById('obsSetting');
|
|
textAreaObj.value = this[this.obsSettings];
|
|
textAreaObj.value = this[this.obsSettings];
|
|
this.cm = CodeMirror.fromTextArea(textAreaObj, this.cmOptions);
|
|
this.cm = CodeMirror.fromTextArea(textAreaObj, this.cmOptions);
|
|
@@ -1283,21 +1284,11 @@
|
|
tmpBalancer.strategy = {
|
|
tmpBalancer.strategy = {
|
|
'type': balancer.strategy
|
|
'type': balancer.strategy
|
|
};
|
|
};
|
|
- if (balancer.strategy == 'leastPing'){
|
|
|
|
- if (!newTemplateSettings.observatory)
|
|
|
|
- newTemplateSettings.observatory = this.defaultObservatory;
|
|
|
|
- if (!newTemplateSettings.observatory.subjectSelector.includes(balancer.tag))
|
|
|
|
- newTemplateSettings.observatory.subjectSelector.push(balancer.tag);
|
|
|
|
- }
|
|
|
|
- if (balancer.strategy == 'leastLoad'){
|
|
|
|
- if (!newTemplateSettings.burstObservatory)
|
|
|
|
- newTemplateSettings.burstObservatory = this.defaultBurstObservatory;
|
|
|
|
- if (!newTemplateSettings.burstObservatory.subjectSelector.includes(balancer.tag))
|
|
|
|
- newTemplateSettings.burstObservatory.subjectSelector.push(balancer.tag);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
newTemplateSettings.routing.balancers.push(tmpBalancer);
|
|
newTemplateSettings.routing.balancers.push(tmpBalancer);
|
|
this.templateSettings = newTemplateSettings;
|
|
this.templateSettings = newTemplateSettings;
|
|
|
|
+ if (balancer.strategy == 'leastPing' || balancer.strategy == 'leastLoad')
|
|
|
|
+ this.updateObservatorySelectors();
|
|
balancerModal.close();
|
|
balancerModal.close();
|
|
this.changeObsCode();
|
|
this.changeObsCode();
|
|
},
|
|
},
|
|
@@ -1332,18 +1323,6 @@
|
|
tmpBalancer.strategy = {
|
|
tmpBalancer.strategy = {
|
|
'type': balancer.strategy
|
|
'type': balancer.strategy
|
|
};
|
|
};
|
|
- if (balancer.strategy == 'leastPing'){
|
|
|
|
- if (!newTemplateSettings.observatory)
|
|
|
|
- newTemplateSettings.observatory = this.defaultObservatory;
|
|
|
|
- if (!newTemplateSettings.observatory.subjectSelector.includes(balancer.tag))
|
|
|
|
- newTemplateSettings.observatory.subjectSelector.push(balancer.tag);
|
|
|
|
- }
|
|
|
|
- if (balancer.strategy == 'leastLoad'){
|
|
|
|
- if (!newTemplateSettings.burstObservatory)
|
|
|
|
- newTemplateSettings.burstObservatory = this.defaultBurstObservatory;
|
|
|
|
- if (!newTemplateSettings.burstObservatory.subjectSelector.includes(balancer.tag))
|
|
|
|
- newTemplateSettings.burstObservatory.subjectSelector.push(balancer.tag);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
newTemplateSettings.routing.balancers[index] = tmpBalancer;
|
|
newTemplateSettings.routing.balancers[index] = tmpBalancer;
|
|
@@ -1356,12 +1335,47 @@
|
|
});
|
|
});
|
|
}
|
|
}
|
|
this.templateSettings = newTemplateSettings;
|
|
this.templateSettings = newTemplateSettings;
|
|
|
|
+ if (balancer.strategy == 'leastPing' || balancer.strategy == 'leastLoad')
|
|
|
|
+ this.updateObservatorySelectors();
|
|
balancerModal.close();
|
|
balancerModal.close();
|
|
this.changeObsCode();
|
|
this.changeObsCode();
|
|
},
|
|
},
|
|
isEdit: true
|
|
isEdit: true
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
+ updateObservatorySelectors(){
|
|
|
|
+ newTemplateSettings = this.templateSettings;
|
|
|
|
+ const leastPings = this.balancersData.filter((b) => b.strategy == 'leastPing');
|
|
|
|
+ const leastLoads = this.balancersData.filter((b) => b.strategy == 'leastLoad');
|
|
|
|
+ if (leastPings.length>0){
|
|
|
|
+ if (!newTemplateSettings.observatory)
|
|
|
|
+ newTemplateSettings.observatory = this.defaultObservatory;
|
|
|
|
+ newTemplateSettings.observatory.subjectSelector = [];
|
|
|
|
+ leastPings.forEach((b) => {
|
|
|
|
+ b.selector.forEach((s) => {
|
|
|
|
+ if (!newTemplateSettings.observatory.subjectSelector.includes(s))
|
|
|
|
+ newTemplateSettings.observatory.subjectSelector.push(s);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ delete newTemplateSettings.observatory
|
|
|
|
+ }
|
|
|
|
+ if (leastLoads.length>0){
|
|
|
|
+ if (!newTemplateSettings.burstObservatory)
|
|
|
|
+ newTemplateSettings.burstObservatory = this.defaultBurstObservatory;
|
|
|
|
+ newTemplateSettings.burstObservatory.subjectSelector = [];
|
|
|
|
+ leastLoads.forEach((b) => {
|
|
|
|
+ b.selector.forEach((s) => {
|
|
|
|
+ if (!newTemplateSettings.burstObservatory.subjectSelector.includes(s))
|
|
|
|
+ newTemplateSettings.burstObservatory.subjectSelector.push(s);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ delete newTemplateSettings.burstObservatory
|
|
|
|
+ }
|
|
|
|
+ this.templateSettings = newTemplateSettings;
|
|
|
|
+ this.changeObsCode();
|
|
|
|
+ },
|
|
deleteBalancer(index) {
|
|
deleteBalancer(index) {
|
|
let newTemplateSettings = { ...this.templateSettings };
|
|
let newTemplateSettings = { ...this.templateSettings };
|
|
|
|
|
|
@@ -1371,27 +1385,14 @@
|
|
// Remove from settings
|
|
// Remove from settings
|
|
let realIndex = newTemplateSettings.routing.balancers.findIndex((b) => b.tag === removedBalancer.tag);
|
|
let realIndex = newTemplateSettings.routing.balancers.findIndex((b) => b.tag === removedBalancer.tag);
|
|
newTemplateSettings.routing.balancers.splice(realIndex, 1);
|
|
newTemplateSettings.routing.balancers.splice(realIndex, 1);
|
|
-
|
|
|
|
- // Remove tag from observatory
|
|
|
|
- if (newTemplateSettings.observatory){
|
|
|
|
- newTemplateSettings.observatory.subjectSelector = newTemplateSettings.observatory.subjectSelector.filter(s => s != removedBalancer.tag);
|
|
|
|
- }
|
|
|
|
- if (newTemplateSettings.burstObservatory){
|
|
|
|
- newTemplateSettings.burstObservatory.subjectSelector = newTemplateSettings.burstObservatory.subjectSelector.filter(s => s != removedBalancer.tag);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Remove related routing rules
|
|
|
|
- newTemplateSettings.routing.rules.forEach((rule) => {
|
|
|
|
- if (rule.balancerTag === removedBalancer.tag) {
|
|
|
|
- delete rule.balancerTag;
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
|
|
// Update balancers property to an empty array if there are no more balancers
|
|
// Update balancers property to an empty array if there are no more balancers
|
|
if (newTemplateSettings.routing.balancers.length === 0) {
|
|
if (newTemplateSettings.routing.balancers.length === 0) {
|
|
delete newTemplateSettings.routing.balancers;
|
|
delete newTemplateSettings.routing.balancers;
|
|
}
|
|
}
|
|
this.templateSettings = newTemplateSettings;
|
|
this.templateSettings = newTemplateSettings;
|
|
|
|
+ this.updateObservatorySelectors();
|
|
|
|
+ this.obsSettings = '';
|
|
this.changeObsCode()
|
|
this.changeObsCode()
|
|
},
|
|
},
|
|
addDNSServer(){
|
|
addDNSServer(){
|
|
@@ -1649,22 +1650,8 @@
|
|
this.templateSettings = newTemplateSettings;
|
|
this.templateSettings = newTemplateSettings;
|
|
},
|
|
},
|
|
},
|
|
},
|
|
- observatoryEnable: {
|
|
|
|
- get: function () { return this.templateSettings != null && this.templateSettings.observatory },
|
|
|
|
- set: function (v) {
|
|
|
|
- newTemplateSettings = this.templateSettings;
|
|
|
|
- newTemplateSettings.observatory = v ? this.defaultObservatory : undefined;
|
|
|
|
- this.templateSettings = newTemplateSettings;
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- burstObservatoryEnable: {
|
|
|
|
- get: function () { return this.templateSettings != null && this.templateSettings.burstObservatory },
|
|
|
|
- set: function (v) {
|
|
|
|
- newTemplateSettings = this.templateSettings;
|
|
|
|
- newTemplateSettings.burstObservatory = v ? this.defaultBurstObservatory : undefined;
|
|
|
|
- this.templateSettings = newTemplateSettings;
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
|
|
+ observatoryEnable: function () { return this.templateSettings != null && this.templateSettings.observatory != undefined },
|
|
|
|
+ burstObservatoryEnable: function () { return this.templateSettings != null && this.templateSettings.burstObservatory != undefined },
|
|
freedomStrategy: {
|
|
freedomStrategy: {
|
|
get: function () {
|
|
get: function () {
|
|
if (!this.templateSettings) return "AsIs";
|
|
if (!this.templateSettings) return "AsIs";
|