blob: 748dbbe37f70e1897bea0be80f50b396699dd6e5 [file] [log] [blame]
Timoney, Daniel (dt5972)324ee362017-02-15 10:37:53 -05001<!DOCTYPE html>
2<html lang="en">
3<head>
4 <meta charset="UTF-8" />
5 <meta http-equiv="X-UA-Compatible" content="IE=edge">
6 <% include ../partials/head %>
7 <% include ../partials/header %>
8 <script type="text/javascript" src="/javascripts/admportal.js" async></script>
9 <title>SDN-C AdminPortal</title>
10
11<script class="init">
12 $(document).ready(function() {
13 $('#nb_vlan_ranges').DataTable( {
14 "order": [[ 0, "asc" ]]
15 } );
16} );
17</script>
18
19</head>
20<body>
21
22<div class="well well-sm">
23<h3>NetBond VLAN Ranges</h3>
24</div>
25
26<% if ( typeof result != 'undefined' ) {
27 if (result.code.length > 0) {
28 if ( result.code == 'success' ) { %>
29 <div class='alert alert-success' role='alert'>
30 <%
31 for ( x in result.msg ){ %>
32 <div><%= result.msg[x] %></div>
33 <% } %>
34 </div>
35 <% } else { %>
36 <div class='alert alert-danger' role='danger'>
37 <%
38 for ( x in result.msg ){ %>
39 <div><%= result.msg[x] %></div>
40 <% } %>
41 </div>
42 <% } %>
43 <% } %>
44<% } %>
45
46<% if( typeof privilege != 'undefined'){
47 var priv = privilege.privilege;
48} else {
49 var priv = 'A';
50} %>
51
52<div class="container-fluid">
53
54 <% if(priv == 'A'){ %>
55 <div class="actions" style="padding:15px 0px;">
56 <button class="btn btn-primary" data-toggle="modal" data-target="#add_vlan_range">
57 Add Range
58 </button>
59 </div>
60 <% } %>
61
62 <table id="nb_vlan_ranges" class="table table-hover table-condensed">
63 <thead>
64 <tr>
65 <th>Vlan Plan Id</th>
66 <th>Purpose</th>
67 <th>Range Start</th>
68 <th>Range End</th>
69 <th>Plan Type</th>
70 <th>Pool Generated</th>
71 <% if(priv == 'A'){ %>
72 <th>Action</th>
73 <% } %>
74 </tr>
75 </thead>
76 <tbody>
77 <% rows.forEach( function(row) { %>
78 <tr>
79 <td><%= row.vlan_plan_id %></td>
80 <td><%= row.purpose %></td>
81 <td><%= row.range_start %></td>
82 <td><%= row.range_end %></td>
83 <td><%= row.plan_type %></td>
84 <td><%= row.generated %></td>
85 <td>
86 <% if (row.generated == 'N' && priv == 'A'){ %>
87 <button type="button" class="btn btn-default btn-xs" onclick="generateVlanPool();">Generate Pool</button>
88 <% } else { %>
89 <button type="button" class="btn btn-default btn-xs disabled"
90 onclick="generateVlanPool('<%= row.purpose %>', '<%= row.vlan_plan_id %>',
91 '<%= row.range_start %>', '<%= row.range_end %>',
92 '<%= row.plan_type %>');">Generate Pool</button>
93 <% } %>
94 <% if (row.generated == 'N'){ %>
95 <button type="button" class="btn btn-default btn-xs disabled" onclick="viewNbVlanPool('<%= row.vlan_plan_id %>','<%= row.range_start %>', '<%= row.range_end %>');">View Pool</button>
96 <% } else { %>
97 <button type="button" class="btn btn-default btn-xs" onclick="viewNbVlanPool('<%= row.vlan_plan_id %>','<%= row.range_start %>', '<%= row.range_end %>');">View Pool</button>
98 <% } %>
99 <% if(priv == 'A') { %>
100 <button type="button" class="btn btn-default btn-xs"
101 onclick="deleteNbVlanRange('<%= row.vlan_plan_id %>',
102 '<%= row.plan_type %>', '<%= row.purpose %>', '<%= row.range_start %>',
103 '<%= row.range_end %>');">Delete</button>
104 <% } %>
105 </td>
106 </tr>
107 <% }); %>
108 </tbody>
109 </table>
110</div>
111
112<% include ../partials/nb_vlan_range %>
113<footer>
114 <% include ../partials/footer %>
115</footer>
116
117<script type="text/javascript">
118
119function generateVlanPool(purpose,vlan_plan_id,range_start,range_end,plan_type)
120{
121 var url_string = encodeURI("/gamma/generateNbVlanPool?vlan_plan_id=" + vlan_plan_id
122 + "&range_start=" + range_start + "&range_end=" + range_end
123 + "&plan_type=" + plan_type + "&purpose=" + purpose);
124 location.assign(url_string);
125 return;
126}
127function viewNbVlanPool(vlan_plan_id, range_start, range_end)
128{
129 var url_string = encodeURI("/gamma/getNbVlanPool?vlan_plan_id=" + vlan_plan_id
130 + "&range_start=" + range_start + "&range_end=" + range_end);
131 location.assign(url_string);
132 return;
133}
134function deleteNbVlanRange(vlan_plan_id,plan_type,purpose,range_start,range_end) {
135
136 bootbox.confirm({
137 message: "Are you sure you want to delete this VLAN Range[" + vlan_plan_id + "]",
138 callback: function(result) {
139 if ( result )
140 {
141 var url_string = encodeURI(
142 "/gamma/deleteNbVlanRange?vlan_plan_id=" + vlan_plan_id
143 + "&plan_type=" + plan_type + "&purpose=" + purpose
144 + "&range_start=" + range_start + "&range_end=" + range_end);
145 location.assign(url_string);
146 }
147 return;
148 },
149 buttons: {
150 cancel: {
151 label: "Cancel"
152 },
153 confirm: {
154 label: "Yes"
155 }
156 }
157 });
158}
159
160function saveNbVlanRange(form)
161{
162 var errorMsg='';
163 var plan_type = form.nf_plan_type.value;
164 var purpose = form.nf_purpose.value;
165 var range_start = form.nf_range_start.value;
166 var range_end = form.nf_range_end.value;
167
168 if ( (range_start == null) || (range_start == "") || isblank(range_start) )
169 {
170 errorMsg += 'Range Start is required.<br>';
171 }
172 if ( (range_end == null) || (range_end == "") || isblank(range_start) )
173 {
174 errorMsg += 'Range End is required.<br>';
175 }
176 if( errorMsg.length > 0 ) {
177 bootbox.alert(errorMsg);
178 return;
179 }
180
181 if ( !$.isNumeric(range_start) ) {
182 bootbox.alert('Range Start is not a number.');
183 return;
184 }
185 if ( !$.isNumeric(range_end) ) {
186 bootbox.alert('Range End is not a number.');
187 return;
188 }
189 var r_start = Number(range_start);
190 var r_end = Number(range_end);
191
192 if ( r_end < r_start )
193 {
194 bootbox.alert('Range End must be greater than Range Start.');
195 return;
196 }
197
198 form.submit();
199}
200
201</script>
202
203</body>
204</html>
205