Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge commit '3a4e2a8fbe67c0cdf57ff9124548cebb05db4d2e' into merge-igor
  • Loading branch information
incentivetoken committed Mar 3, 2016
2 parents 51de1f2 + 3a4e2a8 commit b50447d
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 59 deletions.
Binary file added app/images/loading.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion app/index.html
Expand Up @@ -81,6 +81,7 @@
<script src="bower_components/zeroclipboard/dist/ZeroClipboard.min.js"></script>
<script src="bower_components/dexie/dist/latest/Dexie.js"></script>
<script src="bower_components/dexie/addons/Dexie.Observable/Dexie.Observable.js"></script>
<script src="bower_components/async/dist/async.min.js"></script>


<script src="scripts/lib/es5.js"></script>
Expand Down Expand Up @@ -594,4 +595,4 @@
</div>
</nav>
</body>
</html>
</html>
44 changes: 19 additions & 25 deletions app/partials/merchant-terminal.html
Expand Up @@ -27,44 +27,38 @@
<h3 class="panel-title">Merchant terminal</h3>
</div>
<div class="panel-body">
<h2>Amount <b>{{amountNXT}}</b> {{symbol}}</h2>
<p></p>
<p>
<section ng-if="loading" style="text-align: center">
<img src="/images/loading.gif" />
</section>
<section ng-if="!loading">
<h2>Amount <b>{{amountNXT}}</b> {{asset.name || symbol}}</h2>
<div class="form-group">
<span class="form-control-static">
<div class="form-control-static">
<!-- <label class="control-label">Recipient</label> -->
<div>
<span ng-if="recipientName">{{recipientName}}<br><span class="text-muted">{{paramRecipient}}</span></span>
<span ng-if="!recipientName">{{paramRecipient}}</span>
</div>
</span>
</div>
</div>
</p>
<p>
<div class="form-group">
<span class="form-control-static">
<!-- <label class="control-label">Message</label> -->
<div>{{paramDescription}}</div>
{{paramDescription}}
</span>
</div>
</p>
<p>
<div class="form-group">
<span class="form-control-static">
<!-- <label class="control-label">Message</label> -->
<div>{{paramMessage}}</div>
{{paramMessage}}
</span>
</div>
</p>
<p>
<a class="btn btn-lg pull-right" ng-class="{'btn-success':!success,'btn-default':success}" href
ng-click="payNow()" ng-show="currentAccount" ng-disabled="success">
<span ng-show="!success"><i class="fa fa-1x fa-paper-plane-o fa-fw"></i>&nbsp;&nbsp;<span>Pay</span></span>
<span ng-show="success"><i class="fa fa-1x fa-check fa-fw"></i></span>
</a>
<a class="btn btn-lg btn-success pull-right" href ng-click="signin()" ng-show="!currentAccount">
<i class="fa fa-1x fa-sign-in"></i>&nbsp;&nbsp;<span translate="translate.sign_in"></span></a>
</p>
<p>
<a class="btn btn-lg pull-right" ng-class="{'btn-success':!success,'btn-default':success}" href
ng-click="payNow()" ng-show="currentAccount" ng-disabled="success">
<span ng-show="!success"><i class="fa fa-1x fa-paper-plane-o fa-fw"></i>&nbsp;&nbsp;<span>Pay</span></span>
<span ng-show="success"><i class="fa fa-1x fa-check fa-fw"></i></span>
</a>
<a class="btn btn-lg btn-success pull-right" href ng-click="signin()" ng-show="!currentAccount">
<i class="fa fa-1x fa-sign-in"></i>&nbsp;&nbsp;<span translate="translate.sign_in"></span></a>
</p>
</section>
</div>
</div>
</div>
Expand Down
3 changes: 1 addition & 2 deletions app/plugins/transaction/controllers/transaction.js
Expand Up @@ -25,7 +25,6 @@
var module = angular.module('fim.base');
module.controller('TransactionCreateModalController', function(items, $modalInstance, $scope, nxt,
modals, $sce, $q, plugins, i18n, $timeout, accountsService, $rootScope, Emoji, AccountAutocompleteProvider, AssetAutocompleteProvider) {

$scope.sendSuccess = false;
$scope.show = {};
$scope.show.advanced = false;
Expand Down Expand Up @@ -392,4 +391,4 @@ module.controller('TransactionCreateModalController', function(items, $modalInst
}

});
})();
})();
4 changes: 2 additions & 2 deletions app/plugins/transaction/transactions/assets.js
Expand Up @@ -255,7 +255,7 @@ module.run(function (plugins, modals, $q, $rootScope, nxt, OrderEntryProvider, U
}
return plugin.create(angular.extend(args, {
title: 'Buy Asset',
message: 'Place buy order for asset',
message: args.description || 'Place buy order for asset',
requestType: 'placeBidOrder',
createArguments: function (items, fields) {
var decimals = fields.asset.asset ? fields.asset.asset.decimals : fields.decimals.value;
Expand Down Expand Up @@ -630,4 +630,4 @@ module.run(function (plugins, modals, $q, $rootScope, nxt, OrderEntryProvider, U
}
});
});
})();
})();
2 changes: 1 addition & 1 deletion app/plugins/transaction/transactions/payment.js
Expand Up @@ -113,4 +113,4 @@ module.run(function (plugins, modals, $q, $rootScope, nxt, UserService) {


});
})();
})();
99 changes: 72 additions & 27 deletions app/scripts/controllers/merchant-terminal.js
Expand Up @@ -25,19 +25,21 @@
var module = angular.module('fim.base');

