-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Frontend operations center begin (#208)
* chore: Update RaagService to include SiloRepository (#197) * Renaming route home to operations-center * Operations Center updates * Adding fake endpoints on backends to allow auth * On 404 error, deliver index.html (SPA) * Begin using pre-commit to lint over files * chore: Refactor OpenAiCompatibleV1ApiControllerTest to improve code readability and remove unused imports * chore: Add ErrorHandlerController to handle errors and deliver index.html on 404 error (SPA) * Updating frontend dependencies * chore: Update operations center to fetch numbers on page activation * refactor: Rename header-banner.vue to infrastructure-overall.vue and card-data.vue to jvm-cards.vue * Improving how to retrieve env vars for Testing * Frontend : adding infrastructure overall * chore: Update npm dependencies to latest versions * chore: Add error handling for delivering index.html on 404 error (SPA) * refactor: Update icons in jvm-cards.vue for better visual representation * chore: Add SystemMonitoringServiceTest for system monitoring functionality
- Loading branch information
Showing
59 changed files
with
812 additions
and
729 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
cp .devcontainer/pre-commit .git/hooks/pre-commit | ||
chmod +x .git/hooks/pre-commit | ||
|
||
echo "Let's go for a dRAGon ride! 🐉" |
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 @@ | ||
#!/bin/sh | ||
gradle pnpmLint checkstyleMain checkstyleTest --no-daemon --quiet |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ bin | |
.vscode | ||
.DS_Store | ||
*.class | ||
.pnpm-store | ||
.pnpm-store | ||
.env.local |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
build | ||
build | ||
.env.local |
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
28 changes: 28 additions & 0 deletions
28
backend/src/main/java/ai/dragon/controller/ErrorHandlerController.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,28 @@ | ||
package ai.dragon.controller; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import org.apache.commons.io.IOUtils; | ||
import org.springframework.boot.web.servlet.error.ErrorController; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
|
||
@Controller | ||
public class ErrorHandlerController implements ErrorController { | ||
// We are using a SPA (Single Page Application) so we need to output the | ||
// index.html file when an error occurs : | ||
@RequestMapping("/error") | ||
public @ResponseBody byte[] getImage() throws IOException { | ||
InputStream in = getClass().getResourceAsStream("/static/index.html"); | ||
if (in == null) { | ||
throw new IOException("index.html not found"); | ||
} | ||
return IOUtils.toByteArray(in); | ||
} | ||
|
||
public String getErrorPath() { | ||
return "/error"; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
backend/src/main/java/ai/dragon/controller/api/app/AuthAppApiController.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,43 @@ | ||
package ai.dragon.controller.api.app; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import ai.dragon.dto.api.GenericApiResponse; | ||
import ai.dragon.dto.api.SuccessApiResponse; | ||
import ai.dragon.dto.api.app.auth.LoginAuthAppApiData; | ||
import ai.dragon.dto.api.app.auth.UserInfoAuthAppApiData; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
|
||
@RestController | ||
@RequestMapping("/api/app/auth") | ||
@Tag(name = "Authentication", description = "Authentication API Endpoints") | ||
public class AuthAppApiController { | ||
@PostMapping("/login") | ||
@Operation(summary = "Login", description = "Login to the application.") | ||
public GenericApiResponse login() { | ||
return SuccessApiResponse.builder().data(LoginAuthAppApiData | ||
.builder() | ||
.token("TOKEN_WILL_BE_HERE") | ||
.refreshToken("REFRESH_TOKEN_WILL_BE_HERE") | ||
.build()) | ||
.build(); | ||
} | ||
|
||
@GetMapping("/getUserInfo") | ||
@Operation(summary = "Get User Info", description = "Get user info.") | ||
public GenericApiResponse getUserInfo() { | ||
return SuccessApiResponse.builder().data(UserInfoAuthAppApiData | ||
.builder() | ||
.userId("TODO") | ||
.userName("dRAGon") | ||
.roles(List.of("R_SUPER")) | ||
.build()) | ||
.build(); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
backend/src/main/java/ai/dragon/controller/api/app/DashboardAppApiController.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,62 @@ | ||
package ai.dragon.controller.api.app; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import ai.dragon.dto.api.GenericApiResponse; | ||
import ai.dragon.dto.api.SuccessApiResponse; | ||
import ai.dragon.dto.api.app.dashboard.NumbersDashboardAppApiData; | ||
import ai.dragon.repository.DocumentRepository; | ||
import ai.dragon.repository.FarmRepository; | ||
import ai.dragon.repository.SiloRepository; | ||
import ai.dragon.service.SystemMonitoringService; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
|
||
@RestController | ||
@RequestMapping("/api/app/dashboard") | ||
@Tag(name = "Operations Center", description = "Dashboard API Endpoints") | ||
public class DashboardAppApiController { | ||
@Autowired | ||
private SiloRepository siloRepository; | ||
|
||
@Autowired | ||
private FarmRepository farmRepository; | ||
|
||
@Autowired | ||
private DocumentRepository documentRepository; | ||
|
||
@Autowired | ||
private SystemMonitoringService systemMonitoringService; | ||
|
||
@GetMapping("/numbers") | ||
@Operation(summary = "Get Dashboard main numbers", description = "Returns the main numbers of the dashboard.") | ||
public GenericApiResponse numbers() { | ||
return SuccessApiResponse.builder().data(NumbersDashboardAppApiData | ||
.builder() | ||
.silos(siloRepository.countAll()) | ||
.farms(farmRepository.countAll()) | ||
.documents(documentRepository.countAll()) | ||
.systemLoadAverage(systemMonitoringService.getSystemLoadAverage()) | ||
.availableProcessors(systemMonitoringService.getAvailableProcessors()) | ||
.arch(systemMonitoringService.getArch()) | ||
.usedMemory(systemMonitoringService.getUsedMemory()) | ||
.totalMemory(systemMonitoringService.getTotalMemory()) | ||
.freeMemory(systemMonitoringService.getFreeMemory()) | ||
.usedMemoryPercentage(systemMonitoringService.getUsedMemoryPercentage()) | ||
.freeMemoryPercentage(systemMonitoringService.getFreeMemoryPercentage()) | ||
.uptime(systemMonitoringService.getUptime()) | ||
.heapMemoryUsage(systemMonitoringService.getHeapMemoryUsage()) | ||
.heapMemoryUsagePercentage(systemMonitoringService.getHeapMemoryUsagePercentage()) | ||
.nonHeapMemoryUsage(systemMonitoringService.getNonHeapMemoryUsage()) | ||
.heapMemoryMax(systemMonitoringService.getHeapMemoryMax()) | ||
.heapMemoryCommitted(systemMonitoringService.getHeapMemoryCommitted()) | ||
.nonHeapMemoryCommitted(systemMonitoringService.getNonHeapMemoryCommitted()) | ||
.heapMemoryInit(systemMonitoringService.getHeapMemoryInit()) | ||
.nonHeapMemoryInit(systemMonitoringService.getNonHeapMemoryInit()) | ||
.build()) | ||
.build(); | ||
} | ||
} |
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,5 @@ | ||
package ai.dragon.dto.api; | ||
|
||
public interface GenericApiData { | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
backend/src/main/java/ai/dragon/dto/api/GenericApiResponse.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 ai.dragon.dto.api; | ||
|
||
public interface GenericApiResponse { | ||
public GenericApiData getData(); | ||
public String getCode(); | ||
public String getMsg(); | ||
} |
17 changes: 17 additions & 0 deletions
17
backend/src/main/java/ai/dragon/dto/api/SuccessApiResponse.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,17 @@ | ||
package ai.dragon.dto.api; | ||
|
||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
@Builder | ||
@Data | ||
public class SuccessApiResponse implements GenericApiResponse { | ||
@Builder.Default | ||
private GenericApiData data = null; | ||
|
||
@Builder.Default | ||
private String code = "0000"; | ||
|
||
@Builder.Default | ||
private String msg = "OK"; | ||
} |
12 changes: 12 additions & 0 deletions
12
backend/src/main/java/ai/dragon/dto/api/app/auth/LoginAuthAppApiData.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,12 @@ | ||
package ai.dragon.dto.api.app.auth; | ||
|
||
import ai.dragon.dto.api.GenericApiData; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
@Builder | ||
@Data | ||
public class LoginAuthAppApiData implements GenericApiData { | ||
private String token; | ||
private String refreshToken; | ||
} |
16 changes: 16 additions & 0 deletions
16
backend/src/main/java/ai/dragon/dto/api/app/auth/UserInfoAuthAppApiData.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,16 @@ | ||
package ai.dragon.dto.api.app.auth; | ||
|
||
import java.util.List; | ||
|
||
import ai.dragon.dto.api.GenericApiData; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
@Builder | ||
@Data | ||
public class UserInfoAuthAppApiData implements GenericApiData { | ||
private String userId; | ||
private String userName; | ||
private List<String> roles; | ||
private List<String> buttons; | ||
} |
30 changes: 30 additions & 0 deletions
30
backend/src/main/java/ai/dragon/dto/api/app/dashboard/NumbersDashboardAppApiData.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,30 @@ | ||
package ai.dragon.dto.api.app.dashboard; | ||
|
||
import ai.dragon.dto.api.GenericApiData; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
@Builder | ||
@Data | ||
public class NumbersDashboardAppApiData implements GenericApiData { | ||
private Long silos; | ||
private Long farms; | ||
private Long documents; | ||
private Double systemLoadAverage; | ||
private Integer availableProcessors; | ||
private String arch; | ||
private Long usedMemory; | ||
private Long totalMemory; | ||
private Long freeMemory; | ||
private Long usedMemoryPercentage; | ||
private Long freeMemoryPercentage; | ||
private Long uptime; | ||
private Long heapMemoryUsage; | ||
private Long heapMemoryUsagePercentage; | ||
private Long nonHeapMemoryUsage; | ||
private Long heapMemoryMax; | ||
private Long heapMemoryCommitted; | ||
private Long nonHeapMemoryCommitted; | ||
private Long heapMemoryInit; | ||
private Long nonHeapMemoryInit; | ||
} |
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.