Add auto-refresh to UI

This commit is contained in:
Alex Ellis 2017-01-22 14:11:36 +00:00
parent cf2317696d
commit 79bc6a54ea
6 changed files with 27 additions and 19 deletions

View File

@ -5,7 +5,7 @@ services:
- "/var/run/docker.sock:/var/run/docker.sock" - "/var/run/docker.sock:/var/run/docker.sock"
ports: ports:
- 8080:8080 - 8080:8080
image: alexellis2/faas-gateway:latest-dev2 image: alexellis2/faas-gateway:latest-dev3
networks: networks:
- functions - functions
deploy: deploy:

View File

@ -2,11 +2,11 @@ FROM alpine:latest
WORKDIR /root/ WORKDIR /root/
COPY gateway .
COPY assets assets
EXPOSE 8080 EXPOSE 8080
ENV http_proxy "" ENV http_proxy ""
ENV https_proxy "" ENV https_proxy ""
COPY gateway .
COPY assets assets
CMD ["./gateway"] CMD ["./gateway"]

View File

@ -10,9 +10,10 @@ RUN go get -d github.com/docker/docker/api/types \
WORKDIR /go/src/github.com/alexellis/faas/gateway WORKDIR /go/src/github.com/alexellis/faas/gateway
COPY metrics metrics COPY metrics metrics
COPY requests requests COPY requests requests
COPY server.go . COPY tests tests
COPY proxy.go . COPY server.go .
COPY proxy.go .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app . RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .

View File

@ -1,8 +1,7 @@
<html ng-app="faasGateway" > <html ng-app="faasGateway" >
<head> <head>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,400italic" /> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,400italic" />
<!--<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.css">--> <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.css">
<!-- Angular Material CSS now available via Google CDN; version 1.0.7 used here --> <!-- Angular Material CSS now available via Google CDN; version 1.0.7 used here -->
<link rel="stylesheet" href="style/angular-material.min.css"> <link rel="stylesheet" href="style/angular-material.min.css">
@ -11,9 +10,7 @@
</head> </head>
<body ng-controller="home"> <body ng-controller="home">
<div layout="column" style="height:100%;" ng-cloak>
<div layout="column" style="height:100%;" ng-cloak>
<section id="popupContainer" layout="row" flex> <section id="popupContainer" layout="row" flex>
<md-sidenav <md-sidenav
@ -30,7 +27,7 @@
<md-button ng-click="newFunction()" ng-disabled="isFunctionBeingCreated" class="md-primary">New function</md-button> <md-button ng-click="newFunction()" ng-disabled="isFunctionBeingCreated" class="md-primary">New function</md-button>
<md-list> <md-list>
<md-list-item ng-switch class="md-3-line" ng-click="showFunction(function)" ng-repeat="function in functions" ng-class="function.name == selectedFunction.name ? 'selected' : false"> <md-list-item ng-switch class="md-3-line" ng-click="showFunction(function)" ng-repeat="function in functions | orderBy: '-invocationCount'" ng-class="function.name == selectedFunction.name ? 'selected' : false">
<md-icon ng-switch-when="true" style="color: blue" md-svg-icon="person"></md-icon> <md-icon ng-switch-when="true" style="color: blue" md-svg-icon="person"></md-icon>
<md-icon ng-switch-when="false" md-svg-icon="person-outline"></md-icon> <md-icon ng-switch-when="false" md-svg-icon="person-outline"></md-icon>
<p>{{function.name}}</p> <p>{{function.name}}</p>

View File

@ -1,10 +1,18 @@
"use strict" "use strict"
var app = angular.module('faasGateway', ['ngMaterial']); var app = angular.module('faasGateway', ['ngMaterial']);
app.controller("home", ['$scope', '$log', '$http', '$location', '$timeout', function($scope, $log, $http, $location, $timeout) { app.controller("home", ['$scope', '$log', '$http', '$location', '$timeout', function($scope, $log, $http, $location, $timeout) {
$scope.functions = []; $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.showFunction = function(fn) {
$scope.selectedFunction = fn; $scope.selectedFunction = fn;
@ -18,4 +26,6 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$timeout', func
invokedCount: 0 invokedCount: 0
}); });
}; };
fetch();
}]); }]);

View File

@ -10,4 +10,4 @@ docker rm -f gateway_extract
echo Building alexellis2/faas-gateway:latest echo Building alexellis2/faas-gateway:latest
docker build -t alexellis2/faas-gateway:latest-dev2 . docker build -t alexellis2/faas-gateway:latest-dev3 .