diff --git a/docs/img/web.frontend.png b/docs/img/web.frontend.png index 0c3e238de..a80ab6120 100644 Binary files a/docs/img/web.frontend.png and b/docs/img/web.frontend.png differ diff --git a/server/server.go b/server/server.go index 23d6400fa..6045cd35f 100644 --- a/server/server.go +++ b/server/server.go @@ -162,11 +162,6 @@ func (server *Server) Close() { func (server *Server) startLeadership() { if server.leadership != nil { server.leadership.Participate(server.routinesPool) - // server.leadership.AddGoCtx(func(ctx context.Context) { - // log.Debugf("Started test routine") - // <-ctx.Done() - // log.Debugf("Stopped test routine") - // }) } } diff --git a/server/web.go b/server/web.go index ac1d38fe0..b5f8ad41a 100644 --- a/server/web.go +++ b/server/web.go @@ -92,13 +92,13 @@ func (provider *WebProvider) Provide(configurationChan chan<- types.ConfigMessag systemRouter.Methods("PUT").Path(provider.Path + "api/providers/{provider}").HandlerFunc(func(response http.ResponseWriter, request *http.Request) { if provider.ReadOnly { response.WriteHeader(http.StatusForbidden) - fmt.Fprintf(response, "REST API is in read-only mode") + fmt.Fprint(response, "REST API is in read-only mode") return } vars := mux.Vars(request) if vars["provider"] != "web" { response.WriteHeader(http.StatusBadRequest) - fmt.Fprintf(response, "Only 'web' provider can be updated through the REST API") + fmt.Fprint(response, "Only 'web' provider can be updated through the REST API") return } @@ -174,7 +174,7 @@ func (provider *WebProvider) getHealthHandler(response http.ResponseWriter, requ } func (provider *WebProvider) getPingHandler(response http.ResponseWriter, request *http.Request) { - fmt.Fprintf(response, "OK") + fmt.Fprint(response, "OK") } func (provider *WebProvider) getConfigHandler(response http.ResponseWriter, request *http.Request) { @@ -319,14 +319,14 @@ func (provider *WebProvider) getRouteHandler(response http.ResponseWriter, reque func expvarHandler(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=utf-8") - fmt.Fprintf(w, "{\n") + fmt.Fprint(w, "{\n") first := true expvar.Do(func(kv expvar.KeyValue) { if !first { - fmt.Fprintf(w, ",\n") + fmt.Fprint(w, ",\n") } first = false fmt.Fprintf(w, "%q: %s", kv.Key, kv.Value) }) - fmt.Fprintf(w, "\n}\n") + fmt.Fprint(w, "\n}\n") } diff --git a/webui/readme.md b/webui/readme.md index 7c42346f4..ad7195086 100644 --- a/webui/readme.md +++ b/webui/readme.md @@ -27,7 +27,7 @@ make generate-webui # Generate static contents in `traefik/static/` folder. - `yarn install` - Build static Web UI, execute the following command: - - `gulp` + - `yarn run build` - Static contents are build in the directory `static` @@ -50,7 +50,7 @@ make generate-webui # Generate static contents in `traefik/static/` folder. - Edit files in `webui/src` - Run in development mode : - - `gulp serve` + - `yarn run serve` - Træfɪk API connections are defined in: - `webui/src/app/core/health.resource.js` diff --git a/webui/src/app/core/providers.resource.js b/webui/src/app/core/providers.resource.js index e785290ba..2aa806a0a 100644 --- a/webui/src/app/core/providers.resource.js +++ b/webui/src/app/core/providers.resource.js @@ -8,7 +8,40 @@ angular .module(traefikCoreProvider, ['ngResource']) .factory('Providers', Providers); - /** @ngInject */ - function Providers($resource) { - return $resource('../api/providers'); - } \ No newline at end of file +/** @ngInject */ +function Providers($resource) { + const resourceProvider = $resource('../api/providers'); + return { + get: function () { + const rawProviders = resourceProvider.get(); + + for (let providerName in rawProviders) { + if (rawProviders.hasOwnProperty(providerName)) { + + // BackEnds mapping + let bckends = rawProviders[providerName].backends; + + rawProviders[providerName].backends = Object.keys(bckends) + .map(key => { + const goodBackend = bckends[key]; + goodBackend.backendId = key; + return goodBackend; + }); + + // FrontEnds mapping + let frtends = rawProviders[providerName].frontends; + + rawProviders[providerName].frontends = Object.keys(frtends) + .map(key => { + const goodFrontend = frtends[key]; + goodFrontend.frontendId = key; + return goodFrontend; + }); + + } + } + + return rawProviders; + } + }; +} diff --git a/webui/src/app/sections/providers/backend-monitor/backend-monitor.directive.js b/webui/src/app/sections/providers/backend-monitor/backend-monitor.directive.js index b05740726..89415db0e 100644 --- a/webui/src/app/sections/providers/backend-monitor/backend-monitor.directive.js +++ b/webui/src/app/sections/providers/backend-monitor/backend-monitor.directive.js @@ -8,8 +8,7 @@ function backendMonitor() { controllerAs: 'backendCtrl', bindToController: true, scope: { - backend: '=', - backendId: '=' + backend: '=' } }; } @@ -18,4 +17,4 @@ function BackendMonitorController() { // Nothing } -module.exports = backendMonitor; \ No newline at end of file +module.exports = backendMonitor; diff --git a/webui/src/app/sections/providers/backend-monitor/backend-monitor.html b/webui/src/app/sections/providers/backend-monitor/backend-monitor.html index 100f03172..6001d1384 100644 --- a/webui/src/app/sections/providers/backend-monitor/backend-monitor.html +++ b/webui/src/app/sections/providers/backend-monitor/backend-monitor.html @@ -1,6 +1,6 @@
- {{backendCtrl.backendId}} + {{backendCtrl.backend.backendId}}
diff --git a/webui/src/app/sections/providers/frontend-monitor/frontend-monitor.directive.js b/webui/src/app/sections/providers/frontend-monitor/frontend-monitor.directive.js index 7b6107202..bdfdfdad5 100644 --- a/webui/src/app/sections/providers/frontend-monitor/frontend-monitor.directive.js +++ b/webui/src/app/sections/providers/frontend-monitor/frontend-monitor.directive.js @@ -8,8 +8,7 @@ function frontendMonitor() { controllerAs: 'frontendCtrl', bindToController: true, scope: { - frontend: '=', - frontendId: '=' + frontend: '=' } }; } diff --git a/webui/src/app/sections/providers/frontend-monitor/frontend-monitor.html b/webui/src/app/sections/providers/frontend-monitor/frontend-monitor.html index eb5f8187f..57c26628e 100644 --- a/webui/src/app/sections/providers/frontend-monitor/frontend-monitor.html +++ b/webui/src/app/sections/providers/frontend-monitor/frontend-monitor.html @@ -1,6 +1,6 @@
- {{frontendCtrl.frontendId}} + {{frontendCtrl.frontend.frontendId}}
diff --git a/webui/src/app/sections/providers/providers.controller.js b/webui/src/app/sections/providers/providers.controller.js index 7898d8a86..8f0a4a273 100644 --- a/webui/src/app/sections/providers/providers.controller.js +++ b/webui/src/app/sections/providers/providers.controller.js @@ -2,17 +2,18 @@ /** @ngInject */ function ProvidersController($scope, $interval, $log, Providers) { - var vm = this; + const vm = this; vm.providers = Providers.get(); - var intervalId = $interval(function () { + const intervalId = $interval(function () { Providers.get(function (providers) { vm.providers = providers; }, function (error) { vm.providers = {}; $log.error(error); }); + }, 2000); $scope.$on('$destroy', function () { @@ -20,4 +21,4 @@ function ProvidersController($scope, $interval, $log, Providers) { }); } -module.exports = ProvidersController; \ No newline at end of file +module.exports = ProvidersController; diff --git a/webui/src/app/sections/providers/providers.html b/webui/src/app/sections/providers/providers.html index fd5557f7f..384b649b3 100644 --- a/webui/src/app/sections/providers/providers.html +++ b/webui/src/app/sections/providers/providers.html @@ -1,16 +1,18 @@
+
+
-
- +
+
-
- +
+
diff --git a/webui/src/app/version/version.controller.js b/webui/src/app/version/version.controller.js index 373f28b06..eb30fdd0e 100644 --- a/webui/src/app/version/version.controller.js +++ b/webui/src/app/version/version.controller.js @@ -1,7 +1,7 @@ 'use strict'; /** @ngInject */ -function VersionController($scope, $interval, $log, Version) { +function VersionController($scope, Version) { Version.get(function (version) { $scope.version = version; });