Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
]
Expand Down
10 changes: 7 additions & 3 deletions src/openapi/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
22 changes: 12 additions & 10 deletions src/otomi-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1411,21 +1411,23 @@ export default class OtomiStack {
return internalRepoUrls
}

getDashboard(teamId: string): Array<any> {
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<any> {
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 },
]
}

Expand Down
Loading