Loading app/controllers/NavbarController.scala +6 −2 Original line number Diff line number Diff line Loading @@ -4,7 +4,8 @@ import javax.inject.Inject import controllers.auth.AuthenticationModule import elastic.ElasticClient import models.{CerebroResponse, ElasticServer} import models.CerebroResponse import play.api.libs.json.{JsObject, Json} import scala.concurrent.ExecutionContext.Implicits.global Loading @@ -13,7 +14,10 @@ class NavbarController @Inject()(val authentication: AuthenticationModule, def index = process { request => client.clusterHealth(request.target).map { response => CerebroResponse(response.status, response.body) val body = request.user.fold(response.body) { user => response.body.as[JsObject] ++ Json.obj("username" -> user.name) } CerebroResponse(response.status, body) } } Loading conf/application.conf +5 −5 Original line number Diff line number Diff line Loading @@ -35,11 +35,11 @@ auth { // method = "simple" // user-domain = "domain.com" // } type: basic settings: { username = "admin" password = "1234" } // type: basic // settings: { // username = "admin" // password = "1234" // } } # Logger Loading public/js/app.js +2 −0 Original line number Diff line number Diff line Loading @@ -651,6 +651,7 @@ angular.module('cerebro').controller('NavbarController', ['$scope', '$http', $scope.status = undefined; $scope.cluster_name = undefined; $scope.host = undefined; $scope.username = undefined; $scope.$watch( function() { Loading @@ -661,6 +662,7 @@ angular.module('cerebro').controller('NavbarController', ['$scope', '$http', function(data) { $scope.status = data.status; $scope.cluster_name = data.cluster_name; $scope.username = data.username; $scope.host = DataService.getHost(); PageService.setup($scope.cluster_name, $scope.status); }, Loading public/navbar.html +4 −4 Original line number Diff line number Diff line Loading @@ -64,17 +64,17 @@ <ul class="nav navbar-nav navbar-right"> <li class="hidden-xs"> <a class="nav-item nav-link"> <span ng-hide="host"><i>Not connected</i></span> <span ng-show="host">{{host}}</span> </a> </li> <li> <a href="#connect" class="nav-item nav-link hidden-xs"><i class="fa fa-plug"></i></a> <a href="#connect" class="nav-item nav-link visible-xs">connect...</a> </li> <li> <form action="/auth/logout" method="POST"> <button class="btn btn-lg btn-link" type="submit"><i class="fa fa-power-off"></i></button> <form action="/auth/logout" method="POST" ng-show="username"> <button class="btn btn-lg btn-link" type="submit"> <i class="fa fa-power-off"></i> </button> </form> </li> </ul> Loading src/app/components/navbar/controller.js +2 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ angular.module('cerebro').controller('NavbarController', ['$scope', '$http', $scope.status = undefined; $scope.cluster_name = undefined; $scope.host = undefined; $scope.username = undefined; $scope.$watch( function() { Loading @@ -15,6 +16,7 @@ angular.module('cerebro').controller('NavbarController', ['$scope', '$http', function(data) { $scope.status = data.status; $scope.cluster_name = data.cluster_name; $scope.username = data.username; $scope.host = DataService.getHost(); PageService.setup($scope.cluster_name, $scope.status); }, Loading Loading
app/controllers/NavbarController.scala +6 −2 Original line number Diff line number Diff line Loading @@ -4,7 +4,8 @@ import javax.inject.Inject import controllers.auth.AuthenticationModule import elastic.ElasticClient import models.{CerebroResponse, ElasticServer} import models.CerebroResponse import play.api.libs.json.{JsObject, Json} import scala.concurrent.ExecutionContext.Implicits.global Loading @@ -13,7 +14,10 @@ class NavbarController @Inject()(val authentication: AuthenticationModule, def index = process { request => client.clusterHealth(request.target).map { response => CerebroResponse(response.status, response.body) val body = request.user.fold(response.body) { user => response.body.as[JsObject] ++ Json.obj("username" -> user.name) } CerebroResponse(response.status, body) } } Loading
conf/application.conf +5 −5 Original line number Diff line number Diff line Loading @@ -35,11 +35,11 @@ auth { // method = "simple" // user-domain = "domain.com" // } type: basic settings: { username = "admin" password = "1234" } // type: basic // settings: { // username = "admin" // password = "1234" // } } # Logger Loading
public/js/app.js +2 −0 Original line number Diff line number Diff line Loading @@ -651,6 +651,7 @@ angular.module('cerebro').controller('NavbarController', ['$scope', '$http', $scope.status = undefined; $scope.cluster_name = undefined; $scope.host = undefined; $scope.username = undefined; $scope.$watch( function() { Loading @@ -661,6 +662,7 @@ angular.module('cerebro').controller('NavbarController', ['$scope', '$http', function(data) { $scope.status = data.status; $scope.cluster_name = data.cluster_name; $scope.username = data.username; $scope.host = DataService.getHost(); PageService.setup($scope.cluster_name, $scope.status); }, Loading
public/navbar.html +4 −4 Original line number Diff line number Diff line Loading @@ -64,17 +64,17 @@ <ul class="nav navbar-nav navbar-right"> <li class="hidden-xs"> <a class="nav-item nav-link"> <span ng-hide="host"><i>Not connected</i></span> <span ng-show="host">{{host}}</span> </a> </li> <li> <a href="#connect" class="nav-item nav-link hidden-xs"><i class="fa fa-plug"></i></a> <a href="#connect" class="nav-item nav-link visible-xs">connect...</a> </li> <li> <form action="/auth/logout" method="POST"> <button class="btn btn-lg btn-link" type="submit"><i class="fa fa-power-off"></i></button> <form action="/auth/logout" method="POST" ng-show="username"> <button class="btn btn-lg btn-link" type="submit"> <i class="fa fa-power-off"></i> </button> </form> </li> </ul> Loading
src/app/components/navbar/controller.js +2 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ angular.module('cerebro').controller('NavbarController', ['$scope', '$http', $scope.status = undefined; $scope.cluster_name = undefined; $scope.host = undefined; $scope.username = undefined; $scope.$watch( function() { Loading @@ -15,6 +16,7 @@ angular.module('cerebro').controller('NavbarController', ['$scope', '$http', function(data) { $scope.status = data.status; $scope.cluster_name = data.cluster_name; $scope.username = data.username; $scope.host = DataService.getHost(); PageService.setup($scope.cluster_name, $scope.status); }, Loading