added new blocklist page
This commit is contained in:
parent
f6d870bb5e
commit
c967df577e
@ -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('/', {
|
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: '/'
|
||||||
});
|
});
|
||||||
|
|||||||
@ -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;
|
||||||
}]);
|
}]);
|
||||||
|
|||||||
@ -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…
Reference in New Issue
Block a user