Skip to content

Commit

Permalink
Merge pull request #8 from dalen/puppetdb21
Browse files Browse the repository at this point in the history
Fix compatibility with PuppetDB 2.1
  • Loading branch information
dalen committed Jul 16, 2014
2 parents f1fd6cf + cab393f commit c3375c6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ It has support for multiple PuppetDB servers.

### Dependencies

It is using the V4 PuppetDB API, so therefore it needs PuppetDB 2.0. This is
currently marked as experimental, so PuppetDB 2.1 will likely break
compatibility but we should be able to create a fix for that quickly.
It is using the V4 PuppetDB API from PuppetDB 2.1. Version 1.0.0 works with
PuppetDB 2.0, but the current version only works with PuppetDB 2.1.

### Screenshots

Expand Down
10 changes: 5 additions & 5 deletions app/controllers/nodelist/nodelist.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ angular.module("app").controller "NodeListCtrl", class
{
offset: @Pagination.offset()
limit: @Pagination.perPage
"order-by": angular.toJson([field: "name", order: "asc"])
"order-by": angular.toJson([field: "certname", order: "asc"])
},
(data, total) =>
@Pagination.numItems(total)
Expand All @@ -42,7 +42,7 @@ angular.module("app").controller "NodeListCtrl", class
@PuppetDB.parseAndQuery(
"event-counts"
null
["and", ["=", "certname", node.name], ["=", "latest-report?", true]],
["and", ["=", "certname", node.certname], ["=", "latest-report?", true]],
'summarize-by': 'certname'
'order-by': angular.toJson([field: "certname", order: "asc"])
do (node) ->
Expand All @@ -67,7 +67,7 @@ angular.module("app").controller "NodeListCtrl", class
@PuppetDB.parseAndQuery(
"facts"
null
["=", "certname", node.name],
["=", "certname", node.certname],
'order-by': angular.toJson([field: "name", order: "asc"])
do (node) ->
(data, total) ->
Expand All @@ -85,7 +85,7 @@ angular.module("app").controller "NodeListCtrl", class
# Returns: `undefined`
fetchSelectedNode: () =>
for node in @nodes
if node.name == @$location.search().node
if node.certname == @$location.search().node
@selectNode(node)


Expand All @@ -109,7 +109,7 @@ angular.module("app").controller "NodeListCtrl", class
@$location.search('node', null)
@selectedNode = null
else
@$location.search('node', node.name)
@$location.search('node', node.certname)
@selectedNode = node
unless node.facts?
@fetchNodeFacts(node)
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/nodelist/nodelist.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@
</tr></thead>
<tbody>
<tr ng-repeat="node in nodeList.nodes">
<td ng-click="nodeList.selectNode(node)">{{node.name}}</td>
<td ng-click="nodeList.selectNode(node)">{{node.certname}}</td>
<td title="{{node['catalog-timestamp']}}" am-time-ago="node['catalog-timestamp']"></td>
<td style="text-align:center">{{node.status.successes || ""}}</td>
<td style="text-align:center">{{node.status.noops || ""}}</td>
<td style="text-align:center">{{node.status.skips || ""}}</td>
<td style="text-align:center">{{node.status.failures || ""}}</td>
<td style="text-align:right" ng-click="nodeList.showEvents(node.name)">
<td style="text-align:right" ng-click="nodeList.showEvents(node.certname)">
<i ng-class="nodeList.nodeStatus(node)"></i>
</td>
</tr>
</tbody>
</table>
</div>
<div class="six wide column" ng-if="nodeList.selectedNode">
<h2>{{nodeList.selectedNode.name}}</h2>
<h2>{{nodeList.selectedNode.certname}}</h2>
<table class="ui table segment" ng-if="nodeList.selectedNode.facts">
<thead><tr>
<th>Fact</th>
Expand Down
7 changes: 2 additions & 5 deletions app/services/puppetdb/puppetdb.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,10 @@ angular.module('app').factory "PuppetDB", ($http,
# Public: Parse a query
#
# query - The {String} query to parse
# nodeQuery - A {Boolean} specifying if it should be
# parsed for the nodes endpoint or other endpoints.
#
# Returns: The resulting query
parse: (query, nodeQuery) ->
parse: (query) ->
if query
@puppetdbquery.yy.nodeQuery = nodeQuery
@puppetdbquery.parse query
else
null
Expand All @@ -62,7 +59,7 @@ angular.module('app').factory "PuppetDB", ($http,
parseAndQuery: (endpoint, nodeQuery, additionalQuery, params = {}, success) ->
# Handle all the parsing of the query and putting them together
if nodeQuery
query = @parse(nodeQuery, endpoint is "nodes")
query = @parse(nodeQuery)
else
query = null
if additionalQuery
Expand Down

0 comments on commit c3375c6

Please sign in to comment.