module.config(function($routeProvider) {
$routeProvider.when('/merchant/:recipient?/:amountNQT?/:deadline?/:description?/:message?', {
$routeProvider.when('/merchant/:recipient?/:amountNQT?/:deadline?/:description?/:message?/:assetId?/', {
templateUrl: 'partials/merchant-terminal.html',
controller: 'MerchantTerminalController'
});
});

module.controller('MerchantTerminalController', function ($scope, $rootScope, nxt, $routeParams, plugins, $location) {
module.controller('MerchantTerminalController', function ($scope, $rootScope, nxt, $routeParams, plugins) {

$scope.paramRecipient = $routeParams.recipient;
$scope.paramAmountNQT = $routeParams.amountNQT;
$scope.paramDeadline = $routeParams.deadline;
$scope.paramDescription = $routeParams.description;
$scope.paramMessage = $routeParams.message;
$scope.assetId = $routeParams.assetId;


$scope.amountNXT = nxt.util.convertToNXT($scope.paramAmountNQT);
$scope.recipientName = '';
Expand All @@ -46,41 +48,84 @@ module.controller('MerchantTerminalController', function ($scope, $rootScope, nx
var api = nxt.get($scope.paramRecipient);
$scope.symbol = api.engine.symbol;

api.engine.socket().getAccount({account: $scope.paramRecipient}).then(
function (data) {
$scope.$evalAsync(function () {
$scope.recipientName = data.accountName||data.accountEmail;
if ($scope.recipientName == $scope.paramRecipient) {
$scope.recipientName = '';
}

$scope.loading = true;
async.parallel([
function(cb){
if (!$scope.assetId) return cb()
api.engine.socket().callAPIFunction({requestType:'getAsset', asset: $scope.assetId}).then(function (data) {
$scope.asset = data;
console.log(data)
cb()
});
},
function(cb){
api.engine.socket().getAccount({account: $scope.paramRecipient}).then(
function (data) {
$scope.$evalAsync(function () {
$scope.recipientName = data.accountName||data.accountEmail;
if ($scope.recipientName == $scope.paramRecipient) {
$scope.recipientName = '';
}
cb()
});
}
);
}
);
],function(){
$scope.loading = false;
});


$scope.payNow = function () {
var args = {
recipient: $scope.paramRecipient,
amountNXT: nxt.util.convertNQT($scope.paramAmountNQT, 8),
deadline: $scope.paramDeadline
};
if ($scope.paramMessage) {
args.txnMessage = $scope.paramMessage;
args.txnMessageType = 'to_recipient';
}
$rootScope.executeTransaction('sendMoney', args).then(
function (items) {
if (items) {
$scope.$evalAsync(function () {
$scope.success = true;
});
var args = {};
if ($scope.asset){
args = {
asset: $scope.asset.asset,
recipient: $scope.paramRecipient,
quantity:nxt.util.convertNQT($scope.paramAmountNQT, 8)
};
if ($scope.paramMessage) {
args.txnMessage = $scope.paramMessage;
args.txnMessageType = 'to_recipient';
}

$rootScope.executeTransaction('transferAsset', args).then(
function (items) {
console.log(items)
if (items) {
$scope.$evalAsync(function () {
$scope.success = true;
});
}
}
);
}else{
args = {
recipient: $scope.paramRecipient,
amountNXT: nxt.util.convertNQT($scope.paramAmountNQT, 8),
deadline: $scope.paramDeadline
};
if ($scope.paramMessage) {
args.txnMessage = $scope.paramMessage;
args.txnMessageType = 'to_recipient';
}
);

$rootScope.executeTransaction('sendMoney', args).then(
function (items) {
if (items) {
$scope.$evalAsync(function () {
$scope.success = true;
});
}
}
);
}
}

$scope.signin = function () {
$rootScope.loginWizard('signin', {}, false /* stay on same url */);
}

});
})();
})();
3 changes: 2 additions & 1 deletion bower.json
Expand Up @@ -26,7 +26,8 @@
"angular-nvd3": "1.0.0-beta",
"zeroclipboard": "2.2.0",
"ng-clip": "0.2.6",
"dexie": "1.1.0"
"dexie": "1.1.0",
"async": "latest"
},
"devDependencies": {
"angular-scenario": "1.4.3"
Expand Down

0 comments on commit b50447d

Please sign in to comment.