From b7954f2bda6e8725cbcdbed52ecce5ee07eff962 Mon Sep 17 00:00:00 2001
From: blavenie <benoit.lavenier@e-is.pro>
Date: Fri, 28 Oct 2016 14:39:32 +0200
Subject: [PATCH] - Could not certify - get Error "csConfig not defined" fix
 #190 - ES : view record (and message) > use formatter to display pubkey - ES:
 fill uid if member, even if no profile defined

---
 app/config.json                               |  9 +++++---
 www/js/config.js                              | 23 +++++++++++--------
 www/js/controllers/wot-controllers.js         |  2 +-
 www/js/services/network-services.js           |  6 ++---
 www/js/services/settings-services.js          |  5 ++--
 .../es/js/controllers/message-controllers.js  | 15 +++++++++---
 www/plugins/es/js/services/user-services.js   |  5 ++++
 .../es/templates/market/view_record.html      | 11 ++++++---
 .../es/templates/message/view_message.html    | 14 +++++------
 .../es/templates/registry/view_record.html    | 11 ++++++---
 10 files changed, 67 insertions(+), 34 deletions(-)

diff --git a/app/config.json b/app/config.json
index 02c3f9ae6..92cf4d864 100644
--- a/app/config.json
+++ b/app/config.json
@@ -4,12 +4,13 @@
     "fallbackLanguage": "en",
     "rememberMe": false,
     "showUDHistory": false,
-    "timeout": 4000,
+    "timeout": 10000,
     "timeWarningExpireMembership": 5184000,
     "timeWarningExpire": 7776000,
     "useLocalStorage": true,
     "useRelative": true,
     "initPhase": false,
