diff --git a/www/i18n/locale-en-GB.json b/www/i18n/locale-en-GB.json index 69953ee1722ca8e3a41f94a723902ce1a57d25e3..cbb19401f213ef2c5dd92d50257487f9eb7c3606 100644 --- a/www/i18n/locale-en-GB.json +++ b/www/i18n/locale-en-GB.json @@ -395,7 +395,7 @@ "SHOW_SALT": "Display secret identifier?", "PASSWORD": "Password", "PASSWORD_HELP": "Password", - "PUBKEY_HELP": "Example: « AbsxSY4qoZRzyV2irfep1V9xw1EMNyKJw2TkuVD4N1mv »", + "PUBKEY_HELP": "Public key or pseudonym", "NO_ACCOUNT_QUESTION": "Don't have an account yet?", "CREATE_ACCOUNT": "Create an account", "FORGOTTEN_ID": "Forgot password?", diff --git a/www/i18n/locale-en.json b/www/i18n/locale-en.json index dbb57e2ce597b16eae988c85d75720b458dce849..9ac501dd1a71177a1265d7b8238e0615e509af20 100644 --- a/www/i18n/locale-en.json +++ b/www/i18n/locale-en.json @@ -395,7 +395,7 @@ "SHOW_SALT": "Display secret identifier?", "PASSWORD": "Password", "PASSWORD_HELP": "Password", - "PUBKEY_HELP": "Example: « AbsxSY4qoZRzyV2irfep1V9xw1EMNyKJw2TkuVD4N1mv »", + "PUBKEY_HELP": "Public key or pseudonym", "NO_ACCOUNT_QUESTION": "Don't have an account yet?", "CREATE_ACCOUNT": "Create an account", "FORGOTTEN_ID": "Forgot password?", diff --git a/www/i18n/locale-es-ES.json b/www/i18n/locale-es-ES.json index 26d3701549eed8b1f9d4331abd816199e3688d8e..3196779daa38ea3290d2c76c5313afdd1365ad15 100644 --- a/www/i18n/locale-es-ES.json +++ b/www/i18n/locale-es-ES.json @@ -381,7 +381,7 @@ "SHOW_SALT": "¿Visualizar el identificador secreto?", "PASSWORD": "Frase secreta", "PASSWORD_HELP": "Frase secreta", - "PUBKEY_HELP": "Ejemplo: «AbsxSY4qoZRzyV2irfep1V9xw1EMNyKJw2TkuVD4N1mv»", + "PUBKEY_HELP": "llave pública", "NO_ACCOUNT_QUESTION": "¿Aún no tiene cuenta?", "CREATE_ACCOUNT": "Crear una cuenta", "FORGOTTEN_ID": "¿Olvidó su frase secreta?", diff --git a/www/i18n/locale-fr-FR.json b/www/i18n/locale-fr-FR.json index 2580497c8f57b82dca47ab14d3227039cbc31a7d..971f91659efc5f1f4d6c0e747d0b3983a3ee0f88 100644 --- a/www/i18n/locale-fr-FR.json +++ b/www/i18n/locale-fr-FR.json @@ -395,7 +395,7 @@ "SHOW_SALT": "Afficher l'identifiant secret ?", "PASSWORD": "Mot de passe", "PASSWORD_HELP": "Mot de passe", - "PUBKEY_HELP": "Exemple : « AbsxSY4qoZRzyV2irfep1V9xw1EMNyKJw2TkuVD4N1mv »", + "PUBKEY_HELP": "Clé publique ou pseudonyme", "NO_ACCOUNT_QUESTION": "Vous n'avez pas encore de compte ?", "CREATE_ACCOUNT": "Créer un compte...", "FORGOTTEN_ID": "Mot de passe oublié ?", @@ -729,6 +729,7 @@ "ADD_SECONDARY_WALLET_FAILED": "Echec de l'ajout du portefeuille secondaire.", "UPDATE_WALLET_LIST_FAILED": "Echec du rafraichissement des portefeuilles secondaires.", "LOAD_WALLET_LIST_FAILED": "Echec du chargement des portefeuilles secondaires.", + "SAVE_WALLET_LIST_FAILED": "Echec de la sauvegarde des portefeuilles secondaires.", "COULD_NOT_ADD_MAIN_WALLET": "Le portefeuille à ajouter <b>doit être différent du compte principal</b> avec lequel vous êtes connecté.", "UNKNOWN_WALLET_ID": "Portefeuille secondaire inconnu." }, diff --git a/www/i18n/locale-it-IT.json b/www/i18n/locale-it-IT.json index 673d4e7208060e83c74c2e89ea95232c7017676d..fd900c28b095d4ffa00c8575b0fd3b93d585a95e 100644 --- a/www/i18n/locale-it-IT.json +++ b/www/i18n/locale-it-IT.json @@ -386,7 +386,7 @@ "SHOW_SALT": "Mostrare identificativo segreto?", "PASSWORD": "Passsord", "PASSWORD_HELP": "Password", - "PUBKEY_HELP": "Esempio: « AbsxSY4qoZRzyV2irfep1V9xw1EMNyKJw2TkuVD4N1mv »", + "PUBKEY_HELP": "Chiave pubblica, pseudonimo", "NO_ACCOUNT_QUESTION": "Ancora non hai un conto?", "CREATE_ACCOUNT": "Creare un conto", "FORGOTTEN_ID": "Non ricordi la password?", diff --git a/www/js/controllers/app-controllers.js b/www/js/controllers/app-controllers.js index c71edb5c30d0b1dae23fde5736031f377a558b9a..07b7d9d8092f7fe3cbc83928f49b1a9b9bc32026 100644 --- a/www/js/controllers/app-controllers.js +++ b/www/js/controllers/app-controllers.js @@ -400,12 +400,20 @@ function AppController($scope, $rootScope, $state, $ionicSideMenuDelegate, $q, $ // add listener on wallet event csWallet.api.data.on.login($scope, function(data, deferred) { $scope.login = true; - $rootScope.walletData = data || {}; + //$rootScope.walletData = data || {}; + $scope.walletData = data || {}; + // $scope.walletData = { + // pubkey: data.pubkey, + // uid: data.uid, + // name: data.name, + // avatar: data.avatar + // }; return deferred ? deferred.resolve() : $q.when(); }); csWallet.api.data.on.logout($scope, function() { $scope.login = false; - $rootScope.walletData = {}; + //$rootScope.walletData = {}; + $scope.walletData = {}; }); csWallet.api.data.on.auth($scope, function(data, deferred) { $scope.auth = true; diff --git a/www/js/controllers/login-controllers.js b/www/js/controllers/login-controllers.js index fe64e91f8f993b0abd225ede602920b77584b640..e3de96e9aeb95a5c18efc65e3b6bd55ef4c18c93 100644 --- a/www/js/controllers/login-controllers.js +++ b/www/js/controllers/login-controllers.js @@ -22,6 +22,7 @@ function LoginModalController($scope, $timeout, $q, $ionicPopover, CryptoUtils, $scope.pubkeyPattern = '^(:?{0}|{1})$'.format(BMA.constants.regexp.PUBKEY, BMA.constants.regexp.PUBKEY_WITH_CHECKSUM); $scope.isAuth = parameters.auth; + $scope.okText = parameters.okText; $scope.title = parameters.title || ($scope.isAuth ? 'AUTH.TITLE' : 'LOGIN.TITLE'); $scope.showMethods = angular.isDefined(parameters.showMethods) ? parameters.showMethods : true; $scope.showNewAccountLink = angular.isDefined(parameters.showNewAccountLink) ? parameters.showNewAccountLink : true; @@ -49,8 +50,8 @@ function LoginModalController($scope, $timeout, $q, $ionicPopover, CryptoUtils, // Init method var method = parameters.method || csSettings.data.login && csSettings.data.login.method || 'SCRYPT_DEFAULT'; var params = csSettings.data.login && csSettings.data.login.params; - if ($scope.isAuth && method == 'PUBKEY') { - method = 'SCRYPT_DEFAULT'; // PUBKEY not enable if auth need + if (($scope.isAuth && method === 'PUBKEY') || ( method === 'default')) { + method = 'SCRYPT_DEFAULT'; // PUBKEY not enable if auth need, or if ask for 'default' } $scope.changeMethod(method, params); }; diff --git a/www/js/controllers/transfer-controllers.js b/www/js/controllers/transfer-controllers.js index 12f2faa7cee67e86b568bfa2dfe8f58e6311b76e..bb3c8a6d2ccfcebb46345e7bb7818e74e5959754 100644 --- a/www/js/controllers/transfer-controllers.js +++ b/www/js/controllers/transfer-controllers.js @@ -52,37 +52,12 @@ function TransferController($scope, $controller, UIUtils) { $scope.enter = function(e, state) { - // Compute parameters from state - var parameters = {}; + // Apply state parameters if (state && state.stateParams) { - if (state.stateParams.pubkey) { - parameters.pubkey = state.stateParams.pubkey; - } - if (state.stateParams.amount) { - parameters.useRelative = false; - parameters.amount = state.stateParams.amount; - } - else if (state.stateParams.udAmount) { - parameters.useRelative = true; - parameters.udAmount = state.stateParams.udAmount; - } - if (state.stateParams.comment) { - parameters.comment = state.stateParams.comment; - } - if (state.stateParams.restPub) { - parameters.restPub = state.stateParams.restPub; - } - if (state.stateParams.all) { - parameters.all = state.stateParams.all; - $scope.formData.all = state.stateParams.all; - } - if (state.stateParams.wallet) { - parameters.wallet = state.stateParams.wallet; - } + $scope.setParameters(state.stateParams); } - // Apply parameters - $scope.setParameters(parameters); + // Load wallet return $scope.load() .then(UIUtils.loading.hide); }; @@ -355,7 +330,7 @@ function TransferModalController($scope, $q, $translate, $timeout, $filter, $foc }); }; - $scope.askTransferConfirm = function(confirmationMessage) { + $scope.askTransferConfirm = function() { return $translate(['COMMON.UD', 'COMMON.EMPTY_PARENTHESIS']) .then(function(translations) { var hasRest = $scope.formData.all && $scope.formData.restAmount > 0; diff --git a/www/js/controllers/wallet-controllers.js b/www/js/controllers/wallet-controllers.js index 23de6066a2599d50867715b030778f4d8508aa34..a8dcccc95c7d2c8d3319fa0ccc11657b0be8b8e0 100644 --- a/www/js/controllers/wallet-controllers.js +++ b/www/js/controllers/wallet-controllers.js @@ -6,7 +6,7 @@ angular.module('cesium.wallet.controllers', ['cesium.services', 'cesium.currency .state('app.view_wallet', { - url: "/wallet?refresh", + url: "/account?refresh", views: { 'menuContent': { templateUrl: "templates/wallet/view_wallet.html", @@ -20,7 +20,7 @@ angular.module('cesium.wallet.controllers', ['cesium.services', 'cesium.currency }) .state('app.view_wallet_tx', { - url: "/history?refresh", + url: "/history/account?refresh", views: { 'menuContent': { templateUrl: "templates/wallet/view_wallet_tx.html", @@ -34,7 +34,7 @@ angular.module('cesium.wallet.controllers', ['cesium.services', 'cesium.currency }) .state('app.view_wallet_tx_errors', { - url: "/wallet/tx/errors", + url: "/history/account/errors", views: { 'menuContent': { templateUrl: "templates/wallet/view_wallet_tx_error.html", @@ -60,7 +60,7 @@ angular.module('cesium.wallet.controllers', ['cesium.services', 'cesium.currency }) .state('app.view_wallet_by_id', { - url: "/wallet/list/:id?refresh", + url: "/wallets/:id?refresh", views: { 'menuContent': { templateUrl: "templates/wallet/view_wallet.html", @@ -74,7 +74,7 @@ angular.module('cesium.wallet.controllers', ['cesium.services', 'cesium.currency }) .state('app.view_wallet_tx_by_id', { - url: "/history/:id?refresh", + url: "/history/wallets/:id?refresh", views: { 'menuContent': { templateUrl: "templates/wallet/view_wallet_tx.html", @@ -86,6 +86,19 @@ angular.module('cesium.wallet.controllers', ['cesium.services', 'cesium.currency silentLocationChange: true } }) + + .state('app.view_wallet_tx_errors_by_id', { + url: "/history/wallets/:id/errors", + views: { + 'menuContent': { + templateUrl: "templates/wallet/view_wallet_tx_error.html", + controller: 'WalletTxErrorCtrl' + } + }, + data: { + login: true + } + }) ; }) @@ -143,9 +156,7 @@ function WalletController($scope, $rootScope, $q, $ionicPopup, $timeout, $state, $scope.load = function() { if (!wallet) return; - return $scope.loadWallet({ - wallet: wallet - }) + return wallet.login() .then(function(walletData) { $scope.formData = walletData; $scope.loading=false; // very important, to avoid TX to be display before wallet.currentUd is loaded @@ -538,19 +549,37 @@ function WalletController($scope, $rootScope, $q, $ionicPopup, $timeout, $state, $scope.showCertifications = function() { // Warn: do not use a simple link here (a ng-click is mandatory for help tour) - $state.go(UIUtils.screen.isSmall() ? 'app.wallet_cert' : 'app.wallet_cert_lg', { - pubkey: $scope.formData.pubkey, - uid: $scope.formData.name || $scope.formData.uid, - type: 'received' - }); + if ($scope.isDefaultWallet) { + $state.go(UIUtils.screen.isSmall() ? 'app.wallet_cert' : 'app.wallet_cert_lg', { + type: 'received' + }); + } + else { + $state.go(UIUtils.screen.isSmall() ? 'app.wallet_cert_by_id' : 'app.wallet_cert_by_id_lg', { + id: $scope.walletId, + type: 'received' + }); + } }; $scope.showGivenCertifications = function() { // Warn: do not use a simple link here (a ng-click is mandatory for help tour) + if ($scope.isDefaultWallet) { $state.go(UIUtils.screen.isSmall() ? 'app.wallet_cert' : 'app.wallet_cert_lg', { - pubkey: $scope.formData.pubkey, - uid: $scope.formData.name || $scope.formData.uid, type: 'given' + }); + } + else { + $state.go(UIUtils.screen.isSmall() ? 'app.wallet_cert_by_id' : 'app.wallet_cert_by_id_lg', { + id: $scope.walletId, + type: 'given' + }); + } + }; + + $scope.showTxHistory = function() { + $state.go($scope.isDefaultWallet ? 'app.view_wallet_tx' : 'app.view_wallet_tx_by_id', { + id: $scope.walletId }); }; @@ -727,7 +756,6 @@ function WalletTxController($scope, $ionicPopover, $state, $timeout, $location, if (!wallet) return; var options = { - wallet: wallet, minData: !wallet.isDataLoaded({minData: true}), sources: true, tx: { @@ -735,7 +763,7 @@ function WalletTxController($scope, $ionicPopover, $state, $timeout, $location, } }; - return $scope.loadWallet(options) + return wallet.login(options) .then(function(walletData) { $scope.formData = walletData; $scope.loading = false; // very important, to avoid TX to be display before wallet.currentUd is loaded @@ -997,12 +1025,26 @@ function WalletTxController($scope, $ionicPopover, $state, $timeout, $location, function WalletTxErrorController($scope, UIUtils, csSettings, csWallet) { 'ngInject'; + var wallet; $scope.settings = csSettings.data; $scope.loading = true; $scope.formData = {}; $scope.$on('$ionicView.enter', function(e) { - $scope.loadWallet() + + wallet = (state.stateParams && state.stateParams.id) ? csWallet.children.get(state.stateParams.id) : csWallet; + if (!wallet) { + UIUtils.alert.error('ERROR.UNKNOWN_WALLET_ID'); + return $scope.showHome(); + } + + return $scope.load(); + }); + + $scope.load = function() { + if (!wallet) return; + + return wallet.login() .then(function(walletData) { $scope.formData = walletData; $scope.loading = false; @@ -1010,7 +1052,7 @@ function WalletTxErrorController($scope, UIUtils, csSettings, csWallet) { $scope.showFab('fab-redo-transfer'); UIUtils.loading.hide(); }); - }); + }; // Updating wallet data $scope.doUpdate = function(silent) { @@ -1517,12 +1559,28 @@ function WalletListController($scope, $controller, $state, $timeout, $q, $transl $scope.editWallet = function(event, wallet) { event.preventDefault(); + return $scope.showEditPopup(wallet) .then(function(newName) { if (!newName) return; - wallet.data.name = newName; - $scope.$broadcast('$$rebind::' + 'rebind'); // force rebind - }); + + // Save changes + return csWallet.auth({minData: true}) + .then(function() { + wallet.data.name = newName; + csWallet.store(); + UIUtils.loading.hide(); + $scope.updateView(); + }) + .catch(function(err) { + if (err === 'CANCELLED') { + return UIUtils.loading.hide(); + } + UIUtils.onError('ERROR.SAVE_WALLET_LIST_FAILED')(err); + }); + }) + + }; /* -- modals -- */ @@ -1534,6 +1592,7 @@ function WalletListController($scope, $controller, $state, $timeout, $q, $transl return wallet.login({ showNewAccountLink: false, title: 'ACCOUNT.WALLET_LIST.BTN_NEW', + okText: 'COMMON.BTN_ADD', // Load data options : minData: true, sources: true, @@ -1550,21 +1609,27 @@ function WalletListController($scope, $controller, $state, $timeout, $q, $transl return; } - return csWallet.api.data.raisePromise.load(wallet.data) - // continue, when plugins extension failed (just log in console) - .catch(console.error) + // Make sure to auth on the main wallet + return csWallet.auth({minData: true}) .then(function() { - $scope.listeners.push(wallet.api.data.on.unauth($scope, $scope.updateView)); - $scope.listeners.push(wallet.api.data.on.auth($scope, $scope.updateView)); - csWallet.children.add(wallet); - UIUtils.loading.hide(); - $scope.motion.show({selector: '.list .item.item-wallet', ink: true}); + return csWallet.api.data.raisePromise.load(wallet.data) + // continue, when plugins extension failed (just log in console) + .catch(console.error) + .then(function() { + $scope.listeners.push(wallet.api.data.on.unauth($scope, $scope.updateView)); + $scope.listeners.push(wallet.api.data.on.auth($scope, $scope.updateView)); + csWallet.children.add(wallet); + UIUtils.loading.hide(); + $scope.updateView(); + }); + }) + .catch(function(err) { + if (err === 'CANCELLED') { + return UIUtils.loading.hide(); + } + UIUtils.onError('ERROR.ADD_SECONDARY_WALLET_FAILED')(err); }); - }) - .catch(function(err) { - if (err === 'CANCELLED') return; - UIUtils.onError('ERROR.ADD_SECONDARY_WALLET_FAILED')(err); - }); + }); }; $scope.selectAndRemoveWallet = function() { @@ -1575,7 +1640,20 @@ function WalletListController($scope, $controller, $state, $timeout, $q, $transl }) .then(function(wallet) { if (!wallet || !wallet.id) return; - csWallet.children.remove(wallet.id); + + // Make sure to auth on the main wallet + return csWallet.auth({minData: true}) + .then(function() { + csWallet.children.remove(wallet.id); + UIUtils.loading.hide(); + $scope.updateView(); + }) + .catch(function(err) { + if (err === 'CANCELLED') { + return UIUtils.loading.hide(); + } + UIUtils.onError('ERROR.ADD_SECONDARY_WALLET_FAILED')(err); + }); }); }; diff --git a/www/js/controllers/wot-controllers.js b/www/js/controllers/wot-controllers.js index ab796fb8ac56a736d80c4973e3034a3726f3214c..7098083c01adc9c1eb1ea5f25da620f00b43755a 100644 --- a/www/js/controllers/wot-controllers.js +++ b/www/js/controllers/wot-controllers.js @@ -97,7 +97,7 @@ angular.module('cesium.wot.controllers', ['cesium.services']) // wallet cert .state('app.wallet_cert', { - url: "/wallet/cert/:type", + url: "/account/cert/:type", views: { 'menuContent': { templateUrl: "templates/wot/view_certifications.html", @@ -110,7 +110,31 @@ angular.module('cesium.wot.controllers', ['cesium.services']) }) .state('app.wallet_cert_lg', { - url: "/wallet/cert/lg", + url: "/account/cert/lg", + views: { + 'menuContent': { + templateUrl: "templates/wot/view_certifications.html", + controller: 'WotCertificationsViewCtrl' + } + } + }) + + // wallet cert + .state('app.wallet_cert_by_id', { + url: "/wallets/:id/cert/:type", + views: { + 'menuContent': { + templateUrl: "templates/wot/view_certifications.html", + controller: 'WotCertificationsViewCtrl' + } + }, + data: { + large: 'app.wallet_cert_lg_by_id' + } + }) + + .state('app.wallet_cert_by_id_lg', { + url: "/wallets/:id/cert/lg", views: { 'menuContent': { templateUrl: "templates/wot/view_certifications.html", @@ -1112,6 +1136,9 @@ function WotIdentityTxViewController($scope, $timeout, $q, BMA, csSettings, csWo */ function WotCertificationsViewController($scope, $rootScope, $controller, csSettings, csWallet, UIUtils) { 'ngInject'; + + var wallet; + // Initialize the super class and extend it. angular.extend(this, $controller('WotIdentityAbstractCtrl', {$scope: $scope})); @@ -1132,39 +1159,38 @@ function WotCertificationsViewController($scope, $rootScope, $controller, csSett $scope.motions.avatar.enable = false; } - if (state.stateParams && - state.stateParams.pubkey && - state.stateParams.pubkey.trim().length > 0) { + // First load + if ($scope.loading) { + if (state.stateParams && + state.stateParams.pubkey && + state.stateParams.pubkey.trim().length > 0) { - if ($scope.loading) { // load once return $scope.load(state.stateParams.pubkey.trim(), true /*withCache*/, state.stateParams.uid) - .then(function() { + .then(function () { $scope.doMotion(); $scope.showHelpTip(); }); } - else { - $scope.doMotion(); - } - } - // Load from wallet pubkey - else if (csWallet.isLogin()){ - if ($scope.loading) { - return $scope.load(csWallet.data.pubkey, true /*withCache*/, csWallet.data.uid) - .then(function() { + else { + wallet = (state.stateParams && state.stateParams.id) ? csWallet.children.get(state.stateParams.id) : csWallet; + if (!wallet) { + UIUtils.alert.error('ERROR.UNKNOWN_WALLET_ID'); + return $scope.showHome(); + } + if (!wallet.isLogin()) { + return $scope.showHome(); + } + return $scope.load(wallet.data.pubkey, true /*withCache*/, csWallet.data.uid) + .then(function () { $scope.doMotion(); $scope.showHelpTip(); }); } - else { - $scope.doMotion(); - } } - // Redirect to home else { - $scope.showHome(); + $scope.doMotion(); } }); diff --git a/www/js/platform.js b/www/js/platform.js index 2271ad05d6d8ab29cd60e159d83506851134b5c1..a21b9c10f6f9b2fbb0265f76a34e5a46d2db3695 100644 --- a/www/js/platform.js +++ b/www/js/platform.js @@ -161,7 +161,6 @@ angular.module('cesium.platform', ['ngIdle', 'cesium.config', 'cesium.services'] return started; } - function getLatestRelease() { var latestRelease = csSettings.data.latestReleaseUrl && csHttp.uri.parse(csSettings.data.latestReleaseUrl); if (latestRelease) { diff --git a/www/js/services/wallet-services.js b/www/js/services/wallet-services.js index cefa202cf5d540e60e7c8fc3f9eb8f15f81caba3..c3d2cb5be133ea876a0d1801abd549176a574196 100644 --- a/www/js/services/wallet-services.js +++ b/www/js/services/wallet-services.js @@ -194,8 +194,16 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se } }) - // Read data from pubkey - .then(restoreData) + .then(function() { + // Read data from pubkey (when first login) + if (needLogin) { + return restoreData(); + } + // Or the was login but now auth: just try to decrypt data + else if (needAuth) { + return openEncryptedData(); + } + }) .then(function() { if (needLogin) { @@ -245,7 +253,7 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se var pubkey = data.pubkey; resetData(); // will reset keypair - store({pubkey: pubkey}); // store (if local storage enable) + resetStore(pubkey); // reset store // Send logout event api.data.raise.logout(); @@ -364,8 +372,9 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se return isLogin() && data.pubkey === pubkey; }, - store = function(options) { - var pubkey = data.pubkey || (options && options.pubkey); + // store pubkey and uid + store = function(pubkey) { + pubkey = pubkey && typeof pubkey == 'string' ? pubkey : data.pubkey; if (csSettings.data.useLocalStorage) { if (isLogin() && csSettings.data.rememberMe) { @@ -394,11 +403,6 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se jobs.push(localStorage.put(constants.STORAGE_UID, null)); } - // Store data - if (!options || !options.skipData) { - jobs.push(storeData()); - } - return $q.all(jobs) .then(function() { console.debug("[wallet] Stored in "+ (new Date().getTime() - now) +"ms"); @@ -425,10 +429,31 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se pubkey ? localStorage.put(constants.STORAGE_DATA_PREFIX + pubkey, null) : $q.when() ]); } + }, + + // reset data store for this pubkey + resetStore = function(pubkey) { + sessionStorage.put(constants.STORAGE_SECKEY, null); + localStorage.put(constants.STORAGE_PUBKEY, null); + localStorage.put(constants.STORAGE_UID, null); + + if (csSettings.data.useLocalStorage) { + // Clean data (only in the session storage - keep local) + return pubkey ? sessionStorage.put(constants.STORAGE_DATA_PREFIX + pubkey, null) : $q.when() + } + else { + return $q.all([ + pubkey ? sessionStorage.put(constants.STORAGE_DATA_PREFIX + pubkey, null) : $q.when(), + pubkey ? localStorage.put(constants.STORAGE_DATA_PREFIX + pubkey, null) : $q.when() + ]); + } }, + // store children wallet, notifications read Time, ... storeData = function() { + if (!isLogin()) throw {message:'ERROR.NEED_LOGIN_FIRST'}; + var useEncryption = csSettings.data.useLocalStorageEncryption; var storageKey = constants.STORAGE_DATA_PREFIX + data.pubkey; @@ -468,10 +493,16 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se var contentStr = (content || secureContent) && JSON.stringify(angular.merge({}, content||{}, secureContent||{})); // Not encryption (or nothing to secure content): store without encryption - if (!useEncryption || !secureContent) return contentStr && localStorage.put(storageKey, contentStr); + if (!useEncryption || !secureContent) { + return $q.all([ + sessionStorage.put(storageKey, null), // clear session storage (not used if no encryption) + localStorage.put(storageKey, contentStr || null) + ]); + } // Encryption is enable, but user not auth: use the session storage - if (!isAuth()) return contentStr && sessionStorage.put(storageKey, contentStr); + // (and keep the localstorage value) + if (!isAuth()) return sessionStorage.put(storageKey, contentStr||null); return $q.all([ // Get a unique nonce @@ -479,7 +510,7 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se // Get box keypair CryptoUtils.box.keypair.fromSignKeypair(data.keypair), // Put also (without encryption) in the session storage - contentStr ? sessionStorage.put(storageKey, contentStr) : $q.when() + sessionStorage.put(storageKey, contentStr || null) ]) .then(function(res) { var nonce = res[0]; @@ -579,7 +610,7 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se // Apply children if (content.children) { - removeAllChildrenWallets(); + removeAllChildrenWallets({store: false/*skip store*/}); _.forEach(content.children, function(child, index) { var walletId = index+1; @@ -942,8 +973,10 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se // Refresh requirements return refreshData({requirements: true, sigStock: true}) - // Store (to remember the new uid) - .then(store); + .then(function() { + // Store (to remember the new uid) + return store({skipData: true}); + }); }, isBase = function(amount, base) { @@ -1193,7 +1226,7 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se * Send a WIF wallet */ transferAll = function(destPub, amount, comments, useRelative, restPub) { - if (!isLogin()) return $q.reject('User not login !'); + if (!isLogin()) return $q.reject({message:'ERROR.NEED_LOGIN_FIRST'}); if (!restPub || destPub == restPub) { return $q.reject({message: "Could not have same pubkey for 'destPub' and 'restPub'"}); @@ -1834,14 +1867,14 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se listeners.push(listener); // Delegate start() to the parent wallet - exports.start = function() { + /*exports.start = function() { if (started) return $q.when(); return parentWallet.start() .then(function() { started = true; startPromise=null; }); - }; + };*/ }, addChildWallet = function(wallet, options) { @@ -1852,19 +1885,28 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se data.children.push(wallet); // Store (store children locally) - var finishFn = (!options || angular.isUndefined(options.store) || options.store) ? store : $q.when; - return finishFn(); + if (!options || angular.isUndefined(options.store) || options.store) { + return storeData(); + } + return $q.when(); }, - removeAllChildrenWallets = function() { + removeAllChildrenWallets = function(options) { // unauth all children wallets _.forEach(data.children || [], function(wallet){ wallet.stop(); }); - data.children = []; + data.children.splice(0, data.children.length); + + // Store (store children locally) + if (!options || angular.isUndefined(options.store) || options.store) { + return storeData(); + } + return $q.when(); + }, - removeChildWalletById = function(id) { + removeChildWalletById = function(id, options) { data.children = data.children || []; var childIndex = _.findIndex(data.children, function(child) {return child.id == id;}); if (childIndex === -1) { @@ -1877,13 +1919,24 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se // Force to stop without calling api wallet.stop(); - return wallet; + // Store (store children locally) + if (!options || angular.isUndefined(options.store) || options.store) { + return storeData(); + } }, getChildWalletById = function(id) { return _.find(data.children|| [], function(child) {return child.id == id;}); }, + getChildWalletByPubkey = function(pubkey) { + return _.find(data.children|| [], function(child) {return child.isUserPubkey(pubkey);}); + }, + + hasChildrenWithPubkey = function(pubkey) { + return !!getChildWalletByPubkey(pubkey); + }, + getChildrenWalletCount = function() { return angular.isDefined(data.childrenCount) ? data.childrenCount : (data.children && data.children.length || 0); }, @@ -1995,11 +2048,31 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se } }; + var settings = initSettingsChanged(csSettings.data); + + function initSettingsChanged(settings) { + return { + useLocalStorage: settings.useLocalStorage, + useLocalStorageEncryption: settings.useLocalStorageEncryption, + rememberMe: settings.useLocalStorage, + keepAuthIdle: settings.keepAuthIdle + }; + } + + function onSettingsChanged(newSettings) { + var hasChanged = !angular.equals(settings, initSettingsChanged(newSettings)); + if (hasChanged) { + console.debug("[wallet] Settings changed: applying to wallet (will store, and recheck idle)"); + store(); + storeData(); + checkAuthIdle(); + } + } + function addListeners() { listeners = [ // Listen if settings changed - csSettings.api.data.on.changed($rootScope, store, this), - csSettings.api.data.on.changed($rootScope, checkAuthIdle, this), + csSettings.api.data.on.changed($rootScope, onSettingsChanged, this), // Listen if node changed BMA.api.node.on.restart($rootScope, restart, this) ]; @@ -2095,8 +2168,9 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se if (id !== "default") { //start = $q.when; //started = true; - store = function(){}; + store = $q.when; restore = $q.when; + restoreData = $q.when; //checkAuthIdle = function(){}; } @@ -2134,6 +2208,7 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se }, // local storage store: store, + storeData: storeData, // store children wallet, readTime, etc. // operations transfer: transfer, transferAll: transferAll, @@ -2158,9 +2233,11 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se add: addChildWallet, remove: removeChildWalletById, get: getChildWalletById, + getByPubkey: getChildWalletByPubkey, all: getAllChildrenWallet, setParent: setParentWallet, - count: getChildrenWalletCount + count: getChildrenWalletCount, + hasPubkey: hasChildrenWithPubkey }, api: api }; diff --git a/www/plugins/es/js/controllers/group-controllers.js b/www/plugins/es/js/controllers/group-controllers.js index 7b3f31c0cbf051d3e40eb567f70419ee27e6b89d..2c75e3ebc9a4c1c5ec26377be447f60d4fca018b 100644 --- a/www/plugins/es/js/controllers/group-controllers.js +++ b/www/plugins/es/js/controllers/group-controllers.js @@ -185,7 +185,9 @@ function ESGroupViewController($scope, $state, $ionicPopover, $ionicHistory, $tr $scope.formData = {}; $scope.id = null; $scope.pictures = []; + $scope.canEdit = false; $scope.loading = true; + $scope.motion = UIUtils.motion.fadeSlideIn; $scope.$on('$ionicView.enter', function(e, state) { if (state.stateParams && state.stateParams.id) { // Load by id @@ -208,7 +210,7 @@ function ESGroupViewController($scope, $state, $ionicPopover, $ionicHistory, $tr $scope.id = data.id; $scope.formData = data.record; $scope.issuer= data.issuer; - $scope.canEdit = csWallet.isUserPubkey($scope.formData.issuer); + $scope.canEdit = csWallet.isUserPubkey($scope.formData.issuer) || csWallet.children.hasPubkey($scope.formData.issuer); $scope.pictures = data.record.pictures || []; delete data.record.pictures; // remove, as already stored in $scope.pictures diff --git a/www/plugins/es/js/controllers/invitation-controllers.js b/www/plugins/es/js/controllers/invitation-controllers.js index 59ea417666111b1542980d48f3399f83ad0241a0..5c7e6e048710647db7b7a0d47d3aee410c281d22 100644 --- a/www/plugins/es/js/controllers/invitation-controllers.js +++ b/www/plugins/es/js/controllers/invitation-controllers.js @@ -177,9 +177,7 @@ function InvitationsController($scope, $q, $ionicPopover, $state, $timeout, UIUt var readTime = lastNotification.time ? lastNotification.time : 0; if (readTime && (!wallet.data.invitations.time != readTime)) { wallet.data.invitations.readTime = readTime; - // TODO: check this ! - console.log("Resetting invitations readTime to {0}. TODO: check if store wallet is necessary !".format(readTime)); - wallet.store(); + wallet.storeData(); } }; diff --git a/www/plugins/es/js/controllers/message-controllers.js b/www/plugins/es/js/controllers/message-controllers.js index 73f6105b86a88628b2b8495bd35b557100d08039..b2f7e1c0a26bd94bb51a96ac89100cd217124710 100644 --- a/www/plugins/es/js/controllers/message-controllers.js +++ b/www/plugins/es/js/controllers/message-controllers.js @@ -117,7 +117,7 @@ angular.module('cesium.es.message.controllers', ['cesium.es.services']) ; -function ESMessageAbstractListController($scope, $state, $translate, $ionicHistory, $ionicPopover, $timeout, $filter, +function ESMessageAbstractListController($scope, $state, $translate, $ionicHistory, $ionicPopover, $timeout, csWallet, esModals, UIUtils, esMessage) { 'ngInject'; @@ -451,45 +451,25 @@ function ESMessageOutboxListController($scope, $controller) { $scope.fabButtonNewMessageId = 'fab-add-message-record-outbox'; } -function ESMessageComposeController($scope, $controller, UIUtils) { +function ESMessageComposeController($scope, $controller) { 'ngInject'; // Initialize the super class and extend it. angular.extend(this, $controller('ESMessageComposeModalCtrl', {$scope: $scope, parameters: {}})); - $scope.$on('$ionicView.enter', function(e, state) { - if (state.stateParams) { - if (state.stateParams.pubkey) { - $scope.formData.destPub = state.stateParams.pubkey; - if (state.stateParams.uid) { - $scope.destUid = state.stateParams.uid; - $scope.destPub = ''; - } - else { - $scope.destUid = ''; - $scope.destPub = $scope.formData.destPub; - } - } - if (state.stateParams.title) { - $scope.formData.title = state.stateParams.title; - } + $scope.enter = function(e, state) { - if (state.stateParams.content) { - $scope.formData.content = state.stateParams.content; - } + // Apply state parameters + if (state && state.stateParams) { + $scope.setParameters(state.stateParams); } - $scope.loadWallet({minData: true}) - .then(function() { - UIUtils.loading.hide(); - }) - .catch(function(err){ - if (err === 'CANCELLED') { - $scope.showHome(); - } - }); - }); + // Load wallet + return $scope.load() + .then(UIUtils.loading.hide); + }; + $scope.$on('$ionicView.enter',$scope.enter); $scope.cancel = function() { $scope.showHome(); @@ -508,18 +488,75 @@ function ESMessageComposeController($scope, $controller, UIUtils) { function ESMessageComposeModalController($scope, Modals, UIUtils, csWallet, esHttp, esMessage, parameters) { 'ngInject'; + var wallet; + $scope.formData = { - title: parameters ? parameters.title : null, - content: parameters ? parameters.content : null, - destPub: parameters ? parameters.destPub : null + title: null, + content: null, + destPub: null, + walletId: null + }; + $scope.destUid = null; + $scope.destPub = null; + $scope.isResponse = false; + $scope.enableSelectWallet = true; + + $scope.setParameters = function(parameters) { + if (!parameters) return; + + if (parameters.pubkey || parameters.destPub) { + $scope.formData.destPub = parameters.pubkey || parameters.destPub; + if (parameters.uid || parameters.destUid) { + $scope.destUid = parameters.uid || parameters.destUid; + $scope.destPub = ''; + } + else { + $scope.destUid = ''; + $scope.destPub = $scope.formData.destPub; + } + } + + if (parameters.title) { + $scope.formData.title = parameters.title; + } + + if (parameters.content) { + $scope.formData.content = parameters.content; + } + + $scope.isResponse = parameters.isResponse || false; + + if (parameters.wallet) { + $scope.formData.walletId = parameters.wallet; + } + }; + + // Read default parameters + $scope.setParameters(parameters); + + $scope.load = function() { + $scope.enableSelectWallet = csWallet.children.count() > 0; + + wallet = $scope.enableSelectWallet && ($scope.formData.walletId ? csWallet.children.get($scope.formData.walletId) : csWallet) || csWallet; + if (!wallet.isDefault()) { + console.debug("[message] Using {" + wallet.id + "} wallet"); + } + + return wallet.login({minData: true, silent: true}) + .then(function(data) { + $scope.walletData = data; + }) + .catch(function(err){ + if (err === 'CANCELLED') { + $scope.cancel(); + } + }) }; - $scope.destUid = parameters ? parameters.destUid : null; - $scope.destPub = (parameters && !parameters.destUid) ? parameters.destPub : null; - $scope.isResponse = parameters ? parameters.isResponse : false; + $scope.$on('modal.shown', $scope.load); $scope.doSend = function(forceNoContent) { $scope.form.$submitted=true; - if(!$scope.form.$valid /*|| !$scope.formData.destPub*/) { + if(!$scope.form.$valid) { return; } @@ -535,14 +572,14 @@ function ESMessageComposeModalController($scope, Modals, UIUtils, csWallet, esHt UIUtils.loading.show(); var data = { - issuer: csWallet.data.pubkey, + issuer: wallet.data.pubkey, recipient: $scope.formData.destPub, title: $scope.formData.title, content: $scope.formData.content, time: esHttp.date.now() }; - esMessage.send(data) + esMessage.send(data, {wallet: wallet}) .then(function(id) { $scope.id=id; UIUtils.loading.hide(); @@ -551,6 +588,11 @@ function ESMessageComposeModalController($scope, Modals, UIUtils, csWallet, esHt .catch(UIUtils.onError('MESSAGE.ERROR.SEND_MSG_FAILED')); }; + + $scope.cancel = function() { + $scope.closeModal(); + }; + /* -- Modals -- */ $scope.showWotLookupModal = function() { @@ -572,11 +614,23 @@ function ESMessageComposeModalController($scope, Modals, UIUtils, csWallet, esHt }); }; - $scope.cancel = function() { - $scope.closeModal(); + $scope.showSelectWalletModal = function() { + if (!$scope.enableSelectWallet) return; + + return Modals.showSelectWallet({ + showDefault: true, + showBalance: false + }) + .then(function(newWallet) { + if (!newWallet || (wallet && wallet.id === newWallet.id)) return; + wallet = newWallet; + $scope.walletData = wallet.data; + console.debug("[message] Using {" + wallet.id + "} wallet"); + }); }; + // TODO : for DEV only /*$timeout(function() { $scope.formData.destPub = 'G2CBgZBPLe6FSFUgpx2Jf1Aqsgta6iib3vmDRA1yLiqU'; diff --git a/www/plugins/es/js/controllers/notification-controllers.js b/www/plugins/es/js/controllers/notification-controllers.js index 4abc3a8c6fc20df50259b6b723801af6968644c8..53f38dde95d2c1f080f472ebe7f9af9d3c23488a 100644 --- a/www/plugins/es/js/controllers/notification-controllers.js +++ b/www/plugins/es/js/controllers/notification-controllers.js @@ -164,9 +164,7 @@ function NotificationsController($scope, $ionicPopover, $state, $timeout, UIUtil var readTime = lastNotification.time ? lastNotification.time : 0; if (readTime && (!wallet.data.notifications.readTime != readTime)) { wallet.data.notifications.readTime = readTime; - // TODO: check this ! - console.log("Resetting notifications readTime to {0}. TODO: check if store wallet is necessary !".format(readTime)); - wallet.store(); + wallet.storeData(); } }; diff --git a/www/plugins/es/js/controllers/profile-controllers.js b/www/plugins/es/js/controllers/profile-controllers.js index cbf8d88bd61a2ff14d65685afd535b9d2aa8dc70..cd2e2a8af18e843b07cfcf931ebc987ce4a1d3b7 100644 --- a/www/plugins/es/js/controllers/profile-controllers.js +++ b/www/plugins/es/js/controllers/profile-controllers.js @@ -18,7 +18,7 @@ angular.module('cesium.es.profile.controllers', ['cesium.es.services']) }) .state('app.edit_profile_by_id', { - url: "/wallet/list/:id/profile/edit", + url: "/wallets/:id/profile/edit", views: { 'menuContent': { templateUrl: "plugins/es/templates/user/edit_profile.html", diff --git a/www/plugins/es/js/controllers/registry-controllers.js b/www/plugins/es/js/controllers/registry-controllers.js index cd04f36f33f5bdd76982dd8e74b8a1e12b11fd66..2db3b94e916f94c6b890b4acbbfcc5f67ba2f12a 100644 --- a/www/plugins/es/js/controllers/registry-controllers.js +++ b/www/plugins/es/js/controllers/registry-controllers.js @@ -33,7 +33,7 @@ angular.module('cesium.es.registry.controllers', ['cesium.es.services', 'cesium. }) .state('app.wallet_pages', { - url: "/wallet/pages?refresh", + url: "/account/pages?refresh", views: { 'menuContent': { templateUrl: "plugins/es/templates/registry/view_wallet_pages.html", @@ -42,7 +42,23 @@ angular.module('cesium.es.registry.controllers', ['cesium.es.services', 'cesium. }, data: { login: true, - minData: true + minData: true, + silentLocationChange: true + } + }) + + .state('app.wallet_pages_by_id', { + url: "/wallets/:id/pages?refresh", + views: { + 'menuContent': { + templateUrl: "plugins/es/templates/registry/view_wallet_pages.html", + controller: 'ESWalletPagesCtrl' + } + }, + data: { + login: true, + minData: true, + silentLocationChange: true } }) @@ -68,7 +84,7 @@ angular.module('cesium.es.registry.controllers', ['cesium.es.services', 'cesium. .state('app.registry_add_record', { cache: false, - url: "/page/add/:type", + url: "/page/add/:type?wallet", views: { 'menuContent': { templateUrl: "plugins/es/templates/registry/edit_record.html", @@ -83,7 +99,7 @@ angular.module('cesium.es.registry.controllers', ['cesium.es.services', 'cesium. .state('app.registry_edit_record', { cache: false, - url: "/page/edit/:id/:title", + url: "/page/edit/:id/:title?wallet", views: { 'menuContent': { templateUrl: "plugins/es/templates/registry/edit_record.html", @@ -718,7 +734,7 @@ function ESRegistryLookupController($scope, $focus, $timeout, $filter, $controll } -function ESWalletPagesController($scope, $controller, $timeout, UIUtils, csWallet) { +function ESWalletPagesController($scope, $controller, $timeout, UIUtils, esModals, csWallet) { 'ngInject'; // Initialize the super class and extend it. @@ -726,10 +742,19 @@ function ESWalletPagesController($scope, $controller, $timeout, UIUtils, csWalle $scope.searchTextId = undefined; // avoid focus + var wallet; + // Override the default enter $scope.enter = function(e, state) { if (!$scope.entered) { - return csWallet.login({minData: true}) + + wallet = (state.stateParams && state.stateParams.id) ? csWallet.children.get(state.stateParams.id) : csWallet; + if (!wallet) { + UIUtils.alert.error('ERROR.UNKNOWN_WALLET_ID'); + return $scope.showHome(); + } + + return wallet.login({minData: true}) .then(function(walletData) { UIUtils.loading.hide(); $scope.search.issuer = walletData.pubkey; @@ -747,12 +772,18 @@ function ESWalletPagesController($scope, $controller, $timeout, UIUtils, csWalle }; $scope.doUpdate = function() { - if (!csWallet.isLogin()) return; + if (!wallet || !wallet.isLogin()) return; $scope.search.issuer = csWallet.data.pubkey; $scope.search.advanced = true; return $scope.doSearch(); }; + // Override inherited, to pass the select wallet + $scope.showNewPageModal = function() { + $scope.hidePopovers(); + return esModals.showNewPage({wallet: wallet}); + }; + } @@ -765,6 +796,7 @@ function ESRegistryRecordViewController($scope, $rootScope, $state, $q, $timeout $scope.category = {}; $scope.pictures = []; $scope.canEdit = false; + $scope.showTransfer = false; $scope.loading = true; $scope.motion = UIUtils.motion.fadeSlideIn; @@ -799,7 +831,8 @@ function ESRegistryRecordViewController($scope, $rootScope, $state, $q, $timeout $scope.id= data.id; $scope.formData = data.record; //console.debug('Loading record', $scope.formData); - $scope.canEdit = csWallet.isUserPubkey($scope.formData.issuer); + $scope.canEdit = csWallet.isUserPubkey($scope.formData.issuer) || csWallet.children.hasPubkey($scope.formData.issuer); + $scope.showTransfer = !$scope.canEdit && $scope.formData.pubkey; $scope.issuer = data.issuer; // avatar $scope.avatar = $scope.formData.avatar; @@ -872,12 +905,17 @@ function ESRegistryRecordViewController($scope, $rootScope, $state, $q, $timeout // Edit click $scope.edit = function() { UIUtils.loading.show(); - $state.go('app.registry_edit_record', {id: $scope.id}); + var wallet = csWallet.isUserPubkey($scope.formData.issuer) ? csWallet : csWallet.children.getByPubkey($scope.formData.issuer); + if (!wallet) return; + $state.go('app.registry_edit_record', {id: $scope.id, wallet: wallet.id}); }; $scope.delete = function() { $scope.hideActionsPopover(); + var wallet = csWallet.isUserPubkey($scope.formData.issuer) ? csWallet : csWallet.children.getByPubkey($scope.formData.issuer); + if (!wallet) return; + // translate var translations; $translate(['REGISTRY.VIEW.REMOVE_CONFIRMATION', 'REGISTRY.INFO.RECORD_REMOVED']) @@ -887,15 +925,21 @@ function ESRegistryRecordViewController($scope, $rootScope, $state, $q, $timeout }) .then(function(confirm) { if (confirm) { - esRegistry.record.remove($scope.id) + esRegistry.record.remove($scope.id, {wallet: wallet}) .then(function () { - if (csWallet.data.pages && csWallet.data.pages.count) { - csWallet.data.pages.count--; + if (wallet.data.pages && wallet.data.pages.count) { + wallet.data.pages.count--; } $ionicHistory.nextViewOptions({ historyRoot: true }); - $state.go('app.wallet_pages', {refresh: true}); + if (wallet.isDefault()) { + $state.go('app.wallet_pages', {refresh: true}); + } + else { + $state.go('app.wallet_pages_by_id', {refresh: true, id: wallet.id}); + } + UIUtils.toast.show(translations['REGISTRY.INFO.RECORD_REMOVED']); }) .catch(UIUtils.onError('REGISTRY.ERROR.REMOVE_RECORD_FAILED')); @@ -976,26 +1020,37 @@ function ESRegistryRecordEditController($scope, $timeout, $state, $q, $ionicHis $scope.form = form; }; + var wallet; + $scope.$on('$ionicView.enter', function(e, state) { - $scope.loadWallet({minData: true}) - .then(function(walletData) { - $scope.walletData = walletData; - if (state.stateParams && state.stateParams.id) { // Load by id - $scope.load(state.stateParams.id); - } - else { - if (state.stateParams && state.stateParams.type) { - $scope.updateView({ - record: { - type: state.stateParams.type - } - }); + + if ($scope.loading) { + wallet = (state.stateParams && state.stateParams.wallet && state.stateParams.wallet != 'default') ? csWallet.children.get(state.stateParams.wallet) : csWallet; + if (!wallet) { + UIUtils.alert.error('ERROR.UNKNOWN_WALLET_ID'); + return $scope.showHome(); + } + + return wallet.login({minData: true}) + .then(function(walletData) { + $scope.walletData = walletData; + if (state.stateParams && state.stateParams.id) { // Load by id + $scope.load(state.stateParams.id); } - } - // removeIf(device) - $focus('registry-record-title'); - // endRemoveIf(device) - }); + else { + if (state.stateParams && state.stateParams.type) { + $scope.updateView({ + record: { + type: state.stateParams.type + } + }); + } + } + // removeIf(device) + $focus('registry-record-title'); + // endRemoveIf(device) + }); + } }); $scope.$on('$stateChangeStart', function (event, next, nextParams, fromState) { @@ -1202,15 +1257,15 @@ function ESRegistryRecordEditController($scope, $timeout, $state, $q, $ionicHis .then(function(json){ // Create if (!$scope.id) { - return esRegistry.record.add(json); + return esRegistry.record.add(json, {wallet: wallet}); } // Update - return esRegistry.record.update(json, {id: $scope.id}); + return esRegistry.record.update(json, {id: $scope.id, wallet: wallet}); }) .then(function(id) { console.info("[ES] [page] Record successfully saved."); - if (!$scope.id && csWallet.data.pages && csWallet.data.pages.count) { + if (!$scope.id && wallet.data.pages && wallet.data.pages.count) { csWallet.data.pages.count++; } $scope.id = $scope.id || id; diff --git a/www/plugins/es/js/controllers/wot-controllers.js b/www/plugins/es/js/controllers/wot-controllers.js index 153aead29e0fa967fcc06629cbf0eb96f6ebdc11..634f17503946045f2d61f1fd1692f64376d7ad4c 100644 --- a/www/plugins/es/js/controllers/wot-controllers.js +++ b/www/plugins/es/js/controllers/wot-controllers.js @@ -89,17 +89,13 @@ function ESWotIdentityViewController($scope, $ionicPopover, $q, $controller, UIU // Initialize the super class and extend it. angular.extend(this, $controller('ESExtensionCtrl', {$scope: $scope})); - $scope.enter = function(e, state) { - - }; - $scope.$on('$ionicView.enter', $scope.enter); + $scope.canCertify = false; // disable certity on the popover (by default - override by the wot map controller) /* -- modals -- */ $scope.showNewMessageModal = function(confirm) { - $scope.loadWallet({minData: true}) - + return csWallet.login({minData: true, method: 'default'}) .then(function() { UIUtils.loading.hide(); @@ -133,7 +129,7 @@ function ESWotIdentityViewController($scope, $ionicPopover, $q, $controller, UIU var identities; - return $scope.selectWalletAndAuth() + return csWallet.auth({minData: true}) .then(function(walletData) { UIUtils.loading.hide(); if (!walletData) return; @@ -251,7 +247,10 @@ function ESWotIdentityViewController($scope, $ionicPopover, $q, $controller, UIU $scope.askCertification = function() { $scope.hideCertificationActionsPopover(); - return $scope.selectWalletAndAuth() + return (csWallet.children.count() ? Modals.showSelectWallet({displayBalance: false}) : $q.when(csWallet)) + .then(function(wallet) { + return wallet.auth({minData: true}); + }) .then(function(walletData) { UIUtils.loading.hide(); if (!walletData) return; @@ -283,10 +282,6 @@ function ESWotIdentityViewController($scope, $ionicPopover, $q, $controller, UIU }); }; - $scope.selectWalletAndAuth = function() { - return csWallet.isAuth() ? $q.when(csWallet.data) : csWallet.auth({minData: true}); - }; - /* -- Popover -- */ $scope.showCertificationActionsPopover = function(event) { diff --git a/www/plugins/es/js/services/message-services.js b/www/plugins/es/js/services/message-services.js index 9797c8ed63064a6a5301d6ed467a14cae0626a56..2630d2996513a4397d89502bfa3901e551f2f7e2 100644 --- a/www/plugins/es/js/services/message-services.js +++ b/www/plugins/es/js/services/message-services.js @@ -123,15 +123,20 @@ angular.module('cesium.es.message.services', ['ngResource', 'cesium.platform', }); } - function sendMessage(message) { - return csWallet.getKeypair() + function sendMessage(message, options) { + options = options || {}; + var wallet = options.wallet || csWallet; + return wallet.getKeypair() .then(function(keypair) { + + // Send to recipient inbox return doSendMessage(message, keypair) .then(function (res) { + + // Check if outbox is enable (in settings) var outbox = (csSettings.data.plugins.es.message && angular.isDefined(csSettings.data.plugins.es.message.outbox)) ? csSettings.data.plugins.es.message.outbox : true; - if (!outbox) return res; // Send to outbox @@ -142,11 +147,11 @@ angular.module('cesium.es.message.services', ['ngResource', 'cesium.platform', }); }) .then(function (res) { - // Raise event + // Raise API event api.data.raise.sent(res); return res; - }); + }) }); } diff --git a/www/plugins/es/js/services/modal-services.js b/www/plugins/es/js/services/modal-services.js index 24edc1b31270d07ab17f1cfb21a5bdfcdcdfd34a..06a11add94f65b63b4354b30633e9f5d0ae4eba1 100644 --- a/www/plugins/es/js/services/modal-services.js +++ b/www/plugins/es/js/services/modal-services.js @@ -38,8 +38,9 @@ angular.module('cesium.es.modal.services', ['cesium.modal.services', 'cesium.es. }); } - function showNewPage() { - return csWallet.auth({minData: true}) + function showNewPage(options) { + var wallet = options && options.wallet || csWallet; + return wallet.auth({minData: true}) .then(function() { UIUtils.loading.hide(); @@ -48,7 +49,7 @@ angular.module('cesium.es.modal.services', ['cesium.modal.services', 'cesium.es. }) .then(function(type){ if (type) { - $state.go('app.registry_add_record', {type: type}); + $state.go('app.registry_add_record', {type: type, wallet: wallet.id}); } }); }); diff --git a/www/plugins/es/js/services/notification-services.js b/www/plugins/es/js/services/notification-services.js index 5df41e2debba3c0b54accbdbf7a10e1461d9cf41..0e5f8840c4ab2ec532ef7a610207d218e1597afb 100644 --- a/www/plugins/es/js/services/notification-services.js +++ b/www/plugins/es/js/services/notification-services.js @@ -268,7 +268,7 @@ angular.module('cesium.es.notification.services', ['cesium.platform', 'cesium.es // Load unread notifications count loadUnreadNotificationsCount( data.pubkey, { - readTime: csSettings.data.wallet ? csSettings.data.wallet.notificationReadTime : 0, + readTime: data.notifications && data.notifications.readTime || 0, excludeCodes: constants.EXCLUDED_CODES }) .then(function(unreadCount) { diff --git a/www/plugins/es/js/services/settings-services.js b/www/plugins/es/js/services/settings-services.js index e288251e769a98a6c5e85b82f5b060fd483b25e7..3d7a52c7656c0f881fa07a158f386940e7ef0968 100644 --- a/www/plugins/es/js/services/settings-services.js +++ b/www/plugins/es/js/services/settings-services.js @@ -20,11 +20,14 @@ angular.module('cesium.es.settings.services', ['cesium.services', 'cesium.es.htt excludes: ['timeout', 'cacheTimeMs', 'time', 'login', 'build'], plugins: { es: { - excludes: ['enable', 'host', 'port', 'wsPort', 'fallbackNodes'] + excludes: ['enable', 'host', 'port', 'wsPort', 'fallbackNodes', 'enableGoogleApi', 'googleApiKey'], + notifications: { + } } }, wallet: { - includes: ['alertIfUnusedWallet', 'notificationReadTime'] + includes: ['alertIfUnusedWallet'], + excludes: ['notificationReadTime'] }, helptip: { excludes: ['installDocUrl'] @@ -39,7 +42,6 @@ angular.module('cesium.es.settings.services', ['cesium.services', 'cesium.es.htt askEnable: false, useRemoteStorage: true, notifications: { - readTime: true, txSent: true, txReceived: true, certSent: true, diff --git a/www/plugins/es/js/services/wallet-services.js b/www/plugins/es/js/services/wallet-services.js index 52fb01f96cef02e2fdcb223298b080f2b44816ea..705780a9669548c6559f24d46441ee85908d91f8 100644 --- a/www/plugins/es/js/services/wallet-services.js +++ b/www/plugins/es/js/services/wallet-services.js @@ -115,16 +115,19 @@ angular.module('cesium.es.wallet.services', ['ngResource', 'cesium.platform', 'c return (keypair ? $q.when(keypair) : csWallet.getKeypair({silent: true})) .then(function(keypair) { + // box keypair already computed: use it if (keypair && keypair.boxPk && keypair.boxSk) { return $q.when(keypair); } - return esCrypto.box.getKeypair(keypair); - }) - .then(function(res) { - keypair.boxSk = res.boxSk; - keypair.boxPk = res.boxPk; - console.debug("[ES] [wallet] Box keypair successfully computed"); - return keypair; + // Compute box keypair + return esCrypto.box.getKeypair(keypair) + .then(function(res) { + // Store in the wallet keypair + keypair.boxSk = res.boxSk; + keypair.boxPk = res.boxPk; + console.debug("[ES] [wallet] Box keypair successfully computed"); + return keypair; + }); }); } diff --git a/www/plugins/es/templates/menu_extend.html b/www/plugins/es/templates/menu_extend.html index ad92f334c06c07b1ea416dbc6be003a44142fbc8..345016d0c84d30cda3ab9342ab52f6bddefca866 100644 --- a/www/plugins/es/templates/menu_extend.html +++ b/www/plugins/es/templates/menu_extend.html @@ -10,8 +10,8 @@ active-link-path-prefix="#/app/invitations" ng-click="showInvitationsPopover($event)"> <span - ng-if="$root.walletData.invitations.unreadCount" - class="badge badge-button badge-positive">{{$root.walletData.invitations.unreadCount}}</span> + ng-if="walletData.invitations.unreadCount" + class="badge badge-button badge-positive">{{walletData.invitations.unreadCount}}</span> </button> <!-- messages --> @@ -21,8 +21,8 @@ active-link-path-prefix="#/app/user/message" ng-click="showMessagesPopover($event)"> <span - ng-if="$root.walletData.messages.unreadCount" - class="badge badge-button badge-positive">{{$root.walletData.messages.unreadCount}}</span> + ng-if="walletData.messages.unreadCount" + class="badge badge-button badge-positive">{{walletData.messages.unreadCount}}</span> </button> <!-- notifications --> @@ -32,9 +32,9 @@ active-link-path-prefix="#/app/notifications" ng-click="showNotificationsPopover($event)"> <span - ng-class="{'badge-positive': !$root.walletData.notifications.warnCount, 'badge-assertive': $root.walletData.notifications.warnCount}" - ng-if="$root.walletData.notifications.unreadCount || $root.walletData.notifications.warnCount" - class="badge badge-button ">{{$root.walletData.notifications.unreadCount+$root.walletData.notifications.warnCount}}</span> + ng-class="{'badge-positive': !walletData.notifications.warnCount, 'badge-assertive': walletData.notifications.warnCount}" + ng-if="walletData.notifications.unreadCount || walletData.notifications.warnCount" + class="badge badge-button ">{{walletData.notifications.unreadCount+walletData.notifications.warnCount}}</span> </button> </div> @@ -48,7 +48,7 @@ <i class="icon ion-person-stalker"></i> <span translate>MENU.INVITATIONS</span> <span class="badge badge-positive" - ng-if="$root.walletData.invitations.unreadCount">{{$root.walletData.invitations.unreadCount}}</span> + ng-if="walletData.invitations.unreadCount">{{walletData.invitations.unreadCount}}</span> </a> <a menu-close class="item item-icon-left" active-link="active" @@ -58,7 +58,7 @@ <i class="icon ion-email"></i> <span translate>MENU.MESSAGES</span> <span class="badge badge-positive" - ng-if="$root.walletData.messages.unreadCount">{{$root.walletData.messages.unreadCount}}</span> + ng-if="walletData.messages.unreadCount">{{walletData.messages.unreadCount}}</span> </a> <a menu-close class="item item-icon-left" active-link="active" @@ -68,7 +68,7 @@ <i class="icon ion-android-notifications"></i> <span translate>MENU.NOTIFICATIONS</span> <span class="badge badge-positive" - ng-if="$root.walletData.notifications.unreadCount">{{$root.walletData.notifications.unreadCount}}</span> + ng-if="walletData.notifications.unreadCount">{{walletData.notifications.unreadCount}}</span> </a> </div> diff --git a/www/plugins/es/templates/message/compose_form.html b/www/plugins/es/templates/message/compose_form.html index ee637ce2885056fc3ece86cfe146c21448d98af0..c7bacc370e1cb272ad7d285341bfc859485c4c47 100644 --- a/www/plugins/es/templates/message/compose_form.html +++ b/www/plugins/es/templates/message/compose_form.html @@ -19,18 +19,21 @@ </div> </div> - <div class="item item-text-wrap"> + <ion-item class="item-text-wrap ink" + ng-class="{'item-icon-right': enableSelectWallet}" + ng-click="showSelectWalletModal()"> <span class="gray" translate>TRANSFER.FROM</span> - <span class="badge badge-balanced"> - <ion-spinner icon="android" ng-if="!$root.walletData.pubkey"></ion-spinner> - <span ng-if="$root.walletData.pubkey && !$root.walletData.isMember"> - {{$root.walletData.pubkey| formatPubkey}} + <span class="badge badge-balanced animate-fade-in animate-show-hide" ng-show="!loading"> + <ion-spinner icon="android" ng-if="!walletData.pubkey"></ion-spinner> + <span ng-if="walletData.pubkey && !walletData.isMember"> + <i class="ion-key"></i> {{walletData.pubkey| formatPubkey}} </span> - <span ng-if="$root.walletData.isMember"> - {{$root.walletData.name||$root.walletData.uid}} + <span ng-if="walletData.isMember"> + <i class="ion-person"></i> {{walletData.name||walletData.uid}} </span> </span> - </div> + <i class="gray icon ion-ios-arrow-right" ng-if="enableSelectWallet"></i> + </ion-item> <!-- Object --> <div class="item item-input" diff --git a/www/plugins/es/templates/registry/lookup_list.html b/www/plugins/es/templates/registry/lookup_list.html index 6497132477500ffad60b37bb2e263cc71d1af428..5b98cb48ebab7cbe4ab9ec0155bf952e2009a386 100644 --- a/www/plugins/es/templates/registry/lookup_list.html +++ b/www/plugins/es/templates/registry/lookup_list.html @@ -2,10 +2,9 @@ <ion-list class="{{::motion.ionListClass}}" ng-if="!search.loading && search.results"> - <ion-item ng-repeat="item in search.results" - class="item item-border-large item-avatar item-icon-right ink" - ng-class="::{'item-icon-left': !smallscreen}" - ui-sref="app.view_page({id: item.id, title: item.urlTitle})"> + <div class="item item-avatar item-icon-right item-border-large ink" + ng-repeat="item in search.results" + ui-sref="app.view_page({id: item.id, title: item.urlTitle})"> <i ng-if="::!item.avatar" class="item-image icon cion-page-{{::item.type}}"></i> <i ng-if="::item.avatar" class="item-image avatar" style="background-image: url({{::item.avatar.src}})"></i> @@ -30,5 +29,5 @@ <span ng-if="!item.category">{{::'REGISTRY.TYPE.ENUM.'+item.type|uppercase|translate}}</span> </h4> <i class="icon ion-ios-arrow-right "></i> - </ion-item> + </div> </ion-list> diff --git a/www/plugins/es/templates/registry/view_record.html b/www/plugins/es/templates/registry/view_record.html index 1d7b8a3b64c7ac093223f9ee2f0ac7955900075a..b2313c7bfb97a4c73d7e08ba32375980949acaf2 100644 --- a/www/plugins/es/templates/registry/view_record.html +++ b/www/plugins/es/templates/registry/view_record.html @@ -82,7 +82,7 @@ ng-click="showSharePopover($event)"> </button> <button class="button button-calm ink-dark" - ng-if="formData.pubkey && !isUserPubkey(formData.pubkey)" + ng-if="showTransfer" ng-click="showTransferModal({pubkey:formData.pubkey, uid: formData.title})"> {{'COMMON.BTN_SEND_MONEY' | translate}} </button> @@ -99,11 +99,11 @@ </button> </div> - <ion-item> + <div class="item"> <h2 trust-as-html="formData.description"></h2> - </ion-item> + </div> - <ion-item ng-if="formData.category || formData.address"> + <div class="item" ng-if="formData.category || formData.address"> <h4 ng-if="formData.category"> <span class="gray" translate>REGISTRY.VIEW.CATEGORY</span> <a class="positive" ng-if="formData.category" ui-sref="app.wot_lookup.tab_registry({category:formData.category.id})"> @@ -118,11 +118,11 @@ <span ng-bind-html="formData.city"></span> </a> </h4> - </ion-item> + </div> <!-- Socials networks --> <ng-if ng-if="formData.socials && formData.socials.length>0"> - <ion-item class="item-icon-left" + <div class="item item-icon-left" type="no-padding item-text-wrap" ng-repeat="social in formData.socials track by social.url" id="social-{{social.url|formatSlug}}"> @@ -132,7 +132,7 @@ <h2> <a ng-click="openLink($event, social.url, social.type)">{{social.url}}</a> </h2> - </ion-item> + </div> </ng-if> <!-- pubkey --> diff --git a/www/plugins/es/templates/wot/popover_certification_actions.html b/www/plugins/es/templates/wot/popover_certification_actions.html index 781e514f3f30780e4b23939b2543cdcbb65857bd..8353db1f6676b1b36f559716c687e682001bee98 100644 --- a/www/plugins/es/templates/wot/popover_certification_actions.html +++ b/www/plugins/es/templates/wot/popover_certification_actions.html @@ -5,6 +5,14 @@ <ion-content scroll="false"> <div class="list item-text-wrap"> + <!-- certify --> + <a class="item item-icon-left ink" + ng-if="canCertify" + ng-click="certify()"> + <i class="icon ion-ribbon-b" ></i> + {{'WOT.BTN_CERTIFY' | translate}} + </a> + <!-- ask certification to current identities --> <a class="item item-icon-left ink" ng-if="!isUserPubkey(formData.pubkey) && formData.isMember" diff --git a/www/plugins/map/js/controllers/wot-controllers.js b/www/plugins/map/js/controllers/wot-controllers.js index cb57dbf5efa2bb5febaba422cb456f498b044a2d..93ca78e0171bcbeb4b661b32339558881e7985d3 100644 --- a/www/plugins/map/js/controllers/wot-controllers.js +++ b/www/plugins/map/js/controllers/wot-controllers.js @@ -50,10 +50,15 @@ angular.module('cesium.map.wot.controllers', ['cesium.services', 'cesium.map.ser ; -function MapWotViewController($scope, $filter, $templateCache, $interpolate, $timeout, $location, $translate, $q, +function MapWotViewController($scope, $filter, $templateCache, $interpolate, $timeout, $location, $translate, $q, $controller, + ionicReady, leafletData, UIUtils, csSettings, csWallet, MapUtils, mapWot) { 'ngInject'; + // Initialize the super classes and extend it. + angular.extend(this, $controller('WotIdentityAbstractCtrl', { $scope: $scope})); + angular.extend(this, $controller('ESWotIdentityViewCtrl', {$scope: $scope})); + var // Create a hidden layer, to hold search markers markersSearchLayer, @@ -107,6 +112,13 @@ function MapWotViewController($scope, $filter, $templateCache, $interpolate, $ti loading: true }, $scope.mapId); + $scope.showDescription = !UIUtils.screen.isSmall(); + ionicReady().then(function() { + $scope.showDescription = $scope.showDescription && ionic.Platform.grade.toLowerCase() === 'a'; + if (!$scope.showDescription) { + console.debug("[map] [wot] Disable profile description.", ionic.Platform.grade); + } + }); $scope.$on('$ionicView.beforeEnter', function (event, viewData) { // Enable back button (workaround need for navigation outside tabs - https://stackoverflow.com/a/35064602) @@ -116,6 +128,12 @@ function MapWotViewController($scope, $filter, $templateCache, $interpolate, $ti $scope.enter = function(e, state) { if ($scope.loading) { + + // $translate.get('') + //$ionicBackdrop.retain(); + UIUtils.loading.show({ + noBackdrop: true // avoid a too long release + }); if (state.stateParams && state.stateParams.c) { var cPart = state.stateParams.c.split(':'); $scope.map.center.lat = parseFloat(cPart[0]); @@ -132,20 +150,19 @@ function MapWotViewController($scope, $filter, $templateCache, $interpolate, $ti }, true); // Load the map (and init if need) + var now = new Date().getTime(); $scope.loadMap() + .then($scope.load) .then(function() { - if (csWallet.isLogin()) { - $scope.showHelpTip(); - } - return $scope.load(); + console.debug("[map] [wot] Loaded in "+ (Date.now() - now) +"ms"); + + $scope.showHelpTip(); }); } else { // Make sure to have previous center coordinate defined in the location URL $scope.updateLocationHref(); - if (csWallet.isLogin()) { - $scope.showHelpTip(); - } + $scope.showHelpTip(); } }; $scope.$on('$ionicView.enter', $scope.enter); @@ -265,6 +282,7 @@ function MapWotViewController($scope, $filter, $templateCache, $interpolate, $ti //MapUtils.cache.bind($scope, $scope.mapId, $scope.map); $scope.map.loading = false; + return map; }); }; @@ -283,10 +301,17 @@ function MapWotViewController($scope, $filter, $templateCache, $interpolate, $ti var options = { fields: { - description: !UIUtils.screen.isSmall() + description: ionic.Platform.grade.toLowerCase()==='a' && + !UIUtils.screen.isSmall() } }; + // add bounding box + if ($scope.map.bounds) { + options.bounds = angular.copy($scope.map.bounds); + delete options.bounds.options; + } + // Load wot data, from service return mapWot.load(options) @@ -314,9 +339,17 @@ function MapWotViewController($scope, $filter, $templateCache, $interpolate, $ti lat: hit.geoPoint.lat, lng: hit.geoPoint.lon, getMessageScope: function () { - var scope = $scope.$new(); - scope.hit = hit; - return scope; + $scope.loading = true; + $scope.$applyAsync(function() { + $scope.formData = { + pubkey: hit.pubkey, + uid: hit.uid, + name: hit.name, + profile: hit + }; + $scope.loading = false; + }); + return $scope; }, focus: false, message: hit.type ? pageMarkerTemplate : userMarkerTemplate, @@ -344,10 +377,16 @@ function MapWotViewController($scope, $filter, $templateCache, $interpolate, $ti $scope.map.markers = markers; - $scope.loading = false; + return $timeout(function(){ + $scope.loading = false; + + console.log("dataload"); + + // hide loading indicator + map.fire('dataload'); - // hide loading indicator - map.fire('dataload'); + UIUtils.loading.hide(); + }); }) .catch(function(err) { $scope.map.markers = {}; @@ -367,20 +406,6 @@ function MapWotViewController($scope, $filter, $templateCache, $interpolate, $ti // endRemoveIf(device) }; - // removeIf(device) - // Update the browser location, to be able to refresh the page - // FIXME: not need, should be removed - $scope.$on("centerUrlHash", function(event, centerHash) { - if (!$scope.loading) { - - return $timeout(function() { - $scope.updateLocationHref(centerHash); - }, 300); - } - }); - // endRemoveIf(device) - - /* -- help tip -- */ // Show help tour @@ -390,6 +415,8 @@ function MapWotViewController($scope, $filter, $templateCache, $interpolate, $ti // Show help tip $scope.showHelpTip = function(index, isTour) { + if (!isTour && !csWallet.isLogin()) return; + index = angular.isDefined(index) ? index : (angular.isNumber(csSettings.data.helptip.mapwot) ? csSettings.data.helptip.mapwot : 0); isTour = angular.isDefined(isTour) ? isTour : false; diff --git a/www/plugins/map/js/services/wot-services.js b/www/plugins/map/js/services/wot-services.js index b3d83d140fb4a436d737172545c14caee149e4a0..b46ccf9656b7100f3215d77e12fed29382ced8cd 100644 --- a/www/plugins/map/js/services/wot-services.js +++ b/www/plugins/map/js/services/wot-services.js @@ -10,6 +10,7 @@ angular.module('cesium.map.wot.services', ['cesium.services']) DEFAULT_LOAD_SIZE: 1000 }, fields = { + min: ["title", "geoPoint"], profile: ["title", "geoPoint", "avatar._content_type", "address", "city"] }; @@ -43,8 +44,7 @@ angular.module('cesium.map.wot.services', ['cesium.services']) // Filter on bounding box // see https://www.elastic.co/guide/en/elasticsearch/reference/2.4/geo-point.html if (options.bounds && options.bounds.northEast && options.bounds.southWest) { - query.bool.should = query.bool.should || {}; - query.bool.should.geo_bounding_box = { + var boundingBox = { "geoPoint" : { "top_left" : { "lat" : Math.max(Math.min(options.bounds.northEast.lat, 90), -90), @@ -56,6 +56,9 @@ angular.module('cesium.map.wot.services', ['cesium.services']) } } }; + console.debug("[map] [wot] Filtering on bounds: ", options.bounds); + query.bool.must = query.bool.must || []; + query.bool.must.push({geo_bounding_box: boundingBox}); } return query; } @@ -67,7 +70,7 @@ angular.module('cesium.map.wot.services', ['cesium.services']) options.searchAddress = esGeo.google.isEnable() && (angular.isDefined(options.searchAddress) ? options.searchAddress : true); options.fields = options.fields || {}; - options.fields.description = angular.isDefined(options.fields.description) ? options.fields.description : true; + options.fields.description = angular.isDefined(options.fields.description) ? options.fields.description : false; var request = { query: createFilterQuery(options), diff --git a/www/plugins/map/templates/wot/popup_marker.html b/www/plugins/map/templates/wot/popup_marker.html index 29ba453a2545a1d2288d91db7d7b290e8e43f384..7b00531e1154574823068d4e67408ee2e2fc7556 100644 --- a/www/plugins/map/templates/wot/popup_marker.html +++ b/www/plugins/map/templates/wot/popup_marker.html @@ -1,23 +1,82 @@ -<div class="item no-border no-padding item-avatar" ng-class="::{'item-avatar': hit.avatar}"> - <img ng-if="::hit.avatar" class="item-image avatar" ng-src="{{::hit.avatar.src}}"> - <i ng-if="::!hit.avatar" class="item-image icon " ng-class="::{'ion-person': hit.uid, 'ion-card': !hit.uid}"></i> + +<div class="item no-border no-padding item-avatar " + ng-if="loading"> + + <i class="item-image icon ion-person"></i> + + <div class="item-content item-avatar-left-padding padding-top" > + <h2 class="stable-bg"> + + </h2> + <h4 class="stable-bg col-75"> + + </h4> + <h4 class="stable-bg col-50"> + + </h4> + </div> +</div> + +<a class="item no-border no-padding item-avatar ink animate-fade-in animate-show-hide ng-hide" + ng-show="!loading" + ui-sref="app.wot_identity({pubkey: formData.pubkey, uid: formData.uid})"> + + <i ng-if="formData.avatar" class="item-image avatar" style="background-image: url({{::formData.avatar.src}})"></i> + <i ng-if="!formData.avatar && formData.uid" class="item-image icon ion-person"></i> + <i ng-if="!formData.avatar && !formData.uid" class="item-image icon ion-card"></i> + <div class="item-content item-avatar-left-padding padding-top"> - <h2 class="dark"><a ui-sref="app.wot_identity({pubkey: hit.pubkey, uid: hit.uid})">{{::hit.name}}</a></h2> + <h2 class="dark"> + {{formData.name}} + </h2> <h4> - <span ng-if="::hit.uid" class="positive"> + <span ng-if="formData.uid" class="positive"> <b class="ion-person"></b> - {{::hit.uid}} + {{formData.uid}} </span> - <span class="gray" title="{{::hit.pubkey}}"><b class="ion-key"></b> {{::hit.pubkey|formatPubkey}}</span> - <span class="assertive" ng-if="!hit.uid"> + <span class="gray" title="{{formData.pubkey}}"><b class="ion-key"></b> {{formData.pubkey|formatPubkey}}</span> + <span class="assertive" ng-if="!formData.isMember"> {{::'WOT.NOT_MEMBER_PARENTHESIS'|translate}} </span> </h4> - <h4 ng-if="::hit.city" class="gray" title="{{::hit.city}}"> - <b class="ion-location"></b> {{::hit.city}} + <h4 ng-if="formData.profile.city" class="gray" title="{{formData.profile.city}}"> + <b class="ion-location"></b> {{formData.profile.city}} </h4> </div> +</a> +<!-- buttons --> +<div class="item no-border no-padding"> + <div class="pull-left gray"> + <!-- show description --> + <a class="animate-fade-in animate-show-hide gray ng-hide" + ng-class="{'ion-arrow-down-b': !$parent.showDescription, 'ion-arrow-up-b': $parent.showDescription}" + ng-click="$parent.showDescription=!$parent.showDescription;" + title="{{'PROFILE.DESCRIPTION'|translate}}" + ng-show="!loading && formData.profile.description"> + + </a> + </div> + <div style="font-size: 18px;" class="pull-right gray"> + <!-- share --> + <a class="icon ion-android-share-alt " + ng-click="showSharePopover($event)" + title="{{'COMMON.BTN_SHARE' | translate}}"> </a> + <!-- certify --> + <a class="icon ion-ribbon-b" + ng-click="certify()" + title="{{'WOT.BTN_CERTIFY' | translate}}" + ng-hide="!canCertify"> </a> + <!-- compose message --> + <a class="icon ion-compose" + ng-click="showNewMessageModal()" + title="{{'MESSAGE.BTN_WRITE' | translate}}"> </a> + <!-- transfer --> + <a class="icon ion-card" + ng-click="showTransferModal({pubkey:formData.pubkey, uid: formData.name||formData.uid})" + title="{{'COMMON.BTN_SEND_MONEY' | translate}}"> </a> + + </div> </div> -<div class="item no-border no-padding item-text-wrap hidden-xs" ng-if="::hit.description"> - <small trust-as-html="::hit.description"></small> +<div class="item no-border no-padding item-text-wrap hidden-xs ng-hide" ng-show="$parent.showDescription"> + <small trust-as-html="formData.profile.description|truncText:500"></small> </div> diff --git a/www/templates/common/popover_profile.html b/www/templates/common/popover_profile.html index f21b01bbe810eeb13fa2b843d33550ca3e1e167a..fa6f18f3676882fc7ed7158504c73b234753d433 100644 --- a/www/templates/common/popover_profile.html +++ b/www/templates/common/popover_profile.html @@ -2,19 +2,19 @@ <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" ng-if="$root.walletData.avatar" style="background-image: url('{{$root.walletData.avatar.src}}')"></i> + <i class="avatar avatar-member" ng-if="!walletData.avatar" ng-class="{'royal-bg': login, 'stable-bg': !login}"></i> + <i class="avatar" ng-if="walletData.avatar" style="background-image: url('{{walletData.avatar.src}}')"></i> </div> <div class="col col-66" ng-if="login"> - <h4>{{$root.walletData.name||$root.walletData.uid}}</h4> + <h4>{{walletData.name||walletData.uid}}</h4> <h4 class="gray" - ng-if="!$root.walletData.name && !$root.walletData.uid" - copy-on-click="{{$root.walletData.pubkey}}"> - <i class="icon ion-key"></i> {{$root.walletData.pubkey|formatPubkey}} + ng-if="!walletData.name && !walletData.uid" + copy-on-click="{{walletData.pubkey}}"> + <i class="icon ion-key"></i> {{walletData.pubkey|formatPubkey}} </h4> - <span class="gray" ng-if="$root.walletData.name||$root.walletData.uid" - copy-on-click="{{$root.walletData.pubkey}}"> - <i class="icon ion-key"></i> {{$root.walletData.pubkey|formatPubkey}} + <span class="gray" ng-if="walletData.name||walletData.uid" + copy-on-click="{{walletData.pubkey}}"> + <i class="icon ion-key"></i> {{walletData.pubkey|formatPubkey}} </span> </div> </div> diff --git a/www/templates/home/home.html b/www/templates/home/home.html index 6e9895a8e257449f2f5c58c1bca8773b5a5b4f30..8f1c8b3bc0c896c9a64fa4bb8faa2f95aa7834ef 100644 --- a/www/templates/home/home.html +++ b/www/templates/home/home.html @@ -73,7 +73,7 @@ <!-- disconnect link --> <div class="text-center no-padding" ng-show="login"> <br class="visible-xs visible-sm"/> - <span ng-bind-html="'HOME.NOT_YOUR_ACCOUNT_QUESTION'|translate:$root.walletData"></span> + <span ng-bind-html="'HOME.NOT_YOUR_ACCOUNT_QUESTION'|translate:{pubkey: walletData.pubkey}"></span> <br/> <b> <a class="assertive hidden-xs hidden-sm" ng-click="logout()" translate> diff --git a/www/templates/login/form_login.html b/www/templates/login/form_login.html index dca5628a5abe29a6eca81c21bb1efc4c304fd475..a225c815e68ba165bf99478a0f8d97083082c7d4 100644 --- a/www/templates/login/form_login.html +++ b/www/templates/login/form_login.html @@ -47,7 +47,7 @@ ng-click="closeModal()" type="button" translate>COMMON.BTN_CANCEL </button> <button class="button button-positive ink" ng-class="{'button-assertive': isAuth, 'button-positive': !isAuth}" type="submit"> - {{isAuth ? 'AUTH.BTN_AUTH' : 'COMMON.BTN_LOGIN' | translate}} + {{okText || (isAuth ? 'AUTH.BTN_AUTH' : 'COMMON.BTN_LOGIN') | translate}} </button> </div> diff --git a/www/templates/menu.html b/www/templates/menu.html index e7c6507aa1832be364e23b38013dac4ef0e0d27b..dceca5aa71f4fc15f316fbc7557752519c07ced9 100644 --- a/www/templates/menu.html +++ b/www/templates/menu.html @@ -30,12 +30,12 @@ class="button button-icon button-clear hidden-xs hidden-sm" ng-click="showProfilePopover($event)"> <i class="avatar avatar-member" - ng-if="!$root.walletData.avatar" + ng-if="!walletData.avatar" ng-class="{'disable': !login, 'royal-bg': login}"> </i> <i class="avatar" - ng-if="$root.walletData.avatar" - style="background-image: url('{{$root.walletData.avatar.src}}')"> + ng-if="walletData.avatar" + style="background-image: url('{{walletData.avatar.src}}')"> </i> <span ng-if="login && !auth" class="badge badge-button badge-secondary badge-assertive ion-locked"> </span> @@ -60,12 +60,12 @@ <div class="visible-sm visible-xs hero"> <div class="content"> - <i class="avatar avatar-member hero-icon" ng-if="!$root.walletData.avatar" ng-class="{'royal-bg': login, 'stable-bg': !login}" ng-click="!login ? showHome() : loginAndGo()" menu-close></i> - <a class="avatar hero-icon" ng-if="$root.walletData.avatar" style="background-image: url('{{$root.walletData.avatar.src}}')" ui-sref="app.view_wallet" menu-close></a> + <i class="avatar avatar-member hero-icon" ng-if="!walletData.avatar" ng-class="{'royal-bg': login, 'stable-bg': !login}" ng-click="!login ? showHome() : loginAndGo()" menu-close></i> + <a class="avatar hero-icon" ng-if="walletData.avatar" style="background-image: url('{{walletData.avatar.src}}')" ui-sref="app.view_wallet" menu-close></a> <h4 ng-if="login"> <a class="light" ui-sref="app.view_wallet" menu-close> - {{$root.walletData.name||$root.walletData.uid}} - <span ng-if="!$root.walletData.name && !$root.walletData.uid"><i class="icon ion-key"></i> {{$root.walletData.pubkey|formatPubkey}}</span> + {{walletData.name||walletData.uid}} + <span ng-if="!walletData.name && !walletData.uid"><i class="icon ion-key"></i> {{walletData.pubkey|formatPubkey}}</span> </a> </h4> <h4 ng-if="!login"> @@ -137,7 +137,7 @@ <a menu-close class="item item-icon-left" active-link="active" - active-link-path-prefix="#/app/wallet/main" + active-link-path-prefix="#/app/account" ui-sref="app.view_wallet" ng-class="{'item-menu-disable': !login}"> <i class="icon ion-person"></i> diff --git a/www/templates/wallet/list/item_wallet.html b/www/templates/wallet/list/item_wallet.html index b8cd592a4e11e307e1656ff12b884c5fe98d1f27..6ef3458a6d0a92c5071c18696dea833e7c67492c 100644 --- a/www/templates/wallet/list/item_wallet.html +++ b/www/templates/wallet/list/item_wallet.html @@ -5,7 +5,7 @@ <i ng-if="::!walletData.avatar" class="item-image icon" ng-class=":rebind:{'ion-card': !walletData.isMember, 'ion-persion': walletData.isMember}"></i> <i ng-if="::walletData.avatar" class="item-image avatar" style="background-image: url({{::walletData.avatar.src}})"></i> - <i ng-hide=":rebind:wallet.isAuth()" class="icon-secondary assertive ion-locked" style="top: -16px; left: 66px; font-size: 20px;"></i> + <!--<i ng-hide=":rebind:wallet.isAuth()" class="icon-secondary assertive ion-locked" style="top: -16px; left: 66px; font-size: 20px;"></i>--> <h2> <span class="text-editable" ng-click="editWallet($event, wallet)" title="{{'ACCOUNT.WALLET_LIST.BTN_RENAME'|translate}}"> <ng-if ng-if=":rebind:walletData.name||walletData.uid" ng-bind-html="::walletData.name||walletData.uid"></ng-if> diff --git a/www/templates/wallet/list/view_wallets.html b/www/templates/wallet/list/view_wallets.html index 89db65e6078c39d190fee2fd4c89e1c556a7c71d..28622c4e49ba8975f3c1e9b88fe5571a7c2a1fad 100644 --- a/www/templates/wallet/list/view_wallets.html +++ b/www/templates/wallet/list/view_wallets.html @@ -13,6 +13,7 @@ </ion-nav-buttons> <ion-content scroll="true" + class="padding no-padding-xs" bind-notifier="{ rebind:formData.useRelative, locale:settings.locale.id}"> <ion-refresher pulling-text="{{:locale:'COMMON.BTN_REFRESH' | translate}}" @@ -50,9 +51,9 @@ </div> <ion-list ng-if="!loading" class="{{::motion.ionListClass}}"> - <ng-repeat ng-repeat="wallet in wallets track by wallet.id" - ng-include="'templates/wallet/list/item_wallet.html'"> - </ng-repeat> + <ng-include ng-repeat="wallet in wallets track by wallet.id" + src="'templates/wallet/list/item_wallet.html'"> + </ng-include> </ion-list> </ion-content> diff --git a/www/templates/wallet/view_wallet.html b/www/templates/wallet/view_wallet.html index 69b85f8a0dd09accb75094b9ed516fb6dca63872..d48ed0649c6d5209d66a19c01437658a1cf7f885 100644 --- a/www/templates/wallet/view_wallet.html +++ b/www/templates/wallet/view_wallet.html @@ -156,15 +156,7 @@ <!-- Account transaction --> <a class="item item-icon-left item-icon-right ink" - ng-if="isDefaultWallet" - ui-sref="app.view_wallet_tx"> - <i class="icon ion-card"></i> - <span translate>WOT.ACCOUNT_OPERATIONS</span> - <i class="gray icon ion-ios-arrow-right"></i> - </a> - <a class="item item-icon-left item-icon-right ink" - ng-if="!isDefaultWallet" - ui-sref="app.view_wallet_tx_by_id({id: walletId})"> + ng-click="showTxHistory()"> <i class="icon ion-card"></i> <span translate>WOT.ACCOUNT_OPERATIONS</span> <i class="gray icon ion-ios-arrow-right"></i> diff --git a/www/templates/wallet/view_wallet_tx.html b/www/templates/wallet/view_wallet_tx.html index 49bc1513f2dbe8ac3e32d3f5c67d0c90f4ef353a..92c55bcdeddb4b44797358fb5880e5257c1b4b79 100644 --- a/www/templates/wallet/view_wallet_tx.html +++ b/www/templates/wallet/view_wallet_tx.html @@ -2,8 +2,9 @@ class="view-wallet-tx"> <ion-nav-title> <!-- no title on large screen--> - <span class="visible-xs visible-sm" ng-if="!loading"> - {{formData.name || formData.uid}} - <i class="ion-key"></i> {{formData.pubkey|formatPubkey}} + <span class="visible-xs visible-sm" ng-if="!loading && enableSelectWallet"> + <span ng-if="formData.name || formData.uid">{{formData.name || formData.uid}} </span> + <i class="ion-key"></i> {{formData.pubkey|formatPubkey}} </span> </ion-nav-title> @@ -32,7 +33,8 @@ ng-if="enableSelectWallet" title="{{:locale:'ACCOUNT.SELECT_WALLET_MODAL.TITLE'|translate}}" ng-click="showSelectWalletPopover($event)"> - {{formData.name || formData.uid}} - <i class="ion-key"></i> {{formData.pubkey|formatPubkey}} + <span ng-if="formData.name || formData.uid">{{formData.name || formData.uid}} </span> + <i class="ion-key"></i> {{formData.pubkey|formatPubkey}} <i class="ion-arrow-down-b"></i> </a>