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:
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user