Show current version in web UI
This commit is contained in:
parent
408ef0f5b7
commit
4a43273ee5
6 changed files with 56 additions and 1 deletions
13
web.go
13
web.go
|
@ -15,6 +15,7 @@ import (
|
||||||
"github.com/containous/traefik/middlewares"
|
"github.com/containous/traefik/middlewares"
|
||||||
"github.com/containous/traefik/safe"
|
"github.com/containous/traefik/safe"
|
||||||
"github.com/containous/traefik/types"
|
"github.com/containous/traefik/types"
|
||||||
|
"github.com/containous/traefik/version"
|
||||||
"github.com/elazarl/go-bindata-assetfs"
|
"github.com/elazarl/go-bindata-assetfs"
|
||||||
"github.com/thoas/stats"
|
"github.com/thoas/stats"
|
||||||
"github.com/unrolled/render"
|
"github.com/unrolled/render"
|
||||||
|
@ -60,6 +61,7 @@ func (provider *WebProvider) Provide(configurationChan chan<- types.ConfigMessag
|
||||||
systemRouter.Methods("GET").Path("/ping").HandlerFunc(provider.getPingHandler)
|
systemRouter.Methods("GET").Path("/ping").HandlerFunc(provider.getPingHandler)
|
||||||
// API routes
|
// API routes
|
||||||
systemRouter.Methods("GET").Path("/api").HandlerFunc(provider.getConfigHandler)
|
systemRouter.Methods("GET").Path("/api").HandlerFunc(provider.getConfigHandler)
|
||||||
|
systemRouter.Methods("GET").Path("/api/version").HandlerFunc(provider.getVersionHandler)
|
||||||
systemRouter.Methods("GET").Path("/api/providers").HandlerFunc(provider.getConfigHandler)
|
systemRouter.Methods("GET").Path("/api/providers").HandlerFunc(provider.getConfigHandler)
|
||||||
systemRouter.Methods("GET").Path("/api/providers/{provider}").HandlerFunc(provider.getProviderHandler)
|
systemRouter.Methods("GET").Path("/api/providers/{provider}").HandlerFunc(provider.getProviderHandler)
|
||||||
systemRouter.Methods("PUT").Path("/api/providers/{provider}").HandlerFunc(func(response http.ResponseWriter, request *http.Request) {
|
systemRouter.Methods("PUT").Path("/api/providers/{provider}").HandlerFunc(func(response http.ResponseWriter, request *http.Request) {
|
||||||
|
@ -144,6 +146,17 @@ func (provider *WebProvider) getConfigHandler(response http.ResponseWriter, requ
|
||||||
templatesRenderer.JSON(response, http.StatusOK, currentConfigurations)
|
templatesRenderer.JSON(response, http.StatusOK, currentConfigurations)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (provider *WebProvider) getVersionHandler(response http.ResponseWriter, request *http.Request) {
|
||||||
|
v := struct {
|
||||||
|
Version string
|
||||||
|
Codename string
|
||||||
|
}{
|
||||||
|
Version: version.Version,
|
||||||
|
Codename: version.Codename,
|
||||||
|
}
|
||||||
|
templatesRenderer.JSON(response, http.StatusOK, v)
|
||||||
|
}
|
||||||
|
|
||||||
func (provider *WebProvider) getProviderHandler(response http.ResponseWriter, request *http.Request) {
|
func (provider *WebProvider) getProviderHandler(response http.ResponseWriter, request *http.Request) {
|
||||||
vars := mux.Vars(request)
|
vars := mux.Vars(request)
|
||||||
providerID := vars["provider"]
|
providerID := vars["provider"]
|
||||||
|
|
14
webui/src/app/core/version.resource.js
Normal file
14
webui/src/app/core/version.resource.js
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
'use strict';
|
||||||
|
var angular = require('angular');
|
||||||
|
|
||||||
|
var traefikCoreVersion = 'traefik.core.version';
|
||||||
|
module.exports = traefikCoreVersion;
|
||||||
|
|
||||||
|
angular
|
||||||
|
.module(traefikCoreVersion, ['ngResource'])
|
||||||
|
.factory('Version', Version);
|
||||||
|
|
||||||
|
/** @ngInject */
|
||||||
|
function Version($resource) {
|
||||||
|
return $resource('../api/version');
|
||||||
|
}
|
10
webui/src/app/version/version.controller.js
Normal file
10
webui/src/app/version/version.controller.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
/** @ngInject */
|
||||||
|
function VersionController($scope, $interval, $log, Version) {
|
||||||
|
Version.get(function (version) {
|
||||||
|
$scope.version = version;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = VersionController;
|
11
webui/src/app/version/version.module.js
Normal file
11
webui/src/app/version/version.module.js
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
'use strict';
|
||||||
|
var angular = require('angular');
|
||||||
|
var traefikCoreVersion = require('../core/version.resource');
|
||||||
|
var VersionController = require('./version.controller');
|
||||||
|
|
||||||
|
var traefikVersion = 'traefik.version';
|
||||||
|
module.exports = traefikVersion;
|
||||||
|
|
||||||
|
angular
|
||||||
|
.module(traefikVersion, [traefikCoreVersion])
|
||||||
|
.controller('VersionController', VersionController);
|
|
@ -27,6 +27,11 @@
|
||||||
<li><a ui-sref="health">Health</a></li>
|
<li><a ui-sref="health">Health</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="nav navbar-nav navbar-right">
|
<ul class="nav navbar-nav navbar-right">
|
||||||
|
<li>
|
||||||
|
<a ng-controller="VersionController" href="https://github.com/containous/traefik/tree/{{version.Version}}" target="_blank">
|
||||||
|
<small>{{version.Version}} / {{version.Codename}}</small>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="https://docs.traefik.io" target="_blank">Documentation</a>
|
<a href="https://docs.traefik.io" target="_blank">Documentation</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -10,6 +10,7 @@ var uiRouter = require('angular-ui-router');
|
||||||
var uiBootstrap = require('angular-ui-bootstrap');
|
var uiBootstrap = require('angular-ui-bootstrap');
|
||||||
var moment = require('moment');
|
var moment = require('moment');
|
||||||
var traefikSection = require('./app/sections/sections');
|
var traefikSection = require('./app/sections/sections');
|
||||||
|
var traefikVersion = require('./app/version/version.module');
|
||||||
require('./index.scss');
|
require('./index.scss');
|
||||||
require('animate.css/animate.css');
|
require('animate.css/animate.css');
|
||||||
require('nvd3/build/nv.d3.css');
|
require('nvd3/build/nv.d3.css');
|
||||||
|
@ -28,7 +29,8 @@ angular
|
||||||
ngResource,
|
ngResource,
|
||||||
uiRouter,
|
uiRouter,
|
||||||
uiBootstrap,
|
uiBootstrap,
|
||||||
traefikSection
|
traefikSection,
|
||||||
|
traefikVersion
|
||||||
])
|
])
|
||||||
.run(runBlock)
|
.run(runBlock)
|
||||||
.constant('moment', moment)
|
.constant('moment', moment)
|
||||||
|
|
Loading…
Reference in a new issue