Initial commit for OpenECOMP SDN-C OA&M
[sdnc/oam.git] / admportal / views / gamma / networkProfile.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
11 <script class="init"> 
12         $(document).ready(function() {
13     $('#network_profile').DataTable( {
14         "order": [[ 0, "asc" ]]
15     } );
16 } );
17 </script>
18
19 </head>
20 <body>
21
22 <div class="well well-sm">
23 <h3>Network Profile</h3>
24 </div>
25
26 <% if ( typeof result != 'undefined' ) {
27                 if (result.code.length > 0) { 
28                         if ( result.code == 'success' ) { %>
29                                 <div class='alert alert-success' role='alert'>
30                                 <%
31                                 for ( x in result.msg ){ %>
32                                         <div><%= result.msg[x] %></div>
33                                 <% } %>
34                                 </div>
35                         <% } else { %> 
36                                 <div class='alert alert-danger' role='danger'>
37                                 <%
38                                 for ( x in result.msg ){ %>
39                                         <div><%= result.msg[x] %></div>
40                                 <% } %>
41                                 </div>
42                         <% } %>
43                 <% } %>
44 <% } %>
45
46 <% if( typeof privilege != 'undefined'){
47     var priv = privilege.privilege;
48 } else {
49     var priv = 'A';
50 } %>
51
52
53 <div class="container-fluid">
54
55          <% if(priv == 'A'){ %>
56         <div class="actions" style="padding:15px 0px;">
57             <button class="btn btn-primary btn-md" data-toggle="modal" data-target="#add_network_profile">
58             Add Profile 
59             </button>
60             </div>
61     <% } %>
62
63         <table id="network_profile" class="table table-hover table-condensed">
64       <thead>
65         <tr>
66                   <th>*Network Type</th>
67           <th>Technology</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.network_type %></td>
77             <td><%= row.technology %></td>
78                         <% if(priv == 'A') { %>
79             <td>
80                                 <% if (priv == 'A') { %>
81                                 <button type="button" class="btn btn-default btn-xs" onclick="updateNetworkProfile('<%= row.network_type %>', '<%= row.technology %>');">Update</button>
82                                 <button type="button" class="btn btn-default btn-xs" onclick="deleteNetworkProfile('<%= row.network_type %>');">Delete</button>
83                                 <% } %>
84             </td>
85             <% } %>
86
87         </tr>
88     <% }); %>
89       </tbody>
90     </table>
91 </div>
92
93 <% include ../partials/network_profile %>
94 <footer>
95     <% include ../partials/footer %>
96 </footer>
97
98 <script type="text/javascript">
99 function saveNetworkProfile(form)
100 {
101     var errorMsg='';
102     var network_type = '';
103         var technology = '';
104
105     if ( form.name == 'addForm' )
106     {
107                 network_type = form.nf_network_type;
108                 technology = form.nf_technology;
109     }
110     else
111     {
112                 network_type = form.uf_network_type;
113                 technology = form.uf_technology;
114     }
115
116
117     if ( (network_type.value == null) || (network_type.value == "") || isblank(network_type.value) )
118     {
119         errorMsg += 'Network Type is required.<br>';
120     }
121     if( errorMsg.length > 0 ) {
122         bootbox.alert(errorMsg);
123         return;
124     }
125     form.submit();
126 }
127
128 function updateNetworkProfile(network_type,technology) {
129
130     document.getElementById('uf_network_type').value=network_type;
131     document.getElementById('uf_technology').value=technology;
132
133     document.getElementById('uf_key_network_type').value=network_type;
134
135     $('#update_network_profile').modal('show');
136 }
137
138 function deleteNetworkProfile(network_type) {
139
140     bootbox.confirm({
141         message: "Are you sure you want to delete this Network Profile [" + network_type + "]",
142         callback: function(result) {
143             if ( result )
144             {
145                                 location.assign("/gamma/deleteNetworkProfile?network_type=" + network_type);
146             }
147             return;
148         },
149         buttons: {
150             cancel: {
151                 label: "Cancel"
152             },
153             confirm: {
154                 label: "Yes"
155             }
156         }
157     });
158 }
159
160 </script>
161
162 </body>
163 </html>
164