diff --git a/app/config.json b/app/config.json index 91915d67eec452a7f8a72adcf8b1969379b331c0..41100d3b47275248f364f2be07ff5d20f23f3f49 100644 --- a/app/config.json +++ b/app/config.json @@ -138,5 +138,45 @@ } } } + }, + + "fake": { + "cacheTimeMs": 60000, + "fallbackLanguage": "fr-FR", + "defaultLanguage": "fr-FR", + "rememberMe": true, + "showUDHistory": false, + "timeout": 6000, + "timeWarningExpireMembership": 5184000, + "timeWarningExpire": 7776000, + "useLocalStorage": true, + "useRelative": true, + "initPhase": true, + "expertMode": true, + "helptip": { + "enable": false, + "installDocUrl": { + "fr-FR": "http://www.le-sou.org/devenir-noeud/", + "en": "https://github.com/duniter/duniter/blob/master/doc/install-a-node.md" + } + }, + "node": { + "host": "fakenet.cgeek.fr", + "port": "10900" + }, + "plugins":{ + "es": { + "enable": true, + "askEnable": false, + "host": "localhost", + "port": 9200, + "wsPort": 9400, + "notifications": { + "tx": { + "enable": false + } + } + } + } } } diff --git a/www/i18n/locale-fr-FR.json b/www/i18n/locale-fr-FR.json index 5b9fb2b67b851dd997fe35f51766610a491c27a0..ef7bc8ef9fe711188fd447adc6ba2d31eae5b6b7 100644 --- a/www/i18n/locale-fr-FR.json +++ b/www/i18n/locale-fr-FR.json @@ -343,7 +343,7 @@ "INVALID_COMMENT": "Le champ 'référence' ne doit pas contenir de caractères accentués.", "INVALID_PUBKEY": "La clé publique n'a pas le format attendu.", "IDENTITY_INVALID_BLOCK_HASH": "Cette demande d'adhésion n'est plus valide (car elle référence un bloc que les noeuds du réseau ont annulé) : cette personne doit renouveller sa demande d'adhésion <b>avant</b> d'être certifiée.", - "IDENTITY_EXPIRED": "La publication d'identité a expirée : cette personne doit effectuer une nouvelle demande d'adhésion <b>avant</b> d'être certifiée.", + "IDENTITY_EXPIRED": "La publication de cette identité a expirée : cette personne doit effectuer une nouvelle demande d'adhésion <b>avant</b> d'être certifiée.", "IDENTITY_SANDBOX_FULL": "Le noeud Duniter utilisé par Cesium ne peut plus recevoir de nouvelles identités, car sa file d'attente est pleine.<br/><br/>Veuillez réessayer ultérieurement ou changer de noeud (via le menu <b>Paramètres</b>).", "WOT_PENDING_INVALID_BLOCK_HASH": "Adhésion non valide.", "WALLET_INVALID_BLOCK_HASH": "Votre demande d'adhésion n'est plus valide (car elle référence un bloc que les noeuds du réseau ont annulé).<br/>Vous devez <a ng-click=\"doQuickFix('fixMembership')\">envoyer une nouvelle demande</a> pour résoudre ce problème.", diff --git a/www/js/config.js b/www/js/config.js index 62566ad6c64d1fb30a02689e73022cea66b555c4..e1bf3d8ed4bcd06acf72560a84dd6f5487cdb77b 100644 --- a/www/js/config.js +++ b/www/js/config.js @@ -47,7 +47,7 @@ angular.module("cesium.config", []) } }, "version": "0.5.2", - "build": "2016-12-15T13:50:47.026Z", + "build": "2017-01-05T18:56:38.746Z", "newIssueUrl": "https://github.com/duniter/cesium/issues/new?labels=bug" }) diff --git a/www/js/controllers/wot-controllers.js b/www/js/controllers/wot-controllers.js index ac96b8308f68df59a7d7e67138e8f073a835f01e..37c1399560e281ca806fb2193b960ef3820a2f7d 100644 --- a/www/js/controllers/wot-controllers.js +++ b/www/js/controllers/wot-controllers.js @@ -95,7 +95,7 @@ function WotLookupController($scope, BMA, $state, UIUtils, $timeout, csConfig, c }; $scope.entered = false; $scope.wotSearchTextId = 'wotSearchText'; - $scope.enableFilter = true; + $scope.enableFilter = !csConfig.initPhase; // disable filter on init phase $scope.$on('$ionicView.enter', function(e, state) { if (!$scope.entered) { @@ -508,6 +508,12 @@ function WotCertificationsViewController($scope, $rootScope, $state, $timeout, $ return; } + // Check identity not expired + if ($scope.formData.requirements.expired) { + UIUtils.alert.error('ERROR.IDENTITY_EXPIRED'); + return; + } + // Check not already certified var previousCert = _.findWhere($scope.formData.received_cert, { pubkey: csWallet.data.pubkey, valid: true}); if (previousCert) { @@ -528,6 +534,7 @@ function WotCertificationsViewController($scope, $rootScope, $state, $timeout, $ return; } + UIUtils.alert.confirm('CONFIRM.CERTIFY_RULES') .then(function(confirm){ if (!confirm) { @@ -592,6 +599,12 @@ function WotCertificationsViewController($scope, $rootScope, $state, $timeout, $ return; } + // Check identity not expired + if (identity.requirements.expired) { + UIUtils.alert.error('ERROR.IDENTITY_EXPIRED'); + return; + } + // Check not already certified var previousCert = _.findWhere(identity.received_cert, { pubkey: csWallet.data.pubkey, valid: true}); if (previousCert) { diff --git a/www/js/services/bma-services.js b/www/js/services/bma-services.js index c36f4a0b937bc6bf6425da01cbe10fe93db3ce7d..f2c42572673214a60561c4aee5c7335f488148c2 100644 --- a/www/js/services/bma-services.js +++ b/www/js/services/bma-services.js @@ -7,7 +7,20 @@ angular.module('cesium.bma.services', ['ngResource', 'cesium.http.services', 'ce function factory(host, port, cacheEnable) { - const + function exact(regexpContent) { + return new RegExp("^" + regexpContent + "$"); + } + + var + regex = { + USER_ID: "[A-Za-z0-9_-]+", + CURRENCY: "[A-Za-z0-9_-]+", + PUBKEY: "[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{43,44}", + COMMENT: "[ a-zA-Z0-9-_:/;*\\[\\]()?!^\\+=@&~#{}|\\\\<>%.]*", + // duniter://[uid]:[pubkey]@[host]:[port] + URI_WITH_AT: "duniter://(?:([A-Za-z0-9_-]+):)?([123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{43,44})@([a-zA-Z0-9-.]+.[ a-zA-Z0-9-_:/;*?!^\\+=@&~#|<>%.]+)", + URI_WITH_PATH: "duniter://([a-zA-Z0-9-.]+.[a-zA-Z0-9-_:.]+)/([123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{43,44})(?:/([A-Za-z0-9_-]+))?" + }, errorCodes = { HTTP_LIMITATION: 1006, IDENTITY_SANDBOX_FULL: 1007, @@ -20,35 +33,82 @@ angular.module('cesium.bma.services', ['ngResource', 'cesium.http.services', 'ce BLOCK_NOT_FOUND: 2011, TX_ALREADY_PROCESSED: 2030 }, - regex = { - USER_ID: "[A-Za-z0-9_-]+", - CURRENCY: "[A-Za-z0-9_-]+", - PUBKEY: "[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{43,44}", - COMMENT: "[ a-zA-Z0-9-_:/;*\\[\\]()?!^\\+=@&~#{}|\\\\<>%.]*", - // duniter://[uid]:[pubkey]@[host]:[port] - URI_WITH_AT: "duniter://(?:([A-Za-z0-9_-]+):)?([123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{43,44})@([a-zA-Z0-9-.]+.[ a-zA-Z0-9-_:/;*?!^\\+=@&~#|<>%.]+)", - URI_WITH_PATH: "duniter://([a-zA-Z0-9-.]+.[a-zA-Z0-9-_:.]+)/([123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{43,44})(?:/([A-Za-z0-9_-]+))?" - }, constants = { ROOT_BLOCK_HASH: 'E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855', LIMIT_REQUEST_COUNT: 5, // simultaneous async call of on rest request LIMIT_REQUEST_DELAY: 1000 // time (in second) to wait between to call of a rest request }; - var - exports = { - _internal: {}, - node: { - server: csHttp.getServer(host, port), - host: host, - port: port + + var exports = { + errorCodes: errorCodes, + constants: constants, + regex: { + USER_ID: exact(regex.USER_ID), + COMMENT: exact(regex.COMMENT), + PUBKEY: exact(regex.PUBKEY), + CURRENCY: exact(regex.CURRENCY), + URI: exact(regex.URI) + }, + node: { + server: csHttp.getServer(host, port), + host: host, + port: port, + summary: csHttp.getWithCache(host, port, '/node/summary', csHttp.cache.LONG), + same: function(host2, port2) { + return host2 == host && ((!port && !port2) || (port == port2)); } - }; + }, + network: { + peering: { + peers: csHttp.get(host, port, '/network/peering/peers') + }, + peers: csHttp.get(host, port, '/network/peers') + }, + wot: { + lookup: csHttp.get(host, port, '/wot/lookup/:search'), + certifiedBy: csHttp.get(host, port, '/wot/certified-by/:pubkey'), + certifiersOf: csHttp.get(host, port, '/wot/certifiers-of/:pubkey'), + member: { + all: cacheEnable ? csHttp.getWithCache(host, port, '/wot/members') : csHttp.get(host, port, '/wot/members'), + pending: csHttp.get(host, port, '/wot/pending') + }, + requirements: csHttp.get(host, port, '/wot/requirements/:pubkey'), + add: csHttp.post(host, port, '/wot/add'), + certify: csHttp.post(host, port, '/wot/certify') + }, + blockchain: { + parameters: csHttp.getWithCache(host, port, '/blockchain/parameters', csHttp.cache.LONG), + block: cacheEnable ? csHttp.getWithCache(host, port, '/blockchain/block/:block', csHttp.cache.SHORT) : csHttp.get(host, port, '/blockchain/block/:block'), + current: csHttp.get(host, port, '/blockchain/current'), + membership: csHttp.post(host, port, '/blockchain/membership'), + stats: { + ud: cacheEnable ? csHttp.getWithCache(host, port, '/blockchain/with/ud', csHttp.cache.SHORT) : csHttp.get(host, port, '/blockchain/with/ud'), + tx: csHttp.get(host, port, '/blockchain/with/tx'), + newcomers: csHttp.get(host, port, '/blockchain/with/newcomers'), + hardship: csHttp.get(host, port, '/blockchain/hardship/:pubkey') + } + }, + tx: { + sources: csHttp.get(host, port, '/tx/sources/:pubkey'), + process: csHttp.post(host, port, '/tx/process'), + history: { + all: csHttp.get(host, port, '/tx/history/:pubkey'), + times: cacheEnable ? csHttp.getWithCache(host, port, '/tx/history/:pubkey/times/:from/:to') : csHttp.get(host, port, '/tx/history/:pubkey/times/:from/:to'), + timesNoCache: csHttp.get(host, port, '/tx/history/:pubkey/times/:from/:to'), + blocks: cacheEnable ? csHttp.getWithCache(host, port, '/tx/history/:pubkey/blocks/:from/:to') : csHttp.get(host, port, '/tx/history/:pubkey/blocks/:from/:to'), + pending: csHttp.get(host, port, '/tx/history/:pubkey/pending') + } + }, + ud: { + history: csHttp.get(host, port, '/ud/history/:pubkey') + }, + uri: {}, + raw: { - function exact(regexpContent) { - return new RegExp("^" + regexpContent + "$"); - } + } + }; - function copy(otherNode) { + exports.copy = function(otherNode) { if (!!this.instance) { // if main service impl var instance = this.instance; // keep factory csCache.clearAll(); // clean all caches @@ -58,29 +118,20 @@ angular.module('cesium.bma.services', ['ngResource', 'cesium.http.services', 'ce else { angular.copy(otherNode, this); } - } - - function isSameNode(host2, port2) { - return host2 == host && ((!port && !port2) ||(port == port2)); - } - - exports._internal.getMembers = cacheEnable ? - csHttp.getWithCache(host, port, '/wot/members') : - csHttp.get(host, port, '/wot/members'); + }; - function getMemberUidsByPubkey() { - return exports._internal.getMembers() + exports.wot.member.uids = function() { + return exports.wot.member.all() .then(function(res){ return res.results.reduce(function(res, member){ res[member.pubkey] = member.uid; return res; }, {}); }); - } - exports._internal.getMemberUidsByPubkey = getMemberUidsByPubkey; + }; - function getMemberByPubkey(pubkey) { - return exports._internal.getMemberUidsByPubkey() + exports.wot.member.get = function(pubkey) { + return exports.wot.member.uids() .then(function(memberUidsByPubkey){ var uid = memberUidsByPubkey[pubkey]; return { @@ -88,29 +139,23 @@ angular.module('cesium.bma.services', ['ngResource', 'cesium.http.services', 'ce uid: (uid ? uid : null) }; }); - } - exports._internal.getMemberByPubkey = getMemberByPubkey; - - exports._internal.getBlockchainBlock = cacheEnable ? - csHttp.getWithCache(host, port, '/blockchain/block/:block', csHttp.cache.SHORT) : - csHttp.get(host, port, '/blockchain/block/:block'); + }; /** * Return all expected blocks * @param blockNumbers a rray of block number */ - function getBlockchainBlocks(blockNumbers){ - return exports._internal.getBlockchainBlocksRecursive(blockNumbers, 0, constants.LIMIT_REQUEST_COUNT); - } - exports._internal.getBlockchainBlocks = getBlockchainBlocks; + exports.blockchain.blocks = function(blockNumbers){ + return exports.raw.blocksRecursive(blockNumbers, 0, exports.constants.LIMIT_REQUEST_COUNT); + }; - function getBlockchainBlocksRecursive(blockNumbers, offset, size) { + exports.raw.blocksRecursive = function(blockNumbers, offset, size) { return $q(function(resolve, reject) { var result = []; var jobs = []; _.each(blockNumbers.slice(offset, offset+size), function(blockNumber) { jobs.push( - exports._internal.getBlockchainBlock({block: blockNumber}) + exports.blockchain.block({block: blockNumber}) .then(function(block){ if (!block) return; result.push(block); @@ -122,7 +167,7 @@ angular.module('cesium.bma.services', ['ngResource', 'cesium.http.services', 'ce .then(function() { if (offset < blockNumbers.length - 1) { $timeout(function() { - exports._internal.getBlockchainBlocksRecursive(blockNumbers, offset+size, size) + exports.raw.blocksRecursive(blockNumbers, offset+size, size) .then(function(blocks) { if (!blocks || !blocks.length) { resolve(result); @@ -133,7 +178,7 @@ angular.module('cesium.bma.services', ['ngResource', 'cesium.http.services', 'ce .catch(function(err) { reject(err); }); - }, constants.LIMIT_REQUEST_DELAY); + }, exports.constants.LIMIT_REQUEST_DELAY); } else { resolve(result); @@ -148,29 +193,23 @@ angular.module('cesium.bma.services', ['ngResource', 'cesium.http.services', 'ce } }); }); - } - exports._internal.getBlockchainBlocksRecursive = getBlockchainBlocksRecursive; - - exports._internal.getBlockchainWithUd = cacheEnable ? - csHttp.getWithCache(host, port, '/blockchain/with/ud', csHttp.cache.SHORT) : - csHttp.get(host, port, '/blockchain/with/ud'); + }; - function getBlockchainLastUd() { - return exports._internal.getBlockchainWithUd() + exports.blockchain.stats.lastUd = function() { + return exports.blockchain.stats.ud() .then(function(res) { if (!res.result.blocks || !res.result.blocks.length) { return null; } var lastBlockWithUD = res.result.blocks[res.result.blocks.length - 1]; - return exports._internal.getBlockchainBlock({block: lastBlockWithUD}) + return exports.blockchain.block({block: lastBlockWithUD}) .then(function(block){ return (block.unitbase > 0) ? block.dividend * Math.pow(10, block.unitbase) : block.dividend; }); }); - } - exports._internal.getBlockchainLastUd = getBlockchainLastUd; + }; - function parseUri(uri) { + exports.uri.parse = function(uri) { return $q(function(resolve, reject) { // If pubkey: not need to parse if (exact(regex.PUBKEY).test(uri)) { @@ -221,9 +260,10 @@ angular.module('cesium.bma.services', ['ngResource', 'cesium.http.services', 'ce host: host, currency: parameters.currency }); - }).catch(function(err) { + }) + .catch(function(err) { console.log(err); - reject({message: 'Could not get node parameter. Currency could not be retrieve'}); return; + reject({message: 'Could not get node parameter. Currency could not be retrieve'}); }); } else { @@ -241,17 +281,17 @@ angular.module('cesium.bma.services', ['ngResource', 'cesium.http.services', 'ce // Check if currency are the same (between node and uri) return csHttp.get(host + '/blockchain/parameters')() - .then(function(parameters){ - if (parameters.currency !== currency) { - reject( {message: "Node's currency ["+parameters.currency+"] does not matched URI's currency ["+currency+"]."}); return; - } - resolve({ - uid: uid, - pubkey: pubkey, - host: host, - currency: currency + .then(function(parameters){ + if (parameters.currency !== currency) { + reject( {message: "Node's currency ["+parameters.currency+"] does not matched URI's currency ["+currency+"]."}); return; + } + resolve({ + uid: uid, + pubkey: pubkey, + host: host, + currency: currency + }); }); - }); } } else { @@ -272,62 +312,8 @@ angular.module('cesium.bma.services', ['ngResource', 'cesium.http.services', 'ce } return result; }); - } - - exports.node.summary = csHttp.getWithCache(host, port, '/node/summary', csHttp.cache.LONG); - exports.node.same = isSameNode; - exports.wot = { - lookup: csHttp.get(host, port, '/wot/lookup/:search'), - certifiedBy: csHttp.get(host, port, '/wot/certified-by/:pubkey'), - certifiersOf: csHttp.get(host, port, '/wot/certifiers-of/:pubkey'), - member: { - all: exports._internal.getMembers, - uids: exports._internal.getMemberUidsByPubkey, - get: exports._internal.getMemberByPubkey, - pending: csHttp.get(host, port, '/wot/pending') - }, - requirements: csHttp.get(host, port, '/wot/requirements/:pubkey'), - add: csHttp.post(host, port, '/wot/add'), - certify: csHttp.post(host, port, '/wot/certify') - }; - exports.network = { - peering: { - peers: csHttp.get(host, port, '/network/peering/peers') - }, - peers: csHttp.get(host, port, '/network/peers') - }; - exports.blockchain = { - parameters: csHttp.getWithCache(host, port, '/blockchain/parameters', csHttp.cache.LONG), - current: csHttp.get(host, port, '/blockchain/current'), - block: exports._internal.getBlockchainBlock, - blocks: exports._internal.getBlockchainBlocks, - membership: csHttp.post(host, port, '/blockchain/membership'), - stats: { - ud: exports._internal.getBlockchainWithUd, - tx: csHttp.get(host, port, '/blockchain/with/tx'), - newcomers: csHttp.get(host, port, '/blockchain/with/newcomers'), - hardship: csHttp.get(host, port, '/blockchain/hardship/:pubkey'), - }, - lastUd: exports._internal.getBlockchainLastUd - }; - exports.tx = { - sources: csHttp.get(host, port, '/tx/sources/:pubkey'), - process: csHttp.post(host, port, '/tx/process'), - history: { - all: csHttp.get(host, port, '/tx/history/:pubkey'), - times: cacheEnable ? - csHttp.getWithCache(host, port, '/tx/history/:pubkey/times/:from/:to') : - csHttp.get(host, port, '/tx/history/:pubkey/times/:from/:to'), - timesNoCache: csHttp.get(host, port, '/tx/history/:pubkey/times/:from/:to'), - blocks: cacheEnable ? - csHttp.getWithCache(host, port, '/tx/history/:pubkey/blocks/:from/:to') : - csHttp.get(host, port, '/tx/history/:pubkey/blocks/:from/:to'), - pending: csHttp.get(host, port, '/tx/history/:pubkey/pending') - } }; - exports.ud = { - history: csHttp.get(host, port, '/ud/history/:pubkey') - }; + exports.websocket = { block: function() { return csHttp.ws('ws://' + exports.node.server + '/ws/block'); @@ -338,20 +324,7 @@ angular.module('cesium.bma.services', ['ngResource', 'cesium.http.services', 'ce close : csHttp.closeAllWs }; - exports.copy = copy; - exports.errorCodes = errorCodes; - exports.constants = constants; - exports.regex = { - USER_ID: exact(regex.USER_ID), - COMMENT: exact(regex.COMMENT), - PUBKEY: exact(regex.PUBKEY), - CURRENCY: exact(regex.CURRENCY), - URI: exact(regex.URI) - }; - exports.uri = { - parse: parseUri - }; - return exports + return exports; } var service = factory(csSettings.data.node.host, csSettings.data.node.port, true /*cache*/); diff --git a/www/js/services/network-services.js b/www/js/services/network-services.js index 5a3de98ad866548127a16100f42faf1beb693ca6..0ed037e05030eeab8b65b8a18674c4b6e98912b9 100644 --- a/www/js/services/network-services.js +++ b/www/js/services/network-services.js @@ -119,8 +119,12 @@ angular.module('cesium.network.services', ['ngResource', 'ngApi', 'cesium.bma.se peer.blockNumber = peer.block.replace(/-.+$/, ''); peer.uid = data.uidsByPubkeys[peer.pubkey]; var node = new BMA.instance(peer.getHost(), peer.getPort(), false); + + + + // Get current block return node.blockchain.current() - .then(function(block){ + .then(function(block) { peer.currentNumber = block.number; peer.online = true; peer.buid = buid(block); @@ -128,31 +132,16 @@ angular.module('cesium.network.services', ['ngResource', 'ngApi', 'cesium.bma.se data.knownBlocks.push(peer.buid); } console.debug('[network] Peer [' + peer.server + '] status [UP] block [' + peer.buid.substring(0, 20) + ']'); - - if (csSettings.data.expertMode && !UIUtils.screen.isSmall()) { - // Get Version - return node.node.summary() - .then(function(res){ - peer.version = res && res.duniter && res.duniter.version; - // Get hardship (if member peer) - if (peer.uid) { - return node.blockchain.stats.hardship({pubkey: peer.pubkey}) - .then(function (res) { - peer.level = res && res.level; - return peer; - }); - } - }).catch(function() { - peer.version = null; // continue - peer.level = null; // continue - return peer; - }); - } - else { + return peer; + }) + .catch(function(err) { + // Special case for currency init (root block not exists): use fixed values + if (err && err.ucode == BMA.errorCodes.NO_CURRENT_BLOCK) { + peer.online = true; + peer.buid = buid({number:0, hash: BMA.constants.ROOT_BLOCK_HASH}); + peer.level = 0; return peer; } - }) - .catch(function() { // node is DOWN peer.online=false; peer.currentNumber = null; @@ -160,6 +149,33 @@ angular.module('cesium.network.services', ['ngResource', 'ngApi', 'cesium.bma.se peer.uid = data.uidsByPubkeys[peer.pubkey]; console.debug('[network] Peer [' + peer.server + '] status [DOWN]'); return peer; + }) + .then(function(peer) { + // Exit, if offline, not expert mode, or too small device + if (!peer.online || !csSettings.data.expertMode || UIUtils.screen.isSmall()) return peer; + var jobs = []; + // Get Version + jobs.push(node.node.summary() + .then(function(res){ + peer.version = res && res.duniter && res.duniter.version; + }) + .catch(function() { + peer.version = null; // continue + })); + + // Get hardship (only for a member peer) + if (peer.uid) { + jobs.push(node.blockchain.stats.hardship({pubkey: peer.pubkey}) + .then(function (res) { + peer.level = res && res.level; + }) + .catch(function() { + peer.level = null; // continue + })); + } + + $q.all(jobs); + return peer; }); }, diff --git a/www/js/services/wallet-services.js b/www/js/services/wallet-services.js index 5f74c5915dc3b2a40b10653e4d88e7f5e414442c..a68289ef4e32e9d3658505be390f0543ca28f8a0 100644 --- a/www/js/services/wallet-services.js +++ b/www/js/services/wallet-services.js @@ -393,7 +393,7 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser }) .catch(function(err){ // Special case for currency init (root block not exists): use now - if (err && err.ucode == BMA.errorCodes.BLOCK_NOT_FOUND && blockParts.number === '0') { + if (err && err.ucode == BMA.errorCodes.BLOCK_NOT_FOUND && blockNumber === 0) { data.sigDate = Math.trunc(new Date().getTime() / 1000); resolve(); } @@ -617,6 +617,7 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser .then(function(json){ data.currency = json.currency; data.parameters = json; + if (data.currentUD == -1) data.currentUD = data.parameters.ud0; resolve(); }) .catch(function(err) { @@ -708,10 +709,9 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser return refreshData(options); } - return $q(function(resolve, reject){ - data.loaded = false; + data.loaded = false; - $q.all([ + return $q.all([ // Get currency parameters loadParameters(), @@ -734,32 +734,30 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser // API extension api.data.raisePromise.load(data, null) .catch(function(err) { - console.debug('Error while loading wallet data, on extension point.'); + console.error('Error while loading wallet data, on extension point. Try to continue'); console.error(err); }) ]) .then(function() { // Process transactions and sources - processTransactionsAndSources() - .then(function() { - finishLoadRequirements(); // must be call after loadParameters() and loadRequirements() - - api.data.raisePromise.finishLoad(data) - .then(function() { - data.loaded = true; - resolve(data); - }); - }) - .catch(function(err) { - data.loaded = false; - reject(err); - }); + return processTransactionsAndSources(); + }) + .then(function() { + finishLoadRequirements(); // must be call after loadParameters() and loadRequirements() + return api.data.raisePromise.finishLoad(data) + .catch(function(err) { + console.error('Error while finishing wallet data load, on extension point. Try to continue'); + console.error(err); + }); + }) + .then(function() { + data.loaded = true; + return data; }) .catch(function(err) { data.loaded = false; - reject(err); + throw err; }); - }); }, loadMinData = function() { diff --git a/www/js/services/wot-services.js b/www/js/services/wot-services.js index e90ecbc028af45950c9aeb51ac68d0e45ce1ff8b..f8b4801896672f92f2a203b4e8d208d06fc521d3 100644 --- a/www/js/services/wot-services.js +++ b/www/js/services/wot-services.js @@ -251,7 +251,7 @@ angular.module('cesium.wot.services', ['ngResource', 'ngApi', 'cesium.bma.servic }) .catch(function(err){ // Special case for currency init (root block not exists): use now - if (err && err.ucode == BMA.errorCodes.BLOCK_NOT_FOUND && identity.number === '0') { + if (err && err.ucode == BMA.errorCodes.BLOCK_NOT_FOUND && identity.number === 0) { identity.sigDate = Math.trunc(new Date().getTime() / 1000); return identity; } diff --git a/www/plugins/es/js/services/comment-services.js b/www/plugins/es/js/services/comment-services.js index bcd65f69fcb5285c91205ac9b647bd13e964d67a..81845ac081d218858644773aa7055f1ad79f2ace 100644 --- a/www/plugins/es/js/services/comment-services.js +++ b/www/plugins/es/js/services/comment-services.js @@ -5,13 +5,11 @@ angular.module('cesium.es.comment.services', ['ngResource', 'cesium.bma.services function factory(host, port, wsPort, index) { - const - defaultSizeLimit = 20, + var + DEFAULT_SIZE = 20, fields = { commons: ["issuer", "time", "message", "reply_to"], - }; - - var + }, that, pendings = {}; searchRequest = esHttp.post(host, port, '/'+index+'/comment/_search'), @@ -89,10 +87,10 @@ angular.module('cesium.es.comment.services', ['ngResource', 'cesium.bma.services function loadDataByRecordId(recordId, options) { options = options || {}; options.from = options.from || 0; - options.size = options.size || defaultSizeLimit; + options.size = options.size || DEFAULT_SIZE; options.loadAvatar = angular.isDefined(options.loadAvatar) ? options.loadAvatar : true; options.loadAvatarAllParent = angular.isDefined(options.loadAvatarAllParent) ? (options.loadAvatar && options.loadAvatarAllParent) : false; - if (options.size < 0) options.size = defaultSizeLimit; + if (options.size < 0) options.size = DEFAULT_SIZE; var request = { query : { diff --git a/www/plugins/es/js/services/market-services.js b/www/plugins/es/js/services/market-services.js index a719bb95eb6bede21ef0f2b97683b19ba53f36d2..7ad79499e99006c3bd891d73fbfef11ff79e38d2 100644 --- a/www/plugins/es/js/services/market-services.js +++ b/www/plugins/es/js/services/market-services.js @@ -5,11 +5,10 @@ angular.module('cesium.es.market.services', ['ngResource', 'cesium.services', 'c function factory(host, port, wsPort) { - const + var fields = { commons: ["category", "title", "description", "issuer", "time", "location", "price", "unit", "currency", "thumbnail._content_type", "picturesCount", "type"] - }; - var + }, exports = { _internal: {}, node: { diff --git a/www/plugins/es/js/services/registry-services.js b/www/plugins/es/js/services/registry-services.js index 30e22cc62dd03f7c0dc658f46146d0306e1ed8c4..d3c5027e3b44a58990338f46ce38361351207864 100644 --- a/www/plugins/es/js/services/registry-services.js +++ b/www/plugins/es/js/services/registry-services.js @@ -5,12 +5,13 @@ angular.module('cesium.es.registry.services', ['ngResource', 'cesium.services', function factory(host, port, wsPort) { - const fields = { - commons: ["category", "title", "description", "issuer", "time", "address", "city", "thumbnail._content_type", "picturesCount", "type", "socials", "pubkey"], - comment: { - commons: ["issuer", "time", "message"], - } - }; + var + fields = { + commons: ["category", "title", "description", "issuer", "time", "address", "city", "thumbnail._content_type", "picturesCount", "type", "socials", "pubkey"], + comment: { + commons: ["issuer", "time", "message"], + } + }; var exports = { _internal: {}, diff --git a/www/plugins/es/js/services/user-services.js b/www/plugins/es/js/services/user-services.js index 52e21f7783c532305cd0feb185d1f45ea98f9bcc..1152cc3aaf4d39b17a8980acc73c6cf22c3e6c37 100644 --- a/www/plugins/es/js/services/user-services.js +++ b/www/plugins/es/js/services/user-services.js @@ -250,7 +250,7 @@ angular.module('cesium.es.user.services', ['cesium.services', 'cesium.es.http.se function onWotSearch(text, datas, deferred, pubkeyAtributeName) { deferred = deferred || $q.defer(); - if (!datas || !datas.length) { + if (!text && (!datas || !datas.length)) { deferred.resolve(datas); return deferred.promise; } diff --git a/www/templates/common/popover_profile.html b/www/templates/common/popover_profile.html index 8dab47200fd6fc76cfd5183af6fb386d2820b8d5..4c0509b861f1db01631ae72fbcd206b9c7750a71 100644 --- a/www/templates/common/popover_profile.html +++ b/www/templates/common/popover_profile.html @@ -2,7 +2,7 @@ <ion-content scroll="false"> <div class="row"> <div class="col col-33"> - <i class="avatar avatar-member" ng-if="$root.walletData.avatar" ng-class="{'royal-bg': login, 'stable-bg': !login}"></i> + <i class="avatar avatar-member" ng-if="!$root.walletData.avatar" ng-class="{'royal-bg': login, 'stable-bg': !login}"></i> <i class="avatar" ng-if="$root.walletData.avatar" style="background-image: url({{$root.walletData.avatar.src}})"></i> </div> <div class="col col-66" ng-if="login">