Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show current version in web UI #709

Merged
merged 1 commit into from
Oct 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions web.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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"]
Expand Down
14 changes: 14 additions & 0 deletions webui/src/app/core/version.resource.js
Original file line number Diff line number Diff line change
@@ -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 changes: 10 additions & 0 deletions webui/src/app/version/version.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

/** @ngInject */
function VersionController($scope, $interval, $log, Version) {
Version.get(function (version) {
$scope.version = version;
});
}

module.exports = VersionController;
11 changes: 11 additions & 0 deletions webui/src/app/version/version.module.js
Original file line number Diff line number Diff line change
@@ -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);
5 changes: 5 additions & 0 deletions webui/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
4 changes: 3 additions & 1 deletion webui/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -28,7 +29,8 @@ angular
ngResource,
uiRouter,
uiBootstrap,
traefikSection
traefikSection,
traefikVersion
])
.run(runBlock)
.constant('moment', moment)
Expand Down