Timoney, Daniel (dt5972) | 324ee36 | 2017-02-15 10:37:53 -0500 | [diff] [blame^] | 1 | <!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-FC AdminPortal</title> |
| 10 | <script class="init"> |
| 11 | $(document).ready(function() { |
| 12 | $('#vrr_credentials').DataTable( { |
| 13 | "order": [[ 0, "asc" ]] |
| 14 | } ); |
| 15 | } ); |
| 16 | </script> |
| 17 | |
| 18 | </head> |
| 19 | <body> |
| 20 | |
| 21 | <div class="well well-sm"> |
| 22 | <h3>VRR Credentials</h3> |
| 23 | </div> |
| 24 | |
| 25 | <% if ( typeof result != 'undefined' ) { |
| 26 | if (result.code.length > 0) { |
| 27 | if ( result.code == 'success' ) { %> |
| 28 | <div class='alert alert-success' role='alert'> |
| 29 | <% |
| 30 | for ( x in result.msg ){ %> |
| 31 | <div><%= result.msg[x] %></div> |
| 32 | <% } %> |
| 33 | </div> |
| 34 | <% } else { %> |
| 35 | <div class='alert alert-danger' role='danger'> |
| 36 | <% |
| 37 | for ( x in result.msg ){ %> |
| 38 | <div><%= result.msg[x] %></div> |
| 39 | <% } %> |
| 40 | </div> |
| 41 | <% } %> |
| 42 | <% } %> |
| 43 | <% } %> |
| 44 | |
| 45 | <% if( typeof privilege != 'undefined'){ |
| 46 | var priv = privilege.privilege; |
| 47 | } else { |
| 48 | var priv = 'A'; |
| 49 | } %> |
| 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_vrr_credentials"> |
| 57 | Add VRR Credentials |
| 58 | </button> |
| 59 | </div> |
| 60 | <% } %> |
| 61 | |
| 62 | <table id="vrr_CREDENTIALS" class="table table-hover table-condensed"> |
| 63 | <thead> |
| 64 | <tr> |
| 65 | <th>*Server Name</th> |
| 66 | <th>*IP Address</th> |
| 67 | <th>*Username</th> |
| 68 | <th>*Password</th> |
| 69 | <% if(priv == 'A'){ %> |
| 70 | <th>Action</th> |
| 71 | <% } %> |
| 72 | </tr> |
| 73 | </thead> |
| 74 | <tbody> |
| 75 | <% rows.forEach( function(row) { %> |
| 76 | <tr> |
| 77 | <td><%= row.server_name %></td> |
| 78 | <td><%= row.ip_address %></td> |
| 79 | <td><%= row.username %></td> |
| 80 | <td>*****</td> |
| 81 | <% if(priv == 'A') { %> |
| 82 | <td> |
| 83 | <button type="button" class="btn btn-default btn-xs" |
| 84 | onclick="updateVrrCredentials('<%= row.server_name %>', '<%= row.ip_address %>', '<%= row.username %>','<%= row.password %>');">Update</button> |
| 85 | <button type="button" class="btn btn-default btn-xs" |
| 86 | onclick="deleteVrrCredentials('<%= row.server_name %>');">Delete</button> |
| 87 | </td> |
| 88 | <% } %> |
| 89 | </tr> |
| 90 | <% }); %> |
| 91 | </tbody> |
| 92 | </table> |
| 93 | |
| 94 | </div> |
| 95 | |
| 96 | <% include ../partials/vrr_credentials %> |
| 97 | <footer> |
| 98 | <% include ../partials/footer %> |
| 99 | </footer> |
| 100 | |
| 101 | <script type="text/javascript"> |
| 102 | function submitVrrCredentials(form) |
| 103 | { |
| 104 | var errorMsg=''; |
| 105 | var server_name = ''; |
| 106 | var ip_address = ''; |
| 107 | var username = ''; |
| 108 | var password = ''; |
| 109 | var confirm_password = ''; |
| 110 | |
| 111 | if ( form.name == 'addForm' ) |
| 112 | { |
| 113 | server_name = form.nf_server_name; |
| 114 | ip_address = form.nf_ip_address; |
| 115 | username = form.nf_username; |
| 116 | password = form.nf_password; |
| 117 | confirm_password = form.nf_confirm_password; |
| 118 | |
| 119 | if ( (server_name.value == null) || (server_name.value == "") || isblank(server_name.value) ) |
| 120 | { |
| 121 | errorMsg += 'Server Name is required.<br>'; |
| 122 | } |
| 123 | if ( (ip_address.value == null) || (ip_address.value == "") || isblank(ip_address.value) ) |
| 124 | { |
| 125 | errorMsg += 'IP Address is required.<br>'; |
| 126 | } |
| 127 | if ( (password.value == null) || (password.value == "") || isblank(password.value) ) |
| 128 | { |
| 129 | errorMsg += 'Password is required.<br>'; |
| 130 | } |
| 131 | if ( (confirm_password.value == null) || (confirm_password.value == "") || isblank(confirm_password.value) ) |
| 132 | { |
| 133 | errorMsg += 'Confirm Password is required.<br>'; |
| 134 | } |
| 135 | if( errorMsg.length > 0 ) { |
| 136 | bootbox.alert(errorMsg); |
| 137 | return; |
| 138 | } |
| 139 | if ( password.value != confirm_password.value ) |
| 140 | { |
| 141 | bootbox.alert('Passwords do not match.'); |
| 142 | return; |
| 143 | } |
| 144 | } |
| 145 | else |
| 146 | { |
| 147 | server_name = form.uf_server_name; |
| 148 | ip_address = form.uf_ip_address; |
| 149 | username = form.uf_username; |
| 150 | password = form.uf_password; |
| 151 | confirm_password = form.uf_confirm_password; |
| 152 | |
| 153 | if ( (server_name.value == null) || (server_name.value == "") || isblank(server_name.value) ) |
| 154 | { |
| 155 | errorMsg += 'Server Name is required.<br>'; |
| 156 | } |
| 157 | if ( (ip_address.value == null) || (ip_address.value == "") || isblank(ip_address.value) ) |
| 158 | { |
| 159 | errorMsg += 'IP Address is required.<br>'; |
| 160 | } |
| 161 | if ( (password.value == null) || (password.value == "") || isblank(password.value) ) |
| 162 | { |
| 163 | errorMsg += 'Password is required.<br>'; |
| 164 | } |
| 165 | if ( (confirm_password.value == null) || (confirm_password.value == "") || isblank(confirm_password.value) ) |
| 166 | { |
| 167 | errorMsg += 'Confirm Password is required.<br>'; |
| 168 | } |
| 169 | if( errorMsg.length > 0 ) { |
| 170 | bootbox.alert(errorMsg); |
| 171 | return; |
| 172 | } |
| 173 | |
| 174 | if ( password.value != confirm_password.value ) |
| 175 | { |
| 176 | bootbox.alert('Passwords do not match.'); |
| 177 | return; |
| 178 | } |
| 179 | } |
| 180 | form.submit(); |
| 181 | } |
| 182 | |
| 183 | function updateVrrCredentials(server_name,ip_address,username,password) { |
| 184 | |
| 185 | document.getElementById('uf_server_name').value=server_name; |
| 186 | document.getElementById('uf_key_server_name').value=server_name; |
| 187 | document.getElementById('uf_ip_address').value=ip_address; |
| 188 | document.getElementById('uf_username').value=username; |
| 189 | document.getElementById('uf_password').value=password; |
| 190 | document.getElementById('uf_confirm_password').value=password; |
| 191 | |
| 192 | $('#update_vrr_credentials').modal('show'); |
| 193 | } |
| 194 | |
| 195 | function deleteVrrCredentials(server_name) { |
| 196 | |
| 197 | var url_string = encodeURI("/sdnfc/deleteVrrCredentials?server_name=" + server_name); |
| 198 | |
| 199 | bootbox.confirm({ |
| 200 | message: "Are you sure you want to delete VRR Credential [ " + server_name + " ]", |
| 201 | callback: function(result) { |
| 202 | if ( result ) |
| 203 | { |
| 204 | location.assign(url_string); |
| 205 | } |
| 206 | return; |
| 207 | }, |
| 208 | buttons: { |
| 209 | cancel: { |
| 210 | label: "Cancel" |
| 211 | }, |
| 212 | confirm: { |
| 213 | label: "Yes" |
| 214 | } |
| 215 | } |
| 216 | }); |
| 217 | } |
| 218 | |
| 219 | </script> |
| 220 | |
| 221 | </body> |
| 222 | </html> |
| 223 | |