block page draft

This commit is contained in:
Gustavo Cortez 2014-01-08 11:05:19 -03:00
parent aabc1af9a8
commit 92054210a8
9 changed files with 63 additions and 17 deletions

View File

@ -33,7 +33,7 @@ exports.show = function(req, res) {
* List of blocks at HomePage * List of blocks at HomePage
*/ */
exports.last_blocks = function(req, res) { 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) { if (err) {
res.render('error', { res.render('error', {
status: 500 status: 500

View File

@ -94,4 +94,4 @@ BlockSchema.statics.fromHash = function(hash, cb) {
}).exec(cb); }).exec(cb);
}; };
mongoose.model('Block', BlockSchema); module.exports = mongoose.model('Block', BlockSchema);

View File

@ -4,6 +4,9 @@
angular.module('mystery').config(['$routeProvider', angular.module('mystery').config(['$routeProvider',
function($routeProvider) { function($routeProvider) {
$routeProvider. $routeProvider.
when('/block/:blockHash', {
templateUrl: 'views/block.html'
}).
when('/', { when('/', {
templateUrl: 'views/index.html' templateUrl: 'views/index.html'
}). }).

View File

@ -3,6 +3,14 @@
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.findOne = function() {
Blocks.get({
blockHash: $routeParams.blockHash
}, function(block) {
$scope.block = block;
});
};
// for avoid warning. please remove when you use Blocks // for avoid warning. please remove when you use Blocks
$scope.blocks = Blocks; $scope.blocks = Blocks;
}]); }]);

View File

@ -4,11 +4,8 @@ angular.module('mystery.system').controller('HeaderController', ['$scope', 'Glob
$scope.global = Global; $scope.global = Global;
$scope.menu = [{ $scope.menu = [{
'title': 'Articles', 'title': 'Blocks',
'link': 'articles' 'link': 'blocks'
}, {
'title': 'Create New Article',
'link': 'articles/create'
}]; }];
$scope.isCollapsed = false; $scope.isCollapsed = false;

View File

@ -1,5 +1,7 @@
'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('block/:blockHash', {
blockHash: '@blockHash'
});
}]); }]);

23
public/views/block.html Normal file
View File

@ -0,0 +1,23 @@
<section data-ng-controller="BlocksController" data-ng-init="findOne()">
<div class="page-header">
<h1>Block Page</h1>
</div>
<table class="table table-striped">
<thead>
<th>Height</th>
<th>Age</th>
<th>Transactions</th>
<th>Confirmations</th>
<th>Size (kB)</th>
</thead>
<tbody>
<tr>
<td>{{block.height}}</td>
<td>{{block.time | date:'short'}}</td>
<td>{{block.tx.length }}</td>
<td>{{block.confirmations}}</td>
<td>{{block.size / 1024}}</td>
</tr>
</tbody>
</table>
</section>

View File

@ -6,13 +6,13 @@
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
</button> </button>
<a class="navbar-brand" href="#">Mystery</a> <a class="navbar-brand" href="#!">Mystery</a>
</div> </div>
<div class="collapse navbar-collapse"> <div class="collapse navbar-collapse">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li> <li data-ng-repeat="item in menu" ui-route="/{{item.link}}" ng-class="{active: $uiRoute}">
<li><a href="#about">About</a></li> <a href="#!/{{item.link}}">{{item.title}}</a>
<li><a href="#contact">Contact</a></li> </li>
</ul> </ul>
</div> </div>
</div> </div>

View File

@ -2,9 +2,22 @@
<div class="page-header"> <div class="page-header">
<h1>Hello BitPay!</h1> <h1>Hello BitPay!</h1>
</div> </div>
<ul> <table class="table table-striped">
<li data-ng-repeat="block in blocks"> <thead>
<span>{{block.hash}}</span> <th>Height</th>
</li> <th>Age</th>
</ul> <th>Transactions</th>
<th>Confirmations</th>
<th>Size (kB)</th>
</thead>
<tbody>
<tr data-ng-repeat="block in blocks">
<td><a href="#!/block/{{block.hash}}">{{block.height}}</a></td>
<td>{{block.time | date:'short'}}</td>
<td>{{block.tx.length }}</td>
<td>{{block.confirmations}}</td>
<td>{{block.size / 1024}}</td>
</tr>
</tbody>
</table>
</section> </section>