API Gatway updated, now communicates with frontend
This commit is contained in:
parent
6ad23b3e14
commit
9353c55d1d
10
src/PanoptesFrontend/Pages/TestCard.razor
Normal file
10
src/PanoptesFrontend/Pages/TestCard.razor
Normal file
@ -0,0 +1,10 @@
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<p>@Data.Text</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public Component Data { get; set; }
|
||||
}
|
||||
@ -4,7 +4,7 @@
|
||||
@using System.Text.Json;
|
||||
@inject IHttpService httpService
|
||||
|
||||
@* @if (data != null)
|
||||
@if (data != null)
|
||||
{
|
||||
@foreach (var component in data) {
|
||||
switch (component.Type) {
|
||||
@ -27,16 +27,16 @@
|
||||
}
|
||||
|
||||
}
|
||||
} *@
|
||||
}
|
||||
|
||||
<pre>@response.Text</pre>
|
||||
|
||||
@code {
|
||||
private Component response;
|
||||
private Component[] data;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
response = await httpService.GetAsync<Component>("http://localhost:8080/test");
|
||||
var response = await httpService.GetAsync<Schema>("http://localhost:10000/localhost/schema");
|
||||
data = response.components;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
{
|
||||
@foreach (var module in response){
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
|
||||
<NavLink class="nav-link" href=@module.Name Match="NavLinkMatch.All">
|
||||
<span class="oi oi-home" aria-hidden="true"></span> @module.Name
|
||||
</NavLink>
|
||||
</div>
|
||||
|
||||
@ -31,7 +31,6 @@ type Module struct {
|
||||
Container string `json:"Container"`
|
||||
}
|
||||
|
||||
var Containers []Container
|
||||
|
||||
|
||||
func homePage(w http.ResponseWriter, r *http.Request) {
|
||||
@ -42,9 +41,8 @@ func getSchema(w http.ResponseWriter, r *http.Request){
|
||||
vars := mux.Vars(r)
|
||||
key := vars["container"]
|
||||
|
||||
for _, container := range Containers {
|
||||
if container.Id == key {
|
||||
requestURL := fmt.Sprintf("http://%s:%s/schema", container.Name, container.port)
|
||||
|
||||
requestURL := fmt.Sprintf("http://%s:8080/schema", key)
|
||||
resp, err := http.Get(requestURL)
|
||||
if err != nil {
|
||||
log.Fatal("Request to container failed: %v", err)
|
||||
@ -57,19 +55,17 @@ func getSchema(w http.ResponseWriter, r *http.Request){
|
||||
log.Fatal("Failed to print Body: %v", err)
|
||||
}
|
||||
|
||||
fmt.Fprintf(w,string(body))
|
||||
}
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(resp.StatusCode)
|
||||
w.Write(body)
|
||||
}
|
||||
|
||||
func getStats(w http.ResponseWriter, r *http.Request){
|
||||
vars := mux.Vars(r)
|
||||
key := vars["container"]
|
||||
|
||||
for _, container := range Containers {
|
||||
if container.Id == key {
|
||||
requestURL := fmt.Sprintf("http://%s:%s/stats", container.Name, container.port)
|
||||
|
||||
requestURL := fmt.Sprintf("http://%s:8080/stats", key)
|
||||
resp, err := http.Get(requestURL)
|
||||
if err != nil {
|
||||
log.Fatal("Request to container failed: %v", err)
|
||||
@ -82,10 +78,9 @@ func getStats(w http.ResponseWriter, r *http.Request){
|
||||
log.Fatal("Failed to print Body: %v", err)
|
||||
}
|
||||
|
||||
fmt.Fprintf(w,string(body))
|
||||
}
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(resp.StatusCode)
|
||||
w.Write(body)
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user