Browse Source

added new blocklist page

generic-ui
Mario Colque 11 years ago
parent
commit
c967df577e
  1. 23
      app/controllers/blocks.js
  2. 6
      public/js/config.js
  3. 14
      public/js/controllers/blocks.js
  4. 2
      public/js/services/blocks.js

23
app/controllers/blocks.js

@ -44,3 +44,26 @@ exports.last_blocks = function(req, res) {
}); });
}; };
/**
* List of blocks by date
*/
exports.list = function(req, res) {
var findParam = {};
if (req.query.blockDate) {
findParam = {};
}
Block
.find(findParam)
.limit(5)
.exec(function(err, blocks) {
if (err) {
res.render('error', {
status: 500
});
} else {
res.jsonp(blocks);
}
});
};

6
public/js/config.js

@ -7,6 +7,12 @@ angular.module('mystery').config(['$routeProvider',
when('/', { when('/', {
templateUrl: 'views/index.html' templateUrl: 'views/index.html'
}). }).
when('/blocks', {
templateUrl: 'views/blocks/list.html'
}).
when('/blocks-date/:blockDate', {
templateUrl: 'views/blocks/list_date.html'
}).
otherwise({ otherwise({
redirectTo: '/' redirectTo: '/'
}); });

14
public/js/controllers/blocks.js

@ -3,6 +3,20 @@
angular.module('mystery.blocks').controller('BlocksController', ['$scope', '$routeParams', '$location', 'Global', 'Blocks', function ($scope, $routeParams, $location, Global, Blocks) { angular.module('mystery.blocks').controller('BlocksController', ['$scope', '$routeParams', '$location', 'Global', 'Blocks', function ($scope, $routeParams, $location, Global, Blocks) {
$scope.global = Global; $scope.global = Global;
$scope.list_blocks = function() {
Blocks.query(function(blocks) {
$scope.blocks = blocks;
});
};
$scope.list_blocks_date = function() {
Blocks.query({
blockDate: $routeParams.blockDate
}, function(blocks) {
$scope.blocks = blocks;
});
};
// for avoid warning. please remove when you use Blocks // for avoid warning. please remove when you use Blocks
$scope.blocks = Blocks; $scope.blocks = Blocks;
}]); }]);

2
public/js/services/blocks.js

@ -1,5 +1,5 @@
'use strict'; 'use strict';
angular.module('mystery.blocks').factory('Blocks', ['$resource', function($resource) { angular.module('mystery.blocks').factory('Blocks', ['$resource', function($resource) {
return $resource; return $resource('/api/blocks');
}]); }]);

Loading…
Cancel
Save