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>SDNC-MLC AdminPortal</title> |
| 10 | <script class="init"> |
| 11 | $(document).ready(function() { |
| 12 | $('#partner_properties').DataTable( { |
| 13 | "order": [[ 0, "asc" ]] |
| 14 | } ); |
| 15 | } ); |
| 16 | </script> |
| 17 | |
| 18 | </head> |
| 19 | <body> |
| 20 | |
| 21 | <div class="well well-sm"> |
| 22 | <h3>Partner 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_partner_properties"> |
| 57 | Add Partner Properties |
| 58 | </button> |
| 59 | </div> |
| 60 | <% } %> |
| 61 | |
| 62 | <table id="partner_properties" class="table table-hover table-condensed"> |
| 63 | <thead> |
| 64 | <tr> |
| 65 | <th>*Partner</th> |
| 66 | <th>*Username</th> |
| 67 | <th>*Password</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.partner %></td> |
| 77 | <td><%= row.auth_username %></td> |
| 78 | <td>*****</td> |
| 79 | <% if(priv == 'A') { %> |
| 80 | <td> |
| 81 | <button type="button" class="btn btn-default btn-xs" |
| 82 | onclick="updatePartnerProperties('<%= row.partner %>','<%= row.auth_username %>','<%= row.auth_password %>');">Update</button> |
| 83 | <button type="button" class="btn btn-default btn-xs" |
| 84 | onclick="deletePartnerProperties('<%= row.partner %>');">Delete</button> |
| 85 | </td> |
| 86 | <% } %> |
| 87 | |
| 88 | </tr> |
| 89 | <% }); %> |
| 90 | </tbody> |
| 91 | </table> |
| 92 | |
| 93 | </div> |
| 94 | |
| 95 | <% include ../partials/partner_properties %> |
| 96 | <footer> |
| 97 | <% include ../partials/footer %> |
| 98 | </footer> |
| 99 | |
| 100 | <script type="text/javascript"> |
| 101 | function submitPartnerProperties(form) |
| 102 | { |
| 103 | var errorMsg=''; |
| 104 | var partner = ''; |
| 105 | var auth_username = ''; |
| 106 | var auth_password = ''; |
| 107 | var confirm_auth_password = ''; |
| 108 | |
| 109 | if ( form.name == 'addForm' ) |
| 110 | { |
| 111 | partner = form.nf_partner; |
| 112 | auth_username = form.nf_auth_username; |
| 113 | auth_password = form.nf_auth_password; |
| 114 | confirm_auth_password = form.nf_confirm_auth_password; |
| 115 | |
| 116 | if ( (partner.value == null) || (partner.value == "") || isblank(partner.value) ) |
| 117 | { |
| 118 | errorMsg += 'Partner is required.<br>'; |
| 119 | } |
| 120 | if( errorMsg.length > 0 ) { |
| 121 | bootbox.alert(errorMsg); |
| 122 | return; |
| 123 | } |
| 124 | if ( auth_password.value != confirm_auth_password.value ) |
| 125 | { |
| 126 | bootbox.alert('Passwords do not match.'); |
| 127 | return; |
| 128 | } |
| 129 | } |
| 130 | else |
| 131 | { |
| 132 | partner = form.uf_partner; |
| 133 | auth_username = form.uf_auth_username; |
| 134 | auth_password = form.uf_auth_password; |
| 135 | confirm_auth_password = form.uf_confirm_auth_password; |
| 136 | if ( auth_password.value != confirm_auth_password.value ) |
| 137 | { |
| 138 | bootbox.alert('Passwords do not match.'); |
| 139 | return; |
| 140 | } |
| 141 | } |
| 142 | form.submit(); |
| 143 | } |
| 144 | |
| 145 | function updatePartnerProperties(partner,auth_username,auth_password) { |
| 146 | |
| 147 | document.getElementById('uf_partner').value=partner; |
| 148 | document.getElementById('uf_key_partner').value=partner; |
| 149 | document.getElementById('uf_auth_username').value=auth_username; |
| 150 | document.getElementById('uf_auth_password').value=auth_password; |
| 151 | document.getElementById('uf_confirm_auth_password').value=auth_password; |
| 152 | |
| 153 | $('#update_partner_properties').modal('show'); |
| 154 | } |
| 155 | |
| 156 | function deletePartnerProperties(partner) { |
| 157 | |
| 158 | var url_string = encodeURI("/tunnel/deletePartnerProperties?partner=" + partner); |
| 159 | |
| 160 | bootbox.confirm({ |
| 161 | message: "Are you sure you want to delete Partner Property [ " + partner + " ]", |
| 162 | callback: function(result) { |
| 163 | if ( result ) |
| 164 | { |
| 165 | location.assign(url_string); |
| 166 | } |
| 167 | return; |
| 168 | }, |
| 169 | buttons: { |
| 170 | cancel: { |
| 171 | label: "Cancel" |
| 172 | }, |
| 173 | confirm: { |
| 174 | label: "Yes" |
| 175 | } |
| 176 | } |
| 177 | }); |
| 178 | } |
| 179 | |
| 180 | </script> |
| 181 | |
| 182 | </body> |
| 183 | </html> |
| 184 | |