From 79bc6a54ea2d0e75e98f09a80b7d54b3ddd8a27a Mon Sep 17 00:00:00 2001 From: Alex Ellis Date: Sun, 22 Jan 2017 14:11:36 +0000 Subject: [PATCH] Add auto-refresh to UI --- docker-compose.yml | 2 +- gateway/Dockerfile | 6 +++--- gateway/Dockerfile.build | 9 +++++---- gateway/assets/index.html | 11 ++++------- gateway/assets/script/bootstrap.js | 16 +++++++++++++--- gateway/build.sh | 2 +- 6 files changed, 27 insertions(+), 19 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index d8255824..9b4b382d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: - "/var/run/docker.sock:/var/run/docker.sock" ports: - 8080:8080 - image: alexellis2/faas-gateway:latest-dev2 + image: alexellis2/faas-gateway:latest-dev3 networks: - functions deploy: diff --git a/gateway/Dockerfile b/gateway/Dockerfile index ad71154d..d397da87 100644 --- a/gateway/Dockerfile +++ b/gateway/Dockerfile @@ -2,11 +2,11 @@ FROM alpine:latest WORKDIR /root/ -COPY gateway . -COPY assets assets - EXPOSE 8080 ENV http_proxy "" ENV https_proxy "" +COPY gateway . +COPY assets assets + CMD ["./gateway"] diff --git a/gateway/Dockerfile.build b/gateway/Dockerfile.build index 1f9c1102..f0b78f6e 100644 --- a/gateway/Dockerfile.build +++ b/gateway/Dockerfile.build @@ -10,9 +10,10 @@ RUN go get -d github.com/docker/docker/api/types \ WORKDIR /go/src/github.com/alexellis/faas/gateway -COPY metrics metrics -COPY requests requests -COPY server.go . -COPY proxy.go . +COPY metrics metrics +COPY requests requests +COPY tests tests +COPY server.go . +COPY proxy.go . RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app . diff --git a/gateway/assets/index.html b/gateway/assets/index.html index d3cd755f..43b0c7ce 100644 --- a/gateway/assets/index.html +++ b/gateway/assets/index.html @@ -1,8 +1,7 @@ - - - + + @@ -11,9 +10,7 @@ - - -
+
New function - +

{{function.name}}

diff --git a/gateway/assets/script/bootstrap.js b/gateway/assets/script/bootstrap.js index 05b2285b..43ca49e0 100644 --- a/gateway/assets/script/bootstrap.js +++ b/gateway/assets/script/bootstrap.js @@ -1,10 +1,18 @@ "use strict" var app = angular.module('faasGateway', ['ngMaterial']); + app.controller("home", ['$scope', '$log', '$http', '$location', '$timeout', function($scope, $log, $http, $location, $timeout) { $scope.functions = []; - $http.get("/system/functions").then(function(response) { - $scope.functions = response.data; - }); + + setInterval(function() { + fetch(); + }, 1000); + + var fetch = function() { + $http.get("/system/functions").then(function(response) { + $scope.functions = response.data; + }); + }; $scope.showFunction = function(fn) { $scope.selectedFunction = fn; @@ -18,4 +26,6 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$timeout', func invokedCount: 0 }); }; + + fetch(); }]); diff --git a/gateway/build.sh b/gateway/build.sh index ee340c32..3f93f69e 100755 --- a/gateway/build.sh +++ b/gateway/build.sh @@ -10,4 +10,4 @@ docker rm -f gateway_extract echo Building alexellis2/faas-gateway:latest -docker build -t alexellis2/faas-gateway:latest-dev2 . +docker build -t alexellis2/faas-gateway:latest-dev3 .