diff --git a/app/config.json b/app/config.json index 0ff11f6357ee82a73012b116380ce7a0e2279d6f..25bd48bc6610d404c334fc97627d6448c7ec618d 100644 --- a/app/config.json +++ b/app/config.json @@ -1,37 +1,43 @@ { "default": { - "APP_CONFIG": { - "DUNITER_NODE": "test-net.duniter.fr:9201", - "DUNITER_NODE_ES": "test-net.duniter.fr:9203", - "NEW_ISSUE_LINK": "https://github.com/duniter/cesium/issues/new?labels=bug", - "TIMEOUT": 4000, - "DEBUG": false - } - }, - - "simple": { - "APP_CONFIG": { - "DUNITER_NODE": "test-net.duniter.fr:9201", - "NEW_ISSUE_LINK": "https://github.com/duniter/cesium/issues/new?labels=bug", - "TIMEOUT": 6000, - "DEBUG": false + "timeout": 4000, + "useRelative": true, + "timeWarningExpireMembership": 5184000, + "timeWarningExpire": 7776000, + "useLocalStorage": false, + "rememberMe": false, + "showUDHistory": false, + "node": { + "host": "test-net.duniter.fr", + "port": "9201" + }, + "plugins":{ + "es": { + "enable": "false", + "host": "test-net.duniter.fr", + "port": "9203" + } } }, "dev": { - "APP_CONFIG": { - "DUNITER_NODE": "localhost:9201", - "TIMEOUT": 6000, - "DEBUG": true - } - }, - - "dev-es": { - "APP_CONFIG": { - "DUNITER_NODE": "test-net.duniter.fr:9201", - "DUNITER_NODE_ES": "192.168.0.28:9200", - "TIMEOUT": 6000, - "DEBUG": true + "timeout": 6000, + "useRelative": true, + "timeWarningExpireMembership": 5184000, + "timeWarningExpire": 7776000, + "useLocalStorage": true, + "rememberMe": true, + "showUDHistory": false, + "node": { + "host": "test-net.duniter.fr", + "port": "9201" + }, + "plugins":{ + "es": { + "enable": "true", + "host": "test-net.duniter.fr", + "port": "9203" + } } } } diff --git "a/cesium-logo.large.blue.sand-dune-250\303\227250.png" "b/cesium-logo.large.blue.sand-dune-250\303\227250.png" deleted file mode 100644 index 68fe13e1b3916829585550000d6bc4f1f0dadb42..0000000000000000000000000000000000000000 Binary files "a/cesium-logo.large.blue.sand-dune-250\303\227250.png" and /dev/null differ diff --git a/gulpfile.js b/gulpfile.js index 6a22c5eaf1d2e07a207591a13872ba83d3ad71f1..9a839a42def82f790620090478159b04262d1d24 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -117,14 +117,14 @@ gulp.task('config', function (done) { gutil.log(gutil.colors.green("Building `www/js/config.js` for `" + env + "` environment...")); var version = JSON.parse(fs.readFileSync('./package.json', 'utf8')).version; - config['APP_CONFIG']['VERSION'] = version; - config['APP_CONFIG']['BUILD_DATE'] = (new Date()).toJSON(); + config['version'] = version; + config['build'] = (new Date()).toJSON(); - // TODO : change version config.xml file + // TODO : change version in config.xml file return ngConstant({ name: 'cesium.config', - constants: config, + constants: {"csConfig": config}, stream: true, dest: 'config.js' }) diff --git a/package.json b/package.json index e9a56de3ffc9ec9577594752b1f58c15ff9c785e..cfd8a19e66cbbe00dd8ad5f9ca6386d74463607b 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,25 @@ "name": "cesium", "version": "0.1.28", "description": "Unhosted webapp client for Duniter network", + "repository": { + "type": "git", + "url": "git@github.com:duniter/cesium.git" + }, + "keywords": [ + "duniter", + "cesium", + "ionic", + "angular", + "cordova", + "crypto-currency" + ], + "author": "Duniter team", + "license": "GPLv3", + "readmeFilename": "README.md", + "bugs": { + "url": "https://github.com/duniter/cesium/issues", + "new": "https://github.com/duniter/cesium/issues/new?labels=bug" + }, "dependencies": { "delete-empty": "^0.1.3", "gulp": "^3.9.1", diff --git a/www/i18n/locale-en.json b/www/i18n/locale-en.json index d1c23bdccc8439e136f36de6b98cf5851e6df253..82d35fc4c3832164f12b77ccb41cd3e8982a41d4 100644 --- a/www/i18n/locale-en.json +++ b/www/i18n/locale-en.json @@ -224,6 +224,9 @@ "PASSWORD_NOT_CONFIRMED": "Must match previous password.", "SEND_IDENTITY_FAILED": "Error while trying to register.", "SEND_CERTIFICATION_FAILED": "Could not certify identity.", + "NEED_MEMBER_ACCOUNT_TO_CERTIFY": "You could not send certification, because your account is <b>not</b> a member account.", + "NEED_MEMBER_ACCOUNT_TO_CERTIFY_HAS_SELF": "You could not send certification now, because your are a member yet.<br/>Be patient ! ;-)", + "NOT_MEMBER_FOR_CERTIFICATION": "Votre compte n'est pas encore membre.", "LOGIN_FAILED": "Error while sign in.", "LOAD_IDENTITY_FAILED": "Could not load identity.", "LOAD_REQUIREMENTS_FAILED": "Could not load identity requirements.", @@ -252,7 +255,8 @@ "INVALID_NODE_SUMMARY": "Unreachable node or invalid address", "INVALID_USER_ID": "Field 'pseudonym' must not contains spaces or special caracters.", "INVALID_COMMENT": "Field 'reference' has a bad format.", - "INVALID_PUBKEY": "Public key has a bad format." + "INVALID_PUBKEY": "Public key has a bad format.", + "IDENTITY_SANDBOX_FULL": "Duniter node could not received new identity, beacause it's sandbox is full.<br/><br/>Please retry later or change your node (in <b>Settings</b>)." }, "INFO": { "POPUP_TITLE": "Information", diff --git a/www/i18n/locale-fr-FR.json b/www/i18n/locale-fr-FR.json index 110ff1b7bdf6a4888dc8ea0ea4b4b75b27390670..fc48e267c8c841776722d6ae7b10043973f96984 100644 --- a/www/i18n/locale-fr-FR.json +++ b/www/i18n/locale-fr-FR.json @@ -222,8 +222,11 @@ "FIELD_TOO_LONG": "Valeur trop longue", "FIELD_ACCENT": "Caractères accentués et virgules non autorisés", "PASSWORD_NOT_CONFIRMED": "Ne correspond pas au mot de passe.", - "SEND_IDENTITY_FAILED": "Erreur pendant l'inscription.", - "SEND_CERTIFICATION_FAILED": "Erreur lors de la certification de l'identité.", + "SEND_IDENTITY_FAILED": "Echec de l'inscription.", + "SEND_CERTIFICATION_FAILED": "Echec de la certification.", + "NEED_MEMBER_ACCOUNT_TO_CERTIFY": "Vous ne pouvez pas effectuer de certification, car votre compte n'est <b>pas membre</b>.", + "NEED_MEMBER_ACCOUNT_TO_CERTIFY_HAS_SELF": "Vous ne pouvez pas certifier quelqu'un, car vous n'etes pas encore devenu membre.<br/>Patience ! ;-)", + "NOT_MEMBER_FOR_CERTIFICATION": "Votre compte n'est pas encore membre.", "LOGIN_FAILED": "Erreur lors de l'authentification.", "LOAD_IDENTITY_FAILED": "Erreur de chargement de l'identité.", "LOAD_REQUIREMENTS_FAILED": "Erreur de chargement des prérequis de l'ientité.", @@ -252,7 +255,8 @@ "INVALID_NODE_SUMMARY": "Noeud injoignable ou adresse invalide.", "INVALID_USER_ID": "Le champ 'pseudonyme' ne doit contenir ni espace ni caractère spécial ou accentué.", "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." + "INVALID_PUBKEY": "La clé publique n'a pas le format attendu.", + "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>)." }, "INFO": { "POPUP_TITLE": "Information", diff --git a/www/index.html b/www/index.html index 752c2b4eb45a0e9deeee92144adf75e95ecb2e32..bae90aebbf03ee1b2302d5d721aa6b6b9ef87371 100644 --- a/www/index.html +++ b/www/index.html @@ -51,6 +51,8 @@ <!-- endbuild --> <!-- build:js dist_js/cesium.js --> <!-- services --> + <script src="dist/dist_js/app/services/settings-services.js"></script> + <script src="dist/dist_js/app/services/network-services.js"></script> <script src="dist/dist_js/app/services/crypto-services.js"></script> <script src="dist/dist_js/app/services/utils-services.js"></script> <script src="dist/dist_js/app/services/modal-services.js"></script> diff --git a/www/js/app.js b/www/js/app.js index fe544df69a9840fd4754b8f0d261d2f311ea9d8e..9c9922cbddc1bdbe8e3100a6458d684b1fbc8eff 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -119,10 +119,10 @@ angular.module('cesium', ['ionic', 'ionic-material', 'ngMessages', 'ngAnimate', .useLoaderCache(true); }) - .config(function($httpProvider, APP_CONFIG) { + .config(function($httpProvider, csConfig) { 'ngInject'; // Set default timeout - $httpProvider.defaults.timeout = !!APP_CONFIG.TIMEOUT ? APP_CONFIG.TIMEOUT : 4000 /* default timeout */; + $httpProvider.defaults.timeout = !!csConfig.TIMEOUT ? csConfig.TIMEOUT : 4000 /* default timeout */; //Enable cross domain calls $httpProvider.defaults.useXDomain = true; @@ -131,10 +131,10 @@ angular.module('cesium', ['ionic', 'ionic-material', 'ngMessages', 'ngAnimate', delete $httpProvider.defaults.headers.common['X-Requested-With']; }) - .config(function($compileProvider, APP_CONFIG) { + .config(function($compileProvider, csConfig) { 'ngInject'; - $compileProvider.debugInfoEnabled(!!APP_CONFIG.DEBUG); + $compileProvider.debugInfoEnabled(!!csConfig.DEBUG); }) .config(function($animateProvider) { diff --git a/www/js/config.js b/www/js/config.js index cc193730dc757fd31904cbc0698565af5bebbef7..29394a2ce6a2b935d4a847f31e742cd300640052 100644 --- a/www/js/config.js +++ b/www/js/config.js @@ -8,14 +8,27 @@ angular.module("cesium.config", []) -.constant("APP_CONFIG", { - "DUNITER_NODE": "test-net.duniter.fr:9201", - "DUNITER_NODE_ES": "test-net.duniter.fr:9203", - "NEW_ISSUE_LINK": "https://github.com/duniter/cesium/issues/new?labels=bug", - "TIMEOUT": 4000, - "DEBUG": false, - "VERSION": "0.1.28", - "BUILD_DATE": "2016-08-18T22:15:59.099Z" +.constant("csConfig", { + "timeout": 6000, + "useRelative": true, + "timeWarningExpireMembership": 5184000, + "timeWarningExpire": 7776000, + "useLocalStorage": true, + "rememberMe": true, + "showUDHistory": false, + "node": { + "host": "test-net.duniter.fr", + "port": "9201" + }, + "plugins": { + "es": { + "enable": "true", + "host": "test-net.duniter.fr", + "port": "9203" + } + }, + "version": "0.1.28", + "build": "2016-08-19T10:52:06.309Z" }) ; \ No newline at end of file diff --git a/www/js/controllers/app-controllers.js b/www/js/controllers/app-controllers.js index a4da971501d7c0b7d725fc19185f200a858e0fa7..ed46950a0ccb854b478d5c4f9db270f771f60f5b 100644 --- a/www/js/controllers/app-controllers.js +++ b/www/js/controllers/app-controllers.js @@ -53,17 +53,19 @@ function PluginExtensionPointController($scope, PluginService) { /** * Abstract controller (inherited by other controllers) */ -function AppController($scope, $rootScope, $ionicModal, $state, $ionicSideMenuDelegate, UIUtils, $q, $timeout, - CryptoUtils, BMA, Wallet, APP_CONFIG, $ionicHistory, Device, $ionicPopover, $translate, $filter, - Modals +function AppController($scope, $rootScope, $state, $ionicSideMenuDelegate, UIUtils, $q, $timeout, + BMA, Wallet, csConfig, $ionicHistory, Device, Modals, csSettings ) { 'ngInject'; $scope.search = { text: '', results: {} }; - $scope.config = APP_CONFIG; + $scope.config = csConfig; if (!$rootScope.walletData) { $rootScope.walletData = Wallet.data; } + if (!$rootScope.settings) { + $rootScope.settings = csSettings.data; + } //////////////////////////////////////// // Load currencies @@ -195,9 +197,9 @@ function AppController($scope, $rootScope, $ionicModal, $state, $ionicSideMenuDe return Modals.showLogin() .then(function(formData){ if (!formData) return; - Wallet.data.settings.rememberMe = formData.rememberMe; - if (Wallet.data.settings.rememberMe) { - Wallet.data.settings.useLocalStorage = true; + var rememberMeChanged = (csSettings.data.rememberMe !== formData.rememberMe); + if (rememberMeChanged) { + csSettings.data.useLocalStorage = csSettings.data.rememberMe ? true : csSettings.data.useLocalStorage; Wallet.store(); } return Wallet.login(formData.username, formData.password); diff --git a/www/js/controllers/currency-controllers.js b/www/js/controllers/currency-controllers.js index 6c1880f1434ab9fdf206f52a5326a099bec312a7..18a3368520cae1f32149e6a30c4b1a04461c3526 100644 --- a/www/js/controllers/currency-controllers.js +++ b/www/js/controllers/currency-controllers.js @@ -59,14 +59,14 @@ angular.module('cesium.currency.controllers', ['cesium.services']) ; -function CurrencyLookupController($scope, $state, $q, $timeout, UIUtils, APP_CONFIG, BMA) { +function CurrencyLookupController($scope, $state, UIUtils) { 'ngInject'; $scope.selectedCurrency = ''; $scope.knownCurrencies = []; $scope.search.looking = true; - $scope.$on('$ionicView.enter', function(e, $state) { + $scope.$on('$ionicView.enter', function() { $scope.loadCurrencies() .then(function (res) { $scope.knownCurrencies = res; @@ -91,15 +91,13 @@ function CurrencyLookupController($scope, $state, $q, $timeout, UIUtils, APP_CON }; } -function CurrencyViewController($scope, $rootScope, $state, BMA, $q, UIUtils, $interval, $timeout, Wallet, $translate) { - - PeersController.call(this, $scope, $rootScope, BMA, UIUtils, $q, $interval, $timeout); +function CurrencyViewController($scope, $q, $translate, $timeout, BMA, UIUtils, csSettings, csNetwork) { - $scope.search = {}; + $scope.loadingPeers = true; + $scope.peers = csNetwork.data.peers; $scope.formData = { - useRelative: Wallet.data.settings.useRelative + useRelative: csSettings.data.useRelative }; - $scope.knownBlocks = []; $scope.node = null; $scope.loading = true; @@ -158,11 +156,11 @@ function CurrencyViewController($scope, $rootScope, $state, BMA, $q, UIUtils, $i } $scope.node.websocket.block().on('block', function(block) { - var theFPR = fpr(block); - if ($scope.knownBlocks.indexOf(theFPR) === -1) { - $scope.knownBlocks.push(theFPR); + var buid = csNetwork.buid(block); + if (csNetwork.data.knownBlocks.indexOf(buid) === -1) { + csNetwork.data.knownBlocks.push(buid); // We wait 2s when a new block is received, just to wait for network propagation - var wait = $scope.knownBlocks.length === 1 ? 0 : 2000; + var wait = csNetwork.data.knownBlocks.length === 1 ? 0 : 2000; $timeout(function() { $scope.refresh(); }, wait); @@ -266,128 +264,16 @@ function CurrencyViewController($scope, $rootScope, $state, BMA, $q, UIUtils, $i }) .then(function(){ // Network - $scope.searchPeers(); - }); - }; -} - - -function PeersController($scope, $rootScope, BMA, UIUtils, $q, $interval, $timeout) { - - var newPeers = [], interval, lookingForPeers; - $scope.search.lookingForPeers = false; - $scope.search.peers = []; - - $scope.overviewPeers = function() { - var currents = {}, block; - for (var i = 0, len = $scope.search.peers.length; i < len; i++) { - block = $scope.search.peers[i].current; - if (block) { - var bid = fpr(block); - currents[bid] = currents[bid] || 0; - currents[bid]++; - } - } - var fprs = _.keys(currents).map(function(key) { - return { fpr: key, qty: currents[key] }; - }); - var best = _.max(fprs, function(obj) { - return obj.qty; - }); - var p; - for (var j = 0, len2 = $scope.search.peers.length; j < len2; j++) { - p = $scope.search.peers[j]; - p.hasMainConsensusBlock = fpr(p.current) == best.fpr; - p.hasConsensusBlock = !p.hasMainConsensusBlock && currents[fpr(p.current)] > 1; - } - $scope.search.peers = _.uniq($scope.search.peers, false, function(peer) { - return peer.pubkey; - }); - $scope.search.peers = _.sortBy($scope.search.peers, function(p) { - var score = 1; - score += (10000 * (p.online ? 1 : 0)); - score += (1000 * (p.hasMainConsensusBlock ? 1 : 0)); - score += (100 * (p.uid ? 1 : 0)); - return -score; + $scope.loadingPeers = true; + csNetwork.getPeers() + .then(function(peers) { + $scope.peers = peers; + $scope.loadingPeers = false; + }) + .catch(function(err) { + $scope.peers = []; + $scope.loadingPeers = false; + }) }); }; - - $scope.searchPeers = function() { - - if (interval) { - $interval.cancel(interval); - } - - interval = $interval(function() { - if (newPeers.length) { - $scope.search.peers = $scope.search.peers.concat(newPeers.splice(0)); - $scope.overviewPeers(); - } else if (lookingForPeers && !$scope.search.lookingForPeers) { - // The peer lookup endend, we can make a clean final report - $timeout(function(){ - lookingForPeers = false; - $scope.overviewPeers(); - }, 1000); - } - }, 1000); - - var known = {}; - $rootScope.memberUidsByPubkeys = {}; - $scope.search.peers = []; - $scope.search.lookingForPeers = true; - lookingForPeers = true; - return BMA.network.peering.peers({ leaves: true }) - .then(function(res){ - return BMA.wot.member.uids(true/*cache*/) - .then(function(uids){ - $rootScope.memberUidsByPubkeys = uids; - return res; - }); - }) - .then(function(res){ - return $q.all(res.leaves.map(function(leaf) { - return BMA.network.peering.peers({ leaf: leaf }) - .then(function(subres){ - var peer = subres.leaf.value; - if (peer) { - peer = new Peer(peer); - // Test each peer only once - if (!known[peer.getURL()]) { - peer.dns = peer.getDns(); - peer.blockNumber = peer.block.replace(/-.+$/, ''); - peer.uid = $rootScope.memberUidsByPubkeys[peer.pubkey]; - newPeers.push(peer); - var node = BMA.instance(peer.getURL()); - return node.blockchain.current() - .then(function(block){ - peer.current = block; - peer.online = true; - peer.server = peer.getURL(); - if ($scope.knownBlocks.indexOf(fpr(block)) === -1) { - $scope.knownBlocks.push(fpr(block)); - } - }) - .catch(function(err) { - }); - } - } - }); - })) - .then(function(){ - $scope.search.lookingForPeers = false; - }); - }) - .catch(function(err) { - //console.log(err); - $scope.search.lookingForPeers = false; - }); - }; - - $scope.viewPeer = function() { - - }; -} - -function fpr(block) { - return block && [block.number, block.hash].join('-'); } diff --git a/www/js/controllers/login-controllers.js b/www/js/controllers/login-controllers.js index e7c8357fee6ae3a8e06123d28948f864a54c8910..dc4c03fe0256524e67cd6e88a2f26879b5c32c78 100644 --- a/www/js/controllers/login-controllers.js +++ b/www/js/controllers/login-controllers.js @@ -4,13 +4,13 @@ angular.module('cesium.login.controllers', ['cesium.services']) .controller('LoginModalCtrl', LoginModalController) ; -function LoginModalController($scope, $rootScope, $ionicModal, Wallet, CryptoUtils, UIUtils, $q, $state, $timeout, $ionicSideMenuDelegate, $ionicHistory, Modals) { +function LoginModalController($scope, $timeout, CryptoUtils, UIUtils, Modals, csSettings) { 'ngInject'; $scope.computing = false; $scope.pubkey = null; $scope.formData = { - rememberMe: Wallet.data.settings.rememberMe + rememberMe: csSettings.data.rememberMe }; // Login form submit diff --git a/www/js/controllers/peer-controllers.js b/www/js/controllers/peer-controllers.js index ee129522ad1e56803bb65d44704a5630ddf9b369..fd423f2b54d7219e7ab19d7560956423f869e508 100644 --- a/www/js/controllers/peer-controllers.js +++ b/www/js/controllers/peer-controllers.js @@ -3,7 +3,16 @@ function PeerController($scope, $rootScope, $ionicSlideBoxDelegate, $ionicModal, 'ngInject'; $scope.$on('$ionicView.enter', function(e, $state) { - $scope.showPeer($state.stateParams.server); + if (!$rootScope.memberUidsByPubkeys) { + BMA.wot.member.uids(true/*cache*/) + .then(function(uids){ + $rootScope.memberUidsByPubkeys = uids; + $scope.showPeer($state.stateParams.server); + }); + } + else { + $scope.showPeer($state.stateParams.server); + } }); $scope.showPeer = function(server) { diff --git a/www/js/controllers/settings-controllers.js b/www/js/controllers/settings-controllers.js index b01b86b538f035c4111a41fed7d89d73562bf71e..5ddf4b8be3eed7762c7a0cd93595ef523edda1b9 100644 --- a/www/js/controllers/settings-controllers.js +++ b/www/js/controllers/settings-controllers.js @@ -20,19 +20,19 @@ angular.module('cesium.settings.controllers', ['cesium.services', 'cesium.curren .controller('SettingsCtrl', SettingsController) ; -function SettingsController($scope, $state, UIUtils, Wallet, $translate, BMA, $q, $ionicPopup, $timeout, localStorage) { +function SettingsController($scope, $q, $ionicPopup, $timeout, $translate, UIUtils, BMA, csSettings) { 'ngInject'; - $scope.formData = angular.copy(Wallet.defaultSettings); + $scope.formData = angular.copy(csSettings.data); $scope.loading = true; $scope.$on('$ionicView.enter', function(e, $state) { $scope.loading = true; // to avoid the call of Wallet.store() $scope.locales = UIUtils.locales; $scope.formData.locale = _.findWhere($scope.locales, {id: $translate.use()}); - angular.merge($scope.formData, Wallet.data.settings); - if (Wallet.data.settings.locale && Wallet.data.settings.locale.id) { - $scope.formData.locale = _.findWhere($scope.locales, {id: Wallet.data.settings.locale.id}); + angular.merge($scope.formData, csSettings.data); + if (csSettings.data.locale && csSettings.data.locale.id) { + $scope.formData.locale = _.findWhere($scope.locales, {id: csSettings.data.locale.id}); } UIUtils.loading.hide(); $scope.loading = false; @@ -54,27 +54,26 @@ function SettingsController($scope, $state, UIUtils, Wallet, $translate, BMA, $q // Change node $scope.changeNode= function(node) { - if (!node) { - node = $scope.formData.node; - } - $scope.showNodePopup(node) - .then(function(node) { - if (node == $scope.formData.node) { + $scope.showNodePopup(node || $scope.formData.node) + .then(function(newNode) { + + if (newNode.host === $scope.formData.node.host && + newNode.port === $scope.formData.node.port) { return; // same node = nothing to do } UIUtils.loading.show(); - var nodeBMA = BMA.instance(node); + var nodeBMA = BMA.instance(newNode.host, newNode.port); nodeBMA.node.summary() // ping the node .then(function() { UIUtils.loading.hide(); - $scope.formData.node = node; + $scope.formData.node = newNode; BMA.copy(nodeBMA); }) .catch(function(err){ UIUtils.loading.hide(); UIUtils.alert.error('ERROR.INVALID_NODE_SUMMARY') .then(function(){ - $scope.changeNode(node); // loop + $scope.changeNode(newNode); // loop }); }); }); @@ -83,7 +82,7 @@ function SettingsController($scope, $state, UIUtils, Wallet, $translate, BMA, $q // Show node popup $scope.showNodePopup = function(node) { return $q(function(resolve, reject) { - $scope.formData.newNode = node; + $scope.formData.newNode = [node.host, node.port].join(':'); if (!!$scope.settingsForm) { $scope.settingsForm.$setPristine(); } @@ -113,12 +112,15 @@ function SettingsController($scope, $state, UIUtils, Wallet, $translate, BMA, $q ] }) .then(function(node) { - delete $scope.formData.newNode; if (!node) { // user cancel UIUtils.loading.hide(); return; } - resolve(node); + var parts = node.split(':'); + resolve({ + host: parts[0], + port: parts[1] || 80 + }); }); }); }); @@ -127,8 +129,8 @@ function SettingsController($scope, $state, UIUtils, Wallet, $translate, BMA, $q $scope.onSettingsChanged = function() { if (!$scope.loading) { $scope.loading = true; - angular.merge(Wallet.data.settings, $scope.formData); - Wallet.store(); + angular.merge(csSettings.data, $scope.formData); + csSettings.store(); $scope.loading = false; } }; diff --git a/www/js/controllers/transfer-controllers.js b/www/js/controllers/transfer-controllers.js index 62b265f276e649269f873a059431cd9efddd2b17..151d343bdee90a1c33be1848f80a54740d3c4c2c 100644 --- a/www/js/controllers/transfer-controllers.js +++ b/www/js/controllers/transfer-controllers.js @@ -44,7 +44,7 @@ angular.module('cesium.transfer.controllers', ['cesium.services', 'cesium.curren function TransferController($scope, $rootScope, $state, BMA, Wallet, UIUtils, $timeout, Device, $ionicPopover, $translate, $filter, $q, Modals, $ionicHistory) { 'ngInject'; - TransferModalController.call(this, $scope, $rootScope, $state, BMA, Wallet, UIUtils, $timeout, Device, $ionicPopover, $translate, $filter, $q, Modals); + TransferModalController.call(this, $scope, $rootScope, $state, BMA, Wallet, UIUtils, $timeout, Device, $ionicPopover, $translate, $filter, $q, Modals, csSettings); $scope.$on('$ionicView.enter', function(e, $state) { if (!!$state.stateParams && !!$state.stateParams.pubkey) { @@ -62,7 +62,7 @@ function TransferController($scope, $rootScope, $state, BMA, Wallet, UIUtils, $t $scope.loadWallet() .then(function(walletData) { $scope.walletData = walletData; - $scope.formData.useRelative = walletData.settings.useRelative; + $scope.formData.useRelative = csSettings.data.useRelative; $scope.onUseRelativeChanged(); UIUtils.loading.hide(); }); @@ -78,7 +78,8 @@ function TransferController($scope, $rootScope, $state, BMA, Wallet, UIUtils, $t } -function TransferModalController($scope, $rootScope, $state, BMA, Wallet, UIUtils, $timeout, Device, $ionicPopover, $translate, $filter, $q, Modals, parameters) { +function TransferModalController($scope, $rootScope, $ionicPopover, $translate, $filter, $q, BMA, Wallet, UIUtils, Modals, + csSettings, parameters) { 'ngInject'; $scope.walletData = $rootScope.walletData; @@ -87,7 +88,7 @@ function TransferModalController($scope, $rootScope, $state, BMA, Wallet, UIUtil destPub: null, amount: null, comment: null, - useRelative: Wallet.defaultSettings.useRelative, + useRelative: csSettings.data.useRelative, useComment: false }; $scope.udAmount = null; diff --git a/www/js/controllers/wallet-controllers.js b/www/js/controllers/wallet-controllers.js index c455fd6bcc42ae0892c5b573fcf1d3e5887328aa..1396eb18d6d1c87dde0399f6e7ee18d29a300115 100644 --- a/www/js/controllers/wallet-controllers.js +++ b/www/js/controllers/wallet-controllers.js @@ -32,8 +32,8 @@ angular.module('cesium.wallet.controllers', ['cesium.services', 'cesium.currency .controller('WalletTxErrorCtrl', WalletTxErrorController) ; -function WalletController($scope, $rootScope, $state, $q, $ionicPopup, $ionicActionSheet, $timeout, - UIUtils, Wallet, BMA, $translate, Device, $ionicPopover, Modals) { +function WalletController($scope, $q, $ionicPopup, $timeout, + UIUtils, Wallet, BMA, $translate, $ionicPopover, Modals, csSettings) { 'ngInject'; $scope.walletData = null; @@ -73,7 +73,7 @@ function WalletController($scope, $rootScope, $state, $q, $ionicPopup, $ionicAct if (!$scope.walletData) { return; } - if ($scope.walletData.settings.useRelative) { + if (csSettings.data.useRelative) { $scope.convertedBalance = $scope.walletData.balance ? ($scope.walletData.balance / $scope.walletData.currentUD) : 0; } else { var balance = $scope.walletData.balance; @@ -83,7 +83,7 @@ function WalletController($scope, $rootScope, $state, $q, $ionicPopup, $ionicAct $scope.convertedBalance = balance; } }; - $scope.$watch('walletData.settings.useRelative', $scope.refreshConvertedBalance, true); + csSettings.api.data.on.changed($scope, $scope.refreshConvertedBalance); $scope.$watch('walletData.balance', $scope.refreshConvertedBalance, true); // Update view @@ -241,8 +241,10 @@ function WalletController($scope, $rootScope, $state, $q, $ionicPopup, $ionicAct }) .catch(function(err){ UIUtils.loading.hide(); - UIUtils.alert.info(err); - $scope.self(); // loop + UIUtils.onError('ERROR.SEND_IDENTITY_FAILED')(err) + .then(function() { + $scope.self(); // loop + }); }); }); }; @@ -251,9 +253,6 @@ function WalletController($scope, $rootScope, $state, $q, $ionicPopup, $ionicAct $scope.membershipIn= function() { var doMembershipIn = function(retryCount) { Wallet.membership.inside() - .then(function() { - $scope.doUpdate(); - }) .catch(function(err) { if (!retryCount || retryCount <= 2) { $timeout(function() { @@ -295,9 +294,6 @@ function WalletController($scope, $rootScope, $state, $q, $ionicPopup, $ionicAct $scope.membershipOut = function() { UIUtils.loading.show(); Wallet.membership.out() - .then(function() { - $scope.doUpdate(); - }) .catch(UIUtils.onError('ERROR.SEND_MEMBERSHIP_OUT_FAILED')); }; diff --git a/www/js/controllers/wot-controllers.js b/www/js/controllers/wot-controllers.js index 1b6cd124bbf4fefd252c99cd38debb93534f7788..0acf6dc1761a4cc94b7c0d4ea9c5fb4c1e1b3bd5 100644 --- a/www/js/controllers/wot-controllers.js +++ b/www/js/controllers/wot-controllers.js @@ -234,7 +234,7 @@ function WotCertificationsViewController($scope, $state, BMA, Wallet, UIUtils, $ WotService.load(pubkey) .then(function(identity){ $scope.formData = identity; - $scope.canCertify = Wallet.isLogin() && !Wallet.isUserPubkey(pubkey) && Wallet.data.isMember; + $scope.canCertify = $scope.formData.hasSelf && (!Wallet.isLogin() || (!Wallet.isUserPubkey(pubkey))); $scope.alreadyCertified = $scope.canCertify ? !!_.findWhere(identity.certifications, { uid: Wallet.data.uid, valid: true }) : false; $scope.loading = false; @@ -254,6 +254,11 @@ function WotCertificationsViewController($scope, $state, BMA, Wallet, UIUtils, $ $scope.certify = function() { $scope.loadWallet() .then(function(walletData) { + if (!walletData.isMember) { + UIUtils.alert.error(walletData.requirements.needSelf ? + 'ERROR.NEED_MEMBER_ACCOUNT_TO_CERTIFY' : 'ERROR.NEED_MEMBER_ACCOUNT_TO_CERTIFY_HAS_SELF'); + return; + } UIUtils.loading.hide(); UIUtils.alert.confirm('CONFIRM.CERTIFY_RULES') .then(function(confirm){ diff --git a/www/js/services.js b/www/js/services.js index 2f85d603b7b0bebb195d73f0b351341ad434666e..fa593fda3bce0fa8d9255ba2ddd58e52a644ec1a 100644 --- a/www/js/services.js +++ b/www/js/services.js @@ -1,6 +1,8 @@ angular.module('cesium.services', [ 'cesium.config', + 'cesium.settings.services', 'cesium.http.services', + 'cesium.network.services', 'cesium.bma.services', 'cesium.crypto.services', 'cesium.utils.services', diff --git a/www/js/services/bma-services.js b/www/js/services/bma-services.js index 08867c85bd54e41097a33f6a4cbb879f098a032f..9bc368d59edd1ae1df2d416480c6446212e7ff3c 100644 --- a/www/js/services/bma-services.js +++ b/www/js/services/bma-services.js @@ -1,12 +1,11 @@ //var Base58, Base64, scrypt_module_factory = null, nacl_factory = null; -angular.module('cesium.bma.services', ['cesium.http.services', 'ngResource', - 'cesium.config']) +angular.module('cesium.bma.services', ['ngResource', 'cesium.http.services', 'cesium.settings.services']) -.factory('BMA', function($q, APP_CONFIG, HttpUtils) { +.factory('BMA', function($q, csSettings, HttpUtils, $rootScope) { 'ngInject'; - function BMA(server) { + function BMA(host, port) { var instance = this, @@ -15,7 +14,8 @@ angular.module('cesium.bma.services', ['cesium.http.services', 'ngResource', UID_ALREADY_USED: 2003, NO_MATCHING_MEMBER: 2004, NO_IDTY_MATCHING_PUB_OR_UID: 2021, - MEMBERSHRIP_ALREADY_SEND: 2007 + MEMBERSHIP_ALREADY_SEND: 2007, + IDENTITY_SANDBOX_FULL: 1007 }, regex = { USER_ID: "[A-Za-z0-9_-]+", @@ -29,7 +29,13 @@ angular.module('cesium.bma.services', ['cesium.http.services', 'ngResource', constants = { CACHE_TIME_MS: 60000 }, + protocol = (port === 443 ? 'https' : 'http'), + server = protocol + '://' + host + (port ? ':' + port : ''), data = { + node: { + host: host, + port: port + }, blockchain: { current: null }, @@ -57,7 +63,7 @@ angular.module('cesium.bma.services', ['cesium.http.services', 'ngResource', function getBlockchainCurrent(cache) { - var getBlockchainCurrentNoCache = HttpUtils.get('http://' + server + '/blockchain/current'); + var getBlockchainCurrentNoCache = HttpUtils.get(server + '/blockchain/current'); return $q(function(resolve, reject) { var now = new Date(); if (cache && data.blockchain.current !== null && @@ -72,13 +78,14 @@ angular.module('cesium.bma.services', ['cesium.http.services', 'ngResource', timestamp: now.getTime() }; resolve(block); - }); + }) + .catch(function(err){reject(err);}); }); } function getMembers(cache) { - var getMembersNoCache = HttpUtils.get('http://' + server + '/wot/members'); + var getMembersNoCache = HttpUtils.get(server + '/wot/members'); return $q(function(resolve, reject) { var now = new Date(); if (cache && data.wot && data.wot.members && data.wot.members.length > 0 && @@ -146,8 +153,8 @@ angular.module('cesium.bma.services', ['cesium.http.services', 'ngResource', } function getBlockchainLastUd(cache) { - var getBlockchainWithUd = HttpUtils.get('http://' + server + '/blockchain/with/ud'); - var getBlockchainBlock = HttpUtils.get('http://' + server + '/blockchain/block/:block'); + var getBlockchainWithUd = HttpUtils.get(server + '/blockchain/with/ud'); + var getBlockchainBlock = HttpUtils.get(server + '/blockchain/block/:block'); return $q(function(resolve, reject) { var now = new Date(); if (cache && data.blockchain && data.blockchain.lastUd && (now.getTime() - data.blockchain.lastUdTimestamp) <= constants.CACHE_TIME_MS){ @@ -216,7 +223,7 @@ angular.module('cesium.bma.services', ['cesium.http.services', 'ngResource', if (!currency){ if (host) { - HttpUtils.get('http://' + host + '/blockchain/parameters')() + HttpUtils.get(host + '/blockchain/parameters')() .then(function(parameters){ resolve({ uid: uid, @@ -242,7 +249,7 @@ angular.module('cesium.bma.services', ['cesium.http.services', 'ngResource', } // Check if currency are the same (between node and uri) - return HttpUtils.get('http://' + host + '/blockchain/parameters')() + return HttpUtils.get(host + '/blockchain/parameters')() .then(function(parameters){ if (parameters.currency !== currency) { throw {message: "Node's currency ["+parameters.currency+"] does not matched URI's currency ["+currency+"]."}; @@ -286,55 +293,57 @@ angular.module('cesium.bma.services', ['cesium.http.services', 'ngResource', return { node: { - summary: HttpUtils.get('http://' + server + '/node/summary'), - url: server + summary: HttpUtils.get(server + '/node/summary'), + url: server, + host: host, + port: port }, wot: { - lookup: HttpUtils.get('http://' + server + '/wot/lookup/:search'), + lookup: HttpUtils.get(server + '/wot/lookup/:search'), member: { all: getMembers, uids: getMemberUidsByPubkey, get: getMemberByPubkey }, - requirements: HttpUtils.get('http://' + server + '/wot/requirements/:pubkey'), - add: HttpUtils.post('http://' + server + '/wot/add'), - certify: HttpUtils.post('http://' + server + '/wot/certify') + requirements: HttpUtils.get(server + '/wot/requirements/:pubkey'), + add: HttpUtils.post(server + '/wot/add'), + certify: HttpUtils.post(server + '/wot/certify') }, network: { peering: { - peers: HttpUtils.get('http://' + server + '/network/peering/peers') + peers: HttpUtils.get(server + '/network/peering/peers') }, - peers: HttpUtils.get('http://' + server + '/network/peers') + peers: HttpUtils.get(server + '/network/peers') }, blockchain: { - parameters: HttpUtils.get('http://' + server + '/blockchain/parameters'), + parameters: HttpUtils.get(server + '/blockchain/parameters'), current: getBlockchainCurrent, - block: HttpUtils.get('http://' + server + '/blockchain/block/:block'), - membership: HttpUtils.post('http://' + server + '/blockchain/membership'), + block: HttpUtils.get(server + '/blockchain/block/:block'), + membership: HttpUtils.post(server + '/blockchain/membership'), stats: { - ud: HttpUtils.get('http://' + server + '/blockchain/with/ud'), - tx: HttpUtils.get('http://' + server + '/blockchain/with/tx') + ud: HttpUtils.get(server + '/blockchain/with/ud'), + tx: HttpUtils.get(server + '/blockchain/with/tx') }, lastUd: getBlockchainLastUd }, tx: { - sources: HttpUtils.get('http://' + server + '/tx/sources/:pubkey'), - process: HttpUtils.post('http://' + server + '/tx/process'), + sources: HttpUtils.get(server + '/tx/sources/:pubkey'), + process: HttpUtils.post(server + '/tx/process'), history: { - all: HttpUtils.get('http://' + server + '/tx/history/:pubkey'), - times: HttpUtils.get('http://' + server + '/tx/history/:pubkey/times/:from/:to'), - blocks: HttpUtils.get('http://' + server + '/tx/history/:pubkey/blocks/:from/:to') + all: HttpUtils.get(server + '/tx/history/:pubkey'), + times: HttpUtils.get(server + '/tx/history/:pubkey/times/:from/:to'), + blocks: HttpUtils.get(server + '/tx/history/:pubkey/blocks/:from/:to') } }, ud: { - history: HttpUtils.get('http://' + server + '/ud/history/:pubkey') + history: HttpUtils.get(server + '/ud/history/:pubkey') }, websocket: { block: function() { - return HttpUtils.ws('ws://' + server + '/ws/block'); + return HttpUtils.ws('ws://' + host + ':' + port + '/ws/block'); }, peer: function() { - return HttpUtils.ws('ws://' + server + '/ws/peer'); + return HttpUtils.ws('ws://' + host + ':' + port + '/ws/peer'); }, close : HttpUtils.closeAllWs }, @@ -361,8 +370,22 @@ angular.module('cesium.bma.services', ['cesium.http.services', 'ngResource', }; } - var service = BMA(APP_CONFIG.DUNITER_NODE, APP_CONFIG.TIMEOUT); + var service = BMA(csSettings.data.node.host, csSettings.data.node.port); service.instance = BMA; + + // Listen settings changes + csSettings.api.data.on.changed($rootScope, function(settings) { + + var nodeChanged = + (settings.node.host && settings.node.host != service.node.host) || + (settings.node.port && settings.node.port != service.node.port); + + if (nodeChanged) { + service.copy(BMA(settings.node.host, settings.node.port)); // reload BMA + } + + }); + return service; }) ; diff --git a/www/js/services/http-services.js b/www/js/services/http-services.js index 0c91f95eeefd248fb002a8e79fafbebc8ef3c6ff..0fe2275c205161555267f5020d2ccdc9d28e8c28 100644 --- a/www/js/services/http-services.js +++ b/www/js/services/http-services.js @@ -1,6 +1,6 @@ angular.module('cesium.http.services', ['ngResource']) -.factory('HttpUtils', function($http, $q, APP_CONFIG) { +.factory('HttpUtils', function($http, $q, csSettings) { 'ngInject'; function HttpUtils(timeout) { @@ -165,7 +165,7 @@ angular.module('cesium.http.services', ['ngResource']) }; } - var service = HttpUtils(APP_CONFIG.TIMEOUT); + var service = HttpUtils(csSettings.data.timeout); service.instance = HttpUtils; return service; }) diff --git a/www/js/services/network-services.js b/www/js/services/network-services.js new file mode 100644 index 0000000000000000000000000000000000000000..3c399d8467a4f3180db31ffd6b5e35a304a6c5ba --- /dev/null +++ b/www/js/services/network-services.js @@ -0,0 +1,148 @@ + +angular.module('cesium.network.services', ['ngResource', 'ngApi', 'cesium.bma.services']) + +.factory('csNetwork', function($rootScope, $q, $interval, $timeout, BMA, Api) { + 'ngInject'; + + CSNetwork = function(id) { + + var + data = { + peers: [], + newPeers: [], + knownBlocks: [] + }, + interval, + updatingPeers = false, + searchingPeersOnNetwork = false, + api = new Api(this, "csNetwork-" + id), + + buid = function(block) { + return block && [block.number, block.hash].join('-'); + }, + + processPeers = function() { + // Count peer by current block uid + var currents = {}, block; + _.forEach(data.peers, function(peer){ + if (peer.buid) { + currents[peer.buid] = currents[peer.buid] || 0; + currents[peer.buid]++; + } + }); + var buids = _.keys(currents).map(function(key) { + return { buid: key, count: currents[key] }; + }); + var mainBuid = _.max(buids, function(obj) { + return obj.count; + }).buid; + var p; + _.forEach(data.peers, function(peer){ + peer.hasMainConsensusBlock = peer.buid == mainBuid; + peer.hasConsensusBlock = !peer.hasMainConsensusBlock && currents[peer.buid] > 1; + }); + data.peers = _.uniq(data.peers, false, function(peer) { + return peer.pubkey; + }); + data.peers = _.sortBy(data.peers, function(peer) { + var score = 1; + score += (10000000 * (peer.online ? 1 : 0)); + score += (1000000 * (peer.hasMainConsensusBlock ? 1 : 0)); + score += (100 * (peer.hasConsensusBlock ? currents[peer.buid] : 0)); + score += (10 * (peer.uid ? 1 : 0)); + return -score; + }); + }, + + getPeers = function() { + return $q(function(resolve, reject){ + + if (interval) { + $interval.cancel(interval); + } + + interval = $interval(function() { + if (data.newPeers.length) { + data.peers = data.peers.concat(data.newPeers.splice(0)); + processPeers(); + } else if (updatingPeers && !searchingPeersOnNetwork) { + // The peer lookup endend, we can make a clean final report + $timeout(function(){ + updatingPeers = false; + processPeers(); + resolve(data.peers); + $interval.cancel(interval); + }, 1000); + } + }, 1000); + + var known = {}; + data.peers = []; + searchingPeersOnNetwork = true; + updatingPeers = true; + var uidsByPubkeys; + return BMA.wot.member.uids(true/*cache*/) + .then(function(uids){ + uidsByPubkeys = uids; + return BMA.network.peering.peers({ leaves: true }) + }) + .then(function(res){ + return $q.all(res.leaves.map(function(leaf) { + return BMA.network.peering.peers({ leaf: leaf }) + .then(function(subres){ + var peer = subres.leaf.value; + if (peer) { + peer = new Peer(peer); + // Test each peer only once + if (!known[peer.getURL()]) { + peer.dns = peer.getDns(); + peer.blockNumber = peer.block.replace(/-.+$/, ''); + data.newPeers.push(peer); + var node = BMA.instance(peer.getHost(), peer.getPort()); + return node.blockchain.current() + .then(function(block){ + peer.current = block; + peer.online = true; + peer.server = peer.getURL(); + peer.buid = buid(block); + peer.uid = uidsByPubkeys[peer.pubkey]; + if (data.knownBlocks.indexOf(peer.buid) === -1) { + data.knownBlocks.push(peer.buid); + } + }) + .catch(function(err) { + // nothing to do (node is DOWN ?) + }); + } + } + }); + })) + .then(function(){ + searchingPeersOnNetwork = false; + }); + }) + .catch(function(err) { + //console.log(err); + searchingPeersOnNetwork = false; + }); + }); + }; + + // Register extension points + //api.registerEvent('data', 'load'); + + return { + id: id, + buid: buid, + data: data, + getPeers: getPeers, + // api extension + api: api + }; + }; + + var service = CSNetwork('default'); + + service.instance = CSNetwork; + return service; +}); diff --git a/www/js/services/settings-services.js b/www/js/services/settings-services.js new file mode 100644 index 0000000000000000000000000000000000000000..56568ba604606808e42557fe76c51f732b7904b4 --- /dev/null +++ b/www/js/services/settings-services.js @@ -0,0 +1,96 @@ + +angular.module('cesium.settings.services', ['ngResource', 'ngApi', 'cesium.config']) + +.factory('csSettings', function($q, csConfig, Api, localStorage, $translate) { + 'ngInject'; + + CSSettings = function(id) { + + var + constants = { + STORAGE_KEY: 'CESIUM_SETTINGS' + }, + + defaultSettings = angular.merge({ + useRelative: true, + timeWarningExpireMembership: 2592000 * 2 /*=2 mois*/, + timeWarningExpire: 2592000 * 3 /*=3 mois*/, + useLocalStorage: false, + rememberMe: false, + showUDHistory: true, + locale: { + id: $translate.use() + } + }, csConfig), + + data = angular.copy(defaultSettings), + + api = new Api(this, "csSettings-" + id), + + reset = function() { + angular.merge(data, defaultSettings); + }, + + store = function(options) { + if (data.useLocalStorage) { + localStorage.setObject(constants.STORAGE_KEY, data); + } + else { + localStorage.setObject(constants.STORAGE_KEY, null); + } + + // Emit event on changed + api.data.raise.changed(data); + + }, + + restore = function() { + return $q(function(resolve, reject){ + var storedData = localStorage.getObject(constants.STORAGE_KEY); + if (!storedData) { + resolve(); + return; + } + + var localeChanged = storedData.locale && storedData.locale.id && (data.locale.id !== storedData.locale.id); + angular.merge(data, storedData); + + // Always force the usage of deffault settings + // 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); + } + + + // Emit event on changed + api.data.raisePromise.changed(data); + //resolve(); + }); + }; + + api.registerEvent('data', 'changed'); + + return { + id: id, + data: data, + reset: reset, + store: store, + restore: restore, + defaultSettings: defaultSettings, + // api extension + api: api + }; + }; + + var service = CSSettings('default'); + + service.restore(); + + service.instance = CSSettings; + return service; +}); diff --git a/www/js/services/utils-services.js b/www/js/services/utils-services.js index b3897e57cac40cec1ddcee39d1f70deef082653d..6ce78ee23fce87bf3226eaaa9743889ebe58a532 100644 --- a/www/js/services/utils-services.js +++ b/www/js/services/utils-services.js @@ -146,7 +146,7 @@ angular.module('cesium.utils.services', ['ngResource']) else { console.error(err); hideLoading(10); // timeout, to avoid bug on transfer (when error on reference) - alertError(fullMsg, subtitle); + return alertError(fullMsg, subtitle); } }; } diff --git a/www/js/services/wallet-services.js b/www/js/services/wallet-services.js index 3f2859bec3731d018c94b6a0351a7fb5b4486eaa..d76d5b575fd68139bc6a0ac1f5c22960679dc0ed 100644 --- a/www/js/services/wallet-services.js +++ b/www/js/services/wallet-services.js @@ -1,27 +1,17 @@ -angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.services', 'cesium.crypto.services', 'cesium.utils.services']) +angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.services', 'cesium.crypto.services', 'cesium.utils.services', + 'cesium.settings.services']) -.factory('Wallet', function($q, $rootScope, CryptoUtils, BMA, $translate, localStorage, $filter, Api, UIUtils) { +.factory('Wallet', function($q, $rootScope, CryptoUtils, BMA, $translate, localStorage, $filter, Api, csSettings) { 'ngInject'; Wallet = function(id) { var - events = { - SETTINGS: 'wallet-settings-changed' - }, - - defaultSettings = { - useRelative: true, - timeWarningExpireMembership: 2592000 * 2 /*=2 mois*/, - timeWarningExpire: 2592000 * 3 /*=3 mois*/, - useLocalStorage: false, - rememberMe: false, - node: BMA.node.url, - showUDHistory: true - }, - + constants = { + STORAGE_KEY: "CESIUM_DATA" + } data = { pubkey: null, keypair: { @@ -46,16 +36,6 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser loaded: false, blockUid: null, avatar: null, - settings: { - useRelative: defaultSettings.useRelative, - timeWarningExpireMembership: defaultSettings.timeWarningExpireMembership, - timeWarningExpire: defaultSettings.timeWarningExpire, - locale: {id: $translate.use()}, - useLocalStorage: defaultSettings.useLocalStorage, - rememberMe: defaultSettings.rememberMe, - node: defaultSettings.node, - showUDHistory: defaultSettings.showUDHistory - } }, api = new Api(this, 'WalletService-' + id), @@ -84,17 +64,8 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser data.loaded = false; data.blockUid = null; data.avatar = null; - if (!data.settings.useLocalStorage) { - data.settings = { - useRelative: defaultSettings.useRelative, - timeWarningExpireMembership: defaultSettings.timeWarningExpireMembership, - timeWarningExpire: defaultSettings.timeWarningExpire, - locale: {id: $translate.use()}, - useLocalStorage: defaultSettings.useLocalStorage, - rememberMe: defaultSettings.rememberMe, - node: BMA.node.url, // If changed, use the updated url - showUDHistory: defaultSettings.showUDHistory - }; + if (!csSettings.data.useLocalStorage) { + csSettings.reset(); } }, @@ -177,7 +148,7 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser // Copy result to properties data.pubkey = CryptoUtils.util.encode_base58(keypair.signPk); data.keypair = keypair; - if (data.settings.useLocalStorage) { + if (csSettings.data.useLocalStorage) { store(); } resolve(data); @@ -204,99 +175,64 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser return isLogin() && data.pubkey === pubkey; }, - store = function(options) { - if (data.settings.useLocalStorage) { - - if (!options || options.settings) { - localStorage.setObject('CESIUM_SETTINGS', data.settings); - // Send event when settings changed - $rootScope.$broadcast(events.SETTINGS); - } + store = function() { + if (csSettings.data.useLocalStorage) { - if (!options || options.data) { - if (isLogin() && data.settings.rememberMe) { - var dataToStore = { - keypair: data.keypair, - pubkey: data.pubkey - }; + if (isLogin() && csSettings.data.rememberMe) { + var dataToStore = { + keypair: data.keypair, + pubkey: data.pubkey + }; - if (data.tx && data.tx.pendings && data.tx.pendings.length>0) { - var pendings = data.tx.pendings.reduce(function(res, tx){ - return tx.time ? res.concat({ - amount: tx.amount, - time: tx.time, - hash: tx.hash - }) : res; - }, []); - if (pendings.length) { - dataToStore.tx = { - pendings: pendings - }; - } + if (data.tx && data.tx.pendings && data.tx.pendings.length>0) { + var pendings = data.tx.pendings.reduce(function(res, tx){ + return tx.time ? res.concat({ + amount: tx.amount, + time: tx.time, + hash: tx.hash + }) : res; + }, []); + if (pendings.length) { + dataToStore.tx = { + pendings: pendings + }; } - - localStorage.setObject('CESIUM_DATA', dataToStore); - } - else { - localStorage.setObject('CESIUM_DATA', null); } + + localStorage.setObject(constants.STORAGE_KEY, dataToStore); + } + else { + localStorage.setObject(constants.STORAGE_KEY, null); } } else { - localStorage.setObject('CESIUM_SETTINGS', null); - localStorage.setObject('CESIUM_DATA', null); - // Send event when settings changed - $rootScope.$broadcast(events.SETTINGS); + localStorage.setObject(constants.STORAGE_KEY, null); } - }, restore = function() { return $q(function(resolve, reject){ - var settings = localStorage.getObject('CESIUM_SETTINGS'); - var dataStr = localStorage.get('CESIUM_DATA'); - if (!settings && !dataStr) { + var dataStr = localStorage.get(constants.STORAGE_KEY); + if (!dataStr) { resolve(); return; } - var nodeChanged = (settings && settings.node) && (data.settings.node != settings.node); - if (nodeChanged) { - BMA.copy(BMA.instance(settings.node)); // reload BMA - data.loaded = false; - } - if (settings) { - var refreshLocale = settings.locale && settings.locale.id && (data.settings.locale.id !== settings.locale.id); - data.settings = settings; - - // TODO : This is a workaround for DEV (Need to implement edition in settings) - data.settings.timeWarningExpire = defaultSettings.timeWarningExpire; - data.settings.timeWarningExpireMembership = defaultSettings.timeWarningExpireMembership; - - if (refreshLocale) { - $translate.use(data.settings.locale.id); - } - } - if (dataStr) { - fromJson(dataStr, false) - .then(function(storedData){ - if (storedData && storedData.keypair && storedData.pubkey) { - data.keypair = storedData.keypair; - data.pubkey = storedData.pubkey; - if (storedData.tx && storedData.tx.pendings) { - data.tx.pendings = storedData.tx.pendings; - } - data.loaded = false; + fromJson(dataStr, false) + .then(function(storedData){ + if (storedData && storedData.keypair && storedData.pubkey) { + data.keypair = storedData.keypair; + data.pubkey = storedData.pubkey; + if (storedData.tx && storedData.tx.pendings) { + data.tx.pendings = storedData.tx.pendings; } + data.loaded = false; + } - // Load parameters - // This prevent timeout error, when loading a market record after a browser refresh (e.g. F5) - return loadParameters(); - }) - .catch(function(err){reject(err);}); - } - else { - resolve(); - } + // Load parameters + // This prevent timeout error, when loading a market record after a browser refresh (e.g. F5) + return loadParameters(); + }) + .catch(function(err){reject(err);}); }); }, @@ -356,13 +292,13 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser data.requirements.needMembership = (data.requirements.membershipExpiresIn === 0 && data.requirements.membershipPendingExpiresIn <= 0 ); data.requirements.needRenew = (!data.requirements.needMembership && - data.requirements.membershipExpiresIn <= data.settings.timeWarningExpireMembership && + data.requirements.membershipExpiresIn <= csSettings.data.timeWarningExpireMembership && data.requirements.membershipPendingExpiresIn <= 0); data.requirements.canMembershipOut = (data.requirements.membershipExpiresIn > 0); data.requirements.pendingMembership = (data.requirements.membershipPendingExpiresIn > 0); data.requirements.certificationCount = (idty.certifications) ? idty.certifications.length : 0; data.requirements.willExpireCertificationCount = idty.certifications ? idty.certifications.reduce(function(count, cert){ - if (cert.expiresIn <= data.settings.timeWarningExpire) { + if (cert.expiresIn <= csSettings.data.timeWarningExpire) { return count + 1; } return count; @@ -435,7 +371,7 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser reduceTxAndPush(res.history.pending, txPendings, processedTxMap, false/*exclude pending*/); })); // get UD history - if (data.settings.showUDHistory) { + if (csSettings.data.showUDHistory) { jobs.push( BMA.ud.history({pubkey: data.pubkey}) .then(function(res){ @@ -529,21 +465,23 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser }, loadParameters = function() { - if (!data.parameters || !data.currency) { - return $q(function(resolve, reject) { - BMA.blockchain.parameters() - .then(function(json){ - data.currency = json.currency; - data.parameters = json; - resolve(); - }) - .catch(function(err) { - data.currency = null; - data.parameters = null; - reject(err); - }); + return $q(function(resolve, reject) { + if (data.parameters && data.currency) { + resolve(); + return; + } + BMA.blockchain.parameters() + .then(function(json){ + data.currency = json.currency; + data.parameters = json; + resolve(); + }) + .catch(function(err) { + data.currency = null; + data.parameters = null; + reject(err); }); - } + }); }, loadUDs = function() { @@ -627,25 +565,40 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser }); }, - refreshData = function() { + refreshData = function(options) { + if (!options) { + options = { + uds: true, + requirements: true, + sources: true, + tx: true + } + } return $q(function(resolve, reject){ - $q.all([ - - // Get UDs - loadUDs(), - - // Get requirements - loadRequirements() - .then(function() { - finishLoadRequirements(); - }), - - // Get sources - loadSources(), + var jobs = []; + // Get UDs + if (options.uds) { + jobs.push(loadUDs()); + } + // Get requirements + if (options.uds) { + jobs.push(loadRequirements() + .then(function() { + finishLoadRequirements(); + })); + } + // Get sources + if (options.source) { + jobs.push(loadSources()); + } + // Get transactions + if (options.tx) { + jobs.push(loadTransactions()); + } + // API extension + jobs.push(api.data.raisePromise.load(data)); - // Get transactions - loadTransactions() - ]) + $q.all(jobs) .then(function() { // Process transactions and sources processTransactionsAndSources() @@ -794,18 +747,19 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser return; } - var tx = "Version: 2\n"; - tx += "Type: Transaction\n"; - tx += "Currency: " + data.currency + "\n"; - tx += "Locktime: 0" + "\n"; // no lock - tx += "Issuers:\n"; - tx += data.pubkey + "\n"; - tx += "Inputs:\n"; + var tx = 'Version: 3\n' + + 'Type: Transaction\n' + + 'Currency: ' + data.currency + '\n' + + 'Blockstamp: ' + block.number + '-' + block.hash + '\n' + + 'Locktime: 0\n' + // no lock + 'Issuers:\n' + + data.pubkey + '\n' + + 'Inputs:\n'; _.forEach(inputs.sources, function(source) { - // if D : D:PUBLIC_KEY:BLOCK_ID - // if T : T:T_HASH:T_INDEX - tx += source.type+":"+source.identifier+":"+source.noffset+"\n"; + // if D : AMOUNT:BASE:D:PUBLIC_KEY:BLOCK_ID + // if T : AMOUNT:BASE:T:T_HASH:T_INDEX + tx += [source.amount, source.base, source.type, source.identifier,source.noffset].join(':')+"\n"; }); tx += 'Unlocks:\n'; @@ -899,22 +853,27 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser var signedIdentity = identity + signature + '\n'; // Send signed identity BMA.wot.add({identity: signedIdentity}) - .then(function (result) { - if (!!requirements) { - // Refresh membership data - loadRequirements() - .then(function () { - resolve(); - }).catch(function (err) { - reject(err); - }); - } - else { - data.uid = uid; - data.blockUid = block.number + '-' + block.hash; - resolve(); - } - }).catch(function (err) { + .then(function (result) { + if (!!requirements) { + // Refresh membership data + loadRequirements() + .then(function () { + resolve(); + }).catch(function (err) { + reject(err); + }); + } + else { + data.uid = uid; + data.blockUid = block.number + '-' + block.hash; + resolve(); + } + }) + .catch(function (err) { + if (err && err.ucode === BMA.errorCodes.IDENTITY_SANDBOX_FULL) { + reject({ucode: BMA.errorCodes.IDENTITY_SANDBOX_FULL, message: 'ERROR.IDENTITY_SANDBOX_FULL'}); + return; + } reject(err); }); }).catch(function (err) { @@ -953,11 +912,14 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser // Send signed membership BMA.blockchain.membership({membership: signedMembership}) .then(function(result) { - // Refresh membership data - loadRequirements() - .then(function() { - resolve(); - }).catch(function(err){reject(err);}); + $timeout(function() { + loadRequirements() + .then(function() { + finishLoadRequirements(); + resolve(); + }) + .catch(function(err){reject(err);}); + }, 200); }).catch(function(err){reject(err);}); }).catch(function(err){reject(err);}); }).catch(function(err){reject(err);}); @@ -1047,6 +1009,8 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser // Register extension points api.registerEvent('data', 'load'); + csSettings.api.data.on.changed($rootScope, store); + return { id: id, data: data, @@ -1071,9 +1035,7 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser // serialization toJson: toJson, fromJson: fromJson, - defaultSettings: defaultSettings, - api: api, - events: events + api: api }; }; diff --git a/www/js/services/wot-services.js b/www/js/services/wot-services.js index 68f303e6b7eebf85c09b97a1ee4f4b9cc7a46c68..19f11b9c6265cd526632fe6920043691576ca5a5 100644 --- a/www/js/services/wot-services.js +++ b/www/js/services/wot-services.js @@ -1,7 +1,8 @@ -angular.module('cesium.wot.services', ['ngResource', 'ngApi', 'cesium.bma.services', 'cesium.crypto.services', 'cesium.utils.services']) +angular.module('cesium.wot.services', ['ngResource', 'ngApi', 'cesium.bma.services', 'cesium.crypto.services', 'cesium.utils.services', + 'cesium.settings.services']) -.factory('WotService', function($q, BMA, Api, Wallet) { +.factory('WotService', function($q, BMA, Api, csSettings) { 'ngInject'; WotService = function(id) { @@ -28,19 +29,18 @@ angular.module('cesium.wot.services', ['ngResource', 'ngApi', 'cesium.bma.servic return -score; }); } - var timeWarningExpire = Wallet.isLogin() ? Wallet.data.settings.timeWarningExpire : Wallet.defaultSettings.timeWarningExpire; var requirements = res.identities[0]; // Add useful custom fields requirements.hasSelf = true; requirements.needMembership = (requirements.membershipExpiresIn === 0 && requirements.membershipPendingExpiresIn <= 0 ); - requirements.needRenew = !requirements.needMembership && (requirements.membershipExpiresIn <= timeWarningExpire && + requirements.needRenew = !requirements.needMembership && (requirements.membershipExpiresIn <= csSettings.data.timeWarningExpire && requirements.membershipPendingExpiresIn <= 0 ); requirements.canMembershipOut = (requirements.membershipExpiresIn > 0); requirements.pendingMembership = (requirements.membershipPendingExpiresIn > 0); requirements.certificationCount = (requirements.certifications) ? requirements.certifications.length : 0; requirements.willExpireCertificationCount = requirements.certifications ? requirements.certifications.reduce(function(count, cert){ - if (cert.expiresIn <= timeWarningExpire) { + if (cert.expiresIn <= csSettings.data.timeWarningExpire) { return count + 1; } return count; @@ -95,7 +95,6 @@ angular.module('cesium.wot.services', ['ngResource', 'ngApi', 'cesium.bma.servic identity.hasSelf = !!(identity.uid && identity.timestamp && identity.sig); // Retrieve certifications - var timeWarningExpire = Wallet.isLogin() ? Wallet.data.settings.timeWarningExpire : Wallet.defaultSettings.timeWarningExpire; var expiresInByPub = requirements.certifications.reduce(function(map, cert){ map[cert.from]=cert.expiresIn; return map; @@ -112,7 +111,7 @@ angular.module('cesium.wot.services', ['ngResource', 'ngApi', 'cesium.bma.servic uid: cert.uids[0], block: (cert.meta && cert.meta.block_number) ? cert.meta.block_number : 0, expiresIn: expiresIn, - willExpire: (expiresIn && expiresIn <= timeWarningExpire), + willExpire: (expiresIn && expiresIn <= csSettings.data.timeWarningExpire), valid: (expiresIn && expiresIn > 0), isMember: cert.isMember }); diff --git a/www/plugins/es/js/controllers/common-controllers.js b/www/plugins/es/js/controllers/common-controllers.js index f6b762226174af2ea0799036572750c1e5ca8036..33f42e7157da52884082dbc6a2033306ce62060e 100644 --- a/www/plugins/es/js/controllers/common-controllers.js +++ b/www/plugins/es/js/controllers/common-controllers.js @@ -1,10 +1,10 @@ angular.module('cesium.es.common.controllers', ['ngResource', 'cesium.es.services']) // Configure menu items - .config(function(PluginServiceProvider, APP_CONFIG) { + .config(function(PluginServiceProvider, csConfig) { 'ngInject'; - var enable = !!APP_CONFIG.DUNITER_NODE_ES; + var enable = !!csConfig.DUNITER_NODE_ES; if (enable) { // Menu extension points PluginServiceProvider.extendState('app', { @@ -36,14 +36,14 @@ angular.module('cesium.es.common.controllers', ['ngResource', 'cesium.es.service /** * Control menu extension */ -function ESMenuExtendController($scope, $rootScope, PluginService, Wallet, APP_CONFIG) { +function ESMenuExtendController($scope, $rootScope, PluginService, Wallet, csConfig) { 'ngInject'; $scope.extensionPoint = PluginService.extensions.points.current.get(); $scope.refreshEnable = function() { $scope.enable = Wallet.data && Wallet.data.settings.plugins && Wallet.data.settings.plugins.es ? Wallet.data.settings.plugins.es.enable : - !!APP_CONFIG.DUNITER_NODE_ES; + !!csConfig.DUNITER_NODE_ES; }; $rootScope.$on(Wallet.events.SETTINGS, $scope.refreshEnable); diff --git a/www/plugins/es/js/controllers/settings-controllers.js b/www/plugins/es/js/controllers/settings-controllers.js index 954188b80be617b2cb4e7098ebc4c1c38e96678f..1f9a6f6ceb6e2fdd74eef8a834326d574672c4d4 100644 --- a/www/plugins/es/js/controllers/settings-controllers.js +++ b/www/plugins/es/js/controllers/settings-controllers.js @@ -1,10 +1,10 @@ angular.module('cesium.es.settings.controllers', ['cesium.es.services']) // Configure menu items - .config(function(PluginServiceProvider, $stateProvider, APP_CONFIG) { + .config(function(PluginServiceProvider, $stateProvider, csConfig) { 'ngInject'; - var enable = !!APP_CONFIG.DUNITER_NODE_ES; + var enable = !!csConfig.DUNITER_NODE_ES; if (enable) { // Extend settings via extension points PluginServiceProvider.extendState('app.settings', { @@ -38,7 +38,7 @@ angular.module('cesium.es.settings.controllers', ['cesium.es.services']) /* * Settings extend controller */ -function ESExtendSettingsController ($scope, $rootScope, Wallet, PluginService, APP_CONFIG) { +function ESExtendSettingsController ($scope, $rootScope, Wallet, PluginService, csConfig) { 'ngInject'; $scope.extensionPoint = PluginService.extensions.points.current.get(); @@ -47,7 +47,7 @@ function ESExtendSettingsController ($scope, $rootScope, Wallet, PluginService, // Update settings if need $scope.onSettingsLoaded = function() { if ($scope.loading) { - var enable = !!APP_CONFIG.DUNITER_NODE_ES; + var enable = !!csConfig.DUNITER_NODE_ES; if (enable && Wallet.data.settings && Wallet.data.settings.plugins && Wallet.data.settings.plugins.es) { enable = Wallet.data.settings.plugins.es.enable; } @@ -60,7 +60,7 @@ function ESExtendSettingsController ($scope, $rootScope, Wallet, PluginService, /* * Settings extend controller */ -function ESPluginSettingsController ($scope, $rootScope, $q, $translate, $ionicPopup, $ionicHistory, UIUtils, APP_CONFIG, esHttp, esMarket, +function ESPluginSettingsController ($scope, $rootScope, $q, $translate, $ionicPopup, $ionicHistory, UIUtils, csConfig, esHttp, esMarket, esRegistry, esUser, Wallet) { 'ngInject'; @@ -73,11 +73,11 @@ function ESPluginSettingsController ($scope, $rootScope, $q, $translate, $ionic angular.merge($scope.formData, Wallet.data.settings.plugins.es); } else { - $scope.formData.enable = !!APP_CONFIG.DUNITER_NODE_ES; + $scope.formData.enable = !!csConfig.DUNITER_NODE_ES; } if (!$scope.formData.node) { - $scope.formData.node = APP_CONFIG.DUNITER_NODE_ES; + $scope.formData.node = csConfig.DUNITER_NODE_ES; } } $scope.loading = false; diff --git a/www/plugins/es/js/services/http-services.js b/www/plugins/es/js/services/http-services.js index acbcfef319a80569379ee147c4dbdba26a9b4420..b8bd39df0e4b608c69f40cff76aadabb2d26a6e7 100644 --- a/www/plugins/es/js/services/http-services.js +++ b/www/plugins/es/js/services/http-services.js @@ -3,7 +3,7 @@ angular.module('cesium.es.http.services', ['ngResource', 'cesium.services', 'ces /** * Elastic Search Http */ -.factory('esHttp', function($q, CryptoUtils, HttpUtils, $rootScope, APP_CONFIG, Wallet) { +.factory('esHttp', function($q, CryptoUtils, HttpUtils, $rootScope, csConfig, Wallet) { 'ngInject'; function esHttp(server) { @@ -203,7 +203,7 @@ angular.module('cesium.es.http.services', ['ngResource', 'cesium.services', 'ces }; } - var service = esHttp(APP_CONFIG.DUNITER_NODE_ES); + var service = esHttp(csConfig.DUNITER_NODE_ES); service.instance = esHttp; return service; }) diff --git a/www/plugins/es/js/services/user-services.js b/www/plugins/es/js/services/user-services.js index 57cef594e701e83cecff34b13e78c04a5eb51374..9cd82e7b18561cea42c7932e39b7945bfcbed594 100644 --- a/www/plugins/es/js/services/user-services.js +++ b/www/plugins/es/js/services/user-services.js @@ -1,8 +1,8 @@ angular.module('cesium.es.user.services', ['cesium.services', 'cesium.es.http.services']) -.config(function(PluginServiceProvider, APP_CONFIG) { +.config(function(PluginServiceProvider, csConfig) { 'ngInject'; - var enable = !!APP_CONFIG.DUNITER_NODE_ES; + var enable = !!csConfig.DUNITER_NODE_ES; if (enable) { // Will force to load this service PluginServiceProvider.registerEagerLoadingService('esUser'); diff --git a/www/templates/currency/tabs/view_network.html b/www/templates/currency/tabs/view_network.html index ee491a9e73446825ee5d141ccc30259e57dda4f1..c0c34cee25b0d14c7a12c3c843d3ccc220d1239c 100644 --- a/www/templates/currency/tabs/view_network.html +++ b/www/templates/currency/tabs/view_network.html @@ -3,11 +3,11 @@ <div class="item item-divider item-icon-right"> {{'PEER.PEERS'|translate}} - <ion-spinner class="icon" icon="android" ng-if="search.lookingForPeers"></ion-spinner> + <ion-spinner class="icon" icon="android" ng-if="loadingPeers"></ion-spinner> </div> <a class="peer-item item item-icon-left" - collection-repeat="peer in search.peers" + collection-repeat="peer in peers" ng-class="{ assertive: !peer.online, balanced: (peer.online && peer.hasMainConsensusBlock), energized: (peer.online && !peer.hasMainConsensusBlock) }" ui-sref="app.view_peer(peer)"> <i class="icon ion-android-globe"></i> diff --git a/www/templates/currency/view_currency.html b/www/templates/currency/view_currency.html index c0bae04c6be82d00aa7de3f1c5bd92967cb256c5..5288c7d718922a908a67f290859569cba1ce1afc 100644 --- a/www/templates/currency/view_currency.html +++ b/www/templates/currency/view_currency.html @@ -3,17 +3,15 @@ cache-view="false" > <ion-nav-title> - {{id}} + {{currency}} </ion-nav-title> <ion-nav-buttons side="secondary"> <button class="button button-icon button-clear icon ion-loop" ng-click="refresh()"> </button> </ion-nav-buttons> - <!-- - TODO : use a ng-if to show/hide when small/large - <div class="scroll visible-xs">--> - <div class="scroll"> + + <ion-content scroll="false"> <ion-tabs class="tabs-icon-top tabs-positive has-header"> <ion-tab title="{{'CURRENCY.VIEW.TAB_CURRENCY'|translate}}" icon="ion-stats-bars"> @@ -32,17 +30,6 @@ </ion-tab> </ion-tabs> - </div> + </ion-content> - <!--<ion-content class="has-header hidden-xs"> - <div class="row scroll"> - <div class="col-50 "> - <ng-include src="'templates/explore/tabs/explore_tab_currency.html'"/> - </div> - <div class="col-50 "> - <ng-include src="'templates/explore/tabs/explore_tab_network.html'"/> - </div> - </div> - <div class="scroll-bar scroll-bar-v"></div> - </ion-content>--> </ion-view> diff --git a/www/templates/currency/view_currency_lg.html b/www/templates/currency/view_currency_lg.html index 033bec7ec8ca8da829b83559afbcc008b2dc7074..5c12809869addf4858f5220440503617771e8c32 100644 --- a/www/templates/currency/view_currency_lg.html +++ b/www/templates/currency/view_currency_lg.html @@ -11,8 +11,6 @@ <ion-content> <div class="row"> - </div> - </div> <div class="row responsive-sm"> <div class="col col-50 "> <ng-include src="'templates/currency/tabs/view_parameters.html'"></ng-include> diff --git a/www/templates/settings/settings.html b/www/templates/settings/settings.html index a26847a4f742158c67c5e179a73f4b84698ae1a0..ea8f2e47a3b457f6c06b209b0345efb5edfba840 100644 --- a/www/templates/settings/settings.html +++ b/www/templates/settings/settings.html @@ -79,7 +79,7 @@ <div class="input-label"> {{'SETTINGS.NODE' | translate}} </div> - <span class="item-note dark">{{formData.node}}</span> + <span class="item-note dark">{{formData.node.host}}<ng-if ng-if="formData.node.port && formData.node.port !== 80">:{{formData.node.port}}</ng-if></span> </div> <!-- Allow extension here --> <cs-extension-point name="network"></cs-extension-point> diff --git a/www/templates/wallet/view_wallet.html b/www/templates/wallet/view_wallet.html index e922485464035af4e1890310fa97cbaed699d5b3..2f89e958b4ef503dd169bef227a368c0a5e2d05d 100644 --- a/www/templates/wallet/view_wallet.html +++ b/www/templates/wallet/view_wallet.html @@ -26,8 +26,8 @@ <h3 class="light" ng-if="!walletData.name && walletData.isMember">{{walletData.uid}}</h3> <h3 class="light" ng-if="!walletData.name && !walletData.isMember">{{::walletData.pubkey | formatPubkey}}</h3> <h4 class="light"> - <span ng-if="!walletData.settings.useRelative">{{convertedBalance | formatInteger}} {{walletData.parameters.currency | abbreviate}}</span> - <span ng-if="walletData.settings.useRelative">{{convertedBalance | formatDecimal}} {{'COMMON.UD' | translate}}<sub>{{walletData.parameters.currency | abbreviate}}</sub></span> + <span ng-if="!$root.settings.useRelative">{{convertedBalance | formatInteger}} {{walletData.parameters.currency | abbreviate}}</span> + <span ng-if="$root.settings.useRelative">{{convertedBalance | formatDecimal}} {{'COMMON.UD' | translate}}<sub>{{walletData.parameters.currency | abbreviate}}</sub></span> </h4> </div> <h4 class="content light" ng-if="loading"> @@ -123,8 +123,8 @@ <span class="item item-pending item-divider" ng-if="walletData.tx.pendings && walletData.tx.pendings.length"> <span translate>ACCOUNT.PENDING_TX</span> <div class="badge item-note"> - <span ng-if="!walletData.settings.useRelative">({{walletData.parameters.currency | abbreviate}})</span> - <span ng-if="walletData.settings.useRelative">({{'COMMON.UD' | translate}}<sub>{{walletData.parameters.currency | abbreviate}}</sub>)</span> + <span ng-if="!$root.settings.useRelative">({{walletData.parameters.currency | abbreviate}})</span> + <span ng-if="$root.settings.useRelative">({{'COMMON.UD' | translate}}<sub>{{walletData.parameters.currency | abbreviate}}</sub>)</span> </div> </span> @@ -158,8 +158,8 @@ </h3> <div class="badge badge-pending item-note" ng-class="{'badge-balanced': tx.amount > 0}"> - <span ng-if="!walletData.settings.useRelative">{{::tx.amount | formatInteger}}</span> - <span ng-if="walletData.settings.useRelative">{{::tx.amount/walletData.currentUD | formatDecimal}}</span> + <span ng-if="!$root.settings.useRelative">{{::tx.amount | formatInteger}}</span> + <span ng-if="$root.settings.useRelative">{{::tx.amount/walletData.currentUD | formatDecimal}}</span> </div > </span> @@ -167,8 +167,8 @@ <span class="item item-divider" ng-if="!loading"> <span translate>ACCOUNT.LAST_TX</span> <div class="badge item-note"> - <span ng-if="!walletData.settings.useRelative">({{walletData.parameters.currency | abbreviate}})</span> - <span ng-if="walletData.settings.useRelative">({{'COMMON.UD' | translate}}<sub>{{walletData.parameters.currency | abbreviate}}</sub>)</span> + <span ng-if="!$root.settings.useRelative">({{walletData.parameters.currency | abbreviate}})</span> + <span ng-if="$root.settings.useRelative">({{'COMMON.UD' | translate}}<sub>{{walletData.parameters.currency | abbreviate}}</sub>)</span> </div> </span> @@ -217,8 +217,8 @@ </h3> <div class="badge item-note" ng-class="{'badge-balanced': tx.amount > 0}"> - <span ng-if="!walletData.settings.useRelative">{{::tx.amount | formatInteger}}</span> - <span ng-if="walletData.settings.useRelative">{{::tx.amount/walletData.currentUD | formatDecimal}}</span> + <span ng-if="!$root.settings.useRelative">{{::tx.amount | formatInteger}}</span> + <span ng-if="$root.settings.useRelative">{{::tx.amount/walletData.currentUD | formatDecimal}}</span> </div > </span> </div> diff --git a/www/templates/wallet/view_wallet_tx_error.html b/www/templates/wallet/view_wallet_tx_error.html index 4d0d76c6fa12d904868f53d2f29232683d888a02..c02db0fd61b8fdae648bb7366b383156a8c99a13 100644 --- a/www/templates/wallet/view_wallet_tx_error.html +++ b/www/templates/wallet/view_wallet_tx_error.html @@ -34,8 +34,8 @@ <span class="item item-divider"> <span translate>ACCOUNT.ERROR_TX_SENDED</span> <div class="badge item-note"> - <span ng-if="!walletData.settings.useRelative">({{walletData.currency | abbreviate}})</span> - <span ng-if="walletData.settings.useRelative">({{'COMMON.UD' | translate}}<sub>{{walletData.currency | abbreviate}}</sub>)</span> + <span ng-if="!$root.settings.useRelative">({{walletData.currency | abbreviate}})</span> + <span ng-if="$root.settings.useRelative">({{'COMMON.UD' | translate}}<sub>{{walletData.currency | abbreviate}}</sub>)</span> </div> </span> @@ -66,8 +66,8 @@ {{::tx.comment}}<br/> </h3> <div class="badge item-note assertive"> - <span ng-if="!walletData.settings.useRelative">{{::tx.amount | formatInteger}}</span> - <span ng-if="walletData.settings.useRelative">{{::tx.amount/walletData.currentUD | formatDecimal}}</span> + <span ng-if="!$root.settings.useRelative">{{::tx.amount | formatInteger}}</span> + <span ng-if="$root.settings.useRelative">{{::tx.amount/walletData.currentUD | formatDecimal}}</span> </div > </span> @@ -75,8 +75,8 @@ <span class="item item-divider"> <span translate>ACCOUNT.ERROR_TX_RECEIVED</span> <div class="badge item-note"> - <span ng-if="!walletData.settings.useRelative">({{walletData.currency | abbreviate}})</span> - <span ng-if="walletData.settings.useRelative">({{'COMMON.UD' | translate}}<sub>{{walletData.currency | abbreviate}}</sub>)</span> + <span ng-if="!$root.settings.useRelative">({{walletData.currency | abbreviate}})</span> + <span ng-if="$root.settings.useRelative">({{'COMMON.UD' | translate}}<sub>{{walletData.currency | abbreviate}}</sub>)</span> </div> </span> @@ -107,8 +107,8 @@ {{::tx.comment}}<br/> </h3> <div class="badge badge-assertive item-note"> - <span ng-if="!walletData.settings.useRelative">{{::tx.amount | formatInteger}}</span> - <span ng-if="walletData.settings.useRelative">{{::tx.amount/walletData.currentUD | formatDecimal}}</span> + <span ng-if="!$root.settings.useRelative">{{::tx.amount | formatInteger}}</span> + <span ng-if="$root.settings.useRelative">{{::tx.amount/walletData.currentUD | formatDecimal}}</span> </div > </span> </div> diff --git a/www/templates/wot/view_certifications.html b/www/templates/wot/view_certifications.html index 1b8667be4f1aadcfdec168cafe382df3a749783d..e013f73cedc2b4f67344c1da4c30e0e750417024 100644 --- a/www/templates/wot/view_certifications.html +++ b/www/templates/wot/view_certifications.html @@ -82,8 +82,8 @@ <!-- fab button --> <div class="visible-xs visible-sm"> <button id="fab-certify" class="button button-fab button-fab-bottom-right button-energized-900 spin" - ng-click="certifyIdentity()" - ng-if="canCertify && !alreadyCertified"> + ng-click="certify()" + ng-if="formData.hasSelf && canCertify && !alreadyCertified"> <i class="icon ion-ribbon-b"></i></button> </div>