-
-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1735 from qmonmert/feature/1652
[Angular] health page
- Loading branch information
Showing
54 changed files
with
1,103 additions
and
91 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
...te/generator/client/angular/admin/health/application/AngularHealthApplicationService.java
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,19 @@ | ||
package tech.jhipster.lite.generator.client.angular.admin.health.application; | ||
|
||
import org.springframework.stereotype.Service; | ||
import tech.jhipster.lite.generator.client.angular.admin.health.domain.AngularHealthService; | ||
import tech.jhipster.lite.generator.project.domain.Project; | ||
|
||
@Service | ||
public class AngularHealthApplicationService { | ||
|
||
private final AngularHealthService angularHealthService; | ||
|
||
public AngularHealthApplicationService(AngularHealthService angularHealthService) { | ||
this.angularHealthService = angularHealthService; | ||
} | ||
|
||
public void addHealthAngular(Project project) { | ||
angularHealthService.addHealthAngular(project); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...n/java/tech/jhipster/lite/generator/client/angular/admin/health/domain/AngularHealth.java
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,34 @@ | ||
package tech.jhipster.lite.generator.client.angular.admin.health.domain; | ||
|
||
import java.util.Map; | ||
|
||
public class AngularHealth { | ||
|
||
private AngularHealth() {} | ||
|
||
public static Map<String, String> angularHealthFiles() { | ||
String primaryAppAdmin = "app/admin"; | ||
String primaryAppConfig = "app/config"; | ||
String primaryAppHealth = "app/admin/health"; | ||
String primaryAppHealthModal = "app/admin/health/modal"; | ||
return Map.ofEntries( | ||
Map.entry("admin-routing.module.ts", primaryAppAdmin), | ||
Map.entry("admin-routing.module.spec.ts", primaryAppAdmin), | ||
Map.entry("application-config.service.spec.ts", primaryAppConfig), | ||
Map.entry("application-config.service.ts", primaryAppConfig), | ||
Map.entry("health.component.css", primaryAppHealth), | ||
Map.entry("health.component.html", primaryAppHealth), | ||
Map.entry("health.component.ts", primaryAppHealth), | ||
Map.entry("health.component.spec.ts", primaryAppHealth), | ||
Map.entry("health.model.ts", primaryAppHealth), | ||
Map.entry("health.module.ts", primaryAppHealth), | ||
Map.entry("health.route.ts", primaryAppHealth), | ||
Map.entry("health.service.spec.ts", primaryAppHealth), | ||
Map.entry("health.service.ts", primaryAppHealth), | ||
Map.entry("health-modal.component.css", primaryAppHealthModal), | ||
Map.entry("health-modal.component.html", primaryAppHealthModal), | ||
Map.entry("health-modal.component.ts", primaryAppHealthModal), | ||
Map.entry("health-modal.component.spec.ts", primaryAppHealthModal) | ||
); | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
...hipster/lite/generator/client/angular/admin/health/domain/AngularHealthDomainService.java
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,89 @@ | ||
package tech.jhipster.lite.generator.client.angular.admin.health.domain; | ||
|
||
import static tech.jhipster.lite.common.domain.FileUtils.getPath; | ||
import static tech.jhipster.lite.generator.client.angular.core.domain.Angular.*; | ||
import static tech.jhipster.lite.generator.project.domain.Constants.MAIN_WEBAPP; | ||
import static tech.jhipster.lite.generator.project.domain.DefaultConfig.BASE_NAME; | ||
|
||
import java.util.List; | ||
import tech.jhipster.lite.generator.project.domain.Project; | ||
import tech.jhipster.lite.generator.project.domain.ProjectFile; | ||
import tech.jhipster.lite.generator.project.domain.ProjectRepository; | ||
|
||
public class AngularHealthDomainService implements AngularHealthService { | ||
|
||
public static final String SOURCE = "client/angular/admin"; | ||
public static final String SOURCE_WEBAPP = "client/angular/admin/src/main/webapp"; | ||
private static final String APP = "src/main/webapp/app"; | ||
|
||
private final ProjectRepository projectRepository; | ||
|
||
public AngularHealthDomainService(ProjectRepository projectRepository) { | ||
this.projectRepository = projectRepository; | ||
} | ||
|
||
@Override | ||
public void addHealthAngular(Project project) { | ||
addAppHealthFiles(project); | ||
} | ||
|
||
private void addAppHealthFiles(Project project) { | ||
project.addDefaultConfig(BASE_NAME); | ||
|
||
addHealthFiles(project); | ||
updateAngularFilesForHealth(project); | ||
} | ||
|
||
private void addHealthFiles(Project project) { | ||
project.addDefaultConfig(BASE_NAME); | ||
|
||
List<ProjectFile> files = AngularHealth | ||
.angularHealthFiles() | ||
.entrySet() | ||
.stream() | ||
.map(entry -> | ||
ProjectFile | ||
.forProject(project) | ||
.withSource(getPath(SOURCE_WEBAPP, entry.getValue()), entry.getKey()) | ||
.withDestinationFolder(getPath(MAIN_WEBAPP, entry.getValue())) | ||
) | ||
.toList(); | ||
projectRepository.template(files); | ||
} | ||
|
||
private void updateAngularFilesForHealth(Project project) { | ||
String oldHtml = "// jhipster-needle-angular-route"; | ||
String newHtml = | ||
""" | ||
{ | ||
path: 'admin', | ||
loadChildren: () => import('./admin/admin-routing.module').then(m => m.AdminRoutingModule), | ||
}, | ||
// jhipster-needle-angular-route"""; | ||
projectRepository.replaceText(project, APP, APP_ROUTING_MODULE, oldHtml, newHtml); | ||
|
||
oldHtml = "<!-- jhipster-needle-angular-menu -->"; | ||
newHtml = """ | ||
<a routerLink="admin/health" mat-menu-item><span>Health</span></a> | ||
<!-- jhipster-needle-angular-menu -->"""; | ||
projectRepository.replaceText(project, APP, APP_COMPONENT_HTML, oldHtml, newHtml); | ||
|
||
oldHtml = "// jhipster-needle-angular-menu"; | ||
newHtml = | ||
""" | ||
it('should navigate on admin endpoint', () => { | ||
router.navigateByUrl('/admin'); | ||
}); | ||
// jhipster-needle-angular-menu"""; | ||
projectRepository.replaceText(project, APP, APP_ROUTING_MODULE_SPEC, oldHtml, newHtml); | ||
|
||
oldHtml = "// jhipster-needle-angular-menu"; | ||
newHtml = | ||
""" | ||
it('should navigate on health endpoint', () => { | ||
router.navigateByUrl('/health'); | ||
}); | ||
// jhipster-needle-angular-menu"""; | ||
projectRepository.replaceText(project, APP, ADMIN_ROUTING_MODULE_SPEC, oldHtml, newHtml); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...tech/jhipster/lite/generator/client/angular/admin/health/domain/AngularHealthService.java
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,7 @@ | ||
package tech.jhipster.lite.generator.client.angular.admin.health.domain; | ||
|
||
import tech.jhipster.lite.generator.project.domain.Project; | ||
|
||
public interface AngularHealthService { | ||
void addHealthAngular(Project project); | ||
} |
22 changes: 22 additions & 0 deletions
22
...tor/client/angular/admin/health/infrastructure/config/AngularHealthBeanConfiguration.java
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,22 @@ | ||
package tech.jhipster.lite.generator.client.angular.admin.health.infrastructure.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import tech.jhipster.lite.generator.client.angular.admin.health.domain.AngularHealthDomainService; | ||
import tech.jhipster.lite.generator.client.angular.admin.health.domain.AngularHealthService; | ||
import tech.jhipster.lite.generator.project.domain.ProjectRepository; | ||
|
||
@Configuration | ||
public class AngularHealthBeanConfiguration { | ||
|
||
private final ProjectRepository projectRepository; | ||
|
||
public AngularHealthBeanConfiguration(ProjectRepository projectRepository) { | ||
this.projectRepository = projectRepository; | ||
} | ||
|
||
@Bean | ||
public AngularHealthService angularHealthService() { | ||
return new AngularHealthDomainService(projectRepository); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...erator/client/angular/admin/health/infrastructure/primary/rest/AngularHealthResource.java
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,35 @@ | ||
package tech.jhipster.lite.generator.client.angular.admin.health.infrastructure.primary.rest; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import tech.jhipster.lite.generator.client.angular.admin.health.application.AngularHealthApplicationService; | ||
import tech.jhipster.lite.generator.project.domain.GeneratorAction; | ||
import tech.jhipster.lite.generator.project.domain.Project; | ||
import tech.jhipster.lite.generator.project.infrastructure.primary.dto.ProjectDTO; | ||
import tech.jhipster.lite.technical.infrastructure.primary.annotation.GeneratorStep; | ||
|
||
@RestController | ||
@RequestMapping("/api/clients/angular/admin-pages/health") | ||
@Tag(name = "Angular") | ||
class AngularHealthResource { | ||
|
||
private final AngularHealthApplicationService angularHealthApplicationService; | ||
|
||
public AngularHealthResource(AngularHealthApplicationService angularHealthApplicationService) { | ||
this.angularHealthApplicationService = angularHealthApplicationService; | ||
} | ||
|
||
@Operation(summary = "Angular Health") | ||
@ApiResponse(responseCode = "500", description = "An error occurred while adding Angular Health") | ||
@PostMapping | ||
@GeneratorStep(id = GeneratorAction.ANGULAR_HEALTH) | ||
public void addHealthAngular(@RequestBody ProjectDTO projectDTO) { | ||
Project project = ProjectDTO.toProject(projectDTO); | ||
angularHealthApplicationService.addHealthAngular(project); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
src/main/java/tech/jhipster/lite/generator/client/angular/admin/health/package-info.java
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,2 @@ | ||
@tech.jhipster.lite.BusinessContext | ||
package tech.jhipster.lite.generator.client.angular.admin.health; |
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
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
Oops, something went wrong.