Initial commit for OpenECOMP SDN-C OA&M
[sdnc/oam.git] / admportal / views / resalloc / max_port_speed.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     $('#max_port_speed').DataTable( {
13         "order": [[ 0, "asc" ]]
14     } );
15 } );
16 </script>
17
18 </head>
19 <body>
20
21 <div class="well well-sm">
22 <h3>Max Port Speed</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_max_port_speed">
57         Add Max Port Speed
58         </button>
59                 </div>
60         <% } %>
61
62         <table id="max_port_speed" class="table table-hover table-condensed">
63       <thead>
64         <tr>
65                   <th>*ID</th>
66           <th>*Image File Name</th>
67                   <th>*End Point Position</th>
68           <th>*Interface Name</th>
69           <th>*Max Speed</th>
70           <th>*Unit</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.max_port_speed_id %></td>
80             <td><%= row.image_file_name %></td>
81             <td><%= row.end_point_position %></td>
82             <td><%= row.interface_name %></td>
83             <td><%= row.max_speed %></td>
84             <td><%= row.unit %></td>
85                         <% if(priv == 'A') { %>
86             <td>
87                                 <button type="button" class="btn btn-default btn-xs"
88                     onclick="updateMaxPortSpeed('<%=row.max_port_speed_id %>','<%= row.image_file_name %>','<%= row.end_point_position %>','<%= row.interface_name %>','<%= row.max_speed %>','<%= row.unit %>');">Update</button>
89                                 <button type="button" class="btn btn-default btn-xs"
90                    onclick="deleteMaxPortSpeed('<%= row.max_port_speed_id %>');">Delete</button>
91             </td>
92             <% } %>
93
94         </tr>
95     <% }); %>
96       </tbody>
97     </table>
98
99 </div>
100
101 <% include ../partials/max_port_speed %>
102 <footer>
103     <% include ../partials/footer %>
104 </footer>
105
106 <script type="text/javascript">
107 function submitMaxPortSpeed(form)
108 {
109     var errorMsg='';
110         var image_file_name = '';
111         var end_point_position = '';
112         var interface_name = '';
113         var max_speed = '';
114         var unit = '';
115
116     if ( form.name == 'addForm' )
117     {
118                 image_file_name = form.nf_image_file_name;
119                 end_point_position = form.nf_end_point_position;
120                 interface_name = form.nf_interface_name;
121                 max_speed = form.nf_max_speed;
122                 unit = form.nf_unit;
123     }
124     else
125     {
126                 image_file_name = form.uf_image_file_name;
127                 end_point_position = form.uf_end_point_position;
128                 interface_name = form.uf_interface_name;
129                 max_speed = form.uf_max_speed;
130                 unit = form.uf_unit;
131     }
132
133
134     if ( (image_file_name.value == null) || (image_file_name.value == "") || isblank(image_file_name.value) )
135     {
136         errorMsg += 'Image File Name is required.<br>';
137     }
138     if ( (end_point_position.value == null) || (end_point_position.value == "") || isblank(end_point_position.value) )
139     {
140         errorMsg += 'End Point Position is required.<br>';
141     }
142     if ( (interface_name.value == null) || (interface_name.value == "") || isblank(interface_name.value) ){
143         errorMsg += 'Interface Name is required.<br>';
144     }
145     if ( (max_speed.value == null) || (max_speed.value == "") || isblank(max_speed.value) ){
146         errorMsg += 'Max Speed is required.<br>';
147     }
148     if ( (unit.value == null) || (unit.value == "") || isblank(unit.value) ){
149         errorMsg += 'Unit is required.<br>';
150     }
151     if( errorMsg.length > 0 ) {
152         bootbox.alert(errorMsg);
153         return;
154     }
155
156         if ( !isDigit(max_speed.value) )
157     {
158         bootbox.alert('Max Speed must be a number.');
159         return;
160     }
161
162     form.submit();
163 }
164
165 function updateMaxPortSpeed(max_port_speed_id,image_file_name,end_point_position,interface_name,max_speed,unit) {
166
167     document.getElementById('uf_max_port_speed_id').value=max_port_speed_id;
168     document.getElementById('uf_image_file_name').value=image_file_name;
169     document.getElementById('uf_end_point_position').value=end_point_position;
170     document.getElementById('uf_interface_name').value=interface_name;
171     document.getElementById('uf_max_speed').value=max_speed;
172     document.getElementById('uf_unit').value=unit;
173
174     document.getElementById('uf_key_max_port_speed_id').value=max_port_speed_id;
175
176     $('#update_max_port_speed').modal('show');
177 }
178
179 function deleteMaxPortSpeed(max_port_speed_id) {
180
181     bootbox.confirm({
182         message: "Are you sure you want to delete MAX_PORT_SPEED [" + max_port_speed_id + "]",
183         callback: function(result) {
184             if ( result )
185             {
186                                 location.assign("/resalloc/deleteMaxPortSpeed?max_port_speed_id=" + max_port_speed_id);
187             }
188             return;
189         },
190         buttons: {
191             cancel: {
192                 label: "Cancel"
193             },
194             confirm: {
195                 label: "Yes"
196             }
197         }
198     });
199 }
200
201 </script>
202
203 </body>
204 </html>
205