From 00cef7ef44ffce3dd3dbd8a69f34fe40c1007532 Mon Sep 17 00:00:00 2001
From: Benoit Lavenier <benoit.lavenier@e-is.pro>
Date: Sat, 4 Jan 2020 13:21:29 +0100
Subject: [PATCH] [fix] ES network: Fix page preview in last document explorere
 [fix] ES peer: Add buttons to show stats (data and synchro)

---
 dist/desktop                                  |  2 +-
 platforms/android                             |  2 +-
 www/js/controllers/network-controllers.js     |  6 +-
 www/plugins/es/i18n/locale-en-GB.json         |  2 +-
 www/plugins/es/i18n/locale-en.json            |  2 +-
 www/plugins/es/i18n/locale-fr-FR.json         |  2 +-
 .../es/js/controllers/document-controllers.js | 23 ++++---
 .../es/js/controllers/network-controllers.js  | 62 +++++++++----------
 .../es/js/services/document-services.js       |  9 +--
 www/plugins/es/js/services/http-services.js   | 24 +++----
 .../es/js/services/settings-services.js       |  6 +-
 .../document/item_document_page.html          | 40 ++++++++++++
 .../document/item_document_profile.html       |  2 +-
 .../templates/document/items_documents.html   |  6 +-
 .../{view_peer.html => view_es_peer.html}     | 38 ++++++------
 www/plugins/graph/i18n/locale-fr-FR.json      |  2 +-
 .../js/controllers/network-controllers.js     |  9 +++
 .../js/controllers/synchro-controllers.js     |  2 +
 .../network/view_es_peer_extend.html          | 20 ++++++
 19 files changed, 176 insertions(+), 83 deletions(-)
 create mode 100644 www/plugins/es/templates/document/item_document_page.html
 rename www/plugins/es/templates/network/{view_peer.html => view_es_peer.html} (88%)
 create mode 100644 www/plugins/graph/templates/network/view_es_peer_extend.html

diff --git a/dist/desktop b/dist/desktop
index be5b9ddb..2667bc6e 160000
--- a/dist/desktop
+++ b/dist/desktop
@@ -1 +1 @@
-Subproject commit be5b9ddbbb88a5a129ec47c0968b9061de3bfe29
+Subproject commit 2667bc6efab8ae2393ab57f330c33f7dedf99fe2
diff --git a/platforms/android b/platforms/android
index 34160271..8995b191 160000
--- a/platforms/android
+++ b/platforms/android
@@ -1 +1 @@
-Subproject commit 34160271cd5a12ae2ff5765794ca9a84decb1767
+Subproject commit 8995b1918fb5cb60b86e6ba53073d5fddb4d36c2
diff --git a/www/js/controllers/network-controllers.js b/www/js/controllers/network-controllers.js
index 0fdbb64e..d194b156 100644
--- a/www/js/controllers/network-controllers.js
+++ b/www/js/controllers/network-controllers.js
@@ -257,7 +257,7 @@ function NetworkLookupController($scope,  $state, $location, $ionicPopover, $win
       return;
     }
 
-    // Skipp offline or not a BMA peer
+    // Skip offline or not a BMA peer
     if (!peer.online || !peer.hasBma()) return;
 
     var stateParams = {server: peer.getServer()};
@@ -484,7 +484,7 @@ function PeerInfoPopoverController($scope, $q, csSettings, csCurrency, csHttp, B
           // continue
         }),
 
