feat(web): add database overview panel, collection overview and resizable panels; show/hide system databases; use code editor with change-tracking in document view; add getDatabaseStats API and typings; enable overwrite for S3 uploads
This commit is contained in:
@@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@git.zone/tsview',
|
||||
version: '1.3.0',
|
||||
version: '1.4.0',
|
||||
description: 'A CLI tool for viewing S3 and MongoDB data with a web UI'
|
||||
}
|
||||
|
||||
@@ -53,6 +53,37 @@ export async function registerMongoHandlers(
|
||||
)
|
||||
);
|
||||
|
||||
// Get database stats
|
||||
typedrouter.addTypedHandler(
|
||||
new plugins.typedrequest.TypedHandler<interfaces.IReq_GetDatabaseStats>(
|
||||
'getDatabaseStats',
|
||||
async (reqData) => {
|
||||
try {
|
||||
const client = await getMongoClient();
|
||||
const db = client.db(reqData.databaseName);
|
||||
const stats = await db.stats();
|
||||
const collections = await db.listCollections().toArray();
|
||||
|
||||
return {
|
||||
stats: {
|
||||
collections: collections.length,
|
||||
views: stats.views || 0,
|
||||
objects: stats.objects || 0,
|
||||
avgObjSize: stats.avgObjSize || 0,
|
||||
dataSize: stats.dataSize || 0,
|
||||
storageSize: stats.storageSize || 0,
|
||||
indexes: stats.indexes || 0,
|
||||
indexSize: stats.indexSize || 0,
|
||||
},
|
||||
};
|
||||
} catch (err) {
|
||||
console.error('Error getting database stats:', err);
|
||||
return { stats: null };
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
// List collections
|
||||
typedrouter.addTypedHandler(
|
||||
new plugins.typedrequest.TypedHandler<interfaces.IReq_ListCollections>(
|
||||
|
||||
@@ -292,6 +292,7 @@ export async function registerS3Handlers(
|
||||
await bucket.fastPut({
|
||||
path: reqData.key,
|
||||
contents: content,
|
||||
overwrite: true,
|
||||
});
|
||||
|
||||
return { success: true };
|
||||
@@ -354,6 +355,7 @@ export async function registerS3Handlers(
|
||||
await destBucket.fastPut({
|
||||
path: reqData.destKey,
|
||||
contents: content,
|
||||
overwrite: true,
|
||||
});
|
||||
|
||||
return { success: true };
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -511,3 +511,27 @@ export interface IReq_GetServerStatus extends plugins.typedrequestInterfaces.imp
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export interface IDatabaseStats {
|
||||
collections: number;
|
||||
views: number;
|
||||
objects: number;
|
||||
avgObjSize: number;
|
||||
dataSize: number;
|
||||
storageSize: number;
|
||||
indexes: number;
|
||||
indexSize: number;
|
||||
}
|
||||
|
||||
export interface IReq_GetDatabaseStats extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_GetDatabaseStats
|
||||
> {
|
||||
method: 'getDatabaseStats';
|
||||
request: {
|
||||
databaseName: string;
|
||||
};
|
||||
response: {
|
||||
stats: IDatabaseStats | null;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user