Sha256: 250d3954d35b60a2e4c6b769837ca5e72eed5281fc496703bfec8679aba55ac2

Contents?: true

Size: 1.39 KB

Versions: 2

Compression:

Stored size: 1.39 KB

Contents

(function() {

'use strict';

angular.module('herald.node', [
  'ui.router',
  'herald.page',
  'herald.directives',
  'herald.pagination',
  'angularMoment'
])

.controller('NodeController', 
    ['$http', '$stateParams', 'Page', 'PaginationFactory', 
        function($http, $stateParams, Page, PaginationFactory) {

  var ctrl = this;
  Page.title('Reports');
  ctrl.pagination = PaginationFactory.DEFAULT;
  ctrl.cache = PaginationFactory.createPageCache(60); // 60 seconds cache
  ctrl.node = null;
  ctrl.nav = {
    node: null,
    report: null
  };
  this.nodeId = $stateParams.nodeId;
  var gateway = '/api/v1/nodes/' + this.nodeId;

  function setNode(nodeData) {
    ctrl.node = nodeData;
    ctrl.nav.node = ctrl.node.name;
  }

  function getResultsPage(pageNumber) {
    ctrl.pagination.page(pageNumber);
    if (ctrl.cache.isLoaded(pageNumber)) {
      setNode(ctrl.cache.get(pageNumber));
      return;
    }
    var config = { headers: ctrl.pagination.toHeaders() };
    $http.get(gateway, config).success(function(data, status, headers, config) {
      setNode(data);
      ctrl.pagination = PaginationFactory.fromHeaders(headers);
      var loadedPage = ctrl.pagination.page();
      Page.title('Reports for', data.name);
      ctrl.cache.set(loadedPage, data);
    });
  }
  getResultsPage(ctrl.pagination.page());
  ctrl.onPageChange = function(newPage) {
    getResultsPage(newPage);
  };
}]);
  
})();

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
puppet-herald-0.8.1 lib/puppet-herald/public/node/node.js
puppet-herald-0.8.0 lib/puppet-herald/public/node/node.js