Skip to content

Commit

Permalink
Merge pull request #517 from dOpensource/v0.721
Browse files Browse the repository at this point in the history
merge v0.721 into master
  • Loading branch information
mackhendricks committed May 18, 2023
2 parents 38ab970 + 2db6ceb commit 282d7bc
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 7 deletions.
18 changes: 12 additions & 6 deletions gui/dsiprouter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,8 @@ def displayInboundMapping():
gwgroups = db.query(GatewayGroups).filter(
(GatewayGroups.description.like(endpoint_filter)) | (GatewayGroups.description.like(carrier_filter))).all()

gatewayList = db.query(Gateways).all()

# sort endpoint groups by name
epgroups.sort(key=lambda x: strFieldsToDict(x.description)['name'].lower())
# sort gateway groups by type then by name
Expand All @@ -1094,7 +1096,7 @@ def displayInboundMapping():
debugException(ex)
return showError(type="http", code=ex.status_code, msg="Flowroute Credentials Not Valid")

return render_template('inboundmapping.html', rows=res, gwgroups=gwgroups, epgroups=epgroups, imported_dids=dids)
return render_template('inboundmapping.html', rows=res, gwgroups=gwgroups, epgroups=epgroups, imported_dids=dids, gatewayList=gatewayList)

except sql_exceptions.SQLAlchemyError as ex:
debugException(ex)
Expand Down Expand Up @@ -1283,11 +1285,15 @@ def addUpdateInboundMapping():
# Assign Gateway id to the gateway list
gwlist = Gateway.gwid

if not db.query(Address).filter(Address.ip_addr == settings.INTERNAL_IP_ADDR).scalar():
db.add(Address("myself", settings.INTERNAL_IP_ADDR, 32, 1, gwgroup=gwgroupid))
if settings.IPV6_ENABLED:
if not db.query(Address).filter(Address.ip_addr == settings.INTERNAL_IP6_ADDR).scalar():
db.add(Address("myself", settings.INTERNAL_IP6_ADDR, 32, 1, gwgroup=gwgroupid))
try:
if not db.query(Address).filter(Address.ip_addr == settings.INTERNAL_IP_ADDR).scalar():
db.add(Address("myself", settings.INTERNAL_IP_ADDR, 32, 1, gwgroup=gwgroupid))
if settings.IPV6_ENABLED:
if not db.query(Address).filter(Address.ip_addr == settings.INTERNAL_IP6_ADDR).scalar():
db.add(Address("myself", settings.INTERNAL_IP6_ADDR, 32, 1, gwgroup=gwgroupid))
except sql_exceptions.MultipleResultsFound as ex:
logging.info("Multiple Address rows found")


db.query(InboundMapping).filter(InboundMapping.ruleid == ruleid).update(
{'prefix': prefix, 'gwlist': gwlist, 'description': description}, synchronize_session=False)
Expand Down
16 changes: 16 additions & 0 deletions gui/static/js/inboundmapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@
var ruleid = $(c).find('tr:eq(' + row_index + ') td:eq(1)').text();
var prefix = $(c).find('tr:eq(' + row_index + ') td:eq(2)').text();
var gwgroupid = $(c).find('tr:eq(' + row_index + ') td:eq(3)').text();
var gwgroupname = $(c).find('tr:eq(' + row_index + ') td:eq(4)').text();
var rulename = $(c).find('tr:eq(' + row_index + ') td:eq(5)').text();
var gwlistid = $(c).find('tr:eq(' + row_index + ') td:eq(6)').text();
var hf_ruleid = $(c).find('tr:eq(' + row_index + ') td:eq(9)').text();
var hf_groupid = $(c).find('tr:eq(' + row_index + ') td:eq(10)').text();
var hf_gwgroupid = $(c).find('tr:eq(' + row_index + ') td:eq(11)').text();
Expand Down Expand Up @@ -156,6 +158,20 @@
else {
modal_body.find("input.toggle-failfwd").bootstrapToggle('off');
}


if (gwgroupname === 'Load Balancing Group'){

var selectedGateway = gw_mapping.find((the_gw) => {
return the_gw.id === parseInt(gwlistid);
});

modal_body.find("select.gwgroupid option").filter(function(){
return this.value === selectedGateway.option_value;
}).prop("selected", true);
}


});

$('#inboundmapping').on('click', '#open-Delete', function() {
Expand Down
9 changes: 9 additions & 0 deletions gui/templates/inboundmapping.html
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,15 @@ <h4 class="modal-title custom_align" id="Heading">Import DID's</h4>
{{ script_tag('combobox') }}
<script type="application/javascript">
var DID_LIST = JSON.parse("{{ imported_dids }}") || [];

var gw_mapping = [];
{% for gw in gatewayList %}
gw_mapping.push({
id: {{ gw['gwid'] }},
group: "{{ gw['description']|attrFilter('gwgroup') }}",
option_value: "lb_{{ gw['description']|attrFilter('gwgroup') }}_{{ gw['description']|attrFilter('gwgroup') }}",
});
{% endfor %}
</script>
{{ script_tag('inboundmapping') }}
{% endblock %}
2 changes: 1 addition & 1 deletion resources/git/hooks/post-commit
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ createMDCommentSection() {
local NAME="$1"
local CONTENT="$2"

printf '%s\n' "[//]: # (START_SECTION ${NAME}"
printf '%s\n' "[//]: # (START_SECTION ${NAME})"
printf '%s' "$CONTENT" | sed -e '$a\'
printf '%s\n' "END_SECTION ${NAME})"
}
Expand Down

0 comments on commit 282d7bc

Please sign in to comment.