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-C AdminPortal</title> |
| 10 | <script class="init"> |
| 11 | $(document).ready(function() { |
| 12 | $('#owbc_properties').DataTable( { |
| 13 | "order": [[ 0, "asc" ]] |
| 14 | } ); |
| 15 | } ); |
| 16 | </script> |
| 17 | |
| 18 | </head> |
| 19 | <body> |
| 20 | |
| 21 | <div class="well well-sm"> |
| 22 | <h3>OWBC Properties</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_owbc_properties"> |
| 57 | Add OWBC Properties |
| 58 | </button> |
| 59 | </div> |
| 60 | <% } %> |
| 61 | |
| 62 | <table id="owbc_properties" class="table table-hover table-condensed"> |
| 63 | <thead> |
| 64 | <tr> |
| 65 | <th>Controller ID</th> |
| 66 | <th>Base URL</th> |
| 67 | <th>Service Create Extension</th> |
| 68 | <th>Service Delete Extension</th> |
| 69 | <th>Auth Username</th> |
| 70 | <th>Auth Password</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.controller_id %></td> |
| 80 | <td><%= row.base_uri %></td> |
| 81 | <td><%= row.service_create_extension %></td> |
| 82 | <td><%= row.service_delete_extension %></td> |
| 83 | <td><%= row.auth_username %></td> |
| 84 | <td>*****</td> |
| 85 | <% if(priv == 'A') { %> |
| 86 | <td> |
| 87 | <button type="button" class="btn btn-default btn-xs" |
| 88 | onclick="updateOwbcProperties('<%=row.controller_id %>','<%= row.base_uri %>','<%= row.service_create_extension %>','<%= row.service_delete_extension %>','<%= row.auth_username %>','<%= row.auth_password %>');">Update</button> |
| 89 | <button type="button" class="btn btn-default btn-xs" |
| 90 | onclick="deleteOwbcProperties('<%= row.controller_id %>');">Delete</button> |
| 91 | </td> |
| 92 | <% } %> |
| 93 | |
| 94 | </tr> |
| 95 | <% }); %> |
| 96 | </tbody> |
| 97 | </table> |
| 98 | |
| 99 | </div> |
| 100 | |
| 101 | <% include ../partials/owbc_properties %> |
| 102 | <footer> |
| 103 | <% include ../partials/footer %> |
| 104 | </footer> |
| 105 | |
| 106 | <script type="text/javascript"> |
| 107 | function submitOwbcProperties(form) |
| 108 | { |
| 109 | var errorMsg=''; |
| 110 | var controller_id = ''; |
| 111 | var base_uri = ''; |
| 112 | var service_create_extension = ''; |
| 113 | var service_delete_extension = ''; |
| 114 | var auth_username = ''; |
| 115 | var auth_password = ''; |
| 116 | var confirm_auth_password = ''; |
| 117 | |
| 118 | if ( form.name == 'addForm' ) |
| 119 | { |
| 120 | controller_id = form.nf_controller_id; |
| 121 | base_uri = form.nf_base_uri; |
| 122 | service_create_extension = form.nf_service_create_extension; |
| 123 | service_delete_extension = form.nf_service_delete_extension; |
| 124 | auth_username = form.nf_auth_username; |
| 125 | auth_password = form.nf_auth_password; |
| 126 | confirm_auth_password = form.nf_confirm_auth_password; |
| 127 | |
| 128 | if ( auth_password.value != confirm_auth_password.value ) |
| 129 | { |
| 130 | bootbox.alert('Passwords do not match.'); |
| 131 | return; |
| 132 | } |
| 133 | } |
| 134 | else |
| 135 | { |
| 136 | controller_id = form.uf_controller_id; |
| 137 | base_uri = form.uf_base_uri; |
| 138 | service_create_extension = form.uf_service_create_extension; |
| 139 | service_delete_extension = form.uf_service_delete_extension; |
| 140 | auth_username = form.uf_auth_username; |
| 141 | auth_password = form.uf_auth_password; |
| 142 | confirm_auth_password = form.uf_confirm_auth_password; |
| 143 | |
| 144 | if ( auth_password.value != confirm_auth_password.value ) |
| 145 | { |
| 146 | bootbox.alert('Passwords do not match.'); |
| 147 | return; |
| 148 | } |
| 149 | } |
| 150 | if ( (controller_id.value == null) || (controller_id.value == "") || isblank(controller_id.value) ) |
| 151 | { |
| 152 | errorMsg += 'Controller Id is required.<br>'; |
| 153 | } |
| 154 | if ( (base_uri.value == null) || (base_uri.value == "") || isblank(base_uri.value) ) |
| 155 | { |
| 156 | errorMsg += 'Base URL is required.<br>'; |
| 157 | } |
| 158 | if ( (service_create_extension.value == null) || (service_create_extension.value == "") || isblank(service_create_extension.value) ) |
| 159 | { |
| 160 | errorMsg += 'Service Create Extension is required.<br>'; |
| 161 | } |
| 162 | if ( (service_delete_extension.value == null) || (service_delete_extension.value == "") || isblank(service_delete_extension.value) ) |
| 163 | { |
| 164 | errorMsg += 'Service Delete Extension is required.<br>'; |
| 165 | } |
| 166 | if ( (auth_username.value == null) || (auth_username.value == "") || isblank(auth_username.value) ) |
| 167 | { |
| 168 | errorMsg += 'Auth Username is required.<br>'; |
| 169 | } |
| 170 | if ( (auth_password.value == null) || (auth_password.value == "") || isblank(auth_password.value) ) |
| 171 | { |
| 172 | errorMsg += 'Auth Password is required.<br>'; |
| 173 | } |
| 174 | if( errorMsg.length > 0 ) { |
| 175 | bootbox.alert(errorMsg); |
| 176 | return; |
| 177 | } |
| 178 | form.submit(); |
| 179 | } |
| 180 | |
| 181 | function updateOwbcProperties(controller_id,base_uri,service_create_extension,service_delete_extension,auth_username,auth_password) { |
| 182 | |
| 183 | document.getElementById('uf_controller_id').value=controller_id; |
| 184 | document.getElementById('uf_key_controller_id').value=controller_id; |
| 185 | document.getElementById('uf_base_uri').value=base_uri; |
| 186 | document.getElementById('uf_service_create_extension').value=service_create_extension; |
| 187 | document.getElementById('uf_service_delete_extension').value=service_delete_extension; |
| 188 | document.getElementById('uf_auth_username').value=auth_username; |
| 189 | document.getElementById('uf_auth_password').value=auth_password; |
| 190 | document.getElementById('uf_confirm_auth_password').value=auth_password; |
| 191 | |
| 192 | $('#update_owbc_properties').modal('show'); |
| 193 | } |
| 194 | |
| 195 | function deleteOwbcProperties(controller_id) { |
| 196 | |
| 197 | var url_string = encodeURI("/tunnel/deleteOwbcProperties?controller_id=" + controller_id ); |
| 198 | |
| 199 | bootbox.confirm({ |
| 200 | message: "Are you sure you want to delete OWBC Properties? " + controller_id, |
| 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 | |