From 040615c877517551a89f73182cb10d46a90669c9 Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Sun, 15 Sep 2024 02:03:29 -0400 Subject: [PATCH] add a refresh button --- src/main/resources/static/js/gw.result.browser.js | 14 ++++++++++---- .../content/workspace/result-browser.html | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/resources/static/js/gw.result.browser.js b/src/main/resources/static/js/gw.result.browser.js index b8875ad6..812628c6 100644 --- a/src/main/resources/static/js/gw.result.browser.js +++ b/src/main/resources/static/js/gw.result.browser.js @@ -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 = ''; // Default icon @@ -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); } }); @@ -106,6 +110,8 @@ GW.result.browser = { }, + + formatFileSize: function(bytes){ if (bytes === 0) return '0 B'; const k = 1024; diff --git a/src/main/resources/templates/fragments/content/workspace/result-browser.html b/src/main/resources/templates/fragments/content/workspace/result-browser.html index c481e929..5373358a 100644 --- a/src/main/resources/templates/fragments/content/workspace/result-browser.html +++ b/src/main/resources/templates/fragments/content/workspace/result-browser.html @@ -3,6 +3,7 @@
+