+    "expertMode": false,
     "helptip": {
       "enable": true,
       "installDocUrl": "https://github.com/duniter/duniter/blob/master/doc/install-a-node.md"
@@ -34,12 +35,13 @@
     "defaultLanguage": "fr-FR",
     "rememberMe": false,
     "showUDHistory": false,
-    "timeout": 4000,
+    "timeout": 15000,
     "timeWarningExpireMembership": 5184000,
     "timeWarningExpire": 7776000,
     "useLocalStorage": true,
     "useRelative": true,
     "initPhase": false,
+    "expertMode": false,
     "helptip": {
       "enable": false,
       "installDocUrl": {
@@ -49,7 +51,7 @@
     },
     "node": {
       "host": "duniter.le-sou.org",
-      "port": "9600"
+      "port": "80"
     },
     "plugins":{
       "es": {
@@ -73,6 +75,7 @@
     "useLocalStorage": true,
     "useRelative": true,
     "initPhase": false,
+    "expertMode": false,
     "helptip": {
       "enable": true,
       "installDocUrl": {
diff --git a/www/js/config.js b/www/js/config.js
index 1d8cb0467..ece0d2f92 100644
--- a/www/js/config.js
+++ b/www/js/config.js
@@ -10,33 +10,38 @@ angular.module("cesium.config", [])
 
 .constant("csConfig", {
 	"cacheTimeMs": 60000,
-	"fallbackLanguage": "en",
-	"rememberMe": false,
+	"fallbackLanguage": "fr-FR",
+	"defaultLanguage": "fr-FR",
+	"rememberMe": true,
 	"showUDHistory": false,
-	"timeout": 4000,
+	"timeout": 6000,
 	"timeWarningExpireMembership": 5184000,
 	"timeWarningExpire": 7776000,
 	"useLocalStorage": true,
 	"useRelative": true,
 	"initPhase": false,
+	"expertMode": false,
 	"helptip": {
 		"enable": true,
-		"installDocUrl": "https://github.com/duniter/duniter/blob/master/doc/install-a-node.md"
+		"installDocUrl": {
+			"fr-FR": "http://www.le-sou.org/devenir-noeud/",
+			"en": "https://github.com/duniter/duniter/blob/master/doc/install-a-node.md"
+		}
 	},
 	"node": {
-		"host": "test-net.duniter.fr",
-		"port": "9201"
+		"host": "duniter.le-sou.org",
+		"port": "9600"
 	},
 	"plugins": {
 		"es": {
-			"enable": true,
-			"askEnable": false,
+			"enable": false,
+			"askEnable": true,
 			"host": "data.duniter.fr",
 			"port": "80"
 		}
 	},
 	"version": "0.4.3",
-	"build": "2016-10-26T16:51:20.222Z",
+	"build": "2016-10-26T17:17:16.937Z",
 	"newIssueUrl": "https://github.com/duniter/cesium/issues/new?labels=bug"
 })
 
diff --git a/www/js/controllers/wot-controllers.js b/www/js/controllers/wot-controllers.js
index 9d6e7a2e1..635cab82e 100644
--- a/www/js/controllers/wot-controllers.js
+++ b/www/js/controllers/wot-controllers.js
@@ -415,7 +415,7 @@ function WotIdentityViewController($scope, $state, $timeout, UIUtils, WotService
  * @param Modals
  * @constructor
  */
-function WotCertificationsViewController($scope, $rootScope, $timeout, $translate, csSettings, Wallet, UIUtils, WotService, Modals) {
+function WotCertificationsViewController($scope, $rootScope, $timeout, $translate, csConfig, csSettings, Wallet, UIUtils, WotService, Modals) {
   'ngInject';
 
   $scope.loading = true;
diff --git a/www/js/services/network-services.js b/www/js/services/network-services.js
index e30cfa953..e602fc93c 100644
--- a/www/js/services/network-services.js
+++ b/www/js/services/network-services.js
@@ -1,7 +1,7 @@
 
 angular.module('cesium.network.services', ['ngResource', 'ngApi', 'cesium.bma.services'])
 
-.factory('csNetwork', function($rootScope, $q, $interval, $timeout, BMA, Api, csSettings) {
+.factory('csNetwork', function($rootScope, $q, $interval, $timeout, BMA, Api, csSettings, UIUtils) {
   'ngInject';
 
   factory = function(id) {
@@ -129,12 +129,12 @@ angular.module('cesium.network.services', ['ngResource', 'ngApi', 'cesium.bma.se
             }
             console.debug('[network] Peer [' + peer.server + ']    status [UP]   block [' + peer.buid.substring(0, 20) + ']');
 
-            if (csSettings.data.expertMode) {
+            if (csSettings.data.expertMode && !UIUtils.screen.isSmall()) {
               // Get Version
               return node.node.summary()
                 .then(function(res){
                   peer.version = res && res.duniter && res.duniter.version;
-                  // Get hardship
+                  // Get hardship (if member peer)
                   if (peer.uid) {
                     return node.blockchain.stats.hardship({pubkey: peer.pubkey})
                       .then(function (res) {
diff --git a/www/js/services/settings-services.js b/www/js/services/settings-services.js
index 0669160d2..2c6f177e5 100644
--- a/www/js/services/settings-services.js
+++ b/www/js/services/settings-services.js
@@ -28,7 +28,7 @@ angular.module('cesium.settings.services', ['ngResource', 'ngApi', 'cesium.confi
         showUDHistory: true,
         showLoginSalt: false,
         initPhase: false, // For currency start (when block #0 not written)
-        expertMode: true,
+        expertMode: false,
         helptip: {
           enable: true,
           currency: 0,
@@ -130,10 +130,11 @@ angular.module('cesium.settings.services', ['ngResource', 'ngApi', 'cesium.confi
           angular.merge(data, storedData);
 
           // Always force the usage of deffault settings
-          // This is a workaround for DEV (TODO: implement edition in settings)
+          // This is a workaround for DEV (TODO: implement edition in settings ?)
           data.timeWarningExpire = defaultSettings.timeWarningExpire;
           data.timeWarningExpireMembership = defaultSettings.timeWarningExpireMembership;
           data.cacheTimeMs = defaultSettings.cacheTimeMs;
+          data.timeout = defaultSettings.timeout;
 
           // Apply the new locale (only if need)
           if (localeChanged) {
diff --git a/www/plugins/es/js/controllers/message-controllers.js b/www/plugins/es/js/controllers/message-controllers.js
index 2092312ea..073571ea7 100644
--- a/www/plugins/es/js/controllers/message-controllers.js
+++ b/www/plugins/es/js/controllers/message-controllers.js
@@ -315,7 +315,7 @@ function ESMessageComposeModalController($scope, Modals, UIUtils, CryptoUtils, W
 }
 
 
-function ESMessageViewController($scope, $state, $timeout, $translate, $ionicHistory, UIUtils, esModals, esMessage) {
+function ESMessageViewController($scope, $state, $timeout, $translate, $ionicHistory, UIUtils, esModals, esMessage, esUser) {
   'ngInject';
 
   $scope.formData = {};
@@ -346,9 +346,9 @@ function ESMessageViewController($scope, $state, $timeout, $translate, $ionicHis
 
             if (!message.valid) {
 
-              return UIUtils.alert.error(!$scope.isUserPubkey(message.pubkey) ? 'MESSAGE.ERROR.USER_NOT_RECIPIENT': 'MESSAGE.ERROR.NOT_AUTHENTICATED_MESSAGE',
+              return UIUtils.alert.error(!$scope.isUserPubkey(message.recipient) ? 'MESSAGE.ERROR.USER_NOT_RECIPIENT' : 'MESSAGE.ERROR.NOT_AUTHENTICATED_MESSAGE',
                 'MESSAGE.ERROR.MESSAGE_NOT_READABLE')
-                .then(function() {
+                .then(function () {
                   $state.go('app.user_message');
                 });
             }
@@ -357,6 +357,15 @@ function ESMessageViewController($scope, $state, $timeout, $translate, $ionicHis
             $scope.canDelete = true;
             $scope.loading = false;
 
+            // Load avatar and name (and uid)
+            return esUser.profile.fillAvatars([{pubkey: $scope.formData.issuer}])
+              .then(function (idties) {
+                return idties[0];
+              });
+          })
+          .then(function(member) {
+            $scope.issuer = member;
+
             // Set Motion (only direct children, to exclude .lazy-load children)
             $timeout(function () {
               UIUtils.motion.fadeSlideIn({
diff --git a/www/plugins/es/js/services/user-services.js b/www/plugins/es/js/services/user-services.js
index 33ab592e9..9bd15499c 100644
--- a/www/plugins/es/js/services/user-services.js
+++ b/www/plugins/es/js/services/user-services.js
@@ -176,6 +176,11 @@ angular.module('cesium.es.user.services', ['cesium.services', 'cesium.es.http.se
       ])
       .then(function() {
         if (hits.total === 0) {
+          _.forEach(datas, function(data) {
+            if (!data.uid && data[pubkeyAtributeName]) {
+              data.uid = uidsByPubkey[data[pubkeyAtributeName]];
+            }
+          });
           resolve(datas);
         }
         else {
diff --git a/www/plugins/es/templates/market/view_record.html b/www/plugins/es/templates/market/view_record.html
index 7788f0ed4..bea65d03b 100644
--- a/www/plugins/es/templates/market/view_record.html
+++ b/www/plugins/es/templates/market/view_record.html
@@ -44,9 +44,14 @@
               <span translate>COMMON.SUBMIT_BY</span>
               <a ng-class="{'positive': issuer.uid, 'dark': !issuer.uid}"
                  ui-sref="app.wot_view_identity({pubkey:issuer.pubkey, uid: issuer.name||issuer.uid})">
-                <i class="icon"
-                   ng-class="{'ion-person': issuer.uid, 'ion-key': !issuer.uid}"></i>
-                {{::issuer.name||issuer.uid||issuer.pubkey}}
+                <ng-if ng-if="issuer.uid">
+                  <i class="icon ion-person""></i>
+                  {{::issuer.name||issuer.uid}}
+                </ng-if>
+                <ng-if ng-if="!issuer.uid">
+                  <i class="icon ion-key""></i>
+                  {{::issuer.pubkey|formatPubkey}}
+                </ng-if>
               </a>
               <span>
                 {{formData.time|formatFromNow}}
diff --git a/www/plugins/es/templates/message/view_message.html b/www/plugins/es/templates/message/view_message.html
index 39e3e0b9c..78d32205b 100644
--- a/www/plugins/es/templates/message/view_message.html
+++ b/www/plugins/es/templates/message/view_message.html
@@ -26,20 +26,20 @@
         <ion-list class="animate-fade-slide-in item-text-wrap">
 
 
-          <div class="item" ng-class="{'item-avatar': formData.avatar}">
-            <img ng-if="formData.avatar" class="item-image" ng-src="{{::formData.avatar.src}}">
+          <div class="item" ng-class="{'item-avatar': issuer.avatar}">
+            <img ng-if="issuer.avatar" class="item-image" ng-src="{{::issuer.avatar.src}}">
             <h1 ng-bind-html="formData.title"></h1>
             <h4>
               <i class="ion-clock"></i>
               <span translate>MESSAGE.VIEW.SENDER</span>
-              <a class="positive" ui-sref="app.wot_view_identity({pubkey:formData.pubkey, uid:formData.uid})">
-                <span ng-if="formData.uid">
+              <a class="positive" ui-sref="app.wot_view_identity({pubkey:formData.issuer, uid: issuer.name||issuer.uid})">
+                <span ng-if="issuer.uid">
                   <i class="ion-person"></i>
-                  {{::formData.name||formData.uid}}
+                  {{issuer.name||issuer.uid}}
                 </span>
-                <span ng-if="!formData.uid">
+                <span ng-if="!issuer.uid">
                   <i class="ion-key"></i>
-                  {{::formData.pubkey|formatPubkey}}
+                  {{formData.pubkey|formatPubkey}}
                 </span>
               </a>
               <span>
diff --git a/www/plugins/es/templates/registry/view_record.html b/www/plugins/es/templates/registry/view_record.html
index 7d8f94316..afb9a250e 100644
--- a/www/plugins/es/templates/registry/view_record.html
+++ b/www/plugins/es/templates/registry/view_record.html
@@ -48,9 +48,14 @@
             <span translate>COMMON.SUBMIT_BY</span>
             <a ng-class="{'positive': issuer.uid, 'dark': !issuer.uid}"
                ui-sref="app.wot_view_identity({pubkey:issuer.pubkey, uid: issuer.name||issuer.uid})">
-              <i class="icon"
-                 ng-class="{'ion-person': issuer.uid, 'ion-key': !issuer.uid}"></i>
-              {{::issuer.name||issuer.uid||issuer.pubkey}}
+              <ng-if ng-if="issuer.uid">
+                <i class="icon ion-person""></i>
+                {{::issuer.name||issuer.uid}}
+              </ng-if>
+              <ng-if ng-if="!issuer.uid">
+                <i class="icon ion-key""></i>
+                {{issuer.pubkey|formatPubkey}}
+              </ng-if>
             </a>
             <span>
                 {{formData.time|formatFromNow}}
-- 
GitLab