mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
Request file implementation
This commit is contained in:
parent
04d92b2d8c
commit
6afcb82626
3 changed files with 36 additions and 3 deletions
|
@ -1946,15 +1946,27 @@ function getSetUserInformation(selected_callsign) {
|
|||
|
||||
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");
|
||||
idText.innerText = counter += 1;
|
||||
counter += 1;
|
||||
idText.innerHTML += "<i class=\"bi bi-file-earmark-arrow-down\" style=\"font-size: 1.8rem\"></i> " + counter;
|
||||
id.appendChild(idText);
|
||||
row.appendChild(id);
|
||||
|
||||
|
@ -1966,7 +1978,7 @@ function getSetUserInformation(selected_callsign) {
|
|||
|
||||
let filetype = document.createElement("td");
|
||||
let filetypeText = document.createElement("span");
|
||||
filetypeText.innerHTML = `<i class="bi bi-filetype-${file["extension"]}" style="font-size: 1.8rem"></i>`;
|
||||
filetypeText.innerHTML = `<i class="bi ${type}" style="font-size: 1.8rem"></i>`;
|
||||
filetype.appendChild(filetypeText);
|
||||
row.appendChild(filetype);
|
||||
|
||||
|
@ -1975,7 +1987,10 @@ function getSetUserInformation(selected_callsign) {
|
|||
filesizeText.innerText = formatBytes(file["size"], 2);
|
||||
filesize.appendChild(filesizeText);
|
||||
row.appendChild(filesize);
|
||||
|
||||
row.addEventListener("click", function () {
|
||||
//console.log(name," clicked");
|
||||
sendFileReq(dxcall,name);
|
||||
});
|
||||
tbl.appendChild(row);
|
||||
});
|
||||
} else {
|
||||
|
@ -2110,3 +2125,10 @@ function formatBytes(bytes, decimals = 2) {
|
|||
|
||||
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
|
||||
}
|
||||
function sendFileReq(dxcall, file) {
|
||||
//console.log(file," clicked");
|
||||
ipcRenderer.send("run-tnc-command", {
|
||||
command: "requestSharedFile",
|
||||
dxcallsign: dxcall,
|
||||
file: file
|
||||
})};
|
|
@ -2703,6 +2703,10 @@ ipcRenderer.on("run-tnc-command", (event, arg) => {
|
|||
sock.sendRequestSharedFolderList(arg.dxcallsign);
|
||||
}
|
||||
|
||||
if (arg.command == "requestSharedFile") {
|
||||
sock.sendRequestSharedFile(arg.dxcallsign,arg.file);
|
||||
}
|
||||
|
||||
// responses
|
||||
if (arg.command == "responseUserInfo") {
|
||||
sock.sendResponseInfo(arg.dxcallsign, arg.userinfo);
|
||||
|
|
|
@ -718,6 +718,13 @@ exports.sendRequestSharedFolderList = function (dxcallsign) {
|
|||
sendRequest(dxcallsign, 255, 1, "1", "req");
|
||||
};
|
||||
|
||||
//Send shared file request
|
||||
exports.sendRequestSharedFile = function (dxcallsign,file) {
|
||||
//Command 0 = user/station information
|
||||
//Command 1 = shared folder list
|
||||
sendRequest(dxcallsign, 255, 1, "2" + file, "req");
|
||||
};
|
||||
|
||||
//Send station info response
|
||||
exports.sendResponseInfo = function (dxcallsign, userinfo) {
|
||||
//Command 0 = user/station information
|
||||
|
|
Loading…
Reference in a new issue