From 8bec553e355ec276a89cd802da7c1a5dd8e97f10 Mon Sep 17 00:00:00 2001 From: Karl Newell Date: Thu, 9 Jan 2020 17:36:40 -0500 Subject: [PATCH] Update main.py ui/index.html ui/ui.js Add JS support for dynamic VRF selection based on config Fix dict anomalies when VRF is not present on router --- main.py | 4 +++- ui/index.html | 4 ---- ui/ui.js | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index d307dbf..e6cbe6a 100644 --- a/main.py +++ b/main.py @@ -431,6 +431,8 @@ def loadFlowRouteConfig(self): else: for vrf in self.vrfs: + _vrf_data = dict() + _data = dict() family = '' if vrf == 'default': try: @@ -489,7 +491,7 @@ def loadFlowRouteConfig(self): 'srcPrefix': route['match']['source'] if 'source' in route['match'] else None }) - return True, self.flow_config + return True, self.flow_config, self.vrfs def parseFlow(self, flow=None): _flow = flow.split(',') diff --git a/ui/index.html b/ui/index.html index cdffe57..6ba8452 100644 --- a/ui/index.html +++ b/ui/index.html @@ -174,8 +174,6 @@
@@ -265,8 +263,6 @@
diff --git a/ui/ui.js b/ui/ui.js index 1b9f68a..0c56fb3 100644 --- a/ui/ui.js +++ b/ui/ui.js @@ -44,6 +44,23 @@ $(document).ready(function () { var return_data = new Array(); + selectVrf = document.getElementById('selectVrf'); + selectModVrf = document.getElementById('selectModVrf'); + + $.each( response[2], function( index, value ) { + var opt = document.createElement('option'); + opt.text = value; + opt.value = value; + selectVrf.appendChild(opt); + }); + + $.each( response[2], function( index, value ) { + var opt = document.createElement('option'); + opt.text = value; + opt.value = value; + selectModVrf.appendChild(opt); + }); + $.each( response[1], function( name, flow ) { var action_val = new Array();