aboutsummaryrefslogtreecommitdiffstats
path: root/admportal/views/ucpe/referenceData.ejs
blob: 6196c46ea639720c5218a2ff4180cee78354b6e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <% include ../partials/head %>
  <% include ../partials/header %>
  <script type="text/javascript" src="/javascripts/admportal.js" async></script>
  <title>SDN-C AdminPortal</title>
<script class="init">
    $(document).ready(function() {
    $('#reference_data').DataTable( {
        "order": [[ 0, "asc" ]]
    } );
} );
</script>

</head>
<body>

<div class="well well-sm">
<h3>uCPE Reference Data</h3>
</div>

<% if ( typeof result != 'undefined' ) {
		if (result.code.length > 0) { 
			if ( result.code == 'success' ) { %>
				<div class='alert alert-success' role='alert'>
				<%
				for ( x in result.msg ){ %>
					<div><%= result.msg[x] %></div>
				<% } %>
				</div>
			<% } else { %> 
				<div class='alert alert-danger' role='danger'>
				<%
				for ( x in result.msg ){ %>
					<div><%= result.msg[x] %></div>
				<% } %>
				</div>
			<% } %>
		<% } %>
<% } %>

<% if( typeof privilege != 'undefined'){
    var priv = privilege.privilege;
} else {
    var priv = 'A';
} %>


<div class="container-fluid">

	<table id="reference_data" class="table table-hover table-condensed">
      <thead>
        <tr>
		  <th>REFERENCE_ID</th>
		  <th>STATUS</th>
          <th>FILENAME</th>
          <th>ATTUID</th>
          <th>DATE</th>
		  <% if(priv == 'A'){ %>
          <th>Action</th>
          <% } %>
        </tr>
      </thead>
      <tbody>
		<% var i=0; retData.forEach( function(rowObj) { %>
        <tr>
            <td><%= rowObj.row.reference_id %></td>
            <td><%= rowObj.row.status %></td>
			<td>
                <a data-toggle="collapse"
                    href="#collapseExample<%= i %>" aria-expanded="false"
                    aria-controls="collapseExample"><%= rowObj.row.filename %>
                </a>
                <div class="collapse" id="collapseExample<%= i %>">
                    <div class="well">
                        <pre><%= rowObj.filecontent %></pre>
                    </div>
                </div>
           </td>
            <td><%= rowObj.row.attuid %></td>
            <td><%= rowObj.row.ts %></td>
			<% if(priv == 'A' ) { %>
            <td>
			<% if ( rowObj.row.status == 'pending' ) { %>
				<button type="button" class="btn btn-default btn-xs"
            	onclick="importReferenceData('<%= rowObj.row.reference_id %>','<%= rowObj.row.status %>','<%= rowObj.row.filename %>','<%= rowObj.row.ts %>');">Import</button>
			<% } %>
				<button type="button" class="btn btn-default btn-xs"
            	onclick="deleteReferenceData('<%= rowObj.row.reference_id %>','<%= rowObj.row.filename %>');">Delete</button>
			</td>
            <% } %>
        </tr>
		<% i++; }); %>
      </tbody>
    </table>

	<% if(priv == 'A'){ %>
	<div class="actions" style="padding:0px 25px;">
	<form method="POST" action="/ucpe/uploadReferenceData" enctype="multipart/form-data">
		<div class="form-group">
    		<label for="dest">File input</label>
    		<input name="filename" type="file" id="dest">
    		<p class="help-block">Choose a file to upload.</p>
  		</div>
            <button type="button" class="btn btn-default"
                onclick="uploadFile(this.form);">Upload File</button>
	</form>
	</div>
	<% } %>
</div>

<footer>
    <% include ../partials/footer %>
</footer>

<script type="text/javascript">

