From d0874c48cf975e727cf667de8d4817c3a2a22013 Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Thu, 9 Jan 2014 15:13:26 -0300 Subject: [PATCH] front-end with angularjs: blockpage and transaction page. Basic information. --- app/views/includes/foot.jade | 4 +- config/routes.js | 2 +- public/js/app.js | 3 +- public/js/config.js | 3 ++ public/js/controllers/transactions.js | 14 +++++ public/js/services/transactions.js | 8 +++ public/views/block.html | 74 ++++++++++++++++++++++----- public/views/index.html | 12 ++--- public/views/transaction.html | 32 ++++++++++++ 9 files changed, 128 insertions(+), 24 deletions(-) create mode 100644 public/js/controllers/transactions.js create mode 100644 public/js/services/transactions.js create mode 100644 public/views/transaction.html diff --git a/app/views/includes/foot.jade b/app/views/includes/foot.jade index edca962..ad48757 100755 --- a/app/views/includes/foot.jade +++ b/app/views/includes/foot.jade @@ -1,7 +1,7 @@ #footer .container p.text-muted Place sticky footer content here. - + //script(type='text/javascript', src='/lib/jquery/jquery.min.js') //script(type='text/javascript', src='/lib/bootstrap/dist/js/bootstrap.min.js') @@ -23,6 +23,7 @@ script(type='text/javascript', src='/js/directives.js') script(type='text/javascript', src='/js/filters.js') //Application Services +script(type='text/javascript', src='/js/services/transactions.js') script(type='text/javascript', src='/js/services/blocks.js') script(type='text/javascript', src='/js/services/global.js') script(type='text/javascript', src='/js/services/index.js') @@ -31,4 +32,5 @@ script(type='text/javascript', src='/js/services/index.js') script(type='text/javascript', src='/js/controllers/index.js') script(type='text/javascript', src='/js/controllers/header.js') script(type='text/javascript', src='/js/controllers/blocks.js') +script(type='text/javascript', src='/js/controllers/transactions.js') script(type='text/javascript', src='/js/init.js') diff --git a/config/routes.js b/config/routes.js index ab4c9b1..fd522bd 100644 --- a/config/routes.js +++ b/config/routes.js @@ -14,7 +14,7 @@ module.exports = function(app) { app.get('/last_blocks', blocks.last_blocks); var transactions = require('../app/controllers/transactions'); - app.get('/tx/:txid', transactions.show); + app.get('/api/tx/:txid', transactions.show); app.param('txid', transactions.transaction); diff --git a/public/js/app.js b/public/js/app.js index 2b6bc68..ca50d77 100755 --- a/public/js/app.js +++ b/public/js/app.js @@ -1,7 +1,8 @@ 'use strict'; -angular.module('mystery', ['ngCookies', 'ngResource', 'ngRoute', 'ui.bootstrap', 'ui.route', 'mystery.system', 'mystery.index', 'mystery.blocks']); +angular.module('mystery', ['ngCookies', 'ngResource', 'ngRoute', 'ui.bootstrap', 'ui.route', 'mystery.system', 'mystery.index', 'mystery.blocks', 'mystery.transactions']); angular.module('mystery.system', []); angular.module('mystery.index', []); angular.module('mystery.blocks', []); +angular.module('mystery.transactions', []); diff --git a/public/js/config.js b/public/js/config.js index 35fe383..eaefc25 100755 --- a/public/js/config.js +++ b/public/js/config.js @@ -7,6 +7,9 @@ angular.module('mystery').config(['$routeProvider', when('/block/:blockHash', { templateUrl: 'views/block.html' }). + when('/tx/:txId', { + templateUrl: 'views/transaction.html' + }). when('/', { templateUrl: 'views/index.html' }). diff --git a/public/js/controllers/transactions.js b/public/js/controllers/transactions.js new file mode 100644 index 0000000..53aaf92 --- /dev/null +++ b/public/js/controllers/transactions.js @@ -0,0 +1,14 @@ +'use strict'; + +angular.module('mystery.transactions').controller('transactionsController', ['$scope', '$routeParams', '$location', 'Global', 'Transaction', function ($scope, $routeParams, $location, Global, Transaction) { + $scope.global = Global; + + $scope.findOne = function() { + Transaction.get({ + txId: $routeParams.txId + }, function(tx) { + $scope.tx = tx; + }); + }; +}]); + diff --git a/public/js/services/transactions.js b/public/js/services/transactions.js new file mode 100644 index 0000000..9edfaca --- /dev/null +++ b/public/js/services/transactions.js @@ -0,0 +1,8 @@ +'use strict'; + +angular.module('mystery.transactions').factory('Transaction', ['$resource', function($resource) { + return $resource('/api/tx/:txId', { + txId: '@txId' + }); +}]); + diff --git a/public/views/block.html b/public/views/block.html index 686a6ad..1c89df8 100644 --- a/public/views/block.html +++ b/public/views/block.html @@ -1,23 +1,73 @@
+ +

Summary

+
+
Number Of Transactions
+
--
+
Output Total
+
--
+
Estimated Transaction Volume
+
--
+
Transaction Fees
+
--
+
Height
+
{{block.height}}
+
Timestamp
+
{{block.time}}
+
Received Time
+
{{block.time}}
+
Relayed By
+
--
+
Difficulty
+
{{block.difficulty}}
+
Bits
+
{{block.bits}}
+
Size
+
{{block.size}}
+
Version
+
{{block.version}}
+
Nonce
+
{{block.nonce}}
+
+ +

Hashes

- - - - - + + - - - - - + + + + + + + + + + + + + +
HeightAgeTransactionsConfirmationsSize (kB)Hashes 
{{block.height}}{{block.time | date:'short'}}{{block.tx.length }}{{block.confirmations}}{{block.size / 1024}}Hash{{block.hash}}
Previous Block{{block.previousblockhash}}
Next Block(s){{block.nextblockhash}}
Merkle Root{{block.merkleroot}}
-
\ No newline at end of file + +

Transactions

+ + + + + + + + + +
Hash
{{tx}}
+ diff --git a/public/views/index.html b/public/views/index.html index 953dc31..97d4c36 100644 --- a/public/views/index.html +++ b/public/views/index.html @@ -4,19 +4,13 @@ - - - - - + + - + - - -
HeightAgeTransactionsConfirmationsSize (kB)HashTime
{{block.height}}{{block.hash}} {{block.time | date:'short'}}{{block.tx.length }}{{block.confirmations}}{{block.size / 1024}}
diff --git a/public/views/transaction.html b/public/views/transaction.html new file mode 100644 index 0000000..b5c519b --- /dev/null +++ b/public/views/transaction.html @@ -0,0 +1,32 @@ +
+ + +
+