aboutsummaryrefslogtreecommitdiffstats
path: root/admportal/views/mobility/vnfPreloadData.ejs
blob: 69f02e59fa7e909618ac68b071e467b8f847f572 (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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<!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() {
    $('#vnf_data').DataTable( {
        "order": [[ 0, "asc" ]]
    } );
} );
</script>


</head>
<body>

<div class="well well-sm">
<h3>Pre-load VNF 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="vnf_data" class="table table-hover table-condensed">
      <thead>
        <tr>
		  <th>ID</th>
		  <th>SVC_REQUEST_ID</th>
		  <th>VNF_NAME</th>
		  <th>VNF_TYPE</th>
		  <th>SVC_ACTION</th>
		  <th>UPLOAD STATUS</th>
          <th>FILENAME</th>
          <th>IMPORT/UPLOAD TIMESTAMP</th>
		  <% if(priv == 'A'){ %>
          <th>Action</th>
          <% } %>
        </tr>
      </thead>
      <tbody>
		<% var i=0; retData.forEach( function(rowObj) { %>
        <tr>
            <td><%= rowObj.row.id %></td>
            <td><a href="javascript:getVnfData('<%= rowObj.vnf_name %>','<%= rowObj.vnf_type %>');"><%= rowObj.row.svc_request_id %></a></td>
			<td><%= rowObj.vnf_name %></td>
			<td><%= rowObj.vnf_type %></td>
            <td><%= rowObj.row.svc_action %></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><%= JSON.stringify(rowObj.filecontent,null,4) %></pre>
                    </div>
                </div>
           </td>

            <td><%= rowObj.row.ts %></td>
			<% if(priv == 'A' ) { %>
            <td>
				<button type="button" class="btn btn-default btn-xs"
                onclick="deleteVnfData('<%= rowObj.row.id %>','<%= rowObj.row.svc_request_id %>','<%= rowObj.row.filename %>','<%= rowObj.row.status %>','<%= rowObj.vnf_name %>','<%= rowObj.vnf_type %>');">Delete</button>
            <% if (typeof rowObj.vnf_name != 'undefined' || typeof rowObj.vnf_type != 'undefined'){ %>
				<button type="button" class="btn btn-default btn-xs"
                onclick="loadVnfData('<%= rowObj.row.id %>','<%= rowObj.row.svc_request_id %>','<%= rowObj.row.svc_action %>','<%= rowObj.row.status %>','<%= rowObj.row.filename %>','<%= rowObj.row.ts %>');">Load Data</button>
            <% } %>
            </td>
            <% } %>
        </tr>
		<% i++; }); %>
      </tbody>
    </table>

	<% if(priv == 'A'){ %>
	<div class="row">
    <div class="col-md-8  col-md-push-4">
	<form method="POST" action="/mobility/uploadVnfData" enctype="multipart/form-data">
		<div class="form-group">
    		<label for="dest">Upload pre processed JSON file.</label>
    		<input name="filename" type="file" id="dest">
    		<p class="help-block">Choose a JSON file to upload.</p>
            <button type="button" class="btn btn-default"
				data-toggle="tooltip" data-placement="bottom"
				title="Upload a JSON file that has already been pre processed."
                onclick="uploadFile(this.form);">Upload JSON File</button>
  		</div>
	</form>
    </div>
	<div class="col-md-4 col-md-pull-8">
	<form method="POST" action="/preload/uploadVnfCsv" enctype="multipart/form-data">
		<div class="form-group">
    		<label for="dest">Upload Worksheet CSV files from the <%= preloadImportDirectory %> directory.</label>
    		<input name="filename" type="file" id="dest" multiple>
    		<p class="help-block">Choose Worksheet CSV files to upload.</p>
			<button type="button" class="btn btn-default" 
				data-toggle="tooltip" data-placement="bottom" 
				title="Must upload all the VNF CSV files from <%= preloadImportDirectory %>"
				onclick="importWorksheet(this.form);">Upload VNF Worksheet CSV files
			</button>
  		</div>
	</form>
	</div>
	</div>
	<% } %>
</div>

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

<script type="text/javascript">

function importWorksheet(form)
{
    if ( form.filename.value.length == 0)
    {
        bootbox.alert('Must select a file.');
        return false;
    }
    else { 

		bootbox.confirm({
        	message: "Are you sure you want to import VNF WORKSHEET .csv files from <%= preloadImportDirectory %>",
        	callback: function(result) {
            	if ( result )
            	{
					form.submit();
            	}
            	return;
        	},
        	buttons: {
            	cancel: {
                	label: "Cancel"
            	},
            	confirm: {
                	label: "Yes"
            	}
        	}
    	});
	}
}


function getVnfData(vnf_name,vnf_type,svc_request_id)
{
	location.assign("/mobility/viewVnfData?vnf_name=" + vnf_name + "&vnf_type=" + vnf_type );
	return;
}
function loadVnfData(id,svc_request_id,svc_action,status,filename,ts)
{
	if ( status != 'pending' )
	{
		bootbox.alert("Upload Status must be in 'pending' state.");
		return;
	}
	bootbox.confirm({
        message: "Are you sure you want to load file [" + filename + "]? ",
        callback: function(result) {
            if ( result )
            {
				location.assign("/mobility/loadVnfData?id=" + id + "&svc_request_id=" + svc_request_id + "&filename=" + filename + "&status=" + status);
            }
            return;
        },
        buttons: {
            cancel: {
                label: "Cancel"
            },
            confirm: {
                label: "Yes"
            }
        }
    });
}

function deleteVnfData(id,svc_request_id,filename,status,vnf_name,vnf_type) {

    bootbox.confirm({
        message: "Are you sure you want to delete uploaded file [" + filename + "]? ",
        callback: function(result) {
            if ( result )
            {
				location.assign("/mobility/deleteVnfData?id=" 
					+ id 
					+ "&svc_request_id=" + svc_request_id 
					+ "&filename=" + filename 
					+ "&status=" + status
					+ "&vnf_name=" + vnf_name
					+ "&vnf_type=" + vnf_type);
            }
            return;
        },
        buttons: {
            cancel: {
                label: "Cancel"
            },
            confirm: {
                label: "Yes"
            }
        }
    });
}

</script>

</body>
</html>