diff --git a/www/js/controllers/home-controllers.js b/www/js/controllers/home-controllers.js index 4b840cea0871cd64b5c526b6235fe4ebe04daf17..613ca99579bf23a7333eb9d4ded09d9675ae87a8 100644 --- a/www/js/controllers/home-controllers.js +++ b/www/js/controllers/home-controllers.js @@ -39,7 +39,7 @@ angular.module('cesium.home.controllers', ['cesium.services']) ; -function NewAccountModalController($scope, $ionicModal, $state, $ionicSideMenuDelegate, UIUtils, $q, $timeout, CryptoUtils, BMA, Wallet, csCurrency) { +function NewAccountModalController($scope, $state, UIUtils, CryptoUtils, Wallet, csCurrency) { 'ngInject'; $scope.formData = { @@ -91,12 +91,11 @@ function NewAccountModalController($scope, $ionicModal, $state, $ionicSideMenuDe $scope.showAccountPubkey = function() { $scope.formData.computing=true; - CryptoUtils.connect($scope.formData.username, $scope.formData.password).then( - function(keypair) { - $scope.formData.pubkey = CryptoUtils.util.encode_base58(keypair.signPk); - $scope.formData.computing=false; - } - ) + CryptoUtils.connect($scope.formData.username, $scope.formData.password) + .then(function(keypair) { + $scope.formData.pubkey = CryptoUtils.util.encode_base58(keypair.signPk); + $scope.formData.computing=false; + }) .catch(function(err) { $scope.formData.computing=false; console.error('>>>>>>>' , err); @@ -116,36 +115,35 @@ function NewAccountModalController($scope, $ionicModal, $state, $ionicSideMenuDe } UIUtils.loading.show(); - $scope.closeModal() - .then(function(){ - Wallet.login($scope.formData.username, $scope.formData.password) + $scope.closeModal(); + + Wallet.login($scope.formData.username, $scope.formData.password) + .then(function() { + if (!$scope.formData.isMember) { + // Reset account data, and open wallet view + $scope.cancel(); + $state.go('app.view_wallet'); + return; + } + + // Send self + Wallet.self($scope.formData.pseudo, false/*do NOT load membership here*/) .then(function() { - if (!$scope.formData.isMember) { + // Send membership IN + Wallet.membership.inside() + .then(function() { // Reset account data, and open wallet view $scope.cancel(); $state.go('app.view_wallet'); - return; - } - - // Send self - Wallet.self($scope.formData.pseudo, false/*do NOT load membership here*/) - .then(function() { - // Send membership IN - Wallet.membership.inside() - .then(function() { - // Reset account data, and open wallet view - $scope.cancel(); - $state.go('app.view_wallet'); - }) - .catch(UIUtils.onError('ERROR.SEND_MEMBERSHIP_IN_FAILED')); - }) - .catch(UIUtils.onError('ERROR.SEND_IDENTITY_FAILED')); + }) + .catch(UIUtils.onError('ERROR.SEND_MEMBERSHIP_IN_FAILED')); }) - .catch(function(err) { - UIUtils.loading.hide(); - console.error('>>>>>>>' , err); - UIUtils.alert.error('ERROR.CRYPTO_UNKNOWN_ERROR'); - }); + .catch(UIUtils.onError('ERROR.SEND_IDENTITY_FAILED')); + }) + .catch(function(err) { + UIUtils.loading.hide(); + console.error('>>>>>>>' , err); + UIUtils.alert.error('ERROR.CRYPTO_UNKNOWN_ERROR'); }); }; diff --git a/www/js/services/settings-services.js b/www/js/services/settings-services.js index 09f9c4b0c70c3ffa4525bedb376ed9469430c1dc..f0cc640ade1e305334e5d755431d65e580883e0d 100644 --- a/www/js/services/settings-services.js +++ b/www/js/services/settings-services.js @@ -54,6 +54,31 @@ angular.module('cesium.settings.services', ['ngResource', 'ngApi', 'cesium.confi return; } + // Workaround to get node info from Cesium < 0.2.0 + if (storedData.DUNITER_NODE) { + var nodePart = storedData.DUNITER_NODE.split(':'); + if (nodePart.length == 1 || nodePart.length == 2) { + storedData.node = { + host: nodePart[0], + port: nodePart[1] // could be undefined, but that's fine + }; + } + delete delete data.DUNITER_NODE; + } + if (storedData.DUNITER_NODE_ES) { + var nodePart = storedData.DUNITER_NODE_ES.split(':'); + if (nodePart.length == 1 || nodePart.length == 2) { + storedData.plugins = { + es: { + enable: true, + host: nodePart[0], + port: nodePart[1] // could be undefined, but that's fine + } + }; + } + delete delete data.DUNITER_NODE_ES; + } + var localeChanged = storedData.locale && storedData.locale.id && (data.locale.id !== storedData.locale.id); angular.merge(data, storedData); @@ -61,8 +86,6 @@ angular.module('cesium.settings.services', ['ngResource', 'ngApi', 'cesium.confi // This is a workaround for DEV (TODO: implement edition in settings) data.timeWarningExpire = defaultSettings.timeWarningExpire; data.timeWarningExpireMembership = defaultSettings.timeWarningExpireMembership; - delete data.DUNITER_NODE; - delete data.DUNITER_NODE_ES; if (localeChanged) { $translate.use(data.locale.id); diff --git a/www/plugins/es/js/controllers/market-controllers.js b/www/plugins/es/js/controllers/market-controllers.js index ef7d0779c2a01898512bcffa6e4a5130df9bccf9..6200c957ed1fcf37bb51974ea9a15761e27a98c9 100644 --- a/www/plugins/es/js/controllers/market-controllers.js +++ b/www/plugins/es/js/controllers/market-controllers.js @@ -332,7 +332,7 @@ function ESMarketLookupController($scope, $rootScope, esMarket, $state, $focus, }; } -function ESMarketRecordViewController($scope, $rootScope, Wallet, esMarket, UIUtils, $state, $q, $timeout, BMA, esHttp, $filter) { +function ESMarketRecordViewController($scope, $rootScope, Wallet, esMarket, UIUtils, $state, $q, $timeout, BMA, esHttp, $filter, csSettings) { 'ngInject'; $scope.formData = {}; @@ -447,24 +447,39 @@ function ESMarketRecordViewController($scope, $rootScope, Wallet, esMarket, UIUt }; $scope.refreshConvertedPrice = function() { - if (!$scope.walletData || !$rootScope.walletData.settings) { + if (!$scope.formData.price) { + $scope.convertedPrice = null; return; } - if ($rootScope.walletData.settings.useRelative) { - $scope.convertedPrice = $scope.formData.price ? ($scope.formData.price / $rootScope.walletData.currentUD) : null; - } else { - $scope.convertedPrice = $scope.formData.price; + + // Price in UD + if (!$scope.formData.unit || $scope.formData.unit == 'UD') { + if (!csSettings.data.useRelative) { + $scope.convertedPrice = $scope.formData.price * $rootScope.walletData.currentUD; + } + else { + $scope.convertedPrice = $scope.formData.price; + } + } + // price in qte + else { + if (!csSettings.data.useRelative) { + $scope.convertedPrice = $scope.formData.price; + } + else { + $scope.convertedPrice = $scope.formData.price / $rootScope.walletData.currentUD; + } } }; - $scope.$watch('$root.walletData.settings.useRelative', $scope.refreshConvertedPrice, true); + $scope.$watch('$root.settings.useRelative', $scope.refreshConvertedPrice, true); $scope.edit = function() { $state.go('app.market_edit_record', {id: $scope.id, title: $filter('formatSlug')($scope.formData.title)}); }; } -function ESMarketRecordEditController($scope, $ionicModal, Wallet, esMarket, UIUtils, $state, $q, $ionicPopup, Device, - $timeout, ModalUtils, esHttp, $ionicHistory, $focus) { +function ESMarketRecordEditController($scope, esMarket, UIUtils, $state, + $timeout, ModalUtils, esHttp, $ionicHistory, $focus, csSettings) { 'ngInject'; $scope.walletData = {}; @@ -489,7 +504,7 @@ function ESMarketRecordEditController($scope, $ionicModal, Wallet, esMarket, UIU return $scope.loadWallet(); }) .then(function(walletData) { - $scope.useRelative = walletData.settings.useRelative; + $scope.useRelative = csSettings.data.useRelative; $scope.walletData = walletData; if ($state.stateParams && $state.stateParams.id) { // Load by id $scope.load($state.stateParams.id); @@ -597,7 +612,8 @@ function ESMarketRecordEditController($scope, $ionicModal, Wallet, esMarket, UIU }; $scope.setUseRelative = function(useRelative) { - $scope.formData.unit = useRelative ? 'DU' : 'unit'; + $scope.formData.unit = useRelative ? 'UD' : 'unit'; + $scope.useRelative = useRelative; //$scope.unitPopover.hide(); }; diff --git a/www/plugins/es/templates/market/edit_record.html b/www/plugins/es/templates/market/edit_record.html index bda2fc2bcbba2b9bfcfaa870857470daf142e95a..e8bc6f77e24c68d720c07fa7f852a7e13068c5c8 100644 --- a/www/plugins/es/templates/market/edit_record.html +++ b/www/plugins/es/templates/market/edit_record.html @@ -91,7 +91,7 @@ <!-- price --> <ion-item class="item-input item-floating-label item-button-right" - ng-if="!$root.walletData.settings.useRelative"> + ng-if="!$root.settings.useRelative"> <span class="input-label">{{'MARKET.EDIT.RECORD_PRICE' | translate}} ({{currency | abbreviate}})</span> <input type="text" name="price" placeholder="{{'MARKET.EDIT.RECORD_PRICE_HELP' | translate}} ({{currency | abbreviate}})" ng-model="formData.price" @@ -103,7 +103,7 @@ </span> </ion-item> <ion-item class="item-input item-floating-label item-button-right" - ng-if="$root.walletData.settings.useRelative"> + ng-if="$root.settings.useRelative"> <span class="input-label">{{'MARKET.EDIT.RECORD_PRICE' | translate}} ({{'COMMON.UD' | translate}}<sub>{{currency | abbreviate}}</sub>)</span> <input type="text" name="price" placeholder="{{'MARKET.EDIT.RECORD_PRICE_HELP' | translate}} ({{'COMMON.UD' | translate}} {{currency | abbreviate}})" ng-model="formData.price"> diff --git a/www/plugins/es/templates/market/view_record.html b/www/plugins/es/templates/market/view_record.html index 250ee7f9b23c3d36b8d7ce992786b66dfb090cb7..ff5f84eb4650c19a8ba40c60c48ea8e4ab63a90d 100644 --- a/www/plugins/es/templates/market/view_record.html +++ b/www/plugins/es/templates/market/view_record.html @@ -79,8 +79,8 @@ <span class="item item-icon-left item-button-right" ng-if="formData.price"> <i class="icon ion-pricetag"></i> - <span class="dark" ng-if="formData.currency && !$root.walletData.settings.useRelative">{{convertedPrice|formatInteger}} {{formData.currency|abbreviate}}</span> - <span class="dark" ng-if="formData.currency && $root.walletData.settings.useRelative">{{convertedPrice|formatDecimal}} {{'COMMON.UD'|translate}} <sub>{{formData.currency|abbreviate}}</sub></span> + <span class="dark" ng-if="!$root.settings.useRelative">{{convertedPrice|formatInteger}} {{formData.currency|abbreviate}}</span> + <span class="dark" ng-if="$root.settings.useRelative">{{convertedPrice|formatDecimal}} {{'COMMON.UD'|translate}} <sub>{{formData.currency|abbreviate}}</sub></span> </span> <div class="lazy-load">