Skip to content

Commit f8d03b0

Browse files
v1.0.3
1 parent e5c2407 commit f8d03b0

15 files changed

+454
-538
lines changed

admin/certificates.html

Lines changed: 23 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -245,50 +245,27 @@ <h5 class="modal-title" id="exampleModalLabel">View Certificate</h5>
245245
const urlParams = new URLSearchParams(queryString);
246246
const remoteName = urlParams.get('remote');
247247
const projectName = urlParams.get('project');
248-
var loadCertificateTable = true;
249-
var operationNumber = "";
250248
var certificateToUpdate = "";
251249

252-
function operationStatusCheck(data){
253-
var operationData = JSON.parse(data);
254-
console.log(operationData);
255-
if (operationData.error_code == 404 || operationData.status_code == 200){
256-
operationNumber = "";
257-
$('#spinner').hide();
258-
}
259-
if (operationData.metadata.status_code >= 400){
260-
alert(operationData.metadata.err);
261-
}
262-
}
263-
264250
function loadPageContent(){
265-
//Check the status of an operation if running
266-
if (operationNumber != ""){
267-
$.get("./php/lxd/operation-status.php?remote=" + encodeURI(remoteName) + "&id=" + encodeURI(operationNumber) , operationStatusCheck);
268-
}
269-
270-
if (loadCertificateTable == false){
271-
$('#certificateListTable').DataTable().ajax.reload();
272-
}
273-
274-
if (loadCertificateTable == true){
275-
$('#certificateListTable').DataTable( {
276-
ajax: "./php/lxd/certificate-list.php?remote=" + encodeURI(remoteName) + "&project=" + encodeURI(projectName),
277-
columns: [
278-
{},
279-
{ title: "Name" },
280-
{ title: "Type" },
281-
{ title: "Fingerprint" },
282-
{ title: "Action" }
283-
],
284-
order: [],
285-
columnDefs: [
286-
{ targets: 0, orderable: false, width: "25px" }
287-
]
288-
});
289-
loadCertificateTable = false;
290-
}
251+
$('#certificateListTable').DataTable( {
252+
ajax: "./php/lxd/certificate-list.php?remote=" + encodeURI(remoteName) + "&project=" + encodeURI(projectName),
253+
columns: [
254+
{},
255+
{ title: "Name" },
256+
{ title: "Type" },
257+
{ title: "Fingerprint" },
258+
{ title: "Action" }
259+
],
260+
order: [],
261+
columnDefs: [
262+
{ targets: 0, orderable: false, width: "25px" }
263+
]
264+
});
265+
}
291266

267+
function reloadPageContent(){
268+
$('#certificateListTable').DataTable().ajax.reload();
292269
}
293270

294271
//API uses sync
@@ -301,7 +278,7 @@ <h5 class="modal-title" id="exampleModalLabel">View Certificate</h5>
301278
if (operationData.error_code >= 400){
302279
alert(operationData.error);
303280
}
304-
loadPageContent();
281+
setTimeout(() => { reloadPageContent(); }, 1000);
305282
});
306283
}
307284

@@ -321,6 +298,7 @@ <h5 class="modal-title" id="exampleModalLabel">View Certificate</h5>
321298
});
322299
}
323300

301+
//API uses sync
324302
function updateCertificate(){
325303
var certificateUpdateJSON = $("#jsonEditInput").val();
326304
console.log("Info: updating certificate " + certificateToUpdate);
@@ -330,11 +308,10 @@ <h5 class="modal-title" id="exampleModalLabel">View Certificate</h5>
330308
if (operationData.error_code >= 400){
331309
alert(operationData.error);
332310
}
333-
loadPageContent();
311+
setTimeout(() => { reloadPageContent(); }, 1000);
334312
});
335313
}
336314

337-
338315
//API uses sync
339316
function deleteCertificate(certificateToDelete){
340317
console.log("Info: deleting certificate " + certificateToDelete);
@@ -344,12 +321,11 @@ <h5 class="modal-title" id="exampleModalLabel">View Certificate</h5>
344321
if (operationData.error_code >= 400){
345322
alert(operationData.error);
346323
}
347-
loadPageContent();
324+
setTimeout(() => { reloadPageContent(); }, 1000);
348325
});
349326
}
350327

351328

352-
353329
$(document).ready(function(){
354330

355331
//Load in the sidebar
@@ -363,16 +339,14 @@ <h5 class="modal-title" id="exampleModalLabel">View Certificate</h5>
363339
//Load the card contents
364340
loadPageContent();
365341

366-
//Set page reload every 4 seconds
367-
setInterval(function(){loadPageContent()}, 4000);
342+
//Set page reload every 15 seconds
343+
setInterval(function(){reloadPageContent()}, 15000);
368344

369345
$("#remoteListNav").load("./php/lxd/remote-list-nav.php?remote=" + encodeURI(remoteName) + "&project=" + encodeURI(projectName));
370346
$("#projectListNav").load("./php/lxd/project-list-nav.php?remote=" + encodeURI(remoteName) + "&project=" + encodeURI(projectName));
371347

372348
});
373349

374-
375-
376350
</script>
377351

