diff --git a/www/js/config.js b/www/js/config.js index 7f184f7604268693d57e5e603dbcfabbe599e329..ce44b1cc3d32a2862815b76cae0878b2e0052d3c 100644 --- a/www/js/config.js +++ b/www/js/config.js @@ -29,7 +29,7 @@ angular.module("cesium.config", []) } }, "version": "0.3.0", - "build": "2016-09-16T15:12:33.494Z", + "build": "2016-09-16T15:34:45.590Z", "newIssueUrl": "https://github.com/duniter/cesium/issues/new?labels=bug" }) diff --git a/www/js/controllers/app-controllers.js b/www/js/controllers/app-controllers.js index 3afd5bf482afe1344cb7eb44aa2616c4056f0a58..0ef63ee87f5edbda7d8ca240df9e22f30a785406 100644 --- a/www/js/controllers/app-controllers.js +++ b/www/js/controllers/app-controllers.js @@ -62,6 +62,8 @@ function AppController($scope, $rootScope, $state, $ionicSideMenuDelegate, $q, $ $rootScope.walletData = Wallet.data; $rootScope.settings = csSettings.data; $rootScope.config = csConfig; + $rootScope.device = Device; + $rootScope.login = Wallet.isLogin(); //////////////////////////////////////// // Load currencies @@ -81,12 +83,8 @@ function AppController($scope, $rootScope, $state, $ionicSideMenuDelegate, $q, $ // Device Methods //////////////////////////////////////// - $scope.isDeviceEnable = function() { - return Device.isEnable(); - }; - $scope.scanQrCodeAndGo = function() { - if (!Device.isEnable()) { + if (!Device.enable) { return; } Device.camera.scan() @@ -215,10 +213,13 @@ function AppController($scope, $rootScope, $state, $ionicSideMenuDelegate, $q, $ .catch(UIUtils.onError()); }; - // Is connected - $scope.isLogin = function() { - return Wallet.isLogin(); - }; + // add listener on wallet event + Wallet.api.data.on.login($scope, function() { + $rootScope.login = true; + }, this); + Wallet.api.data.on.logout($scope, function() { + $rootScope.login = false; + }, this); // If connected and same pubkey $scope.isUserPubkey = function(pubkey) { diff --git a/www/js/controllers/wot-controllers.js b/www/js/controllers/wot-controllers.js index 0b102d7268cd0676056d55e1ac014c4ad045b2ce..2a2bd9850b810be56412c50703225d79560027b7 100644 --- a/www/js/controllers/wot-controllers.js +++ b/www/js/controllers/wot-controllers.js @@ -207,7 +207,7 @@ function WotLookupController($scope, BMA, $state, UIUtils, $timeout, Device, Wal }; $scope.scanQrCode = function(){ - if (!Device.isEnable()) { + if (!Device.enable) { return; } Device.camera.scan() diff --git a/www/js/services/device-services.js b/www/js/services/device-services.js index 07a521be93cc7b582e67bd228699058b54bbf789..528be6c3da80d4783137233408f02603744057af 100644 --- a/www/js/services/device-services.js +++ b/www/js/services/device-services.js @@ -15,7 +15,12 @@ angular.module('cesium.device.services', ['ngResource', 'cesium.utils.services'] MAX_WIDTH: 400 }, readyPromise, + + // workaround to quickly no is device or not (even before the ready() event) + enable = true; + // removeIf(device) enable = false; + // endRemoveIf(device) // Replace the '$ionicPlatform.ready()', to enable multiple calls ready = function () { @@ -25,9 +30,9 @@ angular.module('cesium.device.services', ['ngResource', 'cesium.utils.services'] return readyPromise; }; - isEnable = function() { + /*isEnable = function() { return enable; - }; + };*/ getPicture = function(sourceType) { return $q(function (resolve, reject) { @@ -132,7 +137,8 @@ angular.module('cesium.device.services', ['ngResource', 'cesium.utils.services'] return { ready: ready, - isEnable: isEnable, + enable: enable, + /*isEnable: isEnable,*/ clipboard: { copy: copy }, diff --git a/www/js/services/settings-services.js b/www/js/services/settings-services.js index e1b5a4b644c41541e805ae7d323d500ebb4e4ecc..57946b98aeb5d357a335a86948b852405ccd5405 100644 --- a/www/js/services/settings-services.js +++ b/www/js/services/settings-services.js @@ -20,10 +20,10 @@ angular.module('cesium.settings.services', ['ngResource', 'ngApi', 'cesium.confi useRelative: true, timeWarningExpireMembership: 2592000 * 2 /*=2 mois*/, timeWarningExpire: 2592000 * 3 /*=3 mois*/, - useLocalStorage: Device.isEnable(), // on mobile device, use local storage by default + useLocalStorage: Device.enable, // on mobile device, use local storage by default walletHistoryTimeSecond: 30 * 24 * 60 * 60 /*30 days*/, walletHistorySliceSecond: 5 * 24 * 60 * 60 /*download using 5 days slice*/, - rememberMe: Device.isEnable(), // on mobile device, remember me by default + rememberMe: Device.enable, // on mobile device, remember me by default showUDHistory: true, locale: { id: defaultLocale diff --git a/www/js/services/wallet-services.js b/www/js/services/wallet-services.js index d41c07631b9f4a3a3d865b5bf7c7c7548f30a176..6afc47e9666265c87d36a1e1ac45784c8fce6f87 100644 --- a/www/js/services/wallet-services.js +++ b/www/js/services/wallet-services.js @@ -143,19 +143,23 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser }, login = function(salt, password) { - return $q(function(resolve, reject) { - CryptoUtils.connect(salt, password).then( - function(keypair) { - // Copy result to properties - data.pubkey = CryptoUtils.util.encode_base58(keypair.signPk); - data.keypair = keypair; - if (csSettings.data.useLocalStorage) { - store(); - } - resolve(data); - } - ); - }); + return $q(function(resolve, reject) { + CryptoUtils.connect(salt, password).then( + function(keypair) { + // Copy result to properties + data.pubkey = CryptoUtils.util.encode_base58(keypair.signPk); + data.keypair = keypair; + if (csSettings.data.useLocalStorage) { + store(); + } + + // Send login event + api.data.raise.login(data); + + resolve(data); + } + ); + }); }, logout = function(username, password) { @@ -163,12 +167,16 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser resetData(); // will reset keypair store(); // store (if local storage enable) + + // Send logout event + api.data.raise.logout(); + resolve(); }); }, isLogin = function() { - return !!data.pubkey; + return !!data.pubkey; }, // If connected and same pubkey @@ -229,6 +237,8 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser data.loaded = false; } + api.data.raise.login(data); + // Load parameters // This prevent timeout error, when loading a market record after a browser refresh (e.g. F5) return loadParameters(); @@ -1131,6 +1141,8 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser ; // Register extension points + api.registerEvent('data', 'login'); + api.registerEvent('data', 'logout'); api.registerEvent('data', 'load'); api.registerEvent('data', 'reset'); diff --git a/www/plugins/es/js/controllers/common-controllers.js b/www/plugins/es/js/controllers/common-controllers.js index 354a6aea7deff6b7bf7eaa351ecf2679a687fe2a..63328161ee02afa734e255a18174dedca2e819f7 100644 --- a/www/plugins/es/js/controllers/common-controllers.js +++ b/www/plugins/es/js/controllers/common-controllers.js @@ -63,11 +63,11 @@ function ESMenuExtendController($scope, $state, screenmatch, PluginService, csSe } -function ESPicturesEditController($scope, $ionicModal, Wallet, esMarket, UIUtils, $state, CryptoUtils, $q, $ionicPopup, Device, $timeout, ModalUtils) { +function ESPicturesEditController($scope, UIUtils, $q, Device) { 'ngInject'; $scope.selectNewPicture = function() { - if ($scope.isDeviceEnable()){ + if (Device.enable){ openPicturePopup(); } else { diff --git a/www/plugins/es/templates/market/edit_record.html b/www/plugins/es/templates/market/edit_record.html index ed375abcf3c3df0328cf969b0c5fb6019d1f4567..1c6c5f932fb73fc988c9dc7c792335713d0ec16e 100644 --- a/www/plugins/es/templates/market/edit_record.html +++ b/www/plugins/es/templates/market/edit_record.html @@ -94,8 +94,7 @@ ng-show="!useRelative"> <span class="input-label">{{'MARKET.EDIT.RECORD_PRICE' | translate}} ({{currency | abbreviate}})</span> <input type="text" name="price" placeholder="{{'MARKET.EDIT.RECORD_PRICE_HELP' | translate}} ({{currency | abbreviate}})" - ng-model="formData.price" - required> + ng-model="formData.price"> <span class="gray button button-block icon ion-arrow-swap hidden-xs hidden-sm" ng-click="unitPopover.show($event)"> </span> <span class="gray button button-block button-clear button-icon visible-xs visible-sm" ng-click="unitPopover.show($event)"> diff --git a/www/plugins/es/templates/menu_extend.html b/www/plugins/es/templates/menu_extend.html index 8671cecb76ffac8a258f9e407c8bc63a73a28199..f2f1d7815174e5ed2ba17c442431a6da3704fdce 100644 --- a/www/plugins/es/templates/menu_extend.html +++ b/www/plugins/es/templates/menu_extend.html @@ -21,13 +21,13 @@ <ng-if ng-if="enable && extensionPoint === 'menu-user'"> <!-- user profile --> <ion-item menu-close class="item item-icon-left" active-link="active" - ng-if="isLogin()" + ng-if="$root.login" href="#/app/user/profile/edit"> <i class="icon ion-person"></i> <span translate>MENU.USER_PROFILE</span> </ion-item> - <ion-item menu-close class="item item-icon-left" active-link="active" - ng-if="!isLogin()" + <ion-item menu-close class="item item-icon-left item-menu-disable" active-link="active" + ng-if="!$root.login" ng-click="login('app.user_edit_profile')"> <i class="icon ion-person"></i> <span translate>MENU.USER_PROFILE</span> diff --git a/www/plugins/es/templates/user/edit_profile.html b/www/plugins/es/templates/user/edit_profile.html index 8fdb48385defa0ebc55ec079cfa561b2dc2f050f..8d65c3b06f2f7a324b33edc50b9ac0043aae0170 100644 --- a/www/plugins/es/templates/user/edit_profile.html +++ b/www/plugins/es/templates/user/edit_profile.html @@ -44,9 +44,7 @@ <input type="file" id="avatarFile" accept=".png,.jpeg,.jpg" onchange="angular.element(this).scope().fileChanged(event)" style="visibility:hidden; position:absolute;"/> - <ion-list class="animate-ripple item-text-wrap" ng-init="setForm(profileForm)" - can-swipe="isDeviceEnable()"> - + <ion-list class="animate-ripple item-text-wrap" ng-init="setForm(profileForm)"> <div class="item item-divider"> {{'PROFILE.GENERAL_DIVIDER' | translate}} diff --git a/www/templates/home/home.html b/www/templates/home/home.html index 43e97f4d82fd8e36d5ea95d55005828696ca97e4..70e8c20d643def29249808828a40007b11e033b8 100644 --- a/www/templates/home/home.html +++ b/www/templates/home/home.html @@ -28,12 +28,12 @@ <button type="button" class="button button-block button-positive button-raised icon icon-left ion-locked ink-dark" - ng-click="login()" ng-show="!isLogin()" translate>COMMON.BTN_LOGIN</button> + ng-click="login()" ng-show="!$root.login" translate>COMMON.BTN_LOGIN</button> <button type="button" class="button button-block button-positive button-raised icon icon-left ion-card ink-dark" - ui-sref="app.view_wallet" ng-show="isLogin()" translate>HOME.BTN_ACCOUNT</button> + ui-sref="app.view_wallet" ng-show="$root.login" translate>HOME.BTN_ACCOUNT</button> - <div class="text-center no-padding" ng-show="!isLogin()"> + <div class="text-center no-padding" ng-show="!$root.login"> {{'LOGIN.NO_ACCOUNT_QUESTION'|translate}} <br class="visible-xs"> <b> diff --git a/www/templates/menu.html b/www/templates/menu.html index 3625b8be4f4bb6602930666cc2da927f0444eac3..c8fe70a73b94f1a7fa5c223acea1af1bb09fe2a2 100644 --- a/www/templates/menu.html +++ b/www/templates/menu.html @@ -59,11 +59,11 @@ <!-- USER Section --> <div class="item item-divider"></div> - <ion-item menu-close class="item item-icon-left item-menu-disable" ng-click="login('app.view_wallet')" ng-if="!isLogin()"> + <ion-item menu-close class="item item-icon-left item-menu-disable" ng-click="login('app.view_wallet')" ng-if="!$root.login"> <i class="icon ion-card"></i> <span translate>MENU.ACCOUNT</span> </ion-item> - <ion-item menu-close class="item item-icon-left" active-link="active" href="#/app/wallet" ng-if="isLogin()"> + <ion-item menu-close class="item item-icon-left" active-link="active" href="#/app/wallet" ng-if="$root.login"> <i class="icon ion-card"></i> <span translate>MENU.ACCOUNT</span> </ion-item> @@ -77,22 +77,22 @@ </ion-item> <!-- actions --> - <div class="item item-divider" ng-if="isLogin()"></div> - <ion-item menu-close class="item item-button-right" ng-if="isLogin()"> + <div class="item item-divider" ng-if="$root.login"></div> + <ion-item menu-close class="item item-button-right" ng-if="$root.login"> <span translate>MENU.TRANSFER</span> <button class="button button-energized-900" ng-click="showTransferModal()"> <i class="icon ion-paper-airplane"></i> </button> </ion-item> <!-- scan QR code --> - <ion-item menu-close class="item item-button-right" ng-if="isDeviceEnable()"> + <ion-item menu-close class="item item-button-right" ng-if="$root.device.enable"> <span translate>Scan</span> <button class="button button-stable" ng-click="scanQrCodeAndGo()"> <i class="icon ion-qr-scanner"></i> </button> </ion-item> <!-- log out --> - <ion-item menu-close class="item item-button-right" ng-if="isLogin()"> + <ion-item menu-close class="item item-button-right" ng-if="$root.login"> <span translate>COMMON.BTN_LOGOUT</span> <button class="button button-stable" ng-click="logout()"> <i class="icon ion-log-out"></i> diff --git a/www/templates/wot/lookup_form.html b/www/templates/wot/lookup_form.html index 523b7482aab301f5fc983f9cff53ad75f6fc411c..2208efde78c3e236d7c8d10422f5a072e1270582 100644 --- a/www/templates/wot/lookup_form.html +++ b/www/templates/wot/lookup_form.html @@ -50,6 +50,7 @@ <ion-list class="animate-ripple" + can-swipe="$root.device.enable" ng-if="!search.looking && search.results.length"> <ion-item ng-repeat="identity in search.results" class="item-border-large item-avatar item-icon-right ink" ng-click="select(identity)"> diff --git a/www/templates/wot/modal_lookup.html b/www/templates/wot/modal_lookup.html index 8fa7f962846d5796665e9f7c248235fec4906cc9..9ab6b12a49bb262ad729bd0a3010b3d07c790857 100644 --- a/www/templates/wot/modal_lookup.html +++ b/www/templates/wot/modal_lookup.html @@ -4,7 +4,7 @@ <h1 class="title" translate>WOT.MODAL.TITLE</h1> <button class="button button-icon button-clear icon ion-qr-scanner visible-xs hidden-no-device" - ng-if="isDeviceEnable()" + ng-if="$root.device.enable" ng-click="scanQrCode()"> </button> </ion-header-bar>