@@ -347,51 +347,165 @@ export async function showDataView(source: string, type: string, title: string,
347347export async function getTableHtml ( webview : Webview , file : string ) : Promise < string > {
348348 resDir = isGuestSession ? guestResDir : resDir ;
349349 const content = await readContent ( file , 'utf8' ) ;
350-
351350 return `
352351<!DOCTYPE html>
353352<html lang="en">
354353<head>
355354 <meta charset="utf-8">
356355 <meta name="viewport" content="width=device-width, initial-scale=1">
357- <link href="${ String ( webview . asWebviewUri ( Uri . file ( path . join ( resDir , 'bootstrap.min.css' ) ) ) ) } " rel="stylesheet">
358- <link href="${ String ( webview . asWebviewUri ( Uri . file ( path . join ( resDir , 'dataTables.bootstrap4.min.css' ) ) ) ) } " rel="stylesheet">
359- <link href="${ String ( webview . asWebviewUri ( Uri . file ( path . join ( resDir , 'fixedHeader.jqueryui.min.css' ) ) ) ) } " rel="stylesheet">
360- <style type="text/css">
356+ <style media="only screen">
357+ html, body {
358+ height: 100%;
359+ width: 100%;
360+ margin: 0;
361+ box-sizing: border-box;
362+ -webkit-overflow-scrolling: touch;
363+ }
364+
365+ html {
366+ position: absolute;
367+ top: 0;
368+ left: 0;
369+ padding: 0;
370+ overflow: auto;
371+ }
372+
361373 body {
362- color: black;
363- background-color: white;
374+ padding: 0;
375+ overflow: auto;
376+ }
377+
378+ /* Styling for wrapper and header */
379+
380+ [class*="vscode"] div.ag-root-wrapper {
381+ background-color: var(--vscode-editor-background);
382+ }
383+
384+ [class*="vscode"] div.ag-header {
385+ background-color: var(--vscode-sideBar-background);
386+ }
387+
388+ [class*="vscode"] div.ag-header-cell[aria-sort="ascending"], div.ag-header-cell[aria-sort="descending"] {
389+ color: var(--vscode-textLink-activeForeground);
364390 }
365- table {
366- font-size: 0.75em;
391+
392+ /* Styling for rows and cells */
393+
394+ [class*="vscode"] div.ag-row {
395+ color: var(--vscode-editor-foreground);
396+ }
397+
398+ [class*="vscode"] .ag-row-hover {
399+ background-color: var(--vscode-list-hoverBackground) !important;
400+ color: var(--vscode-list-hoverForeground);
401+ }
402+
403+ [class*="vscode"] .ag-row-selected {
404+ background-color: var(--vscode-editor-selectionBackground) !important;
405+ color: var(--vscode-editor-selectionForeground) !important;
406+ }
407+
408+ [class*="vscode"] div.ag-row-even {
409+ border: 0px;
410+ background-color: var(--vscode-editor-background);
411+ }
412+
413+ [class*="vscode"] div.ag-row-odd {
414+ border: 0px;
415+ background-color: var(--vscode-sideBar-background);
416+ }
417+
418+ [class*="vscode"] div.ag-ltr div.ag-has-focus div.ag-cell-focus:not(div.ag-cell-range-selected) {
419+ border-color: var(--vscode-editorCursor-foreground);
420+ }
421+
422+ /* Styling for the filter pop-up */
423+
424+ [class*="vscode"] div.ag-menu {
425+ background-color: var(--vscode-notifications-background);
426+ color: var(--vscode-notifications-foreground);
427+ border-color: var(--vscode-notifications-border);
428+ }
429+
430+ [class*="vscode"] div.ag-filter-apply-panel-button {
431+ background-color: var(--vscode-button-background);
432+ color: var(--vscode-button-foreground);
433+ border: 0;
434+ padding: 5px 10px;
435+ font-size: 12px;
436+ }
437+
438+ [class*="vscode"] div.ag-picker-field-wrapper {
439+ background-color: var(--vscode-editor-background);
440+ color: var(--vscode-editor-foreground);
441+ border-color: var(--vscode-notificationCenter-border);
442+ }
443+
444+ [class*="vscode"] input[class^=ag-] {
445+ border-color: var(--vscode-notificationCenter-border) !important;
367446 }
368447 </style>
369- </head>
370- <body>
371- <div class="container-fluid">
372- <table id="data-table" class="display table table-sm table-striped table-condensed table-hover"></table>
373- </div>
374- <script src="${ String ( webview . asWebviewUri ( Uri . file ( path . join ( resDir , 'jquery.min.js' ) ) ) ) } "></script>
375- <script src="${ String ( webview . asWebviewUri ( Uri . file ( path . join ( resDir , 'jquery.dataTables.min.js' ) ) ) ) } "></script>
376- <script src="${ String ( webview . asWebviewUri ( Uri . file ( path . join ( resDir , 'dataTables.bootstrap4.min.js' ) ) ) ) } "></script>
377- <script src="${ String ( webview . asWebviewUri ( Uri . file ( path . join ( resDir , 'dataTables.fixedHeader.min.js' ) ) ) ) } "></script>
378- <script src="${ String ( webview . asWebviewUri ( Uri . file ( path . join ( resDir , 'fixedHeader.jqueryui.min.js' ) ) ) ) } "></script>
448+ <script src="${ String ( webview . asWebviewUri ( Uri . file ( path . join ( resDir , 'ag-grid-community.min.noStyle.js' ) ) ) ) } "></script>
449+ <link href="${ String ( webview . asWebviewUri ( Uri . file ( path . join ( resDir , 'ag-grid.min.css' ) ) ) ) } " rel="stylesheet">
450+ <link href="${ String ( webview . asWebviewUri ( Uri . file ( path . join ( resDir , 'ag-theme-balham.min.css' ) ) ) ) } " rel="stylesheet">
451+ <link href="${ String ( webview . asWebviewUri ( Uri . file ( path . join ( resDir , 'ag-theme-balham-dark.min.css' ) ) ) ) } " rel="stylesheet">
379452 <script>
380- var data = ${ String ( content ) } ;
381- $(document).ready(function () {
382- $("#data-table").DataTable({
383- data: data.data,
384- columns: data.columns,
385- paging: false,
386- autoWidth: false,
387- order: [],
388- fixedHeader: true
389- });
390- $("#data-table tbody").on("click", "tr", function() {
391- $(this).toggleClass("table-active");
453+ const data = ${ String ( content ) } ;
454+ function updateTheme() {
455+ const gridDiv = document.querySelector('#myGrid');
456+ if (document.body.classList.contains('vscode-light')) {
457+ gridDiv.className = 'ag-theme-balham';
458+ } else {
459+ gridDiv.className = 'ag-theme-balham-dark';
460+ }
461+ }
462+ function autoSizeAll(skipHeader) {
463+ var allColumnIds = [];
464+ gridOptions.columnApi.getAllColumns().forEach(function (column) {
465+ allColumnIds.push(column.colId);
392466 });
467+ gridOptions.columnApi.autoSizeColumns(allColumnIds, skipHeader);
468+ }
469+ const gridOptions = {
470+ defaultColDef: {
471+ sortable: true,
472+ resizable: true,
473+ filter: true,
474+ filterParams: {
475+ buttons: ['reset', 'apply']
476+ }
477+ },
478+ columnDefs: data.columns,
479+ rowData: data.data,
480+ rowSelection: 'multiple',
481+ pagination: true,
482+ enableCellTextSelection: true,
483+ ensureDomOrder: true,
484+ onGridReady: function (params) {
485+ gridOptions.api.sizeColumnsToFit();
486+ autoSizeAll(false);
487+ }
488+ };
489+ document.addEventListener('DOMContentLoaded', () => {
490+ const gridDiv = document.querySelector('#myGrid');
491+ new agGrid.Grid(gridDiv, gridOptions);
393492 });
493+ function onload() {
494+ updateTheme();
495+ const observer = new MutationObserver(function (event) {
496+ updateTheme();
497+ });
498+ observer.observe(document.body, {
499+ attributes: true,
500+ attributeFilter: ['class'],
501+ childList: false,
502+ characterData: false
503+ });
504+ }
394505 </script>
506+ </head>
507+ <body onload='onload()'>
508+ <div id="myGrid" style="height: 100%;"></div>
395509</body>
396510</html>
397511` ;
@@ -412,11 +526,42 @@ export async function getListHtml(webview: Webview, file: string): Promise<strin
412526 <link href="${ String ( webview . asWebviewUri ( Uri . file ( path . join ( resDir , 'jquery.json-viewer.css' ) ) ) ) } " rel="stylesheet">
413527 <style type="text/css">
414528 body {
415- color: black;
416- background-color: white;
529+ color: var(--vscode-editor-foreground);
530+ background-color: var(--vscode-editor-background);
531+ }
532+
533+ .json-document {
534+ padding: 0 0;
417535 }
536+
418537 pre#json-renderer {
419- border: 1px solid #aaa;
538+ font-family: var(--vscode-editor-font-family);
539+ border: 0;
540+ }
541+
542+ ul.json-dict, ol.json-array {
543+ color: var(--vscode-symbolIcon-fieldForeground);
544+ border-left: 1px dotted var(--vscode-editorLineNumber-foreground);
545+ }
546+
547+ .json-literal {
548+ color: var(--vscode-symbolIcon-variableForeground);
549+ }
550+
551+ .json-string {
552+ color: var(--vscode-symbolIcon-stringForeground);
553+ }
554+
555+ a.json-toggle:before {
556+ color: var(--vscode-button-secondaryBackground);
557+ }
558+
559+ a.json-toggle:hover:before {
560+ color: var(--vscode-button-secondaryHoverBackground);
561+ }
562+
563+ a.json-placeholder {
564+ color: var(--vscode-input-placeholderForeground);
420565 }
421566 </style>
422567 <script>
0 commit comments