diff --git a/app/controllers/blocks.js b/app/controllers/blocks.js index f08016a..0407c75 100644 --- a/app/controllers/blocks.js +++ b/app/controllers/blocks.js @@ -33,7 +33,7 @@ exports.show = function(req, res) { * List of blocks at HomePage */ exports.last_blocks = function(req, res) { - Block.find().limit(7).exec(function(err, blocks) { + Block.find().sort({time:-1}).limit(7).exec(function(err, blocks) { if (err) { res.render('error', { status: 500 diff --git a/app/models/Block.js b/app/models/Block.js index af173dc..ee68b94 100644 --- a/app/models/Block.js +++ b/app/models/Block.js @@ -94,4 +94,4 @@ BlockSchema.statics.fromHash = function(hash, cb) { }).exec(cb); }; -mongoose.model('Block', BlockSchema); +module.exports = mongoose.model('Block', BlockSchema); diff --git a/public/js/config.js b/public/js/config.js index fe68006..1e36afd 100755 --- a/public/js/config.js +++ b/public/js/config.js @@ -4,6 +4,9 @@ angular.module('mystery').config(['$routeProvider', function($routeProvider) { $routeProvider. + when('/block/:blockHash', { + templateUrl: 'views/block.html' + }). when('/', { templateUrl: 'views/index.html' }). diff --git a/public/js/controllers/blocks.js b/public/js/controllers/blocks.js index 032b593..13b6bfd 100644 --- a/public/js/controllers/blocks.js +++ b/public/js/controllers/blocks.js @@ -3,6 +3,14 @@ angular.module('mystery.blocks').controller('BlocksController', ['$scope', '$routeParams', '$location', 'Global', 'Blocks', function ($scope, $routeParams, $location, Global, Blocks) { $scope.global = Global; + $scope.findOne = function() { + Blocks.get({ + blockHash: $routeParams.blockHash + }, function(block) { + $scope.block = block; + }); + }; + // for avoid warning. please remove when you use Blocks $scope.blocks = Blocks; }]); diff --git a/public/js/controllers/header.js b/public/js/controllers/header.js index 039a5ac..8dddc14 100755 --- a/public/js/controllers/header.js +++ b/public/js/controllers/header.js @@ -4,11 +4,8 @@ angular.module('mystery.system').controller('HeaderController', ['$scope', 'Glob $scope.global = Global; $scope.menu = [{ - 'title': 'Articles', - 'link': 'articles' - }, { - 'title': 'Create New Article', - 'link': 'articles/create' + 'title': 'Blocks', + 'link': 'blocks' }]; $scope.isCollapsed = false; diff --git a/public/js/services/blocks.js b/public/js/services/blocks.js index e60ded2..fe5cf40 100644 --- a/public/js/services/blocks.js +++ b/public/js/services/blocks.js @@ -1,5 +1,7 @@ 'use strict'; angular.module('mystery.blocks').factory('Blocks', ['$resource', function($resource) { - return $resource; + return $resource('block/:blockHash', { + blockHash: '@blockHash' + }); }]); diff --git a/public/views/block.html b/public/views/block.html new file mode 100644 index 0000000..686a6ad --- /dev/null +++ b/public/views/block.html @@ -0,0 +1,23 @@ +
+ + + + + + + + + + + + + + + + + + +
HeightAgeTransactionsConfirmationsSize (kB)
{{block.height}}{{block.time | date:'short'}}{{block.tx.length }}{{block.confirmations}}{{block.size / 1024}}
+
\ No newline at end of file diff --git a/public/views/header.html b/public/views/header.html index 70189e7..fb034ed 100755 --- a/public/views/header.html +++ b/public/views/header.html @@ -6,13 +6,13 @@ - Mystery + Mystery diff --git a/public/views/index.html b/public/views/index.html index d84010f..953dc31 100644 --- a/public/views/index.html +++ b/public/views/index.html @@ -2,9 +2,22 @@ - + + + + + + + + + + + + + + + + + +
HeightAgeTransactionsConfirmationsSize (kB)
{{block.height}}{{block.time | date:'short'}}{{block.tx.length }}{{block.confirmations}}{{block.size / 1024}}