Skip to content

Commit

Permalink
Merge pull request #3 from Rassyan/revert-2-main
Browse files Browse the repository at this point in the history
Revert "update"
  • Loading branch information
Rassyan authored Mar 2, 2022
2 parents 272201c + 9287acb commit a9308db
Show file tree
Hide file tree
Showing 115 changed files with 13,433 additions and 51,111 deletions.
39 changes: 0 additions & 39 deletions .github/workflows/scala.yml

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
.*
# except for .gitignore
!.gitignore
!.eslintrc.json

# Ignore Play! working directory #
db
Expand Down
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
language: scala

scala:
- 2.13.4
- 2.12.8

jdk:
- openjdk8
- openjdk11

script: sbt ++$TRAVIS_SCALA_VERSION test
12 changes: 1 addition & 11 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,4 @@ First cerebro release.
### v0.9.2 - June 18th, 2020

#### Bug fixes
- Handle node info for nodes without defined attributes Closes #448

### v0.9.3 - December 27th, 2020

#### Improvements
- Support elasticsearch 7.10 data tiers

### v0.9.4 - April 10th, 2021

#### Security updates
- Bump socket.io to 2.4.1
- Handle node info for nodes without defined attributes Closes #448
55 changes: 26 additions & 29 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module.exports = function(grunt) {

var singleRunTests = grunt.option('singleRunTests') !== false;
grunt.initConfig({
clean: {
dist: {
Expand All @@ -21,34 +20,27 @@ module.exports = function(grunt) {
},
copy: {
main: {
files: [
{
expand: true,
cwd: 'node_modules/font-awesome/fonts',
src: ['*'],
dest: 'public/fonts/'
}
]
files: []
}
},
concat: {
vendorjs: {
src: [
'node_modules/jquery/dist/jquery.js',
'node_modules/angular/angular.min.js',
'node_modules/angular-animate/angular-animate.min.js',
'node_modules/angular-route/angular-route.min.js',
'node_modules/bootstrap/dist/js/bootstrap.min.js',
'node_modules/@lmenezes/json-tree/jsontree.js',
'node_modules/angular-ui-bootstrap/dist/ui-bootstrap.js',
'node_modules/ace-builds/src/ace.js'
'src/assets/libs/jquery/*.js',
'src/assets/libs/angularjs/angular.min.js',
'src/assets/libs/angularjs/angular-animate.min.js',
'src/assets/libs/angularjs/angular-route.min.js',
'src/assets/libs/bootstrap/bootstrap.min.js',
'src/assets/libs/jsontree/jsontree.min.js',
'src/assets/libs/typeahead/typeahead.min.js',
'src/assets/libs/ace/ace.min.js'
],
dest: 'public/js/lib.js'
},
vendorcss: {
src: [
'src/assets/css/bootstrap.min.css',
'node_modules/font-awesome/css/font-awesome.css'
'src/assets/css/font-awesome.min.css'
],
dest: 'public/css/lib.css'
},
Expand Down Expand Up @@ -77,20 +69,24 @@ module.exports = function(grunt) {
]
}
},
qunit: {
all: ['./tests/all.html']
},
karma: {
unit: {configFile: 'tests/karma.config.js', singleRun: singleRunTests }
unit: {configFile: 'tests/karma.config.js', keepalive: true}
},
eslint: {
options: {
configFile: 'conf/eslint.json',
fix: true
},
target: [
jscs: {
src: [
'src/app/app.routes.js',
'src/app/components/*/*.js',
'src/app/shared/*.js',
'src/app/shared/*/*.js'
]
],
options: {
preset: 'google',
maximumLineLength: 120,
requireCamelCaseOrUpperCaseIdentifiers: "ignoreProperties"
}
}
});
grunt.loadNpmTasks('grunt-contrib-clean');
Expand All @@ -99,10 +95,11 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-eslint');
grunt.registerTask('dev', ['watch']);
grunt.loadNpmTasks("grunt-jscs");
grunt.registerTask('dev', ['watch'])
grunt.registerTask('build',
['clean', 'jshint', 'eslint', 'concat', 'copy', 'karma']);
['clean', 'jshint', 'jscs', 'concat', 'copy', 'qunit']);
grunt.registerTask('test', ['karma'])
};
15 changes: 2 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
Cerebro
------------
[![Docker Pulls](https://img.shields.io/docker/pulls/lmenezes/cerebro.svg)](https://hub.docker.com/r/lmenezes/cerebro)
![build](https://github.com/lmenezes/cerebro/workflows/build/badge.svg?branch=master)
[![Build Status](https://travis-ci.com/lmenezes/cerebro.svg?branch=master)](https://travis-ci.com/lmenezes/cerebro)

cerebro is an open source(MIT License) elasticsearch web admin tool built using Scala, Play Framework, AngularJS and Bootstrap.

### Requirements

cerebro needs Java 11 or newer to run.
cerebro needs Java 1.8 or newer to run.

### Installation
- Download from [https://github.com/lmenezes/cerebro/releases](https://github.com/lmenezes/cerebro/releases)
- Extract files
- Run bin/cerebro(or bin/cerebro.bat if on Windows)
- Access on http://localhost:9000

### Chocolatey (Windows)

You can install `cerebro` using [Chocolatey](https://chocolatey.org/):

```sh
choco install cerebro-es
```

Package creates windows service ```cerebro```.
Access on http://localhost:9000

### Docker

You can find the official docker images in the official [docker hub repo](https://hub.docker.com/r/lmenezes/cerebro/).
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/AliasesController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AliasesController @Inject()(val authentication: AuthenticationModule,
}

def updateAliases = process { request =>
val changes = request.getOptArray("changes").getOrElse(JsArray()).value.toSeq
val changes = request.getOptArray("changes").getOrElse(JsArray()).value
client.updateAliases(changes, request.target).map { aliases =>
CerebroResponse(aliases.status, aliases.body)
}
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/AuthController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class AuthController @Inject()(system: ActorSystem,
}

def login = Action { implicit request =>
LoginForm.form.bindFromRequest().fold(
LoginForm.form.bindFromRequest.fold(
formWithErrors => {
log.error(badFormMsg)
BadRequest(badFormMsg)
Expand All @@ -53,7 +53,7 @@ class AuthController @Inject()(system: ActorSystem,
}
resp.withSession(AuthAction.SESSION_USER -> username)
case None =>
Redirect(routes.AuthController.index()).flashing(LOGIN_MSG -> "Incorrect username or password")
Redirect(routes.AuthController.index).flashing(LOGIN_MSG -> "Incorrect username or password")
}
}
)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/auth/AuthAction.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class AuthAction(auth: AuthenticationModule, redirect: Boolean, override v
}.getOrElse {
if (redirect) {
Future.successful(
Results.Redirect(routes.AuthController.index()).
Results.Redirect(routes.AuthController.index).
withSession(AuthAction.REDIRECT_URL -> request.uri))
} else {
Future.successful(CerebroResponse(303, JsNull))
Expand Down
2 changes: 1 addition & 1 deletion app/elastic/HTTPElasticClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ class HTTPElasticClient @Inject()(client: WSClient) extends ElasticClient {
request.withAuth(auth.username, auth.password, WSAuthScheme.BASIC)
}

body.fold(request)(request.withBody((_))).execute().map { response =>
body.fold(request)(request.withBody((_))).execute.map { response =>
ElasticResponse(response)
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/models/Hosts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import javax.inject.Singleton
import com.google.inject.{ImplementedBy, Inject}
import play.api.Configuration

import scala.jdk.CollectionConverters._
import scala.collection.JavaConverters._
import scala.util.{Failure, Success, Try}


Expand Down
13 changes: 5 additions & 8 deletions app/models/commons/NodeRoles.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@ object NodeRoles {
}

def apply(nodeInfo: JsValue): NodeRoles = {
// >= 7.10
val dataRoles = Seq("data", "data_content", "data_hot", "data_warm", "data_cold").map(JsString)

(nodeInfo \ "roles").asOpt[JsArray] match {
case Some(JsArray(roles)) => // >= 5.X
case Some(JsArray(roles)) => // 5.X
NodeRoles(
roles.contains(JsString("master")),
roles.exists(role => dataRoles.contains(role)),
roles.contains(JsString("data")),
roles.contains(JsString("ingest"))
)

Expand All @@ -32,9 +29,9 @@ object NodeRoles {
val client = truthy((nodeInfo \ "attributes" \ "client").asOpt[String].getOrElse("false"))

NodeRoles(
master = master && !client,
data = data && !client,
ingest = false // 2.x doesnt support ingest
master && !client,
data && !client,
false // 2.x doesnt support ingest
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/models/overview/Index.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ object Index {
def createShardMap(routingTable: JsValue): Map[String, JsArray] = {
(routingTable \ "shards").as[JsObject].value.toSeq.flatMap { case (_, shards) =>
shards.as[JsArray].value.flatMap(parseShard(_))
}.groupBy(_._1).view.mapValues(v => JsArray(v.map(_._2))).toMap
}.groupBy(_._1).mapValues(v => JsArray(v.map(_._2)))
}

/**
Expand Down
4 changes: 2 additions & 2 deletions app/models/overview/Node.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ object Node extends NodeInfo {
}

def disk(stats: JsValue): JsObject = {
val totalInBytes = (stats \ "fs" \ "total" \ "total_in_bytes").asOpt[Long].getOrElse(0L)
val freeInBytes = (stats \ "fs" \ "total" \ "free_in_bytes").asOpt[Long].getOrElse(0L)
val totalInBytes = (stats \ "fs" \ "total" \ "total_in_bytes").asOpt[Long].getOrElse(0l)
val freeInBytes = (stats \ "fs" \ "total" \ "free_in_bytes").asOpt[Long].getOrElse(0l)
val usedPercent = 100 - (100 * (freeInBytes.toFloat / totalInBytes.toFloat)).toInt
Json.obj(
"total" -> JsNumber(totalInBytes),
Expand Down
4 changes: 2 additions & 2 deletions app/models/rest/AutocompletionIndices.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ object AutocompletionIndices {

def apply(aliases: JsValue): JsArray =
JsArray(
aliases.as[JsObject].value.flatMap {
case (idx, data) => (data \ "aliases").as[JsObject].keys ++ Set(idx)
aliases.as[JsObject].value.flatMap { case (idx, data) =>
(data \ "aliases").as[JsObject].keys + idx
}.toSeq.distinct.map(JsString)
)

Expand Down
16 changes: 8 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ packageSummary := "Elasticsearch web admin tool"
packageDescription := """cerebro is an open source(MIT License) elasticsearch web admin tool built
using Scala, Play Framework, AngularJS and Bootstrap."""

version := "0.9.4"
version := "0.9.2"

scalaVersion := "2.13.4"
scalaVersion := "2.12.11"

rpmVendor := "lmenezes"

Expand All @@ -18,14 +18,14 @@ rpmLicense := Some("MIT")
rpmUrl := Some("http://github.com/lmenezes/cerebro")

libraryDependencies ++= Seq(
"com.typesafe.play" %% "play" % "2.8.7",
"com.typesafe.play" %% "play-json" % "2.9.1",
"com.typesafe.play" %% "play" % "2.8.1",
"com.typesafe.play" %% "play-json" % "2.8.1",
"com.typesafe.play" %% "play-slick" % "5.0.0",
"com.typesafe.play" %% "play-slick-evolutions" % "5.0.0",
"org.xerial" % "sqlite-jdbc" % "3.34.0",
"org.specs2" %% "specs2-junit" % "4.10.0" % "test",
"org.specs2" %% "specs2-core" % "4.10.0" % "test",
"org.specs2" %% "specs2-mock" % "4.10.0" % "test"
"org.xerial" % "sqlite-jdbc" % "3.23.1",
"org.specs2" %% "specs2-junit" % "4.3.4" % "test",
"org.specs2" %% "specs2-core" % "4.3.4" % "test",
"org.specs2" %% "specs2-mock" % "4.3.4" % "test"
)

libraryDependencies += filters
Expand Down
17 changes: 0 additions & 17 deletions conf/eslint.json

This file was deleted.

Loading

0 comments on commit a9308db

Please sign in to comment.