@@ -254,39 +254,272 @@ <h2 class="toast-header">Trust AT (TAT) Management</h2>
254254
255255<!-- DataTables Initialization -->
256256< script >
257- $ ( document ) . ready ( function ( ) {
258- $ ( '#open-terminal-table, #open-ops-table, #approved-terminal-table, #approved-ops-table, #denied-terminal-table, #denied-ops-table' ) . DataTable ( ) ;
257+ function reloadTerminalTATs ( ) {
258+ $ . get ( '/api/v1/zerotrust/accesstoken/list/terminal' , function ( data ) {
259+ const $table = $ ( '#open-terminal-table' ) . DataTable ( ) ;
260+ $table . clear ( ) ;
261+
262+ for ( let s of data ) {
263+ let actions = '' ;
264+ if ( s . canApprove ) {
265+ actions += `<button id="app_btn_${ s . id } " class="btn-secondary app_btn">Approve</button>` ;
266+ }
267+ if ( s . canDeny ) {
268+ actions += `<button id="den_btn_${ s . id } " class="btn-secondary den_btn">Deny</button>` ;
269+ }
270+ if ( s . isCurrentUser ) {
271+ actions += `<button id="rev_btn_${ s . id } " class="btn-secondary rev_btn">Revoke</button>` ;
272+ }
273+
274+ $table . row . add ( [
275+ s . command ,
276+ s . userName ,
277+ s . hostName ,
278+ actions
279+ ] ) ;
280+ }
281+
282+ $table . draw ( ) ;
283+ attachZtatButtonHandlers ( ) ; // re-bind the click events
284+ } ) ;
285+
286+ $ . get ( '/api/v1/zerotrust/accesstoken/list/approved/terminal' , function ( data ) {
287+ const $table = $ ( '#approved-terminal-table' ) . DataTable ( ) ;
288+ $table . clear ( ) ;
289+
290+ for ( let s of data ) {
291+ let actions = '' ;
292+ if ( s . canApprove ) {
293+ actions += `<button id="app_btn_${ s . id } " class="btn-secondary app_btn">Approve</button>` ;
294+ }
295+ if ( s . canDeny ) {
296+ actions += `<button id="den_btn_${ s . id } " class="btn-secondary den_btn">Deny</button>` ;
297+ }
298+ if ( s . isCurrentUser ) {
299+ actions += `<button id="rev_btn_${ s . id } " class="btn-secondary rev_btn">Revoke</button>` ;
300+ }
301+
302+ $table . row . add ( [
303+ s . command ,
304+ s . userName ,
305+ s . hostName ,
306+ s . usesRemaining ,
307+ actions
308+ ] ) ;
309+ }
310+
311+ $table . draw ( ) ;
312+ attachZtatButtonHandlers ( ) ; // re-bind the click events
313+ } ) ;
314+
315+ $ . get ( '/api/v1/zerotrust/accesstoken/list/denied/terminal' , function ( data ) {
316+ const $table = $ ( '#denied-terminal-table' ) . DataTable ( ) ;
317+ $table . clear ( ) ;
318+
319+ for ( let s of data ) {
320+ let actions = '' ;
321+ if ( s . canApprove ) {
322+ actions += `<button id="app_btn_${ s . id } " class="btn-secondary app_btn">Approve</button>` ;
323+ }
324+ if ( s . canDeny ) {
325+ actions += `<button id="den_btn_${ s . id } " class="btn-secondary den_btn">Deny</button>` ;
326+ }
327+
328+ $table . row . add ( [
329+ s . command ,
330+ s . userName ,
331+ s . hostName ,
332+ actions
333+ ] ) ;
334+ }
335+
336+ $table . draw ( ) ;
337+ attachZtatButtonHandlers ( ) ; // re-bind the click events
338+ } ) ;
339+ }
340+
341+ function reloadOpsTATs ( ) {
342+ $ . get ( '/api/v1/zerotrust/accesstoken/list/ops' , function ( data ) {
343+ const $table = $ ( '#open-ops-table' ) . DataTable ( ) ;
344+ $table . clear ( ) ;
345+
346+ for ( let s of data ) {
347+ let actions = '' ;
348+ if ( s . canApprove ) {
349+ actions += `<button id="ops_app_btn_${ s . id } " class="btn-secondary ops_app_btn">Approve</button>` ;
350+ }
351+ if ( s . canDeny ) {
352+ actions += `<button id="ops_den_btn_${ s . id } " class="btn-secondary ops_den_btn">Deny</button>` ;
353+ }
354+ if ( s . isCurrentUser ) {
355+ actions += `<button id="ops_rev_btn_${ s . id } " class="btn-secondary ops_rev_btn">Revoke</button>` ;
356+ }
357+
358+ $table . row . add ( [
359+ s . summary ,
360+ s . userName ,
361+ actions
362+ ] ) ;
363+ }
364+
365+ $table . draw ( ) ;
366+ attachZtatButtonHandlers ( ) ; // re-bind the click events
367+ } ) ;
259368
260- $ ( ".app_btn" ) . click ( function ( ) {
369+ $ . get ( '/api/v1/zerotrust/accesstoken/list/approved/ops' , function ( data ) {
370+ const $table = $ ( '#approved-ops-table' ) . DataTable ( ) ;
371+ $table . clear ( ) ;
372+
373+ for ( let s of data ) {
374+ let actions = '' ;
375+ if ( s . canApprove ) {
376+ actions += `<button id="ops_app_btn_${ s . id } " class="btn-secondary ops_app_btn">Approve</button>` ;
377+ }
378+ if ( s . canDeny ) {
379+ actions += `<button id="ops_den_btn_${ s . id } " class="btn-secondary ops_den_btn">Deny</button>` ;
380+ }
381+ if ( s . isCurrentUser ) {
382+ actions += `<button id="ops_rev_btn_${ s . id } " class="btn-secondary ops_rev_btn">Revoke</button>` ;
383+ }
384+
385+ $table . row . add ( [
386+ s . summary ,
387+ s . userName ,
388+ s . usesRemaining
389+ ] ) ;
390+ }
391+
392+ $table . draw ( ) ;
393+ attachZtatButtonHandlers ( ) ; // re-bind the click events
394+ } ) ;
395+
396+ $ . get ( '/api/v1/zerotrust/accesstoken/list/denied/ops' , function ( data ) {
397+ const $table = $ ( '#denied-ops-table' ) . DataTable ( ) ;
398+ $table . clear ( ) ;
399+
400+ for ( let s of data ) {
401+ let actions = '' ;
402+ if ( s . canApprove ) {
403+ actions += `<button id="ops_app_btn_${ s . id } " class="btn-secondary ops_app_btn">Approve</button>` ;
404+ }
405+ if ( s . canDeny ) {
406+ actions += `<button id="ops_den_btn_${ s . id } " class="btn-secondary ops_den_btn">Deny</button>` ;
407+ }
408+
409+ $table . row . add ( [
410+ s . summary ,
411+ s . userName ,
412+ actions
413+ ] ) ;
414+ }
415+
416+ $table . draw ( ) ;
417+ attachZtatButtonHandlers ( ) ; // re-bind the click events
418+ } ) ;
419+ }
420+
421+
422+ function attachZtatButtonHandlers ( ) {
423+ $ ( ".app_btn" ) . off ( ) . click ( function ( ) {
261424 let id = this . id . split ( "_" ) . pop ( ) ;
262- $ . get ( '/api/v1/zerotrust/accesstoken/terminal/approve?ztatId=' + id , { } , function ( ) {
263- location . reload ( ) ; } ) ;
425+ $ . get ( '/api/v1/zerotrust/accesstoken/terminal/approve?ztatId=' + id , { } , function ( ) {
426+ reloadTerminalTATs ( ) ;
427+ } ) ;
264428 } ) ;
265429
266- $ ( ".den_btn" ) . click ( function ( ) {
430+ $ ( ".den_btn" ) . off ( ) . click ( function ( ) {
267431 let id = this . id . split ( "_" ) . pop ( ) ;
268- $ . get ( '/api/v1/zerotrust/accesstoken/terminal/deny?ztatId=' + id , { } , function ( ) { location . reload ( ) ; } ) ;
432+ $ . get ( '/api/v1/zerotrust/accesstoken/terminal/deny?ztatId=' + id , { } , function ( ) {
433+ reloadTerminalTATs ( ) ;
434+ } ) ;
269435 } ) ;
270436
271- $ ( ".rev_btn" ) . click ( function ( ) {
437+ $ ( ".rev_btn" ) . off ( ) . click ( function ( ) {
272438 let id = this . id . split ( "_" ) . pop ( ) ;
273- $ . get ( '/api/v1/zerotrust/accesstoken/terminal/revoke?ztatId=' + id , { } , function ( ) { location . reload ( ) ; } ) ;
439+ $ . get ( '/api/v1/zerotrust/accesstoken/terminal/revoke?ztatId=' + id , { } , function ( ) {
440+ reloadTerminalTATs ( ) ;
441+ } ) ;
274442 } ) ;
275443
276- $ ( ".ops_app_btn" ) . click ( function ( ) {
444+ $ ( ".ops_app_btn" ) . off ( ) . click ( function ( ) {
277445 let id = this . id . split ( "_" ) . pop ( ) ;
278- $ . get ( '/api/v1/zerotrust/accesstoken/ops/approve?ztatId=' + id , { } , function ( ) { location . reload ( ) ; } ) ;
446+ $ . get ( '/api/v1/zerotrust/accesstoken/ops/approve?ztatId=' + id , { } , function ( ) {
447+ reloadOpsTATs ( ) ;
448+ } ) ;
279449 } ) ;
280450
281- $ ( ".ops_den_btn" ) . click ( function ( ) {
451+ $ ( ".ops_den_btn" ) . off ( ) . click ( function ( ) {
282452 let id = this . id . split ( "_" ) . pop ( ) ;
283- $ . get ( '/api/v1/zerotrust/accesstoken/ops/deny?ztatId=' + id , { } , function ( ) { location . reload ( ) ; } ) ;
453+ $ . get ( '/api/v1/zerotrust/accesstoken/ops/deny?ztatId=' + id , { } , function ( ) {
454+ reloadOpsTATs ( ) ;
455+ } ) ;
284456 } ) ;
285457
286- $ ( ".ops_rev_btn" ) . click ( function ( ) {
458+ $ ( ".ops_rev_btn" ) . off ( ) . click ( function ( ) {
287459 let id = this . id . split ( "_" ) . pop ( ) ;
288- $ . get ( '/api/v1/zerotrust/accesstoken/my/ops/revoke?ztatId=' + id , { } , function ( ) { location . reload ( ) ; } ) ;
460+ $ . get ( '/api/v1/zerotrust/accesstoken/my/ops/revoke?ztatId=' + id , { } , function ( ) {
461+ reloadOpsTATs ( ) ;
462+ } ) ;
289463 } ) ;
464+ }
465+
466+ let openTerminalTable , openOpsTable , approvedTerminalTable , approvedOpsTable , deniedTerminalTable , deniedOpsTable ;
467+
468+ $ ( document ) . ready ( function ( ) {
469+ openTerminalTable = $ ( '#open-terminal-table' ) . DataTable ( {
470+ columns : [
471+ { title : "Operation" } ,
472+ { title : "User" } ,
473+ { title : "System" } ,
474+ { title : "Actions" }
475+ ]
476+ } ) ;
477+
478+ openOpsTable = $ ( '#open-ops-table' ) . DataTable ( {
479+ columns : [
480+ { title : "Operation" } ,
481+ { title : "User" } ,
482+ { title : "Actions" }
483+ ]
484+ } ) ;
485+
486+ approvedTerminalTable = $ ( '#approved-terminal-table' ) . DataTable ( {
487+ columns : [
488+ { title : "Operation" } ,
489+ { title : "User" } ,
490+ { title : "System" } ,
491+ { title : "Uses Remaining" } ,
492+ { title : "Actions" }
493+ ]
494+ } ) ;
495+
496+ approvedOpsTable = $ ( '#approved-ops-table' ) . DataTable ( {
497+ columns : [
498+ { title : "Operation" } ,
499+ { title : "User" } ,
500+ { title : "Uses Remaining" } ,
501+ { title : "Actions" }
502+ ]
503+ } ) ;
504+
505+ deniedTerminalTable = $ ( '#denied-terminal-table' ) . DataTable ( {
506+ columns : [
507+ { title : "Operation" } ,
508+ { title : "User" } ,
509+ { title : "System" } ,
510+ { title : "Actions" }
511+ ]
512+ } ) ;
513+
514+ deniedOpsTable = $ ( '#denied-ops-table' ) . DataTable ( {
515+ columns : [
516+ { title : "Operation" } ,
517+ { title : "User" } ,
518+ { title : "Actions" }
519+ ]
520+ } ) ;
521+
522+ attachZtatButtonHandlers ( ) ;
290523 } ) ;
291524</ script >
292525
0 commit comments