Merge pull request #110 from matiu/feature/ux10

Feature/ux10
This commit is contained in:
Ryan X. Charles 2014-04-20 22:20:48 -03:00
commit a50f4cc638
4 changed files with 38 additions and 17 deletions

View File

@ -286,6 +286,13 @@
</div>
</div>
<div class="large-6 columns text-right">
<span ng-show="!tx.missingSignatures && !tx.sentTs">
Transaction ready.
<button class="secondary round" ng-click="send(tx.ntxid)">
Broadcast Transaction
</button>
</span>
<span ng-show="!tx.missingSignatures && tx.sentTs">
Sent at {{tx.sentTs | date:'medium'}}
</span>
@ -299,8 +306,8 @@
</div>
</div>
</div>
<div class="large-12 columns">
<!--
<h4>Last transactions</h4>
<div class="panel">
<div class="row">
@ -332,6 +339,7 @@
</span>
</div>
</div>
-->
</div>
</div>
</div>

View File

@ -43,6 +43,7 @@ console.log('[transactions.js.10:_updateTxs:]'); //TODO
});
$scope.txs = txs;
console.log('[transactions.js.55] SET HANDL+'); //TODO
w.removeListener('txProposalsUpdated',_updateTxs)
w.once('txProposalsUpdated',_updateTxs);
};
@ -58,6 +59,20 @@ console.log('[transactions.js.55] SET HANDL+'); //TODO
socket.on('connect', controllerUtils.handleTransactionByAddress($scope));
}
$scope.send = function (ntxid) {
var w = $rootScope.wallet;
w.sendTx(ntxid, function(txid) {
console.log('[transactions.js.68:txid:] SENTTX CALLBACK',txid); //TODO
$rootScope.flashMessage = txid
? {type:'success', message: 'Transactions SENT! txid:' + txid}
: {type:'error', message: 'There was an error sending the Transaction'}
;
_updateTxs();
$rootScope.$digest();
});
};
$scope.sign = function (ntxid) {
var w = $rootScope.wallet;
var ret = w.sign(ntxid);
@ -65,19 +80,16 @@ console.log('[transactions.js.55] SET HANDL+'); //TODO
var p = w.getTxProposal(ntxid);
if (p.txp.builder.isFullySigned()) {
w.sendTx(ntxid, function(txid) {
$rootScope.flashMessage = txid
? {type:'success', message: 'Transactions SENT! txid:' + txid}
: {type:'error', message: 'There was an error sending the Transaction'}
;
});
$scope.send(ntxid);
}
else {
$rootScope.flashMessage = ret
? {type:'success', message: 'Transactions signed'}
: {type:'error', message: 'There was an error signing the Transaction'}
;
}
_updateTxs();
$rootScope.$digest();
}
};
});

View File

@ -19,7 +19,7 @@ function TxProposal(opts) {
this.seenBy = opts.seenBy || {};
this.signedBy = opts.signedBy || {};
this.builder = opts.builder;
this.sentTs = null;
this.sentTs = opts.sentTs || null;
}
TxProposal.prototype.toObj = function() {
@ -29,6 +29,11 @@ TxProposal.prototype.toObj = function() {
return o;
};
TxProposal.prototype.setSent = function() {
this.sentTs = Date.now();;
};
TxProposal.fromObj = function(o) {
var t = new TxProposal(o);
var b = new Builder.fromObj(o.builderObj);
@ -36,10 +41,6 @@ TxProposal.fromObj = function(o) {
return t;
};
TxProposal.setSent = function() {
this.sentTs = Date.now();;
};
TxProposal.getSentTs = function() {
return this.sentTs;
};

View File

@ -334,7 +334,7 @@ Wallet.prototype.sign = function(ntxid) {
return ret;
};
Wallet.prototype.sendTx = function(ntxid) {
Wallet.prototype.sendTx = function(ntxid, cb) {
var txp = this.txProposals.txps[ntxid];
if (!txp) return;
@ -350,10 +350,10 @@ Wallet.prototype.sendTx = function(ntxid) {
self.log('BITCOND txid:',txid); //TODO
if (txid) {
self.txProposals.setSent(ntxid);
}
self.sendTxProposals();
self.store();
}
return (txid);
return cb(txid);
});
};