From 7e5cb33fffb9bff272a150da2e8be311c1917dc5 Mon Sep 17 00:00:00 2001 From: rbaul <4RFVbgt%> Date: Fri, 26 Jan 2024 23:45:31 +0200 Subject: [PATCH] Added group and version Change owner to multi owners Support change/resize columns --- .../mock-server/mock.json | 172 +++++++++++------- .../src/app/api/application-api.model.ts | 2 +- .../project-view/project-view.component.html | 38 ++-- .../project-view/project-view.component.ts | 32 +++- .../domain/model/Application.java | 11 +- .../service/loaders/ProjectLoaderService.java | 27 ++- .../service/model/ApplicationDependency.java | 2 + .../web/dto/ApplicationLiteDto.java | 7 +- 8 files changed, 190 insertions(+), 101 deletions(-) diff --git a/microservice-visualization-webapp/mock-server/mock.json b/microservice-visualization-webapp/mock-server/mock.json index 3809062..2e9cca2 100644 --- a/microservice-visualization-webapp/mock-server/mock.json +++ b/microservice-visualization-webapp/mock-server/mock.json @@ -68,31 +68,20 @@ }, "projects": { "id": 2, - "version": "1.0.0", + "version": "main", "applications": [ { - "id": 17, - "name": "ordering", - "label": "Ordering", - "description": "Ordering application", - "type": "MICROSERVICE", - "location": null, - "owner": "Team 2", - "tags": { - "gradle": "7.6.1", - "java": "17", - "Spring Boot": "3.0.5", - "MVC": "3.0.5" - } - }, - { - "id": 13, + "id": 16, "name": "product-api", "label": "Product API", "description": "Product application", "type": "LIBRARY", + "group": null, + "version": null, "location": null, - "owner": "Team 3", + "owners": [ + "Team 3" + ], "tags": { "gradle": "7.6.1", "java": "17", @@ -100,44 +89,59 @@ } }, { - "id": 14, - "name": "customer-api", - "label": "Customer API", + "id": 17, + "name": "customer", + "label": "Customer", "description": "Customer application", - "type": "LIBRARY", + "type": "MICROSERVICE", + "group": null, + "version": null, "location": null, - "owner": "Team 1", + "owners": [ + "Team 1" + ], "tags": { "gradle": "7.6.1", + "RabbitMQ": "2.7.5", "java": "17", "Spring Boot": "2.7.5", + "MongoDB": "2.7.5", "MVC": "2.7.5", "Spring Cloud": "2021.0.5" } }, { - "id": 15, - "name": "ordering-api", - "label": "Ordering API", - "description": "Ordering application", + "id": 9, + "name": "common-lib", + "label": "Common LIB", + "description": "Common library", "type": "LIBRARY", + "group": null, + "version": null, "location": null, - "owner": "Team 2", + "owners": [ + "Team 1" + ], "tags": { "gradle": "7.6.1", + "RabbitMQ": "2.7.10", "java": "17", - "Spring Boot": "3.0.5", - "MVC": "3.0.5" + "Spring Boot": "2.7.10", + "Spring Cloud": "2022.0.2" } }, { - "id": 11, + "id": 14, "name": "basket-api", "label": "Basket API", "description": "Basket application", "type": "LIBRARY", + "group": null, + "version": null, "location": null, - "owner": "Team 1", + "owners": [ + "Team 1" + ], "tags": { "gradle": "7.6.1", "RabbitMQ": "2.7.10", @@ -147,13 +151,36 @@ } }, { - "id": 9, + "id": 12, + "name": "ordering-api", + "label": "Ordering API", + "description": "Ordering application", + "type": "LIBRARY", + "group": null, + "version": null, + "location": null, + "owners": [ + "Team 2" + ], + "tags": { + "gradle": "7.6.1", + "java": "17", + "Spring Boot": "3.0.5", + "MVC": "3.0.5" + } + }, + { + "id": 11, "name": "basket", "label": "Basket", "description": "Basket application", "type": "MICROSERVICE", + "group": null, + "version": null, "location": null, - "owner": "Team 1", + "owners": [ + "Team 1" + ], "tags": { "gradle": "7.6.1", "RabbitMQ": "2.7.10", @@ -165,54 +192,63 @@ } }, { - "id": 10, - "name": "product", - "label": "Product", - "description": "Product application", + "id": 15, + "name": "ordering", + "label": "Ordering", + "description": "Ordering application", "type": "MICROSERVICE", + "group": null, + "version": null, "location": null, - "owner": "Team 3", + "owners": [ + "Team 2" + ], "tags": { "gradle": "7.6.1", - "RabbitMQ": "3.0.5", "java": "17", "Spring Boot": "3.0.5", - "MongoDB": "3.0.5", "MVC": "3.0.5" } }, { - "id": 12, - "name": "common-lib", - "label": "Common LIB", - "description": "Common library", + "id": 13, + "name": "customer-api", + "label": "Customer API", + "description": "Customer application", "type": "LIBRARY", + "group": null, + "version": null, "location": null, - "owner": "Team 1", + "owners": [ + "Team 1" + ], "tags": { "gradle": "7.6.1", - "RabbitMQ": "2.7.10", "java": "17", - "Spring Boot": "2.7.10", - "Spring Cloud": "2022.0.2" + "Spring Boot": "2.7.5", + "MVC": "2.7.5", + "Spring Cloud": "2021.0.5" } }, { - "id": 16, - "name": "customer", - "label": "Customer", - "description": "Customer application", + "id": 10, + "name": "product", + "label": "Product", + "description": "Product application", "type": "MICROSERVICE", + "group": null, + "version": null, "location": null, - "owner": "Team 1", + "owners": [ + "Team 3" + ], "tags": { "gradle": "7.6.1", - "RabbitMQ": "2.7.5", + "RabbitMQ": "3.0.5", "java": "17", - "Spring Boot": "2.7.5", - "MongoDB": "2.7.5", - "MVC": "2.7.5", - "Spring Cloud": "2021.0.5" + "Spring Boot": "3.0.5", + "MongoDB": "3.0.5", + "MVC": "3.0.5" } } ], @@ -272,10 +308,20 @@ ] } ], + "tags": [ + "gradle", + "RabbitMQ", + "java", + "Spring Boot", + "MongoDB", + "H2", + "MVC", + "Spring Cloud" + ], "projectVersion": { "id": 1, - "name": "Demo", - "description": "Demo description" + "name": "Demo project", + "description": "Demo project description" } }, "applications": { @@ -285,7 +331,9 @@ "description": "Product application", "type": "MICROSERVICE", "location": null, - "owner": "Team 3", + "owners": [ + "Team 3" + ], "tags": { "gradle": "7.6.1", "RabbitMQ": "3.0.5", diff --git a/microservice-visualization-webapp/src/app/api/application-api.model.ts b/microservice-visualization-webapp/src/app/api/application-api.model.ts index 4c3822b..92af848 100644 --- a/microservice-visualization-webapp/src/app/api/application-api.model.ts +++ b/microservice-visualization-webapp/src/app/api/application-api.model.ts @@ -17,7 +17,7 @@ export interface ApplicationLiteDto { description: string, type: ApplicationType, location: string, - owner: string, + owners: string[], tags: any } diff --git a/microservice-visualization-webapp/src/app/project-view/project-view.component.html b/microservice-visualization-webapp/src/app/project-view/project-view.component.html index 3a3d33b..98da1c4 100644 --- a/microservice-visualization-webapp/src/app/project-view/project-view.component.html +++ b/microservice-visualization-webapp/src/app/project-view/project-view.component.html @@ -17,7 +17,8 @@ [paginator]="true" [rows]="10" [showCurrentPageReport]="true" (sortFunction)="customSort($event)" [customSort]="true" currentPageReportTemplate="Showing {first} to {last} of {totalRecords} entries" [rowsPerPageOptions]="[10, 25, 50]" [scrollable]="true" scrollHeight="calc(80vh - 200px)" [styleClass]="'p-datatable-sm'" - [globalFilterFields]="globalFilterFields"> + [globalFilterFields]="globalFilterFields" [resizableColumns]="true" + [reorderableColumns]="true" [columns]="selectedColumns">
@@ -27,21 +28,21 @@ - + placeholder="Choose Columns" optionLabel="name">
- + Name - + @@ -58,19 +59,14 @@ Type - - - Owner - - - @for (tag of selectedTags; track $index) { - - - {{tag}} - + @for (column of selectedColumns; track $index) { + + + {{column.name}} + } - + Action @@ -85,12 +81,10 @@ } - - {{ app.owner }} - - @for (tag of selectedTags; track $index) { - - {{app.tags[tag]}} + @for (column of selectedColumns; track $index) { + + {{getData(app, column)}} + } diff --git a/microservice-visualization-webapp/src/app/project-view/project-view.component.ts b/microservice-visualization-webapp/src/app/project-view/project-view.component.ts index 606fadf..ffe85f6 100644 --- a/microservice-visualization-webapp/src/app/project-view/project-view.component.ts +++ b/microservice-visualization-webapp/src/app/project-view/project-view.component.ts @@ -62,8 +62,16 @@ export class ProjectViewComponent implements OnInit, OnDestroy { { label: 'Microservice', value: ApplicationType.MICROSERVICE } ]; - selectedTags: string[] = ['java', 'Spring Boot', 'Spring Cloud', 'gradle']; - tagOptions: string[] = [] + selectedColumns: ColumnData[] = [ + { name: 'Owner', path: 'owners' }, + // { name: 'Description', path: 'description' }, + { name: 'java', path: 'tags.java' }, + { name: 'Spring Boot', path: 'tags.Spring Boot' }, + { name: 'Spring Cloud', path: 'tags.Spring Cloud' }, + { name: 'gradle', path: 'tags.gradle' } + ]; + + columnOptions: ColumnData[] = [] globalFilterFields: string[] = []; @@ -89,7 +97,16 @@ export class ProjectViewComponent implements OnInit, OnDestroy { if (projectId) { this.projectApi.get(projectId).subscribe(result => { this.data = result; - this.tagOptions = this.data.tags || []; + this.columnOptions = this.data.tags?.map(tag => { + return { name: tag, path: `tags.${tag}` } as ColumnData + }) || []; + + this.columnOptions.push( + { name: 'Description', path: 'description' }, + { name: 'Owner', path: 'owners' }, + { name: 'Version', path: 'version' }, + { name: 'Group', path: 'group' } + ); }); } }); @@ -114,6 +131,10 @@ export class ProjectViewComponent implements OnInit, OnDestroy { }); } + getData(application: ApplicationLiteDto, column: ColumnData): string { + return get(application, column.path); + } + onRowSelect($event: any) { console.log(`Row selected ${JSON.stringify($event)}`) } @@ -159,3 +180,8 @@ interface AppType { value: ApplicationType, label: string } + +interface ColumnData { + name: string, + path: string +} \ No newline at end of file diff --git a/microservice-visualization/src/main/java/com/github/rbaul/microservice_visualization/domain/model/Application.java b/microservice-visualization/src/main/java/com/github/rbaul/microservice_visualization/domain/model/Application.java index ddaaf71..b6d891e 100644 --- a/microservice-visualization/src/main/java/com/github/rbaul/microservice_visualization/domain/model/Application.java +++ b/microservice-visualization/src/main/java/com/github/rbaul/microservice_visualization/domain/model/Application.java @@ -11,6 +11,7 @@ import java.util.List; import java.util.Map; +import java.util.Set; @NoArgsConstructor @AllArgsConstructor @@ -31,9 +32,15 @@ public class Application { private String description; + @Column(name = "artifact_group") + private String group; + + private String version; + private String location; - - private String owner; + + @ElementCollection + private Set owners; @Enumerated(EnumType.STRING) private ApplicationType type; diff --git a/microservice-visualization/src/main/java/com/github/rbaul/microservice_visualization/service/loaders/ProjectLoaderService.java b/microservice-visualization/src/main/java/com/github/rbaul/microservice_visualization/service/loaders/ProjectLoaderService.java index 92c0ef9..e35af83 100644 --- a/microservice-visualization/src/main/java/com/github/rbaul/microservice_visualization/service/loaders/ProjectLoaderService.java +++ b/microservice-visualization/src/main/java/com/github/rbaul/microservice_visualization/service/loaders/ProjectLoaderService.java @@ -140,8 +140,18 @@ protected Application convertApplicationDependencyToApplication(ApplicationDepen applicationDependency.description() : String.format("%s application", applicationDependency.name()); application.setDescription(description); application.setLocation(applicationDependency.location()); - application.setOwner(applicationDependency.owner()); + // Owner + String owner = applicationDependency.owner(); + if (StringUtils.hasText(owner)) { + application.setOwners(Arrays.stream(owner.split(";")) + .map(String::trim) + .filter(StringUtils::hasText) + .collect(Collectors.toSet())); + } + application.setLabel(applicationDependency.label()); + application.setGroup(applicationDependency.group()); + application.setVersion(applicationDependency.version()); application.setDependencies(applicationDependency.dependencies()); application.setManagementDependencies(applicationDependency.managementDependencies()); Map tags = new HashMap<>(applicationDependency.tags()); @@ -224,16 +234,13 @@ protected void setApplicationToProject(Project project, ProjectConfig projectCon } else { // From Application Map> owners = new HashMap<>(); applicationDependencies.forEach(application -> { - if (StringUtils.hasText(application.getOwner())) { - String[] multiOwners = application.getOwner().split(";"); - for (String owner : multiOwners) { - String ow = owner.trim(); - if (StringUtils.hasText(ow)) { - if (!owners.containsKey(ow)) { - owners.put(ow, new ArrayList<>()); - } - owners.get(ow).add(application.getName()); + Set multiOwner = application.getOwners(); + if (!CollectionUtils.isEmpty(multiOwner)) { + for (String owner : multiOwner) { + if (!owners.containsKey(owner)) { + owners.put(owner, new ArrayList<>()); } + owners.get(owner).add(application.getName()); } } }); diff --git a/microservice-visualization/src/main/java/com/github/rbaul/microservice_visualization/service/model/ApplicationDependency.java b/microservice-visualization/src/main/java/com/github/rbaul/microservice_visualization/service/model/ApplicationDependency.java index 82c2e90..15e18d7 100644 --- a/microservice-visualization/src/main/java/com/github/rbaul/microservice_visualization/service/model/ApplicationDependency.java +++ b/microservice-visualization/src/main/java/com/github/rbaul/microservice_visualization/service/model/ApplicationDependency.java @@ -10,6 +10,8 @@ public record ApplicationDependency( String name, String label, String description, + String group, + String version, String location, String owner, Map tags, diff --git a/microservice-visualization/src/main/java/com/github/rbaul/microservice_visualization/web/dto/ApplicationLiteDto.java b/microservice-visualization/src/main/java/com/github/rbaul/microservice_visualization/web/dto/ApplicationLiteDto.java index 882e5d2..b0911a5 100644 --- a/microservice-visualization/src/main/java/com/github/rbaul/microservice_visualization/web/dto/ApplicationLiteDto.java +++ b/microservice-visualization/src/main/java/com/github/rbaul/microservice_visualization/web/dto/ApplicationLiteDto.java @@ -9,6 +9,7 @@ import lombok.experimental.SuperBuilder; import java.util.Map; +import java.util.Set; @NoArgsConstructor @AllArgsConstructor @@ -28,9 +29,13 @@ public class ApplicationLiteDto { private ApplicationType type; + private String group; + + private String version; + private String location; - private String owner; + private Set owners; private Map tags; }