diff --git a/src/api/v1/teams/{teamId}/dashboard.ts b/src/api/v1/dashboard.ts similarity index 67% rename from src/api/v1/teams/{teamId}/dashboard.ts rename to src/api/v1/dashboard.ts index fe406f93c..b2762f74a 100644 --- a/src/api/v1/teams/{teamId}/dashboard.ts +++ b/src/api/v1/dashboard.ts @@ -6,9 +6,9 @@ const debug = Debug('otomi:api:v1:dashboard') export default function (): OperationHandlerArray { const get: Operation = [ - ({ otomi, params: { teamId } }: OpenApiRequestExt, res): void => { - debug(`getDashboard(${teamId})`) - const v = otomi.getDashboard(teamId) + ({ otomi, query: { teamName } }: OpenApiRequestExt, res): void => { + debug(`getDashboard(${teamName})`) + const v = otomi.getDashboard(teamName as string) res.json(v) }, ] diff --git a/src/openapi/api.yaml b/src/openapi/api.yaml index d8e3697dc..114fac75a 100644 --- a/src/openapi/api.yaml +++ b/src/openapi/api.yaml @@ -1001,11 +1001,15 @@ paths: schema: $ref: '#/components/schemas/AplBackupResponse' - '/v1/teams/{teamId}/dashboard': - parameters: - - $ref: '#/components/parameters/teamParams' + '/v1/dashboard': get: operationId: getDashboard + parameters: + - name: teamName + in: query + description: Name of the team + schema: + type: string responses: <<: *DefaultGetResponses '200': diff --git a/src/otomi-stack.ts b/src/otomi-stack.ts index 3cfa59bc0..c98696880 100644 --- a/src/otomi-stack.ts +++ b/src/otomi-stack.ts @@ -1411,21 +1411,23 @@ export default class OtomiStack { return internalRepoUrls } - getDashboard(teamId: string): Array { - const projects = this.repoService.getTeamConfigService(teamId).getProjects() - const builds = this.repoService.getTeamConfigService(teamId).getBuilds() - const workloads = this.repoService.getTeamConfigService(teamId).getWorkloads() - const services = this.repoService.getTeamConfigService(teamId).getServices() - const secrets = this.repoService.getTeamConfigService(teamId).getSealedSecrets() - const netpols = this.repoService.getTeamConfigService(teamId).getNetpols() + getDashboard(teamName: string): Array { + const projects = teamName ? this.repoService.getTeamConfigService(teamName).getProjects() : this.getAllProjects() + const builds = teamName ? this.repoService.getTeamConfigService(teamName).getBuilds() : this.getAllBuilds() + const workloads = teamName ? this.repoService.getTeamConfigService(teamName).getWorkloads() : this.getAllWorkloads() + const services = teamName ? this.repoService.getTeamConfigService(teamName).getServices() : this.getAllServices() + const secrets = teamName + ? this.repoService.getTeamConfigService(teamName).getSealedSecrets() + : this.getAllSealedSecrets() + const netpols = teamName ? this.repoService.getTeamConfigService(teamName).getNetpols() : this.getAllNetpols() return [ { name: 'projects', count: projects?.length }, - { name: 'builds', count: builds?.length }, + { name: 'container-images', count: builds?.length }, { name: 'workloads', count: workloads?.length }, { name: 'services', count: services?.length }, - { name: 'sealed secrets', count: secrets?.length }, - { name: 'network policies', count: netpols?.length }, + { name: 'sealed-secrets', count: secrets?.length }, + { name: 'network-policies', count: netpols?.length }, ] }