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

Some more styling improvements to the admin screen #150

Merged
merged 1 commit into from
Sep 29, 2013
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

Expand All @@ -11,7 +12,6 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.index.query.FieldQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestChannel;
import org.elasticsearch.rest.RestController;
Expand All @@ -33,7 +33,6 @@ public RestMongoDBRiverAction(Settings settings, Client client, RestController c
super(settings, client);
controller.registerHandler(RestRequest.Method.GET, BASE_URL + "/{action}", this);
controller.registerHandler(RestRequest.Method.POST, BASE_URL + "/{river}/{action}", this);
controller.registerHandler(RestRequest.Method.POST, BASE_URL + "/{river}/{action}", this);
}

@Override
Expand Down Expand Up @@ -124,16 +123,18 @@ private void errorResponse(RestRequest request, RestChannel channel, Throwable e
}

private List<Map<String, Object>> getRivers() {
QueryBuilder query = new FieldQueryBuilder("type", "mongodb");
SearchResponse searchResponse = client.prepareSearch("_river")
.setQuery(query).execute().actionGet();
SearchResponse searchResponse = client
.prepareSearch("_river")
.setQuery(new FieldQueryBuilder("type", "mongodb"))
.execute().actionGet();
long totalHits = searchResponse.getHits().totalHits();
logger.trace("totalHits: {}", totalHits);
List<Map<String, Object>> rivers = new ArrayList<Map<String, Object>>();
for (SearchHit hit : searchResponse.getHits().hits()) {
Map<String, Object> source = hit.getSource();
source.put("_name", hit.getType());
source.put("_enabled", MongoDBRiverHelper.isRiverEnabled(client, hit.getType()));
Map<String, Object> source = new HashMap<String,Object>();
source.put("name", hit.getType());
source.put("enabled", MongoDBRiverHelper.isRiverEnabled(client, hit.getType()));
source.put("settings", hit.getSource());
logger.trace("source: {}", hit.getSourceAsString());
rivers.add(source);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ protected MongoDBRiverDefinition provideDefinition(
ScriptService scriptService) {
return MongoDBRiverDefinition.parseSettings(
riverName, riverIndexName, settings, scriptService);

}

}
26 changes: 14 additions & 12 deletions src/site/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<html lang="en" data-ng-app="mongoDBRiverApp">
<html lang="en" x-ng-app="mongoDBRiverApp">
<head>
<meta charset="utf-8">
<title>MongoDB River Plugin for ElasticSearch</title>
Expand All @@ -11,25 +11,27 @@
<link rel="icon" href="images/favicon.ico" type="image/x-icon">
</head>
<body>
<div data-ng-controller="MainCtrl" class="container">
<div x-ng-controller="MainCtrl" class="container">
<div class="row">
<div class="col-md-12">
<h3>MongoDB River Administration</h3>
<tabset>
<tab heading="Home">
<div class="content">
<div data-ng-repeat="river in rivers">
<div x-ng-repeat="river in rivers">
<div class="panel panel-info">
<div class="panel-heading">River: {{ river._name }} - Status:
<span data-ng-show="!river._enabled" class="label label-warning">Disabled</span>
<span data-ng-show="river._enabled" class="label label-success">Enabled</span>
<div class="panel-heading">
<h2 class="panel-title">
{{ river.name }}
<span x-ng-if="river.enabled" class="label label-success">Enabled</span>
<span x-ng-if="!river.enabled" class="label label-warning">Disabled</span>
</h2>
</div>
<div class="panel-body">
<pre>Settings:<br/><br/>{{ toString(river.settings) }}</pre>
<span x-ng-if="river.enabled" class="btn btn-small btn-danger" x-ng-click="stop(river.name)">Stop</span>
<span x-ng-if="!river.enabled" class="btn btn-small btn-success" x-ng-click="start(river.name)">Start</span>
</div>
Settings:
<pre>{{ toString(river) }}</pre>
<br/>
Actions:
<span class="btn btn-small btn-success" data-ng-disabled="river._enabled" data-ng-click="start(river._name)">Start</span>
<span class="btn btn-small btn-danger" data-ng-disabled="!river._enabled" data-ng-click="stop(river._name)">Stop</span>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/site/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ mongoDBRiverApp.controller('MainCtrl', function ($log, $scope, $resource) {
return value;
};
function setRiverEnabled(name, enabled) {
var river = _.find($scope.rivers, {'_name': name});
var river = _.find($scope.rivers, {'name': name});
if (river !== undefined) {
river._enabled = enabled;
river.enabled = enabled;
}
}
$scope.list('mongodb');
Expand Down