-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(#1510): implement grouping of services in wallboard
- Loading branch information
Showing
5 changed files
with
322 additions
and
333 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
spring-boot-admin-server-ui/src/main/frontend/services/instanceGroupService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import Instance from "@/services/instance"; | ||
import {groupBy, sortBy, transform} from "lodash-es"; | ||
import Application from "@/services/application"; | ||
|
||
const groupingFunctions = { | ||
'application': (instance: Instance) => instance.registration.name, | ||
'group': (instance: Instance) => instance.registration.metadata?.['group'] ?? "term.no_group", | ||
} | ||
|
||
export type GroupingType = keyof typeof groupingFunctions; | ||
|
||
export type InstancesListType = { | ||
name?: string; | ||
statusKey?: string; | ||
status?: string; | ||
instances?: Instance[]; | ||
applications?: Application[]; | ||
} | ||
|
||
export const groupApplicationsBy = (applications: Application[], groupingFunction: GroupingType) => { | ||
const instances = applications.flatMap(application => application.instances); | ||
return groupInstancesBy(instances, groupingFunction); | ||
} | ||
|
||
export const groupInstancesBy = (instances: Instance[], groupingFunction: GroupingType) => { | ||
const grouped = groupBy<Instance>( | ||
instances, | ||
groupingFunctions[groupingFunction] | ||
); | ||
|
||
const list = transform<Instance[], InstancesListType[]>( | ||
grouped, | ||
(result, instances, name) => { | ||
result.push({ | ||
name, | ||
instances: sortBy(instances, [ | ||
(instance) => instance.registration.name, | ||
]), | ||
}); | ||
}, []); | ||
|
||
return sortBy(list, [(item) => item.status]); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.