Skip to content
Snippets Groups Projects
Commit b6002e1c authored by Alex Ellis's avatar Alex Ellis
Browse files

Add EnvProcess and logo to UI


Signed-off-by: default avatarAlex Ellis <alexellis2@gmail.com>
parent 272bfe05
No related branches found
No related tags found
No related merge requests found
gateway/assets/icon.png

9.43 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"/>&nbsp; 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) {
......
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"`
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment