debugs data features

This commit is contained in:
Ben 2025-06-03 14:01:27 +02:00
parent 54dfd5ee34
commit 51eb29ec5e
No known key found for this signature in database
GPG Key ID: 0F16E812E736C24B
3 changed files with 15 additions and 7 deletions

View File

@ -44,12 +44,20 @@ export class DataService {
debugInfo = async () => {
const debug = this.getCodexDebug();
return await debug.info();
const res = await debug.info();
if (res.error) {
throw new Error(res.data);
}
return res.data;
};
localData = async () => {
const data = this.getCodexData();
return await data.cids();
const res = await data.cids();
if (res.error) {
throw new Error(res.data);
}
return res.data;
};
getCodex = () => {

View File

@ -54,13 +54,13 @@ export class DataMenu {
filesData.content.forEach((file, index) => {
const { cid, manifest } = file;
const {
originalBytes,
datasetSize,
protected: isProtected,
filename,
mimetype,
} = manifest;
const fileSize = (originalBytes / 1024).toFixed(2);
const fileSize = (datasetSize / 1024).toFixed(2);
this.ui.showInfoMessage(
`${chalk.cyan("File")} ${index + 1} of ${filesData.content.length}\n\n` +

View File

@ -11,18 +11,18 @@ export class NodeStatusMenu {
showNodeStatus = async () => {
this.debugInfo = await this.fetchDebugInfo();
if (debugInfo == undefined) return;
if (this.debugInfo == undefined) return;
const peerCount = this.debugInfo.table.nodes.length;
const isOnline = peerCount > 2;
if (isOnline) {
this.showSuccessMessage(
this.ui.showSuccessMessage(
"Node is ONLINE & DISCOVERABLE",
"🔌 Node Status",
);
} else {
this.showInfoMessage(
this.ui.showInfoMessage(
"Node is ONLINE but has few peers",
"🔌 Node Status",
);