Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
218 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package controllers.api; | ||
|
||
import controllers.AuthenticatedController; | ||
import org.graylog2.rest.models.collector.responses.CollectorSummary; | ||
import org.graylog2.restclient.lib.APIException; | ||
import org.graylog2.restclient.models.CollectorService; | ||
import play.libs.Json; | ||
import play.mvc.Result; | ||
|
||
import javax.inject.Inject; | ||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
public class CollectorsApiController extends AuthenticatedController { | ||
private final CollectorService collectorService; | ||
|
||
@Inject | ||
public CollectorsApiController(CollectorService collectorService) { | ||
this.collectorService = collectorService; | ||
} | ||
|
||
public Result index() throws APIException, IOException { | ||
final List<CollectorSummary> collectors = collectorService.all(); | ||
|
||
return ok(Json.toJson(collectors)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
app/views/system/agents/index.scala.html → app/views/system/collectors/index.scala.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
@(currentUser: org.graylog2.restclient.models.User, | ||
breadcrumbs: lib.BreadcrumbList) | ||
|
||
@main("Agents in Cluster", null, "", currentUser, false) { | ||
@main("Collectors in Cluster", null, "", currentUser, false) { | ||
@views.html.partials.breadcrumbs(breadcrumbs) | ||
|
||
<div class="row content content-head"> | ||
<div class="col-md-12"> | ||
<h1><i class="fa fa-cloud"></i> Agents in Cluster</h1> | ||
<h1><i class="fa fa-cloud"></i> Collectors in Cluster</h1> | ||
<p class="description"> | ||
Agents deliver local resources to a remote Graylog cluster. | ||
Collectors deliver local resources to a remote Graylog cluster. | ||
</p> | ||
</div> | ||
</div> | ||
<div class="row content"> | ||
<div class="col-md-12" id="react-agent-list"> | ||
<div class="col-md-12" id="react-collector-list"> | ||
</div> | ||
</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
'use strict'; | ||
|
||
var React = require('react/addons'); | ||
var CollectorsStore = require('../../stores/collectors/CollectorsStore'); | ||
var CollectorRow = require('./CollectorRow'); | ||
|
||
var CollectorList = React.createClass({ | ||
COLLECTOR_DATA_REFRESH: 5*1000, | ||
|
||
getInitialState() { | ||
return { | ||
collectors: [], | ||
filter: "", | ||
sort: undefined, | ||
showInactive: false | ||
}; | ||
}, | ||
componentDidMount() { | ||
this.loadData(); | ||
}, | ||
loadData() { | ||
CollectorsStore.load((collectors) => { | ||
if (this.isMounted()) { | ||
this.setState({ | ||
collectors: collectors | ||
}); | ||
} | ||
}); | ||
|
||
setTimeout(this.loadData, this.COLLECTOR_DATA_REFRESH); | ||
}, | ||
_getFilteredCollectors() { | ||
var filter = this.state.filter.toLowerCase().trim(); | ||
return this.state.collectors.filter((collector) => { return !filter || collector.id.toLowerCase().indexOf(filter) !== -1 || collector.node_id.toLowerCase().indexOf(filter) !== -1 || collector.node_details.operating_system.toLowerCase().indexOf(filter) !== -1; }); | ||
}, | ||
_bySortField(collector1, collector2) { | ||
var sort = this.state.sort || ((collector) => {return collector.id;}); | ||
var field1 = sort(collector1); | ||
var field2 = sort(collector2); | ||
if (typeof(field1) === "number") { | ||
return field2 - field1; | ||
} else { | ||
return field1.localeCompare(field2); | ||
} | ||
}, | ||
render() { | ||
var collectorList; | ||
|
||
if (this.state.collectors.length === 0) { | ||
collectorList = <div><div className="alert alert-info">There are no collectors.</div></div>; | ||
} else { | ||
var collectors = this._getFilteredCollectors() | ||
.filter((collector) => {return (this.state.showInactive || collector.active);}) | ||
.sort(this._bySortField) | ||
.map((collector) => { | ||
return <CollectorRow key={collector.id} collector={collector}/>; | ||
} | ||
); | ||
|
||
var showOrHideInactive = (this.state.showInactive ? "Hide" : "Show"); | ||
|
||
collectorList = ( | ||
<div> | ||
<div className="row"> | ||
<div className="col-md-12"> | ||
<form className="form-inline collectors-filter-form"> | ||
<label htmlFor="collectorsfilter">Filter collectors:</label> | ||
<input type="text" name="filter" id="collectorsfilter" value={this.state.filter} onChange={(event) => {this.setState({filter: event.target.value});}} /> | ||
</form> | ||
|
||
<a onClick={this.toggleShowInactive}>{showOrHideInactive}</a> inactive collectors | ||
|
||
<table className="table table-striped users-list"> | ||
<thead> | ||
<tr> | ||
<th className="name" onClick={this.sortById}> | ||
Collector Id | ||
</th> | ||
<th onClick={this.sortByNodeId}>Host Name</th> | ||
<th onClick={this.sortByCollectorVersion}>Collector Version</th> | ||
<th onClick={this.sortByOperatingSystem}>Operating System</th> | ||
<th onClick={this.sortByLastSeen}>Last Seen</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{collectors} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
return collectorList; | ||
}, | ||
toggleShowInactive() { | ||
this.setState({showInactive: !this.state.showInactive}); | ||
}, | ||
sortById() { | ||
this.setState({sort: (collector) => {return collector.id;}}); | ||
}, | ||
sortByNodeId() { | ||
this.setState({sort: (collector) => {return collector.node_id;}}); | ||
}, | ||
sortByOperatingSystem() { | ||
this.setState({sort: (collector) => {return collector.node_details.operating_system;}}); | ||
}, | ||
sortByLastSeen() { | ||
this.setState({sort: (collector) => {return collector.last_seen;}}); | ||
}, | ||
sortByCollectorVersion() { | ||
this.setState({sort: (collector) => {return collector.collector_version;}}); | ||
} | ||
}); | ||
|
||
module.exports = CollectorList; |
Oops, something went wrong.