Skip to content

Commit

Permalink
first stab at using some templating for UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Nobrega authored and knewell committed May 21, 2019
1 parent 5f297d0 commit 7272960
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
9 changes: 6 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from jnpr.junos.exception import ConfigLoadError, CommitError
from data.fr import FlowRoutesTable, FlowFilterTable

env = Environment(loader=FileSystemLoader('ui'))

class MyDev(object):

Expand Down Expand Up @@ -519,13 +520,15 @@ def load_settings(self):
self.routers = config['routers']
self.vrfs = config['vrfs']


class BGPFlow(object):

@cherrypy.expose
def index(self):
return open('ui/index.html', 'r')

with open('ui/config.yml', 'r') as fp:
configvrf = yaml.load(fp)
vrflist = configvrf['vrfs']
tmpl = env.get_template('index.html')
return tmpl.render(first_option=vrflist[0], second_option=vrflist[1])

@cherrypy.expose
class BGPFlowWS(object):
Expand Down
10 changes: 5 additions & 5 deletions ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>BGP Flow Spec Demo</title>
<title>Internet2 BGP Portal</title>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.css">
Expand All @@ -33,8 +33,8 @@
</head>
<body>

<div class="container col-sm-9 col-md-8 col-lg-12"><h2 style="text-align:left;float:left;">DevOps against DDoS</h2>
<h2 style="text-align:right;float:right;" class="mainheader">Monitoring BGP FlowSpec with Junos PyEZ</h2></div>
<div class="container col-sm-9 col-md-8 col-lg-12"><h2 style="text-align:left;float:left;">Internet2</h2>
<h2 style="text-align:right;float:right;" class="mainheader">BGP FlowSpec Portal</h2></div>
<div id="exTab1" class="container col-sm-9 col-md-8 col-lg-12">
<ul class="nav nav-pills mynav">
<li class="active">
Expand Down Expand Up @@ -213,8 +213,8 @@ <h4 class="modal-title">Add new flow route</h4>
<label for="selectVrf" class="col-sm-2 col-form-label">VRF</label>
<div class="col-sm-3">
<select class="form-control" id="selectVrf">
<option selected="selected">default</option>
<option>trcps</option>
<option selected="selected">{{first_option}}</option>
<option>{{second_option}}</option>
</select>
</div>
</div>
Expand Down

0 comments on commit 7272960

Please sign in to comment.