378352
</html>

admin/cluster.html

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ <h6 class="m-0 font-weight-bold text-primary">Cluster Members</h6>
188188
const urlParams = new URLSearchParams(queryString);
189189
const remoteName = urlParams.get('remote');
190190
const projectName = urlParams.get('project');
191-
var loadClusterMemberTable = true;
192191
var operationNumber = "";
193192

194193

@@ -205,37 +204,27 @@ <h6 class="m-0 font-weight-bold text-primary">Cluster Members</h6>
205204
}
206205

207206
function loadPageContent(){
208-
//Check the status of an operation if running
209-
if (operationNumber != ""){
210-
$.get("./php/lxd/operation-status.php?remote=" + encodeURI(remoteName) + "&id=" + encodeURI(operationNumber) , operationStatusCheck);
211-
}
212-
213-
if (loadClusterMemberTable == false){
214-
$('#clusterMemberListTable').DataTable().ajax.reload();
215-
}
216-
217-
if (loadClusterMemberTable == true){
218-
$('#clusterMemberListTable').DataTable( {
219-
ajax: "./php/lxd/cluster-member-list.php?remote=" + encodeURI(remoteName) + "&project=" + encodeURI(projectName),
220-
columns: [
221-
{},
222-
{ title: "Server Name" },
223-
{ title: "URL" },
224-
{ title: "Database" },
225-
{ title: "Status" },
226-
{ title: "Message" },
227-
{ title: "Action" }
228-
],
229-
order: [],
230-
columnDefs: [
231-
{ targets: 0, orderable: false, width: "25px" }
232-
]
233-
});
234-
loadClusterMemberTable = false;
235-
}
236-
207+
$('#clusterMemberListTable').DataTable( {
208+
ajax: "./php/lxd/cluster-member-list.php?remote=" + encodeURI(remoteName) + "&project=" + encodeURI(projectName),
209+
columns: [
210+
{},
211+
{ title: "Server Name" },
212+
{ title: "URL" },
213+
{ title: "Database" },
214+
{ title: "Status" },
215+
{ title: "Message" },
216+
{ title: "Action" }
217+
],
218+
order: [],
219+
columnDefs: [
220+
{ targets: 0, orderable: false, width: "25px" }
221+
]
222+
});
237223
}
238224

225+
function reloadPageContent() {
226+
$('#clusterMemberListTable').DataTable().ajax.reload();
227+
}
239228

240229
//API uses sync
241230
function deleteClusterMember(memberToDelete){
@@ -246,7 +235,7 @@ <h6 class="m-0 font-weight-bold text-primary">Cluster Members</h6>
246235
if (operationData.error_code >= 400){
247236
alert(operationData.error);
248237
}
249-
loadPageContent();
238+
setTimeout(() => { reloadPageContent(); }, 1000);
250239
});
251240
}
252241

@@ -264,8 +253,8 @@ <h6 class="m-0 font-weight-bold text-primary">Cluster Members</h6>
264253
//Load the card contents
265254
loadPageContent();
266255

267-
//Set page reload every 4 seconds
268-
setInterval(function(){loadPageContent()}, 4000);
256+
//Set page reload every 15 seconds
257+
setInterval(function(){reloadPageContent()}, 15000);
269258

270259
$("#remoteListNav").load("./php/lxd/remote-list-nav.php?remote=" + encodeURI(remoteName) + "&project=" + encodeURI(projectName));
271260
$("#projectListNav").load("./php/lxd/project-list-nav.php?remote=" + encodeURI(remoteName) + "&project=" + encodeURI(projectName));

admin/images.html

Lines changed: 59 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -266,56 +266,56 @@ <h5 class="modal-title" id="exampleModalLabel">Edit Image</h5>
266266
const urlParams = new URLSearchParams(queryString);
267267
const remoteName = urlParams.get('remote');
268268
const projectName = urlParams.get('project');
269-
var loadImageTable = true;
270269
var selectList = "";
271270
var operationNumber = "";
272271
var imageToUpdate = "";
273272

