NonRT-RIC A1 Northbound API
[nonrtric.git] / sdnc-a1-controller / oam / admportal / views / tunnel / linkMaster.ejs
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4
5 <meta charset="UTF-8" />
6 <meta http-equiv="X-UA-Compatible" content="IE=edge">
7 <% include ../partials/head %>
8 <% include ../partials/header %>
9 <script type="text/javascript" src="/javascripts/admportal.js" async></script>
10 <title>SDNC-MLC AdminPortal</title>
11
12
13 <script class="init"> 
14         $(document).ready(function() {
15     $('#linkMaster').DataTable( {
16         "order": [[ 0, "asc" ]]
17     } );
18 } );
19 </script>
20 </head>
21
22 <body>
23
24 <div class="well well-sm">
25 <h3>Link Master</h3>
26 </div>
27
28 <% if ( typeof result != 'undefined' ) {
29                 if (result.code.length > 0) { 
30                         if ( result.code == 'success' ) { %>
31                                 <div class='alert alert-success' role='alert'>
32                                 <%
33                                 for ( x in result.msg ){ %>
34                                         <div><%= result.msg[x] %></div>
35                                 <% } %>
36                                 </div>
37                         <% } else { %> 
38                                 <div class='alert alert-danger' role='danger'>
39                                 <%
40                                 for ( x in result.msg ){ %>
41                                         <div><%= result.msg[x] %></div>
42                                 <% } %>
43                                 </div>
44                         <% } %>
45                 <% } %>
46 <% } %>
47
48 <% if( typeof privilege != 'undefined'){
49     var priv = privilege.privilege;
50 } else {
51     var priv = 'A';
52 } %>
53
54
55 <div class="container-fluid">
56
57         <% if(priv == 'A'){ %>
58         <div class="actions" style="padding:15px 0px;">
59             <button class="btn btn-primary btn-md" data-toggle="modal" data-target="#add_link_master">Add Link</button>
60         </div>
61     <% } %>
62
63         <table id="linkMaster" class="table table-hover table-condensed">
64       <thead>
65         <tr>
66                   <th>*Link Interface IP</th>
67           <th>Source CRS Name</th>
68                   <th>Destination CRS Name</th>
69                   <th>Max Reserved BW</th>
70                   <th>Default Cost</th>
71                   <th>Bundle Name</th>
72                   <th>Shutdown</th>
73                    <% if(priv == 'A'){ %>
74           <th>Action</th>
75           <% } %>
76         </tr>
77       </thead>
78       <tbody>
79       <% rows.forEach( function(row) { %> 
80         <tr>
81             <td><%= row.link_interface_ip %></td>
82             <td><%= row.source_crs_name %></td>
83             <td><%= row.destination_crs_name %></td>
84             <td><%= row.link_speed %></td>
85             <td><%= row.default_cost %></td>
86             <td><%= row.bundle_name %></td>
87                         <td><%= row.shutdown %></td>
88                         <% if(priv == 'A') { %>
89             <td>
90                                 <button type="button" class="btn btn-default btn-xs" onclick="updateLinkMaster('<%= row.link_interface_ip %>', 
91                                         '<%= row.source_crs_name %>', '<%= row.destination_crs_name %>', '<%= row.link_speed %>', '<%= row.default_cost %>',
92                                         '<%= row.bundle_name %>', '<%= row.shutdown %>');">Update</button>
93                                 <button type="button" class="btn btn-default btn-xs" onclick="deleteLinkMaster('<%= row.link_interface_ip %>');">Delete</button>
94             </td>
95             <% } %>
96         </tr>
97     <% }); %>
98       </tbody>
99     </table>
100 </div>
101
102 <% include ../partials/link_master %>
103 <footer>
104     <% include ../partials/footer %>
105 </footer>
106
107 <script type="text/javascript">
108 function saveLinkMaster(form)
109 {
110     var errorMsg='';
111     var link_interface_ip = '';
112         var source_crs_name = '';
113         var destination_crs_name = '';
114         var link_speed = '';
115         var default_cost = '';
116         var bundle_name = '';
117         var shutdown = '';
118
119     if ( form.name == 'addForm' )
120     {
121                 link_interface_ip = form.nf_link_interface_ip;
122                 source_crs_name = form.nf_source_crs_name;
123                 destination_crs_name = form.nf_destination_crs_name;
124                 link_speed = form.nf_link_speed;
125                 default_cost = form.nf_default_cost;
126                 bundle_name = form.nf_bundle_name;
127                 shutdown = form.nf_shutdown;
128     }
129     else
130     {
131                 link_interface_ip = form.uf_link_interface_ip;
132                 source_crs_name = form.uf_source_crs_name;
133                 destination_crs_name = form.uf_destination_crs_name;
134                 link_speed = form.uf_link_speed;
135                 default_cost = form.uf_default_cost;
136                 bundle_name = form.uf_bundle_name;
137                 shutdown = form.uf_shutdown;
138     }
139
140
141     if ( (link_interface_ip.value == null) || (link_interface_ip.value == "") || isblank(link_interface_ip.value) )
142     {
143         errorMsg += 'Link Interface IP is required.<br>';
144     }
145     if ( (source_crs_name.value == null) || (source_crs_name.value == "") || isblank(source_crs_name.value) )
146     {
147         errorMsg += 'Source CRS Name is required.<br>';
148     }
149     if ( (destination_crs_name.value == null) || (destination_crs_name.value == "") || isblank(destination_crs_name.value) )
150     {
151         errorMsg += 'Destination CRS Name is required.<br>';
152     }
153     if( errorMsg.length > 0 ) {
154         bootbox.alert(errorMsg);
155         return;
156     }
157
158         if ( link_speed.value.length >0 && !isDigit(link_speed.value) )
159     {
160         bootbox.alert('Max Reserved BW must be a number.');
161         return;
162     }
163         if ( default_cost.value.length >0 && !isDigit(default_cost.value) )
164     {
165         bootbox.alert('Default Cost must be a number.');
166         return;
167     }
168     form.submit();
169 }
170
171 function updateLinkMaster(link_interface_ip,source_crs_name,destination_crs_name,link_speed,default_cost,bundle_name,shutdown) {
172
173     document.getElementById('uf_link_interface_ip').value=link_interface_ip;
174     document.getElementById('uf_source_crs_name').value=source_crs_name;
175     document.getElementById('uf_destination_crs_name').value=destination_crs_name;
176     document.getElementById('uf_link_speed').value=link_speed;
177     document.getElementById('uf_default_cost').value=default_cost;
178     document.getElementById('uf_bundle_name').value=bundle_name;
179     document.getElementById('uf_shutdown').value=shutdown;
180     document.getElementById('uf_key_link_interface_ip').value=link_interface_ip;
181
182     $('#update_link_master').modal('show');
183 }
184
185 function deleteLinkMaster(link_interface_ip) {
186
187         var url_string = encodeURI("/tunnel/deleteLinkMaster?link_interface_ip=" + link_interface_ip);
188
189     bootbox.confirm({
190         message: "Are you sure you want to delete this Link [" + link_interface_ip + "]",
191         callback: function(result) {
192             if ( result )
193             {
194                                 location.assign(url_string);
195             }
196             return;
197         },
198         buttons: {
199             cancel: {
200                 label: "Cancel"
201             },
202             confirm: {
203                 label: "Yes"
204             }
205         }
206     });
207 }
208
209 </script>
210
211 </body>
212 </html>
213