Initial commit for OpenECOMP SDN-C OA&M
[sdnc/oam.git] / admportal / views / ucpe / referenceData.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     $('#reference_data').DataTable( {
13         "order": [[ 0, "asc" ]]
14     } );
15 } );
16 </script>
17
18 </head>
19 <body>
20
21 <div class="well well-sm">
22 <h3>uCPE Reference Data</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         <table id="reference_data" class="table table-hover table-condensed">
55       <thead>
56         <tr>
57                   <th>REFERENCE_ID</th>
58                   <th>STATUS</th>
59           <th>FILENAME</th>
60           <th>ATTUID</th>
61           <th>DATE</th>
62                   <% if(priv == 'A'){ %>
63           <th>Action</th>
64           <% } %>
65         </tr>
66       </thead>
67       <tbody>
68                 <% var i=0; retData.forEach( function(rowObj) { %>
69         <tr>
70             <td><%= rowObj.row.reference_id %></td>
71             <td><%= rowObj.row.status %></td>
72                         <td>
73                 <a data-toggle="collapse"
74                     href="#collapseExample<%= i %>" aria-expanded="false"
75                     aria-controls="collapseExample"><%= rowObj.row.filename %>
76                 </a>
77                 <div class="collapse" id="collapseExample<%= i %>">
78                     <div class="well">
79                         <pre><%= rowObj.filecontent %></pre>
80                     </div>
81                 </div>
82            </td>
83             <td><%= rowObj.row.attuid %></td>
84             <td><%= rowObj.row.ts %></td>
85                         <% if(priv == 'A' ) { %>
86             <td>
87                         <% if ( rowObj.row.status == 'pending' ) { %>
88                                 <button type="button" class="btn btn-default btn-xs"
89                 onclick="importReferenceData('<%= rowObj.row.reference_id %>','<%= rowObj.row.status %>','<%= rowObj.row.filename %>','<%= rowObj.row.ts %>');">Import</button>
90                         <% } %>
91                                 <button type="button" class="btn btn-default btn-xs"
92                 onclick="deleteReferenceData('<%= rowObj.row.reference_id %>','<%= rowObj.row.filename %>');">Delete</button>
93                         </td>
94             <% } %>
95         </tr>
96                 <% i++; }); %>
97       </tbody>
98     </table>
99
100         <% if(priv == 'A'){ %>
101         <div class="actions" style="padding:0px 25px;">
102         <form method="POST" action="/ucpe/uploadReferenceData" enctype="multipart/form-data">
103                 <div class="form-group">
104                 <label for="dest">File input</label>
105                 <input name="filename" type="file" id="dest">
106                 <p class="help-block">Choose a file to upload.</p>
107                 </div>
108             <button type="button" class="btn btn-default"
109                 onclick="uploadFile(this.form);">Upload File</button>
110         </form>
111         </div>
112         <% } %>
113 </div>
114
115 <footer>
116     <% include ../partials/footer %>
117 </footer>
118
119 <script type="text/javascript">
120
121 function getVnfData(vnf_name,vnf_type,svc_request_id)
122 {
123         location.assign("/mobility/viewVnfData?vnf_name=" + vnf_name + "&vnf_type=" + vnf_type );
124         return;
125 }
126 function importReferenceData(reference_id,status,filename,ts)
127 {
128         var alertMessage = '';
129         if ( status != 'pending' )
130         {
131                 bootbox.alert("Upload Status must be in 'pending' state.");
132                 return;
133         }
134         if ( filename.substring(0,11) == 'ucpedevice_' ){
135         alertMessage = "Are you sure you want to import file:" + filename + " and replace the UCPE_MAPPED_SERVICE_PORT and UCPE_SERVICE_PORT tables?";
136         }else if ( filename.substring(0,14) == 'ucpeapilogins_' ){
137         alertMessage = "Are you sure you want to import file:" + filename + " and replace the UCPE_VNF_LOGINS, UCPE_PHYSICAL_DEVICE_LOGINS and UCPE_API_LOGINS tables?";
138         }else if ( filename.substring(0,17) == 'ucpenminterfaces_' ){
139         alertMessage = "Are you sure you want to import file:" + filename + " and replace the UCPE_VNF_NM_INTERFACES and UCPE_NM_INTERFACES tables?";
140         }else if ( filename.substring(0,15) == 'ucpephsservers_' ){
141         alertMessage = "Are you sure you want to import file:" + filename + " and replace the UCPE_PHS_SERVERS table?";
142         }else if ( filename.substring(0,15) == 'ucpencsservers_' ){
143         alertMessage = "Are you sure you want to import file:" + filename + " and replace the UCPE_CUSTOMER_NCS_SERVERS table?";
144         }else if ( filename.substring(0,15) == 'ucpevnfcatalog_' ){
145         alertMessage = "Are you sure you want to import file:" + filename + " and replace the UCPE_VNF_MODELS, UCPE_VNF_MODEL_SOFTWARE and UCPE_VNF_MODEL_FEATURES tables?";
146         }else if ( filename.substring(0,16) == 'ucpemcapservers_' ){
147         alertMessage = "Are you sure you want to import file:" + filename + " and replace the UCPE_MCAP_SERVERS table?";
148         }else if ( filename.substring(0,23) == 'ucpechainingtopologies_' ){
149         alertMessage = "Are you sure you want to import file:" + filename + " and replace the UCPE_CHAINING_TOPOLOGIES table?";
150         }else if ( filename.substring(0,16) == 'ucpevnfportinfo_' ){
151         alertMessage = "Are you sure you want to import file:" + filename + " and replace the UCPE_VNF_PORT and UCPE_MAP_TO_DEVICE tables?";
152         } else {
153                 bootbox.alert('Invalid Filename in database: ' + filename);
154                 return;
155         }
156         bootbox.confirm({
157         message: alertMessage,
158         callback: function(result) {
159             if ( result )
160             {
161                                 if ( filename.substring(0,11) == 'ucpedevice_' ){
162                                         location.assign("/ucpe/importUcpeDevices?id=" + reference_id + "&filename=" + filename + "&status=" + status);
163                                 }else if ( filename.substring(0,14) == 'ucpeapilogins_' ){
164                                         location.assign("/ucpe/importApiLogins?id=" + reference_id + "&filename=" + filename + "&status=" + status);
165                                 }else if ( filename.substring(0,17) == 'ucpenminterfaces_' ){
166                                         location.assign("/ucpe/importNmInterfaces?id=" + reference_id + "&filename=" + filename + "&status=" + status);
167                                 }else if ( filename.substring(0,15) == 'ucpephsservers_' ){
168                                         location.assign("/ucpe/importPhsServers?id=" + reference_id + "&filename=" + filename + "&status=" + status);
169                                 }else if ( filename.substring(0,15) == 'ucpencsservers_' ){
170                                         location.assign("/ucpe/importNcsServers?id=" + reference_id + "&filename=" + filename + "&status=" + status);
171                                 }else if ( filename.substring(0,15) == 'ucpevnfcatalog_' ){
172                                         location.assign("/ucpe/importVnfCatalog?id=" + reference_id + "&filename=" + filename + "&status=" + status);
173                                 }else if ( filename.substring(0,16) == 'ucpemcapservers_' ){
174                                         location.assign("/ucpe/importMcapServers?id=" + reference_id + "&filename=" + filename + "&status=" + status);
175                                 }else if ( filename.substring(0,23) == 'ucpechainingtopologies_' ){
176                                         location.assign("/ucpe/importChainTopo?id=" + reference_id + "&filename=" + filename + "&status=" + status);
177                                 }else if ( filename.substring(0,16) == 'ucpevnfportinfo_' ){
178                                         location.assign("/ucpe/importVnfPortInfo?id=" + reference_id + "&filename=" + filename + "&status=" + status);
179                                 } else {
180                                         bootbox.alert('Invalid Filename: ' + filename);
181                                         return;
182                                 }
183             }
184             return;
185         },
186         buttons: {
187             cancel: {
188                 label: "Cancel"
189             },
190             confirm: {
191                 label: "Yes"
192             }
193         }
194     });
195 }
196
197 function deleteReferenceData(reference_id,filename)
198 {
199
200     bootbox.confirm({
201         message: "Are you sure you want to delete uploaded file [" + filename + "]? (This action will not effect the database.)",
202         callback: function(result) {
203             if ( result )
204             {
205                                 location.assign("/ucpe/deleteReferenceData?id=" + reference_id + "&filename=" + filename); 
206             }
207             return;
208         },
209         buttons: {
210             cancel: {
211                 label: "Cancel"
212             },
213             confirm: {
214                 label: "Yes"
215             }
216         }
217     });
218 }
219
220 </script>
221
222 </body>
223 </html>
224