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

Add api route to fetch topics #155

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions app/controllers/api/Topic.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Copyright 2015 Yahoo Inc. Licensed under the Apache License, Version 2.0
* See accompanying LICENSE file.
*/

package controllers.api

import controllers.KafkaManagerContext
import controllers.Topic._
import play.api.libs.json._
import play.api.mvc._

object Topic extends Controller {

import play.api.libs.concurrent.Execution.Implicits.defaultContext

private[this] val kafkaManager = KafkaManagerContext.getKafkaManager

def index(c: String) = Action.async { implicit request =>
kafkaManager.getTopicListExtended(c).map { errorOrTopicList =>
errorOrTopicList.fold(
error => BadRequest(Json.obj("msg" -> error.msg)),
topicList => Ok(Json.obj("topicList" -> topicList.list.map(bi => bi._1)))
)
}
}
}

4 changes: 3 additions & 1 deletion app/views/logkafka/logkafkaList.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
@logkafkaScripts = {
<script ype="text/javascript">
$(document).ready(function() {
$('#logkafkas-table').DataTable();
$('#logkafkas-table').DataTable({
"iDisplayLength": 100
});
} );
</script>
}
Expand Down
1 change: 1 addition & 0 deletions conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ POST /clusters/:c/logkafkas/:h/:l/enableConfig controllers.Logkafka.h
GET /api/status/:c/availableBrokers controllers.api.KafkaHealthCheck.availableBrokers(c:String)
GET /api/status/:c/:t/underReplicatedPartitions controllers.api.KafkaHealthCheck.underReplicatedPartitions(c:String,t:String)
GET /api/status/:c/:t/unavailablePartitions controllers.api.KafkaHealthCheck.unavailablePartitions(c:String,t:String)
GET /api/:c/topics controllers.api.Topic.index(c:String)

# Versioned Assets
GET /vassets/*file controllers.Assets.versioned(path="/public", file: Asset)
Expand Down