Timoney, Daniel (dt5972) | 324ee36 | 2017-02-15 10:37:53 -0500 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html lang="en"> |
| 3 | <head> |
| 4 | |
| 5 | <meta charset="UTF-8" /> |
| 6 | <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
| 7 | <% include ../partials/head %> |
| 8 | <% include ../partials/header %> |
| 9 | <script type="text/javascript" src="/javascripts/admportal.js" async></script> |
| 10 | <title>SDN-C AdminPortal</title> |
| 11 | |
| 12 | |
| 13 | <script class="init"> |
| 14 | $(document).ready(function() { |
| 15 | $('#routerMaster').DataTable( { |
| 16 | "order": [[ 0, "asc" ]] |
| 17 | } ); |
| 18 | } ); |
| 19 | </script> |
| 20 | </head> |
| 21 | |
| 22 | <body> |
| 23 | |
| 24 | <div class="well well-sm"> |
| 25 | <h3>Router Master</h3> |
| 26 | </div> |
| 27 | |
| 28 | <% if ( typeof result != 'undefined' ) { |
| 29 | if (result.code.length > 0) { |
| 30 | if ( result.code == 'success' ) { %> |
| 31 | <div class='alert alert-success' role='alert'> |
| 32 | <% |
| 33 | for ( x in result.msg ){ %> |
| 34 | <div><%= result.msg[x] %></div> |
| 35 | <% } %> |
| 36 | </div> |
| 37 | <% } else { %> |
| 38 | <div class='alert alert-danger' role='danger'> |
| 39 | <% |
| 40 | for ( x in result.msg ){ %> |
| 41 | <div><%= result.msg[x] %></div> |
| 42 | <% } %> |
| 43 | </div> |
| 44 | <% } %> |
| 45 | <% } %> |
| 46 | <% } %> |
| 47 | |
| 48 | <% if( typeof privilege != 'undefined'){ |
| 49 | var priv = privilege.privilege; |
| 50 | } else { |
| 51 | var priv = 'A'; |
| 52 | } %> |
| 53 | |
| 54 | |
| 55 | <div class="container-fluid"> |
| 56 | |
| 57 | <% if(priv == 'A'){ %> |
| 58 | <div class="actions" style="padding:15px 0px;"> |
| 59 | <button class="btn btn-primary btn-md" data-toggle="modal" data-target="#add_router_master">Add Router</button> |
| 60 | </div> |
| 61 | <% } %> |
| 62 | |
| 63 | <table id="routerMaster" class="table table-hover table-condensed"> |
| 64 | <thead> |
| 65 | <tr> |
| 66 | <th>*CRS Name</th> |
| 67 | <th>Loopback IP</th> |
| 68 | <% if(priv == 'A'){ %> |
| 69 | <th>Action</th> |
| 70 | <% } %> |
| 71 | </tr> |
| 72 | </thead> |
| 73 | <tbody> |
| 74 | <% rows.forEach( function(row) { %> |
| 75 | <tr> |
| 76 | <td><%= row.crs_name %></td> |
| 77 | <td><%= row.loopback_ip %></td> |
| 78 | <% if(priv == 'A') { %> |
| 79 | <td> |
| 80 | <button type="button" class="btn btn-default btn-xs" onclick="updateRouterMaster('<%= row.crs_name %>', |
| 81 | '<%= row.loopback_ip %>');">Update</button> |
| 82 | <button type="button" class="btn btn-default btn-xs" onclick="deleteRouterMaster('<%= row.crs_name %>');">Delete</button> |
| 83 | </td> |
| 84 | <% } %> |
| 85 | </tr> |
| 86 | <% }); %> |
| 87 | </tbody> |
| 88 | </table> |
| 89 | </div> |
| 90 | |
| 91 | <% include ../partials/router_master %> |
| 92 | <footer> |
| 93 | <% include ../partials/footer %> |
| 94 | </footer> |
| 95 | |
| 96 | <script type="text/javascript"> |
| 97 | function saveRouterMaster(form) |
| 98 | { |
| 99 | var errorMsg=''; |
| 100 | var crs_name = ''; |
| 101 | var loopback_ip = ''; |
| 102 | |
| 103 | if ( form.name == 'addForm' ) |
| 104 | { |
| 105 | crs_name = form.nf_crs_name; |
| 106 | loopback_ip = form.nf_loopback_ip; |
| 107 | } |
| 108 | else |
| 109 | { |
| 110 | crs_name = form.uf_crs_name; |
| 111 | loopback_ip = form.uf_loopback_ip; |
| 112 | } |
| 113 | |
| 114 | |
| 115 | if ( (crs_name.value == null) || (crs_name.value == "") || isblank(crs_name.value) ) |
| 116 | { |
| 117 | errorMsg += 'CRS Name is required.<br>'; |
| 118 | } |
| 119 | if ( (loopback_ip.value == null) || (loopback_ip.value == "") || isblank(loopback_ip.value) ) |
| 120 | { |
| 121 | errorMsg += 'Loopback IP is required.<br>'; |
| 122 | } |
| 123 | if( errorMsg.length > 0 ) { |
| 124 | bootbox.alert(errorMsg); |
| 125 | return; |
| 126 | } |
| 127 | form.submit(); |
| 128 | } |
| 129 | |
| 130 | function updateRouterMaster(crs_name,loopback_ip) { |
| 131 | |
| 132 | document.getElementById('uf_crs_name').value=crs_name; |
| 133 | document.getElementById('uf_loopback_ip').value=loopback_ip; |
| 134 | document.getElementById('uf_key_crs_name').value=crs_name; |
| 135 | |
| 136 | $('#update_router_master').modal('show'); |
| 137 | } |
| 138 | |
| 139 | function deleteRouterMaster(crs_name) { |
| 140 | |
| 141 | var url_string = encodeURI("/tunnel/deleteRouterMaster?crs_name=" + crs_name); |
| 142 | |
| 143 | bootbox.confirm({ |
| 144 | message: "Are you sure you want to delete this Router [" + crs_name + "]", |
| 145 | callback: function(result) { |
| 146 | if ( result ) |
| 147 | { |
| 148 | location.assign(url_string); |
| 149 | } |
| 150 | return; |
| 151 | }, |
| 152 | buttons: { |
| 153 | cancel: { |
| 154 | label: "Cancel" |
| 155 | }, |
| 156 | confirm: { |
| 157 | label: "Yes" |
| 158 | } |
| 159 | } |
| 160 | }); |
| 161 | } |
| 162 | |
| 163 | </script> |
| 164 | |
| 165 | </body> |
| 166 | </html> |
| 167 | |