aboutsummaryrefslogtreecommitdiff
path: root/src/js
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2025-07-24 22:11:45 +0300
committerkaotisk <kaotisk@arching-kaos.org>2025-07-24 22:11:45 +0300
commitf0b67be017c47517116fa2707f915091e9a9cddc (patch)
treed6c0aaff5b05e412aaf3370c7ffc55af39528e05 /src/js
parentd86e492c4d1524b7b0f811432548e7086c17bf20 (diff)
downloadarching-kaos-web-ui-master.tar.gz
arching-kaos-web-ui-master.tar.bz2
arching-kaos-web-ui-master.zip
[fs] Now AKFS downloads are offered with their namesHEADorigin/masterorigin/HEADmaster
Diffstat (limited to 'src/js')
-rw-r--r--src/js/arching-kaos-file-system.js19
-rw-r--r--src/js/utils.js6
2 files changed, 18 insertions, 7 deletions
diff --git a/src/js/arching-kaos-file-system.js b/src/js/arching-kaos-file-system.js
index 1c12a06..bee474e 100644
--- a/src/js/arching-kaos-file-system.js
+++ b/src/js/arching-kaos-file-system.js
@@ -88,10 +88,21 @@ function akfsFromMapGetOriginalHash(reply, params)
function akfsFromMapGetOriginalFilename(reply, params)
{
- const [ hash ] = params;
+ const [ data, toDownload ] = params;
if(typeof(reply) === "string")
{
- console.log(reply.split('\n')[0].split(' ')[1]);
+ // console.log(reply.split('\n')[0].split(' ')[1]);
+ var first_line = reply.split('\n')[0].split(' ');
+ var filename = "";
+ for ( let i = 1; i < first_line.length; i++ )
+ {
+ filename += first_line[i];
+ if ( i < first_line.length - 1 )
+ {
+ filename += " ";
+ }
+ }
+ if ( toDownload ) offerDownloadableData(data, filename);
}
}
@@ -159,9 +170,9 @@ export function akfsWorkOnChunks()
{
akfsSerializeChunks(thingy.root_hash);
var data = makeUpData();
- offerDownloadableData(data);
+ archingKaosFetchBlob(akfsGetMapURL(thingy.map_hash), akfsFromMapGetOriginalFilename, [data, true]);
downloaded = true;
- console.log(workspace);
+ // console.log(workspace);
}
function akfsChunkOrLeaf(reply, params)
diff --git a/src/js/utils.js b/src/js/utils.js
index 6a355a8..a5f34dc 100644
--- a/src/js/utils.js
+++ b/src/js/utils.js
@@ -27,10 +27,10 @@ export function debugLog(message)
if (showDebug) console.log(message);
}
-export function offerDownloadableData(data)
+export function offerDownloadableData(data, filename)
{
var link = document.createElement('a');
- link.download = 'data';
+ link.download = filename === undefined ? 'data': filename;
var blob = new Blob([data]); // , {type: 'text/plain'}
link.href = window.URL.createObjectURL(blob);
link.click();
@@ -46,6 +46,6 @@ export function decodeBase64ToHex(base64String) {
// Convert the byte array to a hex string representation
return Array.from(byteArray)
.map(byte => byte.toString(16).padStart(2, '0')) // Convert to hex and pad with zeros
- .join(''); // Join with spaces for readability
+ .join('');
}
// @license-end