added new blocklist page
This commit is contained in:
parent
f6d870bb5e
commit
c967df577e
@ -23,7 +23,7 @@ exports.block = function(req, res, next, hash) {
|
||||
|
||||
|
||||
/**
|
||||
* Show block
|
||||
* Show block
|
||||
*/
|
||||
exports.show = function(req, res) {
|
||||
res.jsonp(req.block);
|
||||
@ -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);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@ -7,6 +7,12 @@ angular.module('mystery').config(['$routeProvider',
|
||||
when('/', {
|
||||
templateUrl: 'views/index.html'
|
||||
}).
|
||||
when('/blocks', {
|
||||
templateUrl: 'views/blocks/list.html'
|
||||
}).
|
||||
when('/blocks-date/:blockDate', {
|
||||
templateUrl: 'views/blocks/list_date.html'
|
||||
}).
|
||||
otherwise({
|
||||
redirectTo: '/'
|
||||
});
|
||||
|
||||
@ -2,7 +2,21 @@
|
||||
|
||||
angular.module('mystery.blocks').controller('BlocksController', ['$scope', '$routeParams', '$location', 'Global', 'Blocks', function ($scope, $routeParams, $location, Global, Blocks) {
|
||||
$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
|
||||
$scope.blocks = Blocks;
|
||||
}]);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('mystery.blocks').factory('Blocks', ['$resource', function($resource) {
|
||||
return $resource;
|
||||
return $resource('/api/blocks');
|
||||
}]);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user