274-
function operationStatusCheck(data){
275-
var operationData = JSON.parse(data);
276-
console.log(operationData);
277-
if (operationData.error_code == 404){ //remains status code 200 throughout download
278-
operationNumber = "";
279-
$('#spinner').hide();
280-
} else {
281-
if (operationData.status_code == 200){
282-
if (operationData.metadata.status_code >= 400){
283-
alert(operationData.metadata.err);
273+
function operationStatusCheck(){
274+
if (operationNumber != ""){
275+
$.get("./php/lxd/operation-status.php?remote=" + encodeURI(remoteName) + "&id=" + encodeURI(operationNumber) , function (data) {
276+
var operationData = JSON.parse(data);
277+
console.log(operationData);
278+
if (operationData.error_code == 404) {
279+
operationNumber = "";
280+
$('#spinner').hide();
281+
reloadPageContent();
282+
}
283+
if (operationData.status_code == 200) {
284+
if (operationData.metadata.status_code == 200){
285+
operationNumber = "";
286+
$('#spinner').hide();
287+
reloadPageContent();
288+
}
289+
if (operationData.metadata.status_code >= 400){
290+
operationNumber = "";
291+
$('#spinner').hide();
292+
alert(operationData.metadata.err);
293+
reloadPageContent();
294+
}
284295
}
285-
}
296+
});
297+
}
298+
if (operationNumber != "") {
299+
setTimeout(() => { operationStatusCheck(); }, 4000);
286300
}
287301
}
288-
302+
289303
function loadPageContent(){
290-
//Check the status of an operation if running
291-
if (operationNumber != ""){
292-
$.get("./php/lxd/operation-status.php?remote=" + encodeURI(remoteName) + "&id=" + encodeURI(operationNumber) , operationStatusCheck);
293-
}
294-
295-
if (loadImageTable == false){
296-
$('#imageListTable').DataTable().ajax.reload();
297-
}
298-
299-
if (loadImageTable == true){
300-
$('#imageListTable').DataTable( {
301-
ajax: "./php/lxd/image-list.php?remote=" + encodeURI(remoteName) + "&project=" + encodeURI(projectName),
302-
columns: [
303-
{},
304-
{ title: "Description" },
305-
{ title: "Fingerprint" },
306-
{ title: "Type" },
307-
{ title: "Size" },
308-
{ title: "Action" }
309-
],
310-
order: [],
311-
columnDefs: [
312-
{ targets: 0, orderable: false, width: "25px" }
313-
]
314-
});
315-
loadImageTable = false;
316-
}
317-
318-
304+
$('#imageListTable').DataTable( {
305+
ajax: "./php/lxd/image-list.php?remote=" + encodeURI(remoteName) + "&project=" + encodeURI(projectName),
306+
columns: [
307+
{},
308+
{ title: "Description" },
309+
{ title: "Fingerprint" },
310+
{ title: "Type" },
311+
{ title: "Size" },
312+
{ title: "Action" }
313+
],
314+
order: [],
315+
columnDefs: [
316+
{ targets: 0, orderable: false, width: "25px" }
317+
]
318+
});
319319

320320
//Load the select List for Download Image Modal
321321
$.get("./php/lxd/simplestreams-list-select.php?remote=" + encodeURI(remoteName) + "&project=" + encodeURI(projectName), function (data) {
@@ -324,7 +324,18 @@ <h5 class="modal-title" id="exampleModalLabel">Edit Image</h5>
324324
selectList = data;
325325
}
326326
});
327+
}
328+
329+
function reloadPageContent() {
330+
$('#imageListTable').DataTable().ajax.reload();
327331

332+
//Load the select List for Download Image Modal
333+
$.get("./php/lxd/simplestreams-list-select.php?remote=" + encodeURI(remoteName) + "&project=" + encodeURI(projectName), function (data) {
334+
if (selectList != data){
335+
$("#selectRepoInput").html(data);
336+
selectList = data;
337+
}
338+
});
328339
}
329340

330341
//API uses async
@@ -340,7 +351,7 @@ <h5 class="modal-title" id="exampleModalLabel">Edit Image</h5>
340351
if (operationData.metadata.status_code >= 400){
341352
alert(operationData.metadata.err);
342353
}
343-
loadPageContent();
354+
setTimeout(() => { operationStatusCheck(); }, 4000);
344355
});
345356
}
346357

@@ -357,7 +368,7 @@ <h5 class="modal-title" id="exampleModalLabel">Edit Image</h5>
357368
if (operationData.metadata.status_code >= 400){
358369
alert(operationData.metadata.err);
359370
}
360-
loadPageContent();
371+
setTimeout(() => { operationStatusCheck(); }, 4000);
361372
});
362373
}
363374

@@ -377,7 +388,7 @@ <h5 class="modal-title" id="exampleModalLabel">Edit Image</h5>
377388
if (operationData.metadata.status_code >= 400){
378389
alert(operationData.metadata.err);
379390
}
380-
loadPageContent();
391+
setTimeout(() => { operationStatusCheck(); }, 4000);
381392
});
382393
}
383394

@@ -406,11 +417,10 @@ <h5 class="modal-title" id="exampleModalLabel">Edit Image</h5>
406417
if (operationData.error_code >= 400){
407418
alert(operationData.error);
408419
}
409-
loadPageContent();
420+
setTimeout(() => { operationStatusCheck(); }, 4000);
410421
});
411422
}
412423

413-
414424
$(document).ready(function(){
415425

416426
//Load in the sidebar
@@ -424,8 +434,8 @@ <h5 class="modal-title" id="exampleModalLabel">Edit Image</h5>
424434
//Load the card contents
425435
loadPageContent();
426436

427-
//Set page reload every 4 seconds
428-
setInterval(function(){loadPageContent()}, 4000);
437+
//Set page reload every 15 seconds
438+
setInterval(function(){reloadPageContent()}, 15000);
429439

430440
$("#remoteListNav").load("./php/lxd/remote-list-nav.php?remote=" + encodeURI(remoteName) + "&project=" + encodeURI(projectName));
431441
$("#projectListNav").load("./php/lxd/project-list-nav.php?remote=" + encodeURI(remoteName) + "&project=" + encodeURI(projectName));

0 commit comments

Comments
 (0)