Enhance dashboard to display data for all Active Directory objects and dynamically generate available fields.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 705f2157-ef97-4fbd-89e4-8c7f2ecaea90
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7ed01c5f-a82d-405a-b728-b2e3d127c60c/3caa578d-3a2c-45ec-a6c0-75313ad18bfb.jpg
This commit is contained in:
alphaeusmote
2025-04-10 00:32:56 +00:00
parent d0748723c3
commit 9d39faf2cf
5 changed files with 874 additions and 58 deletions
+156
View File
@@ -5056,6 +5056,162 @@ export async function registerRoutes(app: Express): Promise<Server> {
}
});
/**
* @swagger
* /api/ou-dashboard-data:
* get:
* summary: Get Organizational Unit data for dashboard visualizations
* tags: [Dashboard]
* security:
* - cookieAuth: []
* - bearerAuth: []
* responses:
* 200:
* description: Organizational Unit data for dashboard
* 401:
* $ref: '#/components/responses/UnauthorizedError'
*/
app.get("/api/ou-dashboard-data", requireAuth({ allowApiToken: true }), async (req, res, next) => {
try {
// Get data from the first available LDAP connection
const connections = await storage.listLdapConnections();
if (connections.length === 0) {
return res.status(200).json({ data: [], message: "No LDAP connections available" });
}
const connectionId = connections[0].id;
const ous = await storage.listAdOrgUnits(connectionId);
// Add objectType to make filtering easier in the dashboard
const result = ous.map(ou => ({
...ou,
objectType: 'organizationalUnit'
}));
res.json({ data: result });
} catch (error) {
next(error);
}
});
/**
* @swagger
* /api/domain-dashboard-data:
* get:
* summary: Get domain data for dashboard visualizations
* tags: [Dashboard]
* security:
* - cookieAuth: []
* - bearerAuth: []
* responses:
* 200:
* description: Domain data for dashboard
* 401:
* $ref: '#/components/responses/UnauthorizedError'
*/
app.get("/api/domain-dashboard-data", requireAuth({ allowApiToken: true }), async (req, res, next) => {
try {
// Get data from the first available LDAP connection
const connections = await storage.listLdapConnections();
if (connections.length === 0) {
return res.status(200).json({ data: [], message: "No LDAP connections available" });
}
const connectionId = connections[0].id;
const domains = await storage.listAdDomains(connectionId);
// Add objectType to make filtering easier in the dashboard
const result = domains.map(domain => ({
...domain,
objectType: 'domain'
}));
res.json({ data: result });
} catch (error) {
next(error);
}
});
/**
* @swagger
* /api/site-dashboard-data:
* get:
* summary: Get site data for dashboard visualizations
* tags: [Dashboard]
* security:
* - cookieAuth: []
* - bearerAuth: []
* responses:
* 200:
* description: Site data for dashboard
* 401:
* $ref: '#/components/responses/UnauthorizedError'
*/
app.get("/api/site-dashboard-data", requireAuth({ allowApiToken: true }), async (req, res, next) => {
try {
// Get data from the first available LDAP connection
const connections = await storage.listLdapConnections();
if (connections.length === 0) {
return res.status(200).json({ data: [], message: "No LDAP connections available" });
}
const connectionId = connections[0].id;
const sites = await storage.listAdSites(connectionId);
// Add objectType to make filtering easier in the dashboard
const result = sites.map(site => ({
...site,
objectType: 'site'
}));
res.json({ data: result });
} catch (error) {
next(error);
}
});
/**
* @swagger
* /api/subnet-dashboard-data:
* get:
* summary: Get subnet data for dashboard visualizations
* tags: [Dashboard]
* security:
* - cookieAuth: []
* - bearerAuth: []
* responses:
* 200:
* description: Subnet data for dashboard
* 401:
* $ref: '#/components/responses/UnauthorizedError'
*/
app.get("/api/subnet-dashboard-data", requireAuth({ allowApiToken: true }), async (req, res, next) => {
try {
// Get data from the first available LDAP connection
const connections = await storage.listLdapConnections();
if (connections.length === 0) {
return res.status(200).json({ data: [], message: "No LDAP connections available" });
}
const connectionId = connections[0].id;
const subnets = await storage.listAdSubnets(connectionId);
// Add objectType to make filtering easier in the dashboard
const result = subnets.map(subnet => ({
...subnet,
objectType: 'subnet'
}));
res.json({ data: result });
} catch (error) {
next(error);
}
});
/**
* @swagger
* /api/dashboard-summary: