Loading app/controllers/ConnectController.scala +9 −8 Original line number Diff line number Diff line Loading @@ -5,30 +5,31 @@ import javax.inject.Inject import controllers.auth.AuthenticationModule import elastic.ElasticClient import models.CerebroResponse import play.api.Play import play.api.Configuration import play.api.libs.json.{JsArray, Json} import play.api.mvc.Controller class ConnectController @Inject()(val authentication: AuthenticationModule, config: Configuration, client: ElasticClient) extends Controller with AuthSupport { def index = AuthAction(authentication) { request => { val hosts = Play.current.configuration.getConfigSeq("hosts") match { case Some(configs) => configs.map { config => val username = config.getString("auth.username") val password = config.getString("auth.password") val hosts = config.getConfigSeq("hosts") match { case Some(hostsConfig) => hostsConfig.map { hostConfig => val username = hostConfig.getString("auth.username") val password = hostConfig.getString("auth.password") (username, password) match { case (Some(username), Some(password)) => Json.obj( "host" -> config.getString("host").get, "host" -> hostConfig.getString("host").get, "username" -> username, "password" -> password ) case _ => Json.obj("host" -> config.getString("host").get) Json.obj("host" -> hostConfig.getString("host").get) } } case None => Loading app/models/UnexpectedResponseFormatException.scala 0 → 100644 +5 −0 Original line number Diff line number Diff line package models import play.api.libs.json.JsValue case class UnexpectedResponseFormatException(response: JsValue) extends RuntimeException(s"Unexpected format for [${response.toString}]") app/models/overview/ClusterOverview.scala +1 −1 Original line number Diff line number Diff line Loading @@ -81,7 +81,7 @@ object Nodes { val load = (nodeStats \ "os" \ "cpu" \ "load_average" \ "1m").asOpt[Float].getOrElse( // 5.X (nodeStats \ "os" \ "load_average").asOpt[Float].getOrElse(0f) // FIXME: 2.X ) JsNumber(BigDecimal(load)) JsNumber(BigDecimal(load.toDouble)) } def cpuPercent(nodeStats: JsValue): JsNumber = { Loading app/models/repository/Repositories.scala +2 −0 Original line number Diff line number Diff line package models.repository import models.UnexpectedResponseFormatException import play.api.libs.json.{JsArray, JsObject, JsValue, Json} object Repositories { Loading @@ -16,6 +17,7 @@ object Repositories { ) }.toSeq ) case _ => throw UnexpectedResponseFormatException(json) } } Loading build.sbt +6 −6 Original line number Diff line number Diff line Loading @@ -2,14 +2,14 @@ name := "cerebro" version := "0.5.0" scalaVersion := "2.11.6" scalaVersion := "2.11.8" libraryDependencies ++= Seq( "com.typesafe.play" %% "play" % "2.4.6", "com.typesafe.play" %% "play-ws" % "2.4.6", "org.specs2" %% "specs2-junit" % "3.6.5" % "test", "org.specs2" %% "specs2-core" % "3.6.5" % "test", "org.specs2" %% "specs2-mock" % "3.6.5" % "test" "com.typesafe.play" %% "play" % "2.5.10", "com.typesafe.play" %% "play-ws" % "2.5.10", "org.specs2" %% "specs2-junit" % "3.8.4" % "test", "org.specs2" %% "specs2-core" % "3.8.4" % "test", "org.specs2" %% "specs2-mock" % "3.8.4" % "test" ) lazy val root = (project in file(".")).enablePlugins(PlayScala) Loading Loading
app/controllers/ConnectController.scala +9 −8 Original line number Diff line number Diff line Loading @@ -5,30 +5,31 @@ import javax.inject.Inject import controllers.auth.AuthenticationModule import elastic.ElasticClient import models.CerebroResponse import play.api.Play import play.api.Configuration import play.api.libs.json.{JsArray, Json} import play.api.mvc.Controller class ConnectController @Inject()(val authentication: AuthenticationModule, config: Configuration, client: ElasticClient) extends Controller with AuthSupport { def index = AuthAction(authentication) { request => { val hosts = Play.current.configuration.getConfigSeq("hosts") match { case Some(configs) => configs.map { config => val username = config.getString("auth.username") val password = config.getString("auth.password") val hosts = config.getConfigSeq("hosts") match { case Some(hostsConfig) => hostsConfig.map { hostConfig => val username = hostConfig.getString("auth.username") val password = hostConfig.getString("auth.password") (username, password) match { case (Some(username), Some(password)) => Json.obj( "host" -> config.getString("host").get, "host" -> hostConfig.getString("host").get, "username" -> username, "password" -> password ) case _ => Json.obj("host" -> config.getString("host").get) Json.obj("host" -> hostConfig.getString("host").get) } } case None => Loading
app/models/UnexpectedResponseFormatException.scala 0 → 100644 +5 −0 Original line number Diff line number Diff line package models import play.api.libs.json.JsValue case class UnexpectedResponseFormatException(response: JsValue) extends RuntimeException(s"Unexpected format for [${response.toString}]")
app/models/overview/ClusterOverview.scala +1 −1 Original line number Diff line number Diff line Loading @@ -81,7 +81,7 @@ object Nodes { val load = (nodeStats \ "os" \ "cpu" \ "load_average" \ "1m").asOpt[Float].getOrElse( // 5.X (nodeStats \ "os" \ "load_average").asOpt[Float].getOrElse(0f) // FIXME: 2.X ) JsNumber(BigDecimal(load)) JsNumber(BigDecimal(load.toDouble)) } def cpuPercent(nodeStats: JsValue): JsNumber = { Loading
app/models/repository/Repositories.scala +2 −0 Original line number Diff line number Diff line package models.repository import models.UnexpectedResponseFormatException import play.api.libs.json.{JsArray, JsObject, JsValue, Json} object Repositories { Loading @@ -16,6 +17,7 @@ object Repositories { ) }.toSeq ) case _ => throw UnexpectedResponseFormatException(json) } } Loading
build.sbt +6 −6 Original line number Diff line number Diff line Loading @@ -2,14 +2,14 @@ name := "cerebro" version := "0.5.0" scalaVersion := "2.11.6" scalaVersion := "2.11.8" libraryDependencies ++= Seq( "com.typesafe.play" %% "play" % "2.4.6", "com.typesafe.play" %% "play-ws" % "2.4.6", "org.specs2" %% "specs2-junit" % "3.6.5" % "test", "org.specs2" %% "specs2-core" % "3.6.5" % "test", "org.specs2" %% "specs2-mock" % "3.6.5" % "test" "com.typesafe.play" %% "play" % "2.5.10", "com.typesafe.play" %% "play-ws" % "2.5.10", "org.specs2" %% "specs2-junit" % "3.8.4" % "test", "org.specs2" %% "specs2-core" % "3.8.4" % "test", "org.specs2" %% "specs2-mock" % "3.8.4" % "test" ) lazy val root = (project in file(".")).enablePlugins(PlayScala) Loading