Skip to content

Commit

Permalink
add a refresh button
Browse files Browse the repository at this point in the history
  • Loading branch information
ZihengSun committed Sep 15, 2024
1 parent 010ab7d commit 040615c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/main/resources/static/js/gw.result.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ GW.result.browser = {
// GW.result.browser.loadFileList();
GW.result.browser.render_file_list()

$('#result-refresh-button').on('click', function() {
GW.result.browser.loadFolderContents("", GW.result.browser.fileTable);; // Reload the data from the server
});

},

render_file_list: function(){
var fileTable = $('#file-list-table').DataTable({
GW.result.browser.fileTable = $('#file-list-table').DataTable({
columns: [
{ data: 'name', render: function (data, type, row) {
let icon = '<i class="fas fa-file"></i>'; // Default icon
Expand Down Expand Up @@ -73,15 +77,15 @@ GW.result.browser = {
]
});

GW.result.browser.loadFolderContents("", fileTable);
GW.result.browser.loadFolderContents("", GW.result.browser.fileTable);

// Add click event to folder rows
$('#file-list-table tbody').on('click', 'tr td:first-child', function () {
var rowData = fileTable.row($(this).closest('tr')).data();
var rowData = GW.result.browser.fileTable.row($(this).closest('tr')).data();
if (rowData.isDirectory) {
// If the row is a folder, navigate into it
var path = rowData.path;
GW.result.browser.loadFolderContents(path, fileTable);
GW.result.browser.loadFolderContents(path, GW.result.browser.fileTable);
}
});

Expand All @@ -106,6 +110,8 @@ GW.result.browser = {

},



formatFileSize: function(bytes){
if (bytes === 0) return '0 B';
const k = 1024;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<div id="main-result-content" style="width:100%; height:100%; overflow-y: scroll; padding: 10px; ">
<div class="card" style="padding:5px;">
<div class="card-body">
<button id="result-refresh-button" class="btn btn-link"><i class="fas fa-sync-alt"></i></button>
<table id="file-list-table" class="display" style="width:100%;">
<thead>
<tr>
Expand Down

0 comments on commit 040615c

Please sign in to comment.