Hi,
I followed this example to create my Kibana application. My use case is to display list of indices, select one and modify a specific line. As you see, this is the list of indices
Ths is my source code:
routes.js:
export default function (server) {
let call = server.plugins.elasticsearch.callWithRequest;
server.route({
path: '/api/indices_view/_list',
method: 'GET',
handler(req, reply) {
call(req, 'cluster.state').then(function (response) {
// Return just the names of all indices to the client.
reply(Object.keys(response.data.indices));
});
}
});
server.route({
path: '/api/indices_view/index/{name}',
method: 'GET',
handler(req, reply) {
call(req, 'cluster.state', {
metric: 'metadata',
index: req.params.name
}).then(function (response) {
//console.log("Route RES ======>", response);
reply(response.metadata.indices[req.params.name]);
});
}
});
}
app.js:
import { uiModules } from 'ui/modules';
import uiRoutes from 'ui/routes';
import 'angular-ui-bootstrap';
import 'ui/autoload/styles';
import './less/style.less';
import index from './templates/index.html';
import list from './templates/list.html';
uiRoutes.enable();
uiRoutes
.when('/', {
template: index,
controller: 'indicesView',
controllerAs: 'ctrl'
})
.when('/index/:name', {
template: list,
controller: 'getIndiceByName',
controllerAs: 'ctrl'
});
uiModules
.get('app/indices_view')
.controller('indicesView', function ($http) {
$http.get('../api/indices_view/_list').then((response) => {
this.indices = Object.keys(response.data.indices);
});
})
.controller('getIndiceByName', function($routeParams, $http) {
this.index = $routeParams.name;
$http.get(`../api/indices_view/index/${this.index}`).then((response) => {
this.status = response.data;
console.log("App RES ======>", response);
});
});
index.html:
<div class="container-fluid">
<div class="row col-md-12 panel panel-default">
<div class="panel-body">
<div class="container">
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
<div id="imaginary_container">
<div class="input-group stylish-input-group">
<input type="text" class="form-control" placeholder="Search" ng-model="indice">
<span class="input-group-addon">
<button type="submit">
<span class="glyphicon glyphicon-search"></span>
</button>
</span>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-8 col-sm-offset-2">
<ul class="list-group">
<li class="list-group-item" ng-repeat="index in ctrl.indices | filter : indice"">
<a href="#/index/{{index}}">{{ index }}</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
I got this in my log: GET http://localhost:5601/api/indices_view/index/logstash-2015.05.20 404 (Not Found)
Did I miss something ? (This is the first time I use AngularJS)
I'll appreciate any help and thanks for advance
Best regards !