function getVnfData(vnf_name,vnf_type,svc_request_id)
{
	location.assign("/mobility/viewVnfData?vnf_name=" + vnf_name + "&vnf_type=" + vnf_type );
	return;
}
function importReferenceData(reference_id,status,filename,ts)
{
	var alertMessage = '';
	if ( status != 'pending' )
	{
		bootbox.alert("Upload Status must be in 'pending' state.");
		return;
	}
	if ( filename.substring(0,11) == 'ucpedevice_' ){
        alertMessage = "Are you sure you want to import file:" + filename + " and replace the UCPE_MAPPED_SERVICE_PORT and UCPE_SERVICE_PORT tables?";
	}else if ( filename.substring(0,14) == 'ucpeapilogins_' ){
        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?";
	}else if ( filename.substring(0,17) == 'ucpenminterfaces_' ){
        alertMessage = "Are you sure you want to import file:" + filename + " and replace the UCPE_VNF_NM_INTERFACES and UCPE_NM_INTERFACES tables?";
	}else if ( filename.substring(0,15) == 'ucpephsservers_' ){
        alertMessage = "Are you sure you want to import file:" + filename + " and replace the UCPE_PHS_SERVERS table?";
	}else if ( filename.substring(0,15) == 'ucpencsservers_' ){
        alertMessage = "Are you sure you want to import file:" + filename + " and replace the UCPE_CUSTOMER_NCS_SERVERS table?";
	}else if ( filename.substring(0,15) == 'ucpevnfcatalog_' ){
        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?";
	}else if ( filename.substring(0,16) == 'ucpemcapservers_' ){
        alertMessage = "Are you sure you want to import file:" + filename + " and replace the UCPE_MCAP_SERVERS table?";
	}else if ( filename.substring(0,23) == 'ucpechainingtopologies_' ){
        alertMessage = "Are you sure you want to import file:" + filename + " and replace the UCPE_CHAINING_TOPOLOGIES table?";
	}else if ( filename.substring(0,16) == 'ucpevnfportinfo_' ){
        alertMessage = "Are you sure you want to import file:" + filename + " and replace the UCPE_VNF_PORT and UCPE_MAP_TO_DEVICE tables?";
	} else {
		bootbox.alert('Invalid Filename in database: ' + filename);
		return;
	}
	bootbox.confirm({
        message: alertMessage,
        callback: function(result) {
            if ( result )
            {
				if ( filename.substring(0,11) == 'ucpedevice_' ){
					location.assign("/ucpe/importUcpeDevices?id=" + reference_id + "&filename=" + filename + "&status=" + status);
				}else if ( filename.substring(0,14) == 'ucpeapilogins_' ){
					location.assign("/ucpe/importApiLogins?id=" + reference_id + "&filename=" + filename + "&status=" + status);
				}else if ( filename.substring(0,17) == 'ucpenminterfaces_' ){
					location.assign("/ucpe/importNmInterfaces?id=" + reference_id + "&filename=" + filename + "&status=" + status);
				}else if ( filename.substring(0,15) == 'ucpephsservers_' ){
					location.assign("/ucpe/importPhsServers?id=" + reference_id + "&filename=" + filename + "&status=" + status);
				}else if ( filename.substring(0,15) == 'ucpencsservers_' ){
					location.assign("/ucpe/importNcsServers?id=" + reference_id + "&filename=" + filename + "&status=" + status);
				}else if ( filename.substring(0,15) == 'ucpevnfcatalog_' ){
					location.assign("/ucpe/importVnfCatalog?id=" + reference_id + "&filename=" + filename + "&status=" + status);
				}else if ( filename.substring(0,16) == 'ucpemcapservers_' ){
					location.assign("/ucpe/importMcapServers?id=" + reference_id + "&filename=" + filename + "&status=" + status);
				}else if ( filename.substring(0,23) == 'ucpechainingtopologies_' ){
					location.assign("/ucpe/importChainTopo?id=" + reference_id + "&filename=" + filename + "&status=" + status);
				}else if ( filename.substring(0,16) == 'ucpevnfportinfo_' ){
					location.assign("/ucpe/importVnfPortInfo?id=" + reference_id + "&filename=" + filename + "&status=" + status);
				} else {
					bootbox.alert('Invalid Filename: ' + filename);
					return;
				}
            }
            return;
        },
        buttons: {
            cancel: {
                label: "Cancel"
            },
            confirm: {
                label: "Yes"
            }
        }
    });
}

function deleteReferenceData(reference_id,filename)
{

    bootbox.confirm({
        message: "Are you sure you want to delete uploaded file [" + filename + "]? (This action will not effect the database.)",
        callback: function(result) {
            if ( result )
            {
				location.assign("/ucpe/deleteReferenceData?id=" + reference_id + "&filename=" + filename); 
            }
            return;
        },
        buttons: {
            cancel: {
                label: "Cancel"
            },
            confirm: {
                label: "Yes"
            }
        }
    });
}

</script>

</body>
</html>