From 400adcb31b2e2f3f4cbf1c42a1a46eac456d419d Mon Sep 17 00:00:00 2001
From: blavenie <benoit.lavenier@e-is.pro>
Date: Sat, 11 Feb 2017 16:34:08 +0100
Subject: [PATCH] - blockchain: Fix new block refreshing - fix #322 - Currency
 block tab (small device): enable search button  - Network: disable search
 block if extension has been disable

---
 www/css/ionic.app.css                         |  6 ----
 www/index.html                                |  1 +
 www/js/controllers/blockchain-controllers.js  |  4 +--
 .../js/controllers/blockchain-controllers.js  | 14 +++++++-
 .../es/js/controllers/currency-controllers.js | 35 +++++++++++++++++++
 www/plugins/es/js/plugin.js                   |  1 +
 .../templates/currency/tab_blocks_extend.html |  5 +--
 www/templates/currency/tabs/tab_blocks.html   |  7 ++--
 8 files changed, 58 insertions(+), 15 deletions(-)

diff --git a/www/css/ionic.app.css b/www/css/ionic.app.css
index a5a3c970c..4419ce067 100644
--- a/www/css/ionic.app.css
+++ b/www/css/ionic.app.css
@@ -15027,9 +15027,3 @@ a.underline:hover,
   font-size: 16px;
   left: 25px;
   top: -7px; }
-
-/*********
-* Tabs
-***********/
-.has-tabs-top {
-  /*top: 44px;*/ }
diff --git a/www/index.html b/www/index.html
index e5caaf1e2..219f32555 100644
--- a/www/index.html
+++ b/www/index.html
@@ -118,6 +118,7 @@
   <script src="dist/dist_js/plugins/es/js/controllers/common-controllers.js"></script>
   <script src="dist/dist_js/plugins/es/js/controllers/app-controllers.js"></script>
   <script src="dist/dist_js/plugins/es/js/controllers/settings-controllers.js"></script>
+  <script src="dist/dist_js/plugins/es/js/controllers/currency-controllers.js"></script>
   <script src="dist/dist_js/plugins/es/js/controllers/wot-controllers.js"></script>
   <script src="dist/dist_js/plugins/es/js/controllers/market-controllers.js"></script>
   <script src="dist/dist_js/plugins/es/js/controllers/registry-controllers.js"></script>
diff --git a/www/js/controllers/blockchain-controllers.js b/www/js/controllers/blockchain-controllers.js
index 0527a15fa..95a09c85e 100644
--- a/www/js/controllers/blockchain-controllers.js
+++ b/www/js/controllers/blockchain-controllers.js
@@ -353,7 +353,7 @@ function BlockLookupController($scope, $timeout, $focus, $filter, $state, $ancho
             console.debug('[ES] [blockchain] new block #{0} received (by websocket)'.format(block.number));
             $scope.search.total++;
             $scope.search.results.push(block);
-            return showBlock(existingBlock);
+            return showBlock(block);
           });
       }
       else {
@@ -380,7 +380,7 @@ function BlockLookupController($scope, $timeout, $focus, $filter, $state, $ancho
               // Insert at index 0
               $scope.search.total++;
               $scope.search.results.splice(0, 0, block);
-              return showBlock(existingBlock);
+              return showBlock(block);
             });
         }
       }
diff --git a/www/plugins/es/js/controllers/blockchain-controllers.js b/www/plugins/es/js/controllers/blockchain-controllers.js
index 97ed2ceb2..f7f3fd9dc 100644
--- a/www/plugins/es/js/controllers/blockchain-controllers.js
+++ b/www/plugins/es/js/controllers/blockchain-controllers.js
@@ -179,8 +179,20 @@ function ESBlockLookupController($scope, $state, $controller, UIUtils, esBlockch
   };
 }
 