-      // Get duniter latest version
+      // Get latest version
       BMA.version.latest()
         .then(function(latestRelease){
           $scope.formData.latestRelease = latestRelease;
@@ -567,7 +567,7 @@ function PeerViewController($scope, $q, $window, $state, UIUtils, csWot, BMA) {
       useTor: useTor
     };
     var serverParts = server.split(':');
-    if (serverParts.length == 2) {
+    if (serverParts.length === 2) {
       node.host = serverParts[0];
       node.port = serverParts[1];
     }
diff --git a/www/plugins/es/i18n/locale-en-GB.json b/www/plugins/es/i18n/locale-en-GB.json
index e45f63b4..48952569 100644
--- a/www/plugins/es/i18n/locale-en-GB.json
+++ b/www/plugins/es/i18n/locale-en-GB.json
@@ -423,7 +423,7 @@
       "READ": "Read",
       "BTN_REMOVE": "Delete this document",
       "BTN_COMPACT": "Compact",
-      "HAS_REGISTERED": "create or edit his profile",
+      "HAS_CREATE_OR_UPDATE_PROFILE": "create or edit his profile",
       "POPOVER_ACTIONS": {
         "TITLE": "Actions",
         "REMOVE_ALL": "Delete these documents..."
diff --git a/www/plugins/es/i18n/locale-en.json b/www/plugins/es/i18n/locale-en.json
index e45f63b4..48952569 100644
--- a/www/plugins/es/i18n/locale-en.json
+++ b/www/plugins/es/i18n/locale-en.json
@@ -423,7 +423,7 @@
       "READ": "Read",
       "BTN_REMOVE": "Delete this document",
       "BTN_COMPACT": "Compact",
-      "HAS_REGISTERED": "create or edit his profile",
+      "HAS_CREATE_OR_UPDATE_PROFILE": "create or edit his profile",
       "POPOVER_ACTIONS": {
         "TITLE": "Actions",
         "REMOVE_ALL": "Delete these documents..."
diff --git a/www/plugins/es/i18n/locale-fr-FR.json b/www/plugins/es/i18n/locale-fr-FR.json
index cdf39e9c..2b3175d2 100644
--- a/www/plugins/es/i18n/locale-fr-FR.json
+++ b/www/plugins/es/i18n/locale-fr-FR.json
@@ -474,7 +474,7 @@
       "READ": "Lu",
       "BTN_REMOVE": "Supprimer ce document",
       "BTN_COMPACT": "Compacter",
-      "HAS_REGISTERED": "a créé ou modifié son profil",
+      "HAS_CREATE_OR_UPDATE_PROFILE": "a créé ou modifié son profil",
       "POPOVER_ACTIONS": {
         "TITLE": "Actions",
         "REMOVE_ALL": "Supprimer ces documents..."
diff --git a/www/plugins/es/js/controllers/document-controllers.js b/www/plugins/es/js/controllers/document-controllers.js
index 7d5d335c..7605c974 100644
--- a/www/plugins/es/js/controllers/document-controllers.js
+++ b/www/plugins/es/js/controllers/document-controllers.js
@@ -331,9 +331,12 @@ function ESDocumentLookupController($scope, $ionicPopover, $location, $timeout,
 }
 
 
-function ESLastDocumentsController($scope, $controller, $timeout, $state) {
+function ESLastDocumentsController($scope, $controller, $timeout, $state, $filter) {
   'ngInject';
 
+  // Initialize the super class and extend it.
+  angular.extend(this, $controller('ESDocumentLookupCtrl', {$scope: $scope}));
+
   $scope.search = {
     loading: true,
     hasMore: true,
@@ -345,11 +348,9 @@ function ESLastDocumentsController($scope, $controller, $timeout, $state) {
   };
   $scope.expertMode = false;
   $scope.defaultSizeLimit = 20;
-  $scope._source = ["issuer", "hash", "time", "creationTime", "title", "avatar._content_type", "city", "message", "record"];
+  $scope._source = ["issuer", "hash", "time", "creationTime", "title", "avatar._content_type", "city", "message", "record", "type"];
   $scope.showHeaders = false;
 
-  // Initialize the super class and extend it.
-  angular.extend(this, $controller('ESDocumentLookupCtrl', {$scope: $scope}));
   $scope.$on('$ionicParentView.enter', $scope.enter);
 
   $scope.selectDocument = function(event, doc) {
@@ -361,13 +362,21 @@ function ESLastDocumentsController($scope, $controller, $timeout, $state) {
     }
     else if (doc.index === "page" && doc.type === "record") {
       $state.go('app.view_page', {title: doc.title, id: doc.id});
-      return
+    }
+    else if (doc.index === "page" && doc.type === "comment") {
+      var anchor = $filter('formatHash')(doc.id);
+      $state.go('app.view_page_anchor', {title: doc.title, id: doc.record, anchor: anchor});
     }
     else if (doc.index === "group" && doc.type === "record") {
       $state.go('app.view_group', {title: doc.title, id: doc.id});
-      return
     }
-    console.warn("Click on this kind of document not implement yet!", doc)
+    else if (doc.index === "group" && doc.type === "comment") {
+      var anchor = $filter('formatHash')(doc.id);
+      $state.go('app.view_group_anchor', {title: doc.title, id: doc.record, anchor: anchor});
+    }
+    else {
+      console.warn("Click on this kind of document not implement yet!", doc)
+    }
   };
 
   // Override parent function computeOptions
diff --git a/www/plugins/es/js/controllers/network-controllers.js b/www/plugins/es/js/controllers/network-controllers.js
index c94988af..57370f54 100644
--- a/www/plugins/es/js/controllers/network-controllers.js
+++ b/www/plugins/es/js/controllers/network-controllers.js
@@ -42,11 +42,11 @@ angular.module('cesium.es.network.controllers', ['cesium.es.services'])
     })
 
     .state('app.view_es_peer', {
-      url: "/data/network/peer/:server?ssl&tor",
+      url: "/network/data/peer/:server?ssl&tor",
       cache: false,
       views: {
         'menuContent': {
-          templateUrl: "plugins/es/templates/network/view_peer.html",
+          templateUrl: "plugins/es/templates/network/view_es_peer.html",
           controller: 'ESPeerViewCtrl'
         }
       },
@@ -166,6 +166,7 @@ function ESNetworkLookupController($scope,  $state, $location, $ionicPopover, $w
   $scope.load = function() {
 
     if ($scope.search.loading){
+      // Start network scan
       esNetwork.start($scope.node, $scope.computeOptions());
 
       // Catch event on new peers
@@ -197,12 +198,12 @@ function ESNetworkLookupController($scope,  $state, $location, $ionicPopover, $w
     $scope.search.memberPeersCount = data.memberPeersCount;
     // Always tru if network not started (e.g. after leave+renter the view)
     $scope.search.loading = !$scope.networkStarted || esNetwork.isBusy();
+    if (!$scope.loading) {
+      $scope.$broadcast('$$rebind::rebind'); // force data binding
+    }
     if ($scope.motion && $scope.search.results && $scope.search.results.length > 0) {
       $scope.motion.show({selector: '.item-peer'});
     }
-    if (!$scope.loading) {
-      $scope.$broadcast('$$rebind::' + 'rebind'); // force data binding
-    }
   };
 
   $scope.refresh = function() {
@@ -227,7 +228,7 @@ function ESNetworkLookupController($scope,  $state, $location, $ionicPopover, $w
 
     // Update location href
     if ($scope.enableLocationHref) {
-      $location.search({online: $scope.search.online}).replace();
+      $location.search($scope.search.online ? {} : {online: false}).replace();
     }
   };
 
@@ -281,30 +282,27 @@ function ESNetworkLookupController($scope,  $state, $location, $ionicPopover, $w
   /* -- popover -- */
 
   $scope.showActionsPopover = function(event) {
-    if (!$scope.actionsPopover) {
-      $ionicPopover.fromTemplateUrl('templates/network/lookup_popover_actions.html', {
-        scope: $scope
-      }).then(function(popover) {
+    UIUtils.popover.show(event, {
+      templateUrl: 'plugins/es/templates/network/lookup_popover_actions.html',
+      scope: $scope,
+      autoremove: true,
+      afterShow: function(popover) {
         $scope.actionsPopover = popover;
-        //Cleanup the popover when we're done with it!
-        $scope.$on('$destroy', function() {
-          $scope.actionsPopover.remove();
-        });
-        $scope.actionsPopover.show(event);
-      });
-    }
-    else {
-      $scope.actionsPopover.show(event);
-    }
+      }
+    });
   };
 
   $scope.hideActionsPopover = function() {
     if ($scope.actionsPopover) {
       $scope.actionsPopover.hide();
+      $scope.actionsPopover = null;
     }
   };
 
   $scope.showEndpointsPopover = function($event, peer, endpointFilter) {
+    $event.preventDefault();
+    $event.stopPropagation();
+
     var endpoints = peer.getEndpoints(endpointFilter);
     endpoints = (endpoints||[]).reduce(function(res, ep) {
       var bma = esHttp.node.parseEndPoint(ep);
@@ -322,7 +320,6 @@ function ESNetworkLookupController($scope,  $state, $location, $ionicPopover, $w
         items: endpoints
       }
     });
-    $event.stopPropagation();
   };
 
   $scope.showWs2pPopover = function($event, peer) {
@@ -348,8 +345,8 @@ function ESNetworkLookupController($scope,  $state, $location, $ionicPopover, $w
                 label: 'NETWORK.VIEW.POW_PREFIX',
                 value: peer.powPrefix
               }]
-          }
-        });
+            }
+          });
       });
   };
 
@@ -482,7 +479,7 @@ function ESPeerInfoPopoverController($scope, $q, csSettings, csCurrency, csHttp,
           // continue
         }),
 
-      // Get duniter latest version
+      // Get latest version
       esHttp.version.latest()
         .then(function(latestRelease){
           $scope.formData.latestRelease = latestRelease;
@@ -494,7 +491,7 @@ function ESPeerInfoPopoverController($scope, $q, csSettings, csCurrency, csHttp,
     ])
       .then(function() {
         // Compare, to check if newer
-        if ($scope.formData.latestRelease && $scope.formData.software == 'duniter') {
+        if ($scope.formData.latestRelease && $scope.formData.software === 'cesium-plus-pod') {
           var compare = csHttp.version.compare($scope.formData.version, $scope.formData.latestRelease.version);
           $scope.formData.isPreRelease = compare > 0;
           $scope.formData.hasNewRelease = compare < 0;
@@ -504,7 +501,7 @@ function ESPeerInfoPopoverController($scope, $q, csSettings, csCurrency, csHttp,
           $scope.formData.hasNewRelease = false;
         }
         $scope.loading = false;
-        $scope.$broadcast('$$rebind::' + 'rebind'); // force data binding
+        $scope.$broadcast('$$rebind::rebind'); // force data binding
       });
   };
 
@@ -557,6 +554,9 @@ function ESPeerViewController($scope, $q, $window, $state, UIUtils, csWot, esHtt
       })
       .then(function(){
         $scope.loading = false;
+      })
+      .catch(function() {
+        $scope.loading = false;
       });
   });
 
@@ -568,7 +568,7 @@ function ESPeerViewController($scope, $q, $window, $state, UIUtils, csWot, esHtt
       useTor: useTor
     };
     var serverParts = server.split(':');
-    if (serverParts.length == 2) {
+    if (serverParts.length === 2) {
       node.host = serverParts[0];
       node.port = serverParts[1];
     }
@@ -589,8 +589,8 @@ function ESPeerViewController($scope, $q, $window, $state, UIUtils, csWot, esHtt
           // find the current peer
           var peers = (res && res.peers || []).reduce(function(res, json) {
             var peer = new EsPeer(json);
-            if (!peer.hasEndpoint('GCHANGE_API')) return res;
-            var ep = esHttp.node.parseEndPoint(peer.getEndpoints('GCHANGE_API')[0]);
+            if (!peer.hasEsEndpoint()) return res;
+            var ep = esHttp.node.parseEndPoint(peer.getEsEndpoints()[0]);
             if((ep.dns == node.host || ep.ipv4 == node.host || ep.ipv6 == node.host) && (
               ep.port == node.port)) {
               peer.ep = ep;
@@ -632,10 +632,10 @@ function ESPeerViewController($scope, $q, $window, $state, UIUtils, csWot, esHtt
         .then(function(json) {
           var peers = json.peers.reduce(function (res, p) {
             var peer = new EsPeer(p);
-            if (!peer.hasEndpoint('GCHANGE_API')) return res;
+            if (!peer.hasEsEndpoint()) return res;
             peer.online = p.status === 'UP';
             peer.blockNumber = peer.block.replace(/-.+$/, '');
-            peer.ep = esHttp.node.parseEndPoint(peer.getEndpoints('GCHANGE_API')[0]);
+            peer.ep = esHttp.node.parseEndPoint(peer.getEsEndpoints()[0]);
             peer.dns = peer.getDns();
             peer.id = peer.keyID();
             peer.server = peer.getServer();
diff --git a/www/plugins/es/js/services/document-services.js b/www/plugins/es/js/services/document-services.js
index 7e987962..cba149d9 100644
--- a/www/plugins/es/js/services/document-services.js
+++ b/www/plugins/es/js/services/document-services.js
@@ -32,7 +32,7 @@ angular.module('cesium.es.document.services', ['ngResource', 'cesium.platform',
       if (!options || !options.index || !options.type) throw new Error('Missing mandatory options [index, type]');
 
       var side = 'desc';
-      if (options.type == 'peer') {
+      if (options.type === 'peer') {
         if (!options.sort || options.sort.time) {
           side = options.sort && options.sort.time || side;
           options.sort = {
@@ -48,7 +48,7 @@ angular.module('cesium.es.document.services', ['ngResource', 'cesium.platform',
           return doc.time;
         };
       }
-      else if (options.type == 'movement') {
+      else if (options.type === 'movement') {
         if (!options.sort || options.sort.time) {
           side = options.sort && options.sort.time || side;
           options.sort = {'medianTime': side};
@@ -68,12 +68,13 @@ angular.module('cesium.es.document.services', ['ngResource', 'cesium.platform',
 
       var hits = (res && res.hits && res.hits.hits || []).reduce(function(res, hit) {
         var doc = hit._source || {};
+        doc.docType = doc.type; // Save source.type, before replacement
         doc.index = hit._index;
         doc.type = hit._type;
         doc.id = hit._id;
         doc.pubkey = doc.issuer || options.issuerField && doc[options.issuerField] || doc.pubkey; // need to call csWot.extendAll()
         doc.time = options.getTimeFunction && options.getTimeFunction(doc) || doc.time;
-        doc.thumbnail = esHttp.image.fromHit(hit, 'thumbnail');
+        doc.thumbnail = esHttp.image.fromHit(hit, 'avatar') || esHttp.image.fromHit(hit, 'thumbnail');
         return res.concat(doc);
       }, []);
 
@@ -143,7 +144,7 @@ angular.module('cesium.es.document.services', ['ngResource', 'cesium.platform',
       var request = {
         text: queryString,
         index: options.index || 'user',
-        type: options.type || 'event',
+        type: options.type || 'profiles',
         from: options.from || 0,
         size: options.size || constants.DEFAULT_LOAD_SIZE,
         sort: options.sort || 'time:desc',
diff --git a/www/plugins/es/js/services/http-services.js b/www/plugins/es/js/services/http-services.js
index 1aa5d2df..b4a7e6e0 100644
--- a/www/plugins/es/js/services/http-services.js
+++ b/www/plugins/es/js/services/http-services.js
@@ -224,17 +224,19 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic
     that.wsChanges = function(source) {
       var wsChanges = that.ws('/ws/_changes')();
       if (!source) return wsChanges;
-      // var oldOpen = wsChanges.open;
-      // wsChanges.open = function() {
-      //   return oldOpen.call(wsChanges).then(function(sock) {
-      //     if(sock) {
-      //       sock.send(source);
-      //     }
-      //     else {
-      //       console.warn('Trying to access ws changes, but no sock anymore... already open ?');
-      //     }
-      //   });
-      // };
+
+      // If a source is given, send it just after connection open
+      var _inheritedOpen = wsChanges.open;
+      wsChanges.open = function() {
+        return _inheritedOpen.call(wsChanges).then(function(sock) {
+          if(sock) {
+            sock.send(source);
+          }
+          else {
+            console.warn('Trying to access ws changes, but no sock anymore... already open ?');
+          }
+        });
+      };
       return wsChanges;
     };
 
diff --git a/www/plugins/es/js/services/settings-services.js b/www/plugins/es/js/services/settings-services.js
index aa2e539f..a9904d55 100644
--- a/www/plugins/es/js/services/settings-services.js
+++ b/www/plugins/es/js/services/settings-services.js
@@ -20,7 +20,7 @@ angular.module('cesium.es.settings.services', ['cesium.services', 'cesium.es.htt
       excludes: ['timeout', 'cacheTimeMs', 'version', 'build', 'minVersion', 'fallbackLanguage'],
       plugins: {
         es: {
-          excludes: ['enable', 'host', 'port', 'fallbackNodes', 'enableGoogleApi', 'googleApiKey'],
+          excludes: ['enable', 'host', 'port', 'fallbackNodes', 'enableGoogleApi', 'googleApiKey', 'document'],
           notifications: {
           }
         }
@@ -57,6 +57,10 @@ angular.module('cesium.es.settings.services', ['cesium.services', 'cesium.es.htt
             wot: {
               enableMixedSearch: true
             },
+            document: {
+              index: 'user,page,group',
+              type: 'profile,record,comment'
+            },
             registry: {
               defaultSearch: {
                 location: null,
diff --git a/www/plugins/es/templates/document/item_document_page.html b/www/plugins/es/templates/document/item_document_page.html
new file mode 100644
index 00000000..c1840d0c
--- /dev/null
+++ b/www/plugins/es/templates/document/item_document_page.html
@@ -0,0 +1,40 @@
+<ion-item id="doc-{{::doc.id}}"
+          class="item item-document item-icon-left ink {{::ionItemClass}} no-padding-top no-padding-bottom"
+          ng-class="{'positive-100-bg': doc.updated}"
+          ng-click="selectDocument($event, doc)">
+
+  <i ng-if=":rebind:doc.thumbnail" class="avatar" style="background-image: url({{:rebind:doc.thumbnail.src}})"></i>
+  <i ng-if=":rebind:!doc.thumbnail" class="avatar icon dark cion-registry-{{doc.docType}}" ></i>
+
+  <div class="row no-padding">
+    <div class="col">
+      <h3 ng-if="doc.title">
+        {{:rebind:doc.title}}
+      </h3>
+      <h4>
+        <span class="dark" ng-if=":rebind:doc.picturesCount > 1">
+          <i class="ion-camera"></i> {{:rebind:doc.picturesCount}}
+        </span>
+        <span class="dark" ng-if=":rebind:doc.city">
+          <i class="ion-location"></i> {{:rebind:doc.city}}
+        </span>
+        <span class="gray" ng-if=":rebind:doc.name">
+          <i class="ion-person"></i> {{:rebind:doc.name}}
+        </span>
+      </h4>
+    </div>
+
+    <div class="col col-33">
+      <small class="gray pull-right"><i class="ion-clock"></i> {{:rebind:doc.time|formatDate}}
+      </small>
+      <a
+        ng-if=":rebind:login && doc.pubkey==walletData.pubkey"
+        ng-click="remove($event, $index)"
+        class="gray pull-right hidden-xs hidden-sm"
+        title="{{'DOCUMENT.LOOKUP.BTN_REMOVE'|translate}}">
+        <i class="ion-trash-a"></i>
+      </a>
+    </div>
+
+  </div>
+</ion-item>
diff --git a/www/plugins/es/templates/document/item_document_profile.html b/www/plugins/es/templates/document/item_document_profile.html
index 94168814..2e06d778 100644
--- a/www/plugins/es/templates/document/item_document_profile.html
+++ b/www/plugins/es/templates/document/item_document_profile.html
@@ -14,7 +14,7 @@
          {{:rebind:doc.title}}
         </span>
         <span class="gray" >
-          {{:rebind:'DOCUMENT.LOOKUP.HAS_REGISTERED'|translate}}
+          {{:rebind:'DOCUMENT.LOOKUP.HAS_CREATE_OR_UPDATE_PROFILE' |translate}}
         </span>
       </h4>
       <h4>
diff --git a/www/plugins/es/templates/document/items_documents.html b/www/plugins/es/templates/document/items_documents.html
index b72f39ca..30a8ebce 100644
--- a/www/plugins/es/templates/document/items_documents.html
+++ b/www/plugins/es/templates/document/items_documents.html
@@ -29,11 +29,15 @@
 <ng-repeat ng-repeat="doc in :rebind:search.results track by doc.id"
            ng-switch on="doc.type">
   <div ng-switch-when="comment">
-    <ng-include src="::'plugins/es/templates/document/item_document_comment.html'"></ng-include>
+    <ng-include  src="::'plugins/es/templates/document/item_document_comment.html'"></ng-include>
   </div>
   <div ng-switch-when="profile">
     <ng-include src="::'plugins/es/templates/document/item_document_profile.html'"></ng-include>
   </div>
+  <div ng-switch-when="record">
+    <ng-include ng-if="doc.index === 'page'" src="::'plugins/es/templates/document/item_document_page.html'"></ng-include>
+    <ng-include ng-if="doc.index !== 'page'" src="::'plugins/es/templates/document/item_document.html'"></ng-include>
+  </div>
   <div ng-switch-default>
     <ng-include src="::'plugins/es/templates/document/item_document.html'"></ng-include>
   </div>
diff --git a/www/plugins/es/templates/network/view_peer.html b/www/plugins/es/templates/network/view_es_peer.html
similarity index 88%
rename from www/plugins/es/templates/network/view_peer.html
rename to www/plugins/es/templates/network/view_es_peer.html
index 8d102bf9..64bc49fa 100644
--- a/www/plugins/es/templates/network/view_peer.html
+++ b/www/plugins/es/templates/network/view_es_peer.html
@@ -1,6 +1,7 @@
 <ion-view>
   <ion-nav-title>
-    <span translate>PEER.VIEW.TITLE</span>
+    <span translate>PEER.VIEW.TITLE</span>&nbsp;
+    <span translate>ES_SETTINGS.PLUGIN_NAME</span>
   </ion-nav-title>
 
   <ion-content class="has-header" scroll="true">
@@ -74,23 +75,6 @@
           <h4 class="dark text-left">{{node.pubkey}}</h4>
         </ion-item>
 
-        <ion-item class="item item-icon-left item-text-wrap"
-                  ng-if="isReachable">
-          <i class="icon ion-document"></i>
-          <span translate>ES_PEER.DOCUMENT_COUNT</span>
-          <div class="badge badge-stable" ng-if="!loading">
-            {{node.docCount|formatInteger}}
-          </div>
-        </ion-item>
-
-        <!--<a class="item item-icon-left item-icon-right item-text-wrap ink"-->
-           <!--ng-if="isReachable"-->
-           <!--ui-sref="app.document_search(options.document)">-->
-          <!--<i class="icon ion-document" style="font-size: 25px;"></i>-->
-          <!--<i class="icon-secondary ion-clock" style="font-size: 18px; left: 33px; top: -12px;"></i>-->
-          <!--<span translate>DOCUMENT.LOOKUP.LAST_DOCUMENTS</span>-->
-          <!--<i class="gray icon ion-ios-arrow-right"></i>-->
-        <!--</a>-->
 
         <ion-item class="item item-icon-left item-text-wrap ink"
                   ng-if="isReachable">
@@ -101,6 +85,24 @@
           </div>
         </ion-item>
 
+        <ion-item class="item item-icon-left item-text-wrap"
+                  ng-if="isReachable">
+          <i class="icon ion-document"></i>
+          <span translate>ES_PEER.DOCUMENT_COUNT</span>
+          <div class="badge badge-stable" ng-if="!loading">
+            {{node.docCount|formatInteger}}
+          </div>
+        </ion-item>
+
+        <a class="item item-icon-left item-icon-right item-text-wrap ink"
+           ng-if="isReachable"
+           ui-sref="app.document_search(options.document)">
+          <i class="icon ion-document" style="font-size: 25px;"></i>
+          <i class="icon-secondary ion-clock" style="font-size: 18px; left: 33px; top: -12px;"></i>
+          <span translate>DOCUMENT.LOOKUP.LAST_DOCUMENTS</span>
+          <i class="gray icon ion-ios-arrow-right"></i>
+        </a>
+
         <!-- Allow extension here -->
         <cs-extension-point name="general"></cs-extension-point>
 
diff --git a/www/plugins/graph/i18n/locale-fr-FR.json b/www/plugins/graph/i18n/locale-fr-FR.json
index 83edacad..b79de1bc 100644
--- a/www/plugins/graph/i18n/locale-fr-FR.json
+++ b/www/plugins/graph/i18n/locale-fr-FR.json
@@ -68,7 +68,7 @@
       }
     },
     "DOC_STATS": {
-      "TITLE": "Statistiques de stockage (Cesium+)",
+      "TITLE": "Statistiques de stockage",
       "USER": {
         "TITLE": "Nombre de documents liés à un compte",
         "USER_PROFILE": "Profils utilisateur",
diff --git a/www/plugins/graph/js/controllers/network-controllers.js b/www/plugins/graph/js/controllers/network-controllers.js
index 946e7fdc..93cef43c 100644
--- a/www/plugins/graph/js/controllers/network-controllers.js
+++ b/www/plugins/graph/js/controllers/network-controllers.js
@@ -34,6 +34,15 @@ angular.module('cesium.graph.network.controllers', ['chart.js', 'cesium.graph.se
             }
           }
         })
+
+        .extendState('app.view_es_peer', {
+          points: {
+            'general': {
+              templateUrl: "plugins/graph/templates/network/view_es_peer_extend.html",
+              controller: 'ESExtensionCtrl'
+            }
+          }
+        })
       ;
 
       $stateProvider
diff --git a/www/plugins/graph/js/controllers/synchro-controllers.js b/www/plugins/graph/js/controllers/synchro-controllers.js
index c4216492..3a5f24b7 100644
--- a/www/plugins/graph/js/controllers/synchro-controllers.js
+++ b/www/plugins/graph/js/controllers/synchro-controllers.js
@@ -31,6 +31,8 @@ function GpSynchroController($scope, $controller, $q, $translate, gpColor, gpDat
   // Initialize the super class and extend it.
   angular.extend(this, $controller('GpCurrencyAbstractCtrl', {$scope: $scope}));
 
+  $scope.formData.rangeDuration = 'month';
+
   $scope.hiddenDatasets = [];
 
   $scope.charts = [
diff --git a/www/plugins/graph/templates/network/view_es_peer_extend.html b/www/plugins/graph/templates/network/view_es_peer_extend.html
new file mode 100644
index 00000000..bcb3a9e2
--- /dev/null
+++ b/www/plugins/graph/templates/network/view_es_peer_extend.html
@@ -0,0 +1,20 @@
+<!-- Buttons section -->
+<ng-if ng-if="enable && extensionPoint === 'general'">
+
+  <a class="item item-icon-left item-icon-right item-text-wrap ink"
+     ng-if="isReachable"
+     ui-sref="app.doc_stats_lg">
+    <i class="icon ion-stats-bars"></i>
+    <span translate>GRAPH.DOC_STATS.TITLE</span>
+    <i class="gray icon ion-ios-arrow-right"></i>
+  </a>
+
+  <a class="item item-icon-left item-icon-right item-text-wrap ink"
+     ng-if="isReachable"
+     ui-sref="app.doc_synchro_lg">
+    <i class="icon ion-stats-bars"></i>
+    <span translate>GRAPH.SYNCHRO.TITLE</span>
+    <i class="gray icon ion-ios-arrow-right"></i>
+  </a>
+</ng-if>
+
-- 
GitLab