From 6f81d1d46d250a9278b5b011f6e279b582254c57 Mon Sep 17 00:00:00 2001 From: DJ2LS <75909252+DJ2LS@users.noreply.github.com> Date: Sun, 19 Mar 2023 08:25:52 +0100 Subject: [PATCH 01/17] replace user info with placeholder on error --- gui/preload-chat.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gui/preload-chat.js b/gui/preload-chat.js index 37c4d002..5ca55b59 100644 --- a/gui/preload-chat.js +++ b/gui/preload-chat.js @@ -1915,9 +1915,11 @@ function getSetUserInformation(selected_callsign) { document.getElementById("user-image-" + selected_callsign).src = data.user_info_image; } else { - document.getElementById("dx_user_info_image").src = defaultUserIcon; - document.getElementById("user-image-" + selected_callsign).src = - defaultUserIcon; + // throw error and use placeholder data + throw new Error('Data not available or corrupted'); + //document.getElementById("dx_user_info_image").src = defaultUserIcon; + //document.getElementById("user-image-" + selected_callsign).src = + // defaultUserIcon; } // Callsign list elements From 779a8494b21759150b0d36468c9238d94cd8f060 Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Sun, 19 Mar 2023 07:26:17 +0000 Subject: [PATCH 02/17] Prettified Code! --- gui/preload-chat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/preload-chat.js b/gui/preload-chat.js index 5ca55b59..57648223 100644 --- a/gui/preload-chat.js +++ b/gui/preload-chat.js @@ -1916,7 +1916,7 @@ function getSetUserInformation(selected_callsign) { data.user_info_image; } else { // throw error and use placeholder data - throw new Error('Data not available or corrupted'); + throw new Error("Data not available or corrupted"); //document.getElementById("dx_user_info_image").src = defaultUserIcon; //document.getElementById("user-image-" + selected_callsign).src = // defaultUserIcon; From baf75c5ee99adfb50b0a8c524432890a6636f2b8 Mon Sep 17 00:00:00 2001 From: DJ2LS <75909252+DJ2LS@users.noreply.github.com> Date: Sun, 19 Mar 2023 16:18:32 +0100 Subject: [PATCH 03/17] attempt fixing shared folder --- gui/preload-chat.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gui/preload-chat.js b/gui/preload-chat.js index 57648223..53017404 100644 --- a/gui/preload-chat.js +++ b/gui/preload-chat.js @@ -560,7 +560,7 @@ ipcRenderer.on("return-shared-folder-files", (event, arg) => { tbl.innerHTML = ""; let counter = 0; arg.files.forEach((file) => { - console.log(file["name"]); + //console.log(file["name"]); var row = document.createElement("tr"); let id = document.createElement("td"); @@ -903,7 +903,10 @@ ipcRenderer.on("action-new-msg-received", (event, arg) => { console.log(filelist); userData.user_shared_folder = filelist; addFileListToUserDatabaseIfNotExists(userData); - getSetUserInformation(selected_callsign); + console.log(selected_callsign) + getSetUserInformation(obj.dxcallsign); + + //getSetUserInformation(selected_callsign); } else if (splitted_data[1] == "res-2") { console.log("In received respons-2"); let sharedFileInfo = splitted_data[2].split("/", 2); @@ -1670,6 +1673,7 @@ addFileListToUserDatabaseIfNotExists = function (obj) { console.log("File List: UPDATED USER"); console.log(response); console.log(obj); + getSetUserInformation(obj.user_info_callsign); }) .catch(function (err) { console.log(err); @@ -1682,6 +1686,8 @@ addFileListToUserDatabaseIfNotExists = function (obj) { }) .then(function (response) { console.log("File List: NEW USER ADDED"); + getSetUserInformation(obj.user_info_callsign); + }) .catch(function (err) { console.log(err); From 6a8e3f4afcc18c7244b4b7595515ecb5a80a885f Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Sun, 19 Mar 2023 15:19:05 +0000 Subject: [PATCH 04/17] Prettified Code! --- gui/preload-chat.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gui/preload-chat.js b/gui/preload-chat.js index 53017404..f25ebdeb 100644 --- a/gui/preload-chat.js +++ b/gui/preload-chat.js @@ -903,7 +903,7 @@ ipcRenderer.on("action-new-msg-received", (event, arg) => { console.log(filelist); userData.user_shared_folder = filelist; addFileListToUserDatabaseIfNotExists(userData); - console.log(selected_callsign) + console.log(selected_callsign); getSetUserInformation(obj.dxcallsign); //getSetUserInformation(selected_callsign); @@ -1687,7 +1687,6 @@ addFileListToUserDatabaseIfNotExists = function (obj) { .then(function (response) { console.log("File List: NEW USER ADDED"); getSetUserInformation(obj.user_info_callsign); - }) .catch(function (err) { console.log(err); From 6ef7b34204bc80cc2f7992cb5c79b915a3c5a065 Mon Sep 17 00:00:00 2001 From: DJ2LS <75909252+DJ2LS@users.noreply.github.com> Date: Sun, 19 Mar 2023 16:32:57 +0100 Subject: [PATCH 05/17] another attempt fixing shared folder --- gui/preload-chat.js | 146 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 144 insertions(+), 2 deletions(-) diff --git a/gui/preload-chat.js b/gui/preload-chat.js index f25ebdeb..3461e588 100644 --- a/gui/preload-chat.js +++ b/gui/preload-chat.js @@ -903,8 +903,7 @@ ipcRenderer.on("action-new-msg-received", (event, arg) => { console.log(filelist); userData.user_shared_folder = filelist; addFileListToUserDatabaseIfNotExists(userData); - console.log(selected_callsign); - getSetUserInformation(obj.dxcallsign); + getSetUserSharedFolder(obj.dxcallsign); //getSetUserInformation(selected_callsign); } else if (splitted_data[1] == "res-2") { @@ -1687,6 +1686,7 @@ addFileListToUserDatabaseIfNotExists = function (obj) { .then(function (response) { console.log("File List: NEW USER ADDED"); getSetUserInformation(obj.user_info_callsign); + }) .catch(function (err) { console.log(err); @@ -1898,6 +1898,145 @@ async function updateAllChat(clear) { } } + +function getSetUserSharedFolder(selected_callsign){ + if ( + selected_callsign == "" || + selected_callsign == null || + typeof selected_callsign == "undefined" + ) + return; + + returnObjFromCallsign(users, selected_callsign) + .then(function (data) { + + console.log(data) + + console.log(data.user_shared_folder); + + if (typeof data.user_shared_folder !== "undefined") { + // shared folder table + var icons = [ + "aac", + "ai", + "bmp", + "cs", + "css", + "csv", + "doc", + "docx", + "exe", + "gif", + "heic", + "html", + "java", + "jpg", + "js", + "json", + "jsx", + "key", + "m4p", + "md", + "mdx", + "mov", + "mp3", + "mp4", + "otf", + "pdf", + "php", + "png", + "ppt", + "pptx", + "psd", + "py", + "raw", + "rb", + "sass", + "scss", + "sh", + "sql", + "svg", + "tiff", + "tsx", + "ttf", + "txt", + "wav", + "woff", + "xls", + "xlsx", + "xml", + "yml", + ]; + var tbl = document.getElementById("sharedFolderTableDX"); + tbl.innerHTML = ""; + let counter = 0; + data.user_shared_folder.forEach((file) => { + var row = document.createElement("tr"); + + let dxcall = selected_callsign; + let name = file["name"]; + let type = file["extension"]; + + if (icons.indexOf(type) == -1) { + type = "bi-file-earmark"; + } else { + type = "bi-filetype-" + type; + } + + let id = document.createElement("td"); + let idText = document.createElement("span"); + counter += 1; + idText.innerHTML += + ' ' + + counter; + id.appendChild(idText); + row.appendChild(id); + + let filename = document.createElement("td"); + let filenameText = document.createElement("span"); + filenameText.innerText = file["name"]; + filename.appendChild(filenameText); + row.appendChild(filename); + + let filetype = document.createElement("td"); + let filetypeText = document.createElement("span"); + filetypeText.innerHTML = ``; + filetype.appendChild(filetypeText); + row.appendChild(filetype); + + let filesize = document.createElement("td"); + let filesizeText = document.createElement("span"); + filesizeText.innerText = formatBytes(file["size"], 2); + filesize.appendChild(filesizeText); + row.appendChild(filesize); + id.addEventListener("click", function () { + //console.log(name," clicked"); + sendFileReq(dxcall, name); + }); + tbl.appendChild(row); + }); + } else { + document.getElementById("sharedFolderTableDX").innerHTML = "no data"; + } + }) + .catch(function (err) { + + document.getElementById("sharedFolderTableDX").innerHTML = "no data"; + }); + + + + + + + + + + + +} + + function getSetUserInformation(selected_callsign) { //Get user information @@ -1913,6 +2052,9 @@ function getSetUserInformation(selected_callsign) { returnObjFromCallsign(users, selected_callsign) .then(function (data) { + + console.log(data) + // image if (typeof data.user_info_image !== "undefined") { document.getElementById("dx_user_info_image").src = From 594d6b0c95ea2c1dff08fea99dfbe0ac1c20dab2 Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Sun, 19 Mar 2023 15:33:19 +0000 Subject: [PATCH 06/17] Prettified Code! --- gui/preload-chat.js | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/gui/preload-chat.js b/gui/preload-chat.js index 3461e588..83e66f01 100644 --- a/gui/preload-chat.js +++ b/gui/preload-chat.js @@ -1686,7 +1686,6 @@ addFileListToUserDatabaseIfNotExists = function (obj) { .then(function (response) { console.log("File List: NEW USER ADDED"); getSetUserInformation(obj.user_info_callsign); - }) .catch(function (err) { console.log(err); @@ -1898,8 +1897,7 @@ async function updateAllChat(clear) { } } - -function getSetUserSharedFolder(selected_callsign){ +function getSetUserSharedFolder(selected_callsign) { if ( selected_callsign == "" || selected_callsign == null || @@ -1909,8 +1907,7 @@ function getSetUserSharedFolder(selected_callsign){ returnObjFromCallsign(users, selected_callsign) .then(function (data) { - - console.log(data) + console.log(data); console.log(data.user_shared_folder); @@ -2020,23 +2017,10 @@ function getSetUserSharedFolder(selected_callsign){ } }) .catch(function (err) { - document.getElementById("sharedFolderTableDX").innerHTML = "no data"; }); - - - - - - - - - - - } - function getSetUserInformation(selected_callsign) { //Get user information @@ -2052,8 +2036,7 @@ function getSetUserInformation(selected_callsign) { returnObjFromCallsign(users, selected_callsign) .then(function (data) { - - console.log(data) + console.log(data); // image if (typeof data.user_info_image !== "undefined") { From d1873af2e3a11adad5a5b1f64ad4bb2d1e77db66 Mon Sep 17 00:00:00 2001 From: DJ2LS <75909252+DJ2LS@users.noreply.github.com> Date: Sun, 19 Mar 2023 16:53:23 +0100 Subject: [PATCH 07/17] and another attempt fixing shared folder --- gui/preload-chat.js | 108 +------------------------------------------- 1 file changed, 1 insertion(+), 107 deletions(-) diff --git a/gui/preload-chat.js b/gui/preload-chat.js index 83e66f01..1a17329d 100644 --- a/gui/preload-chat.js +++ b/gui/preload-chat.js @@ -2095,112 +2095,7 @@ function getSetUserInformation(selected_callsign) { document.getElementById("dx_user_info_antenna").className = ""; document.getElementById("dx_user_info_comments").className = ""; - console.log(data.user_shared_folder); - if (typeof data.user_shared_folder !== "undefined") { - // shared folder table - var icons = [ - "aac", - "ai", - "bmp", - "cs", - "css", - "csv", - "doc", - "docx", - "exe", - "gif", - "heic", - "html", - "java", - "jpg", - "js", - "json", - "jsx", - "key", - "m4p", - "md", - "mdx", - "mov", - "mp3", - "mp4", - "otf", - "pdf", - "php", - "png", - "ppt", - "pptx", - "psd", - "py", - "raw", - "rb", - "sass", - "scss", - "sh", - "sql", - "svg", - "tiff", - "tsx", - "ttf", - "txt", - "wav", - "woff", - "xls", - "xlsx", - "xml", - "yml", - ]; - var tbl = document.getElementById("sharedFolderTableDX"); - tbl.innerHTML = ""; - let counter = 0; - data.user_shared_folder.forEach((file) => { - var row = document.createElement("tr"); - - let dxcall = selected_callsign; - let name = file["name"]; - let type = file["extension"]; - - if (icons.indexOf(type) == -1) { - type = "bi-file-earmark"; - } else { - type = "bi-filetype-" + type; - } - - let id = document.createElement("td"); - let idText = document.createElement("span"); - counter += 1; - idText.innerHTML += - ' ' + - counter; - id.appendChild(idText); - row.appendChild(id); - - let filename = document.createElement("td"); - let filenameText = document.createElement("span"); - filenameText.innerText = file["name"]; - filename.appendChild(filenameText); - row.appendChild(filename); - - let filetype = document.createElement("td"); - let filetypeText = document.createElement("span"); - filetypeText.innerHTML = ``; - filetype.appendChild(filetypeText); - row.appendChild(filetype); - - let filesize = document.createElement("td"); - let filesizeText = document.createElement("span"); - filesizeText.innerText = formatBytes(file["size"], 2); - filesize.appendChild(filesizeText); - row.appendChild(filesize); - id.addEventListener("click", function () { - //console.log(name," clicked"); - sendFileReq(dxcall, name); - }); - tbl.appendChild(row); - }); - } else { - document.getElementById("sharedFolderTableDX").innerHTML = "no data"; - } }) .catch(function (err) { // Callsign list elements @@ -2238,7 +2133,6 @@ function getSetUserInformation(selected_callsign) { document.getElementById("dx_user_info_comments").className = "placeholder col-7"; - document.getElementById("sharedFolderTableDX").innerHTML = "no data"; }); } @@ -2264,7 +2158,7 @@ function sendSharedFolderList(dxcallsign) { function sendSharedFolderFile(dxcallsign, filename) { let filePath = path.join(config.shared_folder_path, filename); - console.log("In fuction sendSharedFolderFile ", filePath); + console.log("In function sendSharedFolderFile ", filePath); //Make sure nothing sneaky is going on if (!filePath.startsWith(config.shared_folder_path)) { From 704dccb9986d05d3355cb4941e65a0599fc33b64 Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Sun, 19 Mar 2023 15:53:42 +0000 Subject: [PATCH 08/17] Prettified Code! --- gui/preload-chat.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/gui/preload-chat.js b/gui/preload-chat.js index 1a17329d..f3adc6b0 100644 --- a/gui/preload-chat.js +++ b/gui/preload-chat.js @@ -2094,8 +2094,6 @@ function getSetUserInformation(selected_callsign) { document.getElementById("dx_user_info_radio").className = ""; document.getElementById("dx_user_info_antenna").className = ""; document.getElementById("dx_user_info_comments").className = ""; - - }) .catch(function (err) { // Callsign list elements @@ -2132,7 +2130,6 @@ function getSetUserInformation(selected_callsign) { "placeholder col-4"; document.getElementById("dx_user_info_comments").className = "placeholder col-7"; - }); } From a9a4ce684aa107cdd65d1af13fe425c93f97517d Mon Sep 17 00:00:00 2001 From: DJ2LS <75909252+DJ2LS@users.noreply.github.com> Date: Sun, 19 Mar 2023 16:56:11 +0100 Subject: [PATCH 09/17] removed unused button --- gui/src/chat-module.html | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/gui/src/chat-module.html b/gui/src/chat-module.html index 5f64f0b6..ab2ac4cb 100644 --- a/gui/src/chat-module.html +++ b/gui/src/chat-module.html @@ -677,15 +677,7 @@ > - +