mirror of
https://github.com/logos-storage/logos-storage-installer.git
synced 2026-01-02 13:33:11 +00:00
sets up previous menu and functionality
This commit is contained in:
parent
8379de4b32
commit
0e85190026
@ -47,7 +47,10 @@ export class DataService {
|
||||
return await debug.info();
|
||||
}
|
||||
|
||||
|
||||
localData = async () => {
|
||||
const data = this.getCodexData();
|
||||
return await data.cids();
|
||||
};
|
||||
|
||||
getCodex = () =>{
|
||||
const config = this.configService.get();
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import chalk from "chalk";
|
||||
|
||||
export class DataMenu {
|
||||
constructor(uiService, fsService, dataService) {
|
||||
this.ui = uiService;
|
||||
@ -35,6 +37,36 @@ export class DataMenu {
|
||||
};
|
||||
|
||||
showLocalData = async () => {
|
||||
try {
|
||||
const localData = await this.dataService.localData();
|
||||
this.displayLocalData(localData);
|
||||
}
|
||||
catch (exception) {
|
||||
this.ui.showErrorMessage("Failed to fetch local data: " + exception);
|
||||
}
|
||||
};
|
||||
|
||||
displayLocalData = (filesData) => {
|
||||
if (filesData.content && filesData.content.length > 0) {
|
||||
this.ui.showInfoMessage(`Found ${filesData.content.length} local file(s)`);
|
||||
|
||||
filesData.content.forEach((file, index) => {
|
||||
const { cid, manifest } = file;
|
||||
const { originalBytes, protected: isProtected, filename, mimetype } = manifest;
|
||||
|
||||
const fileSize = (originalBytes / 1024).toFixed(2);
|
||||
|
||||
this.ui.showInfoMessage(
|
||||
`${chalk.cyan('File')} ${index + 1} of ${filesData.content.length}\n\n` +
|
||||
`${chalk.cyan('Filename:')} ${filename}\n` +
|
||||
`${chalk.cyan('CID:')} ${cid}\n` +
|
||||
`${chalk.cyan('Size:')} ${fileSize} KB\n` +
|
||||
`${chalk.cyan('MIME Type:')} ${mimetype}\n` +
|
||||
`${chalk.cyan('Protected:')} ${isProtected ? chalk.green('Yes') : chalk.red('No')}`,
|
||||
);
|
||||
});
|
||||
} else {
|
||||
this.ui.showInfoMessage("Node contains no datasets.");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user