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>SDNC-MLC AdminPortal</title> |
| 11 | |
| 12 | |
| 13 | <script class="init"> |
| 14 | $(document).ready(function() { |
| 15 | $('#roadmMapping').DataTable( { |
| 16 | "order": [[ 0, "asc" ]] |
| 17 | } ); |
| 18 | } ); |
| 19 | </script> |
| 20 | </head> |
| 21 | |
| 22 | <body> |
| 23 | |
| 24 | <div class="well well-sm"> |
| 25 | <h3>ROADM Mapping</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_roadm_mapping">Add Mapping</button> |
| 60 | </div> |
| 61 | <% } %> |
| 62 | |
| 63 | <table id="roadmMapping" class="table table-hover table-condensed"> |
| 64 | <thead> |
| 65 | <tr> |
| 66 | <th>*Router Name</th> |
| 67 | <th>*ROADM Name</th> |
| 68 | <th>*CLLI</th> |
| 69 | <th>*City Name</th> |
| 70 | <th>*LAT</th> |
| 71 | <th>*LON</th> |
| 72 | <th>*SNRC</th> |
| 73 | <% if(priv == 'A'){ %> |
| 74 | <th>Action</th> |
| 75 | <% } %> |
| 76 | </tr> |
| 77 | </thead> |
| 78 | <tbody> |
| 79 | <% rows.forEach( function(row) { %> |
| 80 | <tr> |
| 81 | <td><%= row.router_name %></td> |
| 82 | <td><%= row.roadm_name %></td> |
| 83 | <td><%= row.clli %></td> |
| 84 | <td><%= row.city_name %></td> |
| 85 | <td><%= row.lat %></td> |
| 86 | <td><%= row.lon %></td> |
| 87 | <td><%= row.snrc %></td> |
| 88 | <% if(priv == 'A') { %> |
| 89 | <td> |
| 90 | <button type="button" class="btn btn-default btn-xs" onclick="updateRoadmMapping('<%= row.router_name %>', |
| 91 | '<%= row.roadm_name %>', '<%= row.clli %>', '<%= row.city_name %>', '<%= row.lat %>', '<%= row.lon %>', '<%= row.snrc %>');">Update</button> |
| 92 | <button type="button" class="btn btn-default btn-xs" onclick="deleteRoadmMapping('<%= row.router_name %>');">Delete</button> |
| 93 | </td> |
| 94 | <% } %> |
| 95 | </tr> |
| 96 | <% }); %> |
| 97 | </tbody> |
| 98 | </table> |
| 99 | |
| 100 | <% if(priv == 'A'){ %> |
| 101 | <div class="actions" style="padding:0px 25px;"> |
| 102 | <form method="POST" action="/tunnel/uploadRoadmMapping" enctype="multipart/form-data"> |
| 103 | <div class="form-group"> |
| 104 | <label for="dest">File input</label> |
| 105 | <input name="filename" type="file" id="dest"> |
| 106 | <p class="help-block">Choose a file to upload.</p> |
| 107 | </div> |
| 108 | <button type="button" class="btn btn-default" onclick="uploadFile(this.form);">Upload File</button> |
| 109 | </form> |
| 110 | </div> |
| 111 | <% } %> |
| 112 | |
| 113 | </div> |
| 114 | |
| 115 | <% include ../partials/roadm_mapping %> |
| 116 | <footer> |
| 117 | <% include ../partials/footer %> |
| 118 | </footer> |
| 119 | |
| 120 | <script type="text/javascript"> |
| 121 | function saveRoadmMapping(form) |
| 122 | { |
| 123 | var errorMsg=''; |
| 124 | var router_name = ''; |
| 125 | var roadm_name = ''; |
| 126 | var clli = ''; |
| 127 | var city_name = ''; |
| 128 | var lat = ''; |
| 129 | var lon = ''; |
| 130 | var snrc = ''; |
| 131 | |
| 132 | if ( form.name == 'addForm' ) |
| 133 | { |
| 134 | router_name = form.nf_router_name; |
| 135 | roadm_name = form.nf_roadm_name; |
| 136 | clli = form.nf_clli; |
| 137 | city_name = form.nf_city_name; |
| 138 | lat = form.nf_lat; |
| 139 | lon = form.nf_lon; |
| 140 | snrc = form.nf_snrc; |
| 141 | } |
| 142 | else |
| 143 | { |
| 144 | router_name = form.uf_router_name; |
| 145 | roadm_name = form.uf_roadm_name; |
| 146 | clli = form.uf_clli; |
| 147 | city_name = form.uf_city_name; |
| 148 | lat = form.uf_lat; |
| 149 | lon = form.uf_lon; |
| 150 | snrc = form.uf_snrc; |
| 151 | } |
| 152 | |
| 153 | if ( (router_name.value == null) || (router_name.value == "") || isblank(router_name.value) ) |
| 154 | { |
| 155 | errorMsg += 'Router Name is required.<br>'; |
| 156 | } |
| 157 | if ( (roadm_name.value == null) || (roadm_name.value == "") || isblank(roadm_name.value) ) |
| 158 | { |
| 159 | errorMsg += 'ROADM Name is required.<br>'; |
| 160 | } |
| 161 | if ( (clli.value == null) || (clli.value == "") || isblank(clli.value) ) |
| 162 | { |
| 163 | errorMsg += 'CLLI is required.<br>'; |
| 164 | } |
| 165 | if ( (city_name.value == null) || (city_name.value == "") || isblank(city_name.value) ) |
| 166 | { |
| 167 | errorMsg += 'City Name is required.<br>'; |
| 168 | } |
| 169 | if ( (lat.value == null) || (lat.value == "") || isblank(lat.value) ) |
| 170 | { |
| 171 | errorMsg += 'LAT (latitude) is required.<br>'; |
| 172 | } |
| 173 | if ( (lon.value == null) || (lon.value == "") || isblank(lon.value) ) |
| 174 | { |
| 175 | errorMsg += 'LON (longitude) is required.<br>'; |
| 176 | } |
| 177 | if ( (snrc.value == null) || (snrc.value == "") || isblank(snrc.value) ) |
| 178 | { |
| 179 | errorMsg += 'SNRC is required.<br>'; |
| 180 | } |
| 181 | if( errorMsg.length > 0 ) { |
| 182 | bootbox.alert(errorMsg); |
| 183 | return; |
| 184 | } |
| 185 | form.submit(); |
| 186 | } |
| 187 | |
| 188 | function updateRoadmMapping(router_name,roadm_name,clli,city_name,lat,lon,snrc) { |
| 189 | |
| 190 | document.getElementById('uf_router_name').value=router_name; |
| 191 | document.getElementById('uf_roadm_name').value=roadm_name; |
| 192 | document.getElementById('uf_clli').value=clli; |
| 193 | document.getElementById('uf_city_name').value=city_name; |
| 194 | document.getElementById('uf_lat').value=lat; |
| 195 | document.getElementById('uf_lon').value=lon; |
| 196 | document.getElementById('uf_snrc').value=snrc; |
| 197 | document.getElementById('uf_key_router_name').value=router_name; |
| 198 | |
| 199 | $('#update_roadm_mapping').modal('show'); |
| 200 | } |
| 201 | |
| 202 | function deleteRoadmMapping(router_name) { |
| 203 | |
| 204 | var url_string = encodeURI("/tunnel/deleteRoadmMapping?router_name=" + router_name); |
| 205 | |
| 206 | bootbox.confirm({ |
| 207 | message: "Are you sure you want to delete this mapping? [" + router_name + "]", |
| 208 | callback: function(result) { |
| 209 | if ( result ) |
| 210 | { |
| 211 | location.assign(url_string); |
| 212 | } |
| 213 | return; |
| 214 | }, |
| 215 | buttons: { |
| 216 | cancel: { |
| 217 | label: "Cancel" |
| 218 | }, |
| 219 | confirm: { |
| 220 | label: "Yes" |
| 221 | } |
| 222 | } |
| 223 | }); |
| 224 | } |
| 225 | |
| 226 | </script> |
| 227 | |
| 228 | </body> |
| 229 | </html> |
| 230 | |