mirror of
https://github.com/openfaas/faas.git
synced 2025-06-08 16:26:47 +00:00
Add EnvProcess and logo to UI
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
This commit is contained in:
parent
272bfe0563
commit
b6002e1c85
BIN
gateway/assets/icon.png
Normal file
BIN
gateway/assets/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.4 KiB |
@ -17,7 +17,7 @@
|
||||
<md-sidenav class="md-sidenav-left" md-component-id="left" md-is-locked-open="$mdMedia('gt-sm')" md-whiteframe="4" layout="column">
|
||||
|
||||
<md-toolbar class="md-theme-indigo">
|
||||
<h1 class="md-toolbar-tools">FaaS Gateway</h1>
|
||||
<h1 class="md-toolbar-tools"><img src="icon.png" alt="OpenFaaS Icon" width="60px" height="60px" class="md-avatar"/> OpenFaaS Portal</h1>
|
||||
</md-toolbar>
|
||||
|
||||
<md-content layout-padding>
|
||||
@ -55,8 +55,8 @@
|
||||
<md-card-title-text>
|
||||
|
||||
<span class="md-headline">
|
||||
{{function.name}}
|
||||
</span>
|
||||
{{function.name}}
|
||||
</span>
|
||||
<div layout-gt-sm="row">
|
||||
<md-input-container class="md-icon-float md-block">
|
||||
<label>Replicas</label>
|
||||
@ -74,6 +74,12 @@
|
||||
<input ng-model="function.image" type="text" readonly="readonly">
|
||||
</md-input-container>
|
||||
</div>
|
||||
<div layout-gt-sm="row" ng-show="function.envProcess">
|
||||
<md-input-container class="md-block" flex-gt-sm>
|
||||
<label>Watchdog process</label>
|
||||
<input ng-model="function.envProcess" type="text" readonly="readonly">
|
||||
</md-input-container>
|
||||
</div>
|
||||
<md-card-title-text>
|
||||
</md-card-title>
|
||||
</md-card>
|
||||
|
@ -44,47 +44,6 @@ func getCounterValue(service string, code string, metricsOptions *metrics.Metric
|
||||
return invocations
|
||||
}
|
||||
|
||||
// MakeFunctionReader gives a summary of Function structs with Docker service stats overlaid with Prometheus counters.
|
||||
func MakeFunctionReader(metricsOptions metrics.MetricOptions, c *client.Client) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
serviceFilter := filters.NewArgs()
|
||||
|
||||
options := types.ServiceListOptions{
|
||||
Filters: serviceFilter,
|
||||
}
|
||||
|
||||
services, err := c.ServiceList(context.Background(), options)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
// TODO: Filter only "faas" functions (via metadata?)
|
||||
var functions []requests.Function
|
||||
|
||||
for _, service := range services {
|
||||
|
||||
if len(service.Spec.TaskTemplate.ContainerSpec.Labels["function"]) > 0 {
|
||||
invocations := getCounterValue(service.Spec.Name, "200", &metricsOptions) +
|
||||
getCounterValue(service.Spec.Name, "500", &metricsOptions)
|
||||
|
||||
f := requests.Function{
|
||||
Name: service.Spec.Name,
|
||||
Image: service.Spec.TaskTemplate.ContainerSpec.Image,
|
||||
InvocationCount: invocations,
|
||||
Replicas: *service.Spec.Mode.Replicated.Replicas,
|
||||
}
|
||||
functions = append(functions, f)
|
||||
}
|
||||
}
|
||||
|
||||
functionBytes, _ := json.Marshal(functions)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(200)
|
||||
w.Write(functionBytes)
|
||||
}
|
||||
}
|
||||
|
||||
func MakeDeleteFunctionHandler(metricsOptions metrics.MetricOptions, c *client.Client) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
|
67
gateway/handlers/reader.go
Normal file
67
gateway/handlers/reader.go
Normal file
@ -0,0 +1,67 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"strings"
|
||||
|
||||
"github.com/alexellis/faas/gateway/metrics"
|
||||
"github.com/alexellis/faas/gateway/requests"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/client"
|
||||
)
|
||||
|
||||
// MakeFunctionReader gives a summary of Function structs with Docker service stats overlaid with Prometheus counters.
|
||||
func MakeFunctionReader(metricsOptions metrics.MetricOptions, c *client.Client) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
serviceFilter := filters.NewArgs()
|
||||
|
||||
options := types.ServiceListOptions{
|
||||
Filters: serviceFilter,
|
||||
}
|
||||
|
||||
services, err := c.ServiceList(context.Background(), options)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
// TODO: Filter only "faas" functions (via metadata?)
|
||||
var functions []requests.Function
|
||||
|
||||
for _, service := range services {
|
||||
|
||||
if len(service.Spec.TaskTemplate.ContainerSpec.Labels["function"]) > 0 {
|
||||
invocations := getCounterValue(service.Spec.Name, "200", &metricsOptions) +
|
||||
getCounterValue(service.Spec.Name, "500", &metricsOptions)
|
||||
|
||||
var envProcess string
|
||||
|
||||
for _, env := range service.Spec.TaskTemplate.ContainerSpec.Env {
|
||||
if strings.Index(env, "fprocess=") > -1 {
|
||||
envProcess = env[len("fprocess="):]
|
||||
}
|
||||
}
|
||||
|
||||
f := requests.Function{
|
||||
Name: service.Spec.Name,
|
||||
Image: service.Spec.TaskTemplate.ContainerSpec.Image,
|
||||
InvocationCount: invocations,
|
||||
Replicas: *service.Spec.Mode.Replicated.Replicas,
|
||||
EnvProcess: envProcess,
|
||||
}
|
||||
|
||||
functions = append(functions, f)
|
||||
}
|
||||
}
|
||||
|
||||
functionBytes, _ := json.Marshal(functions)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(200)
|
||||
w.Write(functionBytes)
|
||||
}
|
||||
}
|
@ -75,4 +75,5 @@ type Function struct {
|
||||
Image string `json:"image"`
|
||||
InvocationCount float64 `json:"invocationCount"` // TODO: shouldn't this be int64?
|
||||
Replicas uint64 `json:"replicas"`
|
||||
EnvProcess string `json:"envProcess"`
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user