Skip to content

Commit 49c04d2

Browse files
feat: update dashboard endpoint for inventory section (#700)
Co-authored-by: ElderMatt <[email protected]>
1 parent a94061e commit 49c04d2

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

src/api/v1/teams/{teamId}/dashboard.ts renamed to src/api/v1/dashboard.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ const debug = Debug('otomi:api:v1:dashboard')
66

77
export default function (): OperationHandlerArray {
88
const get: Operation = [
9-
({ otomi, params: { teamId } }: OpenApiRequestExt, res): void => {
10-
debug(`getDashboard(${teamId})`)
11-
const v = otomi.getDashboard(teamId)
9+
({ otomi, query: { teamName } }: OpenApiRequestExt, res): void => {
10+
debug(`getDashboard(${teamName})`)
11+
const v = otomi.getDashboard(teamName as string)
1212
res.json(v)
1313
},
1414
]

src/openapi/api.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,11 +1001,15 @@ paths:
10011001
schema:
10021002
$ref: '#/components/schemas/AplBackupResponse'
10031003

1004-
'/v1/teams/{teamId}/dashboard':
1005-
parameters:
1006-
- $ref: '#/components/parameters/teamParams'
1004+
'/v1/dashboard':
10071005
get:
10081006
operationId: getDashboard
1007+
parameters:
1008+
- name: teamName
1009+
in: query
1010+
description: Name of the team
1011+
schema:
1012+
type: string
10091013
responses:
10101014
<<: *DefaultGetResponses
10111015
'200':

src/otomi-stack.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,21 +1411,23 @@ export default class OtomiStack {
14111411
return internalRepoUrls
14121412
}
14131413

1414-
getDashboard(teamId: string): Array<any> {
1415-
const projects = this.repoService.getTeamConfigService(teamId).getProjects()
1416-
const builds = this.repoService.getTeamConfigService(teamId).getBuilds()
1417-
const workloads = this.repoService.getTeamConfigService(teamId).getWorkloads()
1418-
const services = this.repoService.getTeamConfigService(teamId).getServices()
1419-
const secrets = this.repoService.getTeamConfigService(teamId).getSealedSecrets()
1420-
const netpols = this.repoService.getTeamConfigService(teamId).getNetpols()
1414+
getDashboard(teamName: string): Array<any> {
1415+
const projects = teamName ? this.repoService.getTeamConfigService(teamName).getProjects() : this.getAllProjects()
1416+
const builds = teamName ? this.repoService.getTeamConfigService(teamName).getBuilds() : this.getAllBuilds()
1417+
const workloads = teamName ? this.repoService.getTeamConfigService(teamName).getWorkloads() : this.getAllWorkloads()
1418+
const services = teamName ? this.repoService.getTeamConfigService(teamName).getServices() : this.getAllServices()
1419+
const secrets = teamName
1420+
? this.repoService.getTeamConfigService(teamName).getSealedSecrets()
1421+
: this.getAllSealedSecrets()
1422+
const netpols = teamName ? this.repoService.getTeamConfigService(teamName).getNetpols() : this.getAllNetpols()
14211423

14221424
return [
14231425
{ name: 'projects', count: projects?.length },
1424-
{ name: 'builds', count: builds?.length },
1426+
{ name: 'container-images', count: builds?.length },
14251427
{ name: 'workloads', count: workloads?.length },
14261428
{ name: 'services', count: services?.length },
1427-
{ name: 'sealed secrets', count: secrets?.length },
1428-
{ name: 'network policies', count: netpols?.length },
1429+
{ name: 'sealed-secrets', count: secrets?.length },
1430+
{ name: 'network-policies', count: netpols?.length },
14291431
]
14301432
}
14311433

0 commit comments

Comments
 (0)