-function ESNetworkViewExtendController($scope, PluginService) {
+function ESNetworkViewExtendController($scope, PluginService, csSettings) {
   'ngInject';
 
   $scope.extensionPoint = PluginService.extensions.points.current.get();
+
+  $scope.updateView = function() {
+    $scope.enable = csSettings.data.plugins && csSettings.data.plugins.es ?
+      csSettings.data.plugins.es.enable :
+      !!csSettings.data.plugins.host;
+  };
+
+  csSettings.api.data.on.changed($scope, function() {
+    $scope.updateView();
+  });
+
+  $scope.updateView();
 }
diff --git a/www/plugins/es/js/controllers/currency-controllers.js b/www/plugins/es/js/controllers/currency-controllers.js
index 146de96c1..294cee034 100644
--- a/www/plugins/es/js/controllers/currency-controllers.js
+++ b/www/plugins/es/js/controllers/currency-controllers.js
@@ -1,5 +1,40 @@
 angular.module('cesium.es.currency.controllers', ['ngResource', 'cesium.es.services'])
 
+  .config(function(PluginServiceProvider, csConfig) {
+    'ngInject';
 
+    var enable = csConfig.plugins && csConfig.plugins.es;
+    if (enable) {
+      PluginServiceProvider.extendState('app.currency.tab_blocks', {
+        points: {
+          'nav-buttons': {
+            templateUrl: "plugins/es/templates/currency/tab_blocks_extend.html",
+            controller: 'ESCurrencyTabBlocksExtendCtrl'
+          }
+        }
+      })
+      ;
+    }
+  })
 
+  .controller('ESCurrencyTabBlocksExtendCtrl', ESCurrencyTabBlocksExtendController)
 ;
+
+function ESCurrencyTabBlocksExtendController($scope, PluginService, csSettings) {
+  'ngInject';
+
+  $scope.extensionPoint = PluginService.extensions.points.current.get();
+
+  $scope.updateView = function() {
+    $scope.enable = csSettings.data.plugins && csSettings.data.plugins.es ?
+      csSettings.data.plugins.es.enable :
+      !!csSettings.data.plugins.host;
+  };
+
+  csSettings.api.data.on.changed($scope, function() {
+    $scope.updateView();
+  });
+
+  $scope.updateView();
+
+}
diff --git a/www/plugins/es/js/plugin.js b/www/plugins/es/js/plugin.js
index 34eae6e87..56c2d5901 100644
--- a/www/plugins/es/js/plugin.js
+++ b/www/plugins/es/js/plugin.js
@@ -6,6 +6,7 @@ angular.module('cesium.es.plugin', [
     'cesium.es.app.controllers',
     'cesium.es.common.controllers',
     'cesium.es.settings.controllers',
+    'cesium.es.currency.controllers',
     'cesium.es.wot.controllers',
     'cesium.es.user.controllers',
     'cesium.es.message.controllers',
diff --git a/www/plugins/es/templates/currency/tab_blocks_extend.html b/www/plugins/es/templates/currency/tab_blocks_extend.html
index dd79451ff..6524798fe 100644
--- a/www/plugins/es/templates/currency/tab_blocks_extend.html
+++ b/www/plugins/es/templates/currency/tab_blocks_extend.html
@@ -1,7 +1,8 @@
+
 <!-- Buttons section -->
 <ng-if ng-if="enable && extensionPoint === 'nav-buttons'">
-  <button class="button button-icon button-clear visible-xs visible-sm"
+
+  <button class="button button-icon button-clear icon ion-android-search visible-xs visible-sm"
           ui-sref="app.blockchain_search">
-    <i class="icon ion-android-search"></i>
   </button>
 </ng-if>
diff --git a/www/templates/currency/tabs/tab_blocks.html b/www/templates/currency/tabs/tab_blocks.html
index d1f7802f8..ff6ed292f 100644
--- a/www/templates/currency/tabs/tab_blocks.html
+++ b/www/templates/currency/tabs/tab_blocks.html
@@ -1,15 +1,14 @@
 <ion-view>
   <ion-nav-buttons side="secondary">
 
-    <button class="button button-icon button-clear visible-xs visible-sm"
+    <button class="button button-icon button-clear icon ion-navicon visible-xs visible-sm"
             ng-click="toggleCompactMode()">
-      <i class="icon ion-navicon"></i>
       <b class="icon-secondary"
          ng-class="{'ion-arrow-down-b': !compactMode, 'ion-arrow-up-b': compactMode}"
-         style="top: -9px; left: 9px; font-size: 8px;"></b>
+         style="top: -12px; left: 11px; font-size: 10px;"></b>
       <b class="icon-secondary"
          ng-class="{'ion-arrow-up-b': !compactMode,'ion-arrow-down-b': compactMode}"
-         style="top: 9px; left: 9px; font-size: 8px;"></b>
+         style="top: 12px; left: 11px; font-size: 10px;"></b>
     </button>
 
     <!-- Allow extension here -->
-- 
GitLab