Merge pull request #709 from vhf/webui-show-version

Show current version in web UI
This commit is contained in:
Emile Vauge 2016-10-03 11:37:20 +02:00 committed by GitHub
commit 6632247c9c
6 changed files with 56 additions and 1 deletions

13
web.go
View file

@ -15,6 +15,7 @@ import (
"github.com/containous/traefik/middlewares"
"github.com/containous/traefik/safe"
"github.com/containous/traefik/types"
"github.com/containous/traefik/version"
"github.com/elazarl/go-bindata-assetfs"
"github.com/thoas/stats"
"github.com/unrolled/render"
@ -60,6 +61,7 @@ func (provider *WebProvider) Provide(configurationChan chan<- types.ConfigMessag
systemRouter.Methods("GET").Path("/ping").HandlerFunc(provider.getPingHandler)
// API routes
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/{provider}").HandlerFunc(provider.getProviderHandler)
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)
}
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) {
vars := mux.Vars(request)
providerID := vars["provider"]

View 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');
}

View file

@ -0,0 +1,10 @@
'use strict';
/** @ngInject */
function VersionController($scope, $interval, $log, Version) {
Version.get(function (version) {
$scope.version = version;
});
}
module.exports = VersionController;

View 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);

View file

@ -27,6 +27,11 @@
<li><a ui-sref="health">Health</a></li>
</ul>
<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>
<a href="https://docs.traefik.io" target="_blank">Documentation</a>
</li>

View file

@ -10,6 +10,7 @@ var uiRouter = require('angular-ui-router');
var uiBootstrap = require('angular-ui-bootstrap');
var moment = require('moment');
var traefikSection = require('./app/sections/sections');
var traefikVersion = require('./app/version/version.module');
require('./index.scss');
require('animate.css/animate.css');
require('nvd3/build/nv.d3.css');
@ -28,7 +29,8 @@ angular
ngResource,
uiRouter,
uiBootstrap,
traefikSection
traefikSection,
traefikVersion
])
.run(runBlock)
.constant('moment', moment)