Initial commit for OpenECOMP SDN-C OA&M
[sdnc/oam.git] / admportal / views / ucpe / ncsCredentials.ejs
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     $('#ncs_server_credentials').DataTable( {
13         "order": [[ 0, "asc" ]]
14     } );
15 } );
16 </script>
17
18 </head>
19 <body>
20
21 <div class="well well-sm">
22 <h3>NCS Server 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_ncs_credentials">
57             Add NCS Credentials
58             </button>
59             </div>
60     <% } %>
61
62         <table id="ncs_server_credentials" class="table table-hover table-condensed">
63       <thead>
64         <tr>
65           <th>*Customer Name</th>
66           <th>NCS Username</th>
67           <th>NCS 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.customer_name %></td>
77             <td><%= row.ncs_username %></td>
78             <td>*****</td>
79                         <% if(priv == 'A') { %>
80             <td>
81                                 <button type="button" class="btn btn-default btn-xs"
82                 onclick="updateNcsCredentials('<%= row.customer_name %>','<%= row.ncs_username %>','<%= row.ncs_password %>');">Update</button>
83                                 <button type="button" class="btn btn-default btn-xs"
84                                 onclick="deleteNcsCredentials('<%= row.customer_name %>');">Delete</button>
85             </td>
86             <% } %>
87
88         </tr>
89     <% }); %>
90       </tbody>
91     </table>
92
93 </div>
94
95 <% include ../partials/ncs_credentials %>
96 <footer>
97     <% include ../partials/footer %>
98 </footer>
99
100 <script type="text/javascript">
101 function submitNcsCredentials(form)
102 {
103     var errorMsg='';
104         var customer_name = '';
105         var ncs_username = '';
106         var ncs_password = '';
107         var confirm_ncs_password = '';
108
109     if ( form.name == 'addForm' )
110     {
111                 customer_name = form.nf_customer_name;
112                 ncs_username = form.nf_ncs_username;
113                 ncs_password = form.nf_ncs_password;
114                 confirm_ncs_password = form.nf_confirm_ncs_password;
115
116         if ( (customer_name.value == null) || (customer_name.value == "") || isblank(customer_name.value) )
117         {
118                 errorMsg += 'Customer Name is required.<br>';
119         }
120         if( errorMsg.length > 0 ) {
121                 bootbox.alert(errorMsg);
122                 return;
123         }
124                 if ( ncs_password.value != confirm_ncs_password.value )
125         {
126             bootbox.alert('Passwords do not match.');
127             return;
128         }
129     }
130     else
131     {
132                 customer_name = form.uf_customer_name;
133                 ncs_username = form.uf_ncs_username;
134                 ncs_password = form.uf_ncs_password;
135                 confirm_ncs_password = form.uf_confirm_ncs_password;
136                 if ( ncs_password.value != confirm_ncs_password.value )
137         {
138             bootbox.alert('Passwords do not match.');
139             return;
140         }
141     }
142     form.submit();
143 }
144
145 function updateNcsCredentials(customer_name,ncs_username,ncs_password) {
146
147     document.getElementById('uf_customer_name').value=customer_name;
148     document.getElementById('uf_ncs_username').value=ncs_username;
149     document.getElementById('uf_ncs_password').value=ncs_password;
150
151     $('#update_ncs_credentials').modal('show');
152 }
153
154 function deleteNcsCredentials(customer_name) {
155
156     bootbox.confirm({
157         message: "Are you sure you want to delete NCS Credentials [ " + customer_name + " ]",
158         callback: function(result) {
159             if ( result )
160             {
161                                 location.assign("/ucpe/deleteNcsCredentials?customer_name=" + customer_name); 
162             }
163             return;
164         },
165         buttons: {
166             cancel: {
167                 label: "Cancel"
168             },
169             confirm: {
170                 label: "Yes"
171             }
172         }
173     });
174 }
175
176 </script>
177
178 </body>
179 </html>
180