feat(streams): Add multiple upstreams for basic load balancing

This commit is contained in:
Teagan glenn
2024-06-29 21:03:19 +00:00
parent 51414ced3a
commit f368985a60
9 changed files with 135 additions and 60 deletions

View File

@ -6,6 +6,8 @@ const template = require('./form.ejs');
require('jquery-serializejson');
require('jquery-mask-plugin');
require('selectize');
const Helpers = require("../../../lib/helpers");
const certListItemTemplate = require("../certificates-list-item.ejs");
module.exports = Mn.View.extend({
template: template,
@ -13,7 +15,7 @@ module.exports = Mn.View.extend({
ui: {
form: 'form',
forwarding_host: 'input[name="forwarding_host"]',
forwarding_hosts: 'input[name="forwarding_hosts"]',
type_error: '.forward-type-error',
buttons: '.modal-footer button',
switches: '.custom-switch-input',
@ -48,6 +50,10 @@ module.exports = Mn.View.extend({
data.tcp_forwarding = !!data.tcp_forwarding;
data.udp_forwarding = !!data.udp_forwarding;
if (typeof data.forwarding_hosts === 'string' && data.forwarding_hosts) {
data.forwarding_hosts = data.forwarding_hosts.split(',');
}
let method = App.Api.Nginx.Streams.create;
let is_new = true;
@ -76,6 +82,24 @@ module.exports = Mn.View.extend({
}
},
onRender: function () {
let view = this;
// Domain names
this.ui.forwarding_hosts.selectize({
delimiter: ',',
persist: false,
maxOptions: 15,
create: function (input) {
return {
value: input,
text: input
};
},
createFilter: /^(?:\*\.)?(?:[^.*]+\.?)+[^.]$/
});
},
initialize: function (options) {
if (typeof options.model === 'undefined' || !options.model) {
this.model = new StreamModel.Model();