@@ -266,56 +266,56 @@ <h5 class="modal-title" id="exampleModalLabel">Edit Image</h5>
266
266
const urlParams = new URLSearchParams ( queryString ) ;
267
267
const remoteName = urlParams . get ( 'remote' ) ;
268
268
const projectName = urlParams . get ( 'project' ) ;
269
- var loadImageTable = true ;
270
269
var selectList = "" ;
271
270
var operationNumber = "" ;
272
271
var imageToUpdate = "" ;
273
272
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
+ }
284
295
}
285
- }
296
+ } ) ;
297
+ }
298
+ if ( operationNumber != "" ) {
299
+ setTimeout ( ( ) => { operationStatusCheck ( ) ; } , 4000 ) ;
286
300
}
287
301
}
288
-
302
+
289
303
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
+ } ) ;
319
319
320
320
//Load the select List for Download Image Modal
321
321
$ . 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>
324
324
selectList = data ;
325
325
}
326
326
} ) ;
327
+ }
328
+
329
+ function reloadPageContent ( ) {
330
+ $ ( '#imageListTable' ) . DataTable ( ) . ajax . reload ( ) ;
327
331
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
+ } ) ;
328
339
}
329
340
330
341
//API uses async
@@ -340,7 +351,7 @@ <h5 class="modal-title" id="exampleModalLabel">Edit Image</h5>
340
351
if ( operationData . metadata . status_code >= 400 ) {
341
352
alert ( operationData . metadata . err ) ;
342
353
}
343
- loadPageContent ( ) ;
354
+ setTimeout ( ( ) => { operationStatusCheck ( ) ; } , 4000 ) ;
344
355
} ) ;
345
356
}
346
357
@@ -357,7 +368,7 @@ <h5 class="modal-title" id="exampleModalLabel">Edit Image</h5>
357
368
if ( operationData . metadata . status_code >= 400 ) {
358
369
alert ( operationData . metadata . err ) ;
359
370
}
360
- loadPageContent ( ) ;
371
+ setTimeout ( ( ) => { operationStatusCheck ( ) ; } , 4000 ) ;
361
372
} ) ;
362
373
}
363
374
@@ -377,7 +388,7 @@ <h5 class="modal-title" id="exampleModalLabel">Edit Image</h5>
377
388
if ( operationData . metadata . status_code >= 400 ) {
378
389
alert ( operationData . metadata . err ) ;
379
390
}
380
- loadPageContent ( ) ;
391
+ setTimeout ( ( ) => { operationStatusCheck ( ) ; } , 4000 ) ;
381
392
} ) ;
382
393
}
383
394
@@ -406,11 +417,10 @@ <h5 class="modal-title" id="exampleModalLabel">Edit Image</h5>
406
417
if ( operationData . error_code >= 400 ) {
407
418
alert ( operationData . error ) ;
408
419
}
409
- loadPageContent ( ) ;
420
+ setTimeout ( ( ) => { operationStatusCheck ( ) ; } , 4000 ) ;
410
421
} ) ;
411
422
}
412
423
413
-
414
424
$ ( document ) . ready ( function ( ) {
415
425
416
426
//Load in the sidebar
@@ -424,8 +434,8 @@ <h5 class="modal-title" id="exampleModalLabel">Edit Image</h5>
424
434
//Load the card contents
425
435
loadPageContent ( ) ;
426
436
427
- //Set page reload every 4 seconds
428
- setInterval ( function ( ) { loadPageContent ( ) } , 4000 ) ;
437
+ //Set page reload every 15 seconds
438
+ setInterval ( function ( ) { reloadPageContent ( ) } , 15000 ) ;
429
439
430
440
$ ( "#remoteListNav" ) . load ( "./php/lxd/remote-list-nav.php?remote=" + encodeURI ( remoteName ) + "&project=" + encodeURI ( projectName ) ) ;
431
441
$ ( "#projectListNav" ) . load ( "./php/lxd/project-list-nav.php?remote=" + encodeURI ( remoteName ) + "&project=" + encodeURI ( projectName ) ) ;
0 commit comments