NonRT-RIC A1 Northbound API
[nonrtric.git] / sdnc-a1-controller / oam / admportal / views / mobility / vmProfile.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     $('#vm_profile').DataTable( {
13         "order": [[ 0, "asc" ]]
14     } );
15 } );
16 </script>
17
18 </head>
19 <body>
20
21 <div class="well well-sm">
22 <h3>VM Profile </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 btn-md" data-toggle="modal" data-target="#add_vm_profile">
57       Add VM Profile
58     </button>
59         </div>
60         <% } %>
61
62         <table id="vm_profile" class="table table-hover table-condensed">
63       <thead>
64         <tr>
65                   <th>*VNF_TYPE</th>
66                   <th>*VM_TYPE</th>
67                   <th>VM_COUNT</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.vnf_type %></td>
77             <td><%= row.vm_type %></td>
78             <td><%= row.vm_count %></td>
79                         <% if(priv == 'A' ) { %>
80             <td>
81                                 <button type="button" class="btn btn-default btn-xs"
82                    onclick="deleteVmProfile('<%= row.vnf_type %>', '<%= row.vm_type %>');">Delete</button>
83             </td>
84             <% } %>
85         </tr>
86                 <% }); %>
87       </tbody>
88     </table>
89
90         <% if(priv == 'A'){ %>
91         <div class="actions" style="padding:0px 25px;">
92         <form method="POST" action="/mobility/uploadVmProfile" enctype="multipart/form-data">
93                 <div class="form-group">
94                 <label for="dest">File input</label>
95                 <input name="filename" type="file" id="dest">
96                 <p class="help-block">Choose a file to upload.</p>
97                 </div>
98         <button type="button" class="btn btn-default"
99                 onclick="uploadFile(this.form);">Upload File</button>
100         </form>
101         </div>
102         <% } %>
103 </div>
104
105 <% include ../partials/vm_profile %>
106 <footer>
107     <% include ../partials/footer %>
108 </footer>
109
110 <script type="text/javascript">
111
112 function addVmProfile(form)
113 {
114         var errorMsg='';
115         var vnf_type='';
116         var vm_type='';
117         var vm_count='';
118
119         if ( form.name == 'addForm' )
120         {
121                 vnf_type = form.nf_vnf_type;
122                 vm_type = form.nf_vm_type;
123                 vm_count = form.nf_vm_count;
124         }
125
126         if ( (vnf_type.value == null) || (vnf_type.value == "") || isblank(vnf_type.value) )
127         {
128                 errorMsg += 'VNF Type is required.<br>';
129         }
130         if ( (vm_type.value == null) || (vm_type.value == "") || isblank(vm_type.value) )
131         {
132                 errorMsg += 'VM Type is required.<br>';
133         }
134         if( errorMsg.length > 0 ) {
135                 bootbox.alert(errorMsg);
136                 return;
137         }
138
139         if ( vm_count.value.length > 0 && !isDigit(vm_count.value) )
140         {
141                 bootbox.alert('VM Count must be a number.');
142                 return;
143         }
144         form.submit();
145 }
146
147 function deleteVmProfile(vnf_type, vm_type) {
148
149     bootbox.confirm({
150         message: "Are you sure you want to delete VM_PROFILE [" + vnf_type + "][" + vm_type + "]",
151         callback: function(result) {
152             if ( result )
153             {
154                                 location.assign("/mobility/deleteVmProfile?vnf_type=" + vnf_type + "&vm_type=" + vm_type);
155             }
156             return;
157         },
158         buttons: {
159             cancel: {
160                 label: "Cancel"
161             },
162             confirm: {
163                 label: "Yes"
164             }
165         }
166     });
167 }
168
169 </script>
170
171 </body>
172 </html>
173