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
*/
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

View File

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

View File

@ -4,6 +4,9 @@
angular.module('mystery').config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/block/:blockHash', {
templateUrl: 'views/block.html'
}).
when('/', {
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) {
$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;
}]);

View File

@ -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;

View File

@ -1,5 +1,7 @@
'use strict';
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>
</button>
<a class="navbar-brand" href="#">Mystery</a>
<a class="navbar-brand" href="#!">Mystery</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
<li data-ng-repeat="item in menu" ui-route="/{{item.link}}" ng-class="{active: $uiRoute}">
<a href="#!/{{item.link}}">{{item.title}}</a>
</li>
</ul>
</div>
</div>

View File

@ -2,9 +2,22 @@
<div class="page-header">
<h1>Hello BitPay!</h1>
</div>
<ul>
<li data-ng-repeat="block in blocks">
<span>{{block.hash}}</span>
</li>
</ul>
<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 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>