Commit b03b53ca authored by Benoit Lavenier's avatar Benoit Lavenier

[fix] Network: Click peer Cs+ API should open a popover (and not the detail view)

parent 9518fee9
......@@ -300,25 +300,28 @@ function NetworkLookupController($scope, $state, $location, $ionicPopover, $win
}
};
$scope.showEndpointsPopover = function($event, peer, endpoint) {
var endpoints = peer.getEndpoints(endpoint);
$scope.showEndpointsPopover = function($event, peer, endpointName) {
$event.preventDefault();
$event.stopPropagation();
var endpoints = peer.getEndpoints(endpointName);
endpoints = (endpoints||[]).reduce(function(res, ep) {
var bma = BMA.node.parseEndPoint(ep);
var bma = BMA.node.parseEndPoint(ep) || BMA.node.parseEndPoint(ep, endpointName);
return res.concat({
label: 'NETWORK.VIEW.NODE_ADDRESS',
value: peer.getServer() + (bma.path||'')
value: peer.getServer(bma) + (bma && bma.path||'')
});
}, []);
if (!endpoints.length) return;
// Call extension points
UIUtils.popover.show($event, {
templateUrl: 'templates/network/popover_endpoints.html',
bindings: {
titleKey: 'NETWORK.VIEW.ENDPOINTS.' + endpoint,
titleKey: 'NETWORK.VIEW.ENDPOINTS.' + endpointName,
items: endpoints
}
});
$event.stopPropagation();
};
$scope.showWs2pPopover = function($event, peer) {
......
......@@ -123,24 +123,24 @@ Peer.prototype.getPort = function() {
return bma.port ? bma.port : null;
};
Peer.prototype.getHost = function() {
var bma = this.bma || this.getBMA();
Peer.prototype.getHost = function(getHost) {
bma = getHost || this.bma || this.getBMA();
return ((bma.port == 443 || bma.useSsl) && bma.dns) ? bma.dns :
(this.hasValid4(bma) ? bma.ipv4 :
(bma.dns ? bma.dns :
(bma.ipv6 ? '[' + bma.ipv6 + ']' :'')));
};
Peer.prototype.getURL = function() {
var bma = this.bma || this.getBMA();
var host = this.getHost();
Peer.prototype.getURL = function(bma) {
bma = bma || this.bma || this.getBMA();
var host = this.getHost(bma);
var protocol = (bma.port == 443 || bma.useSsl) ? 'https' : 'http';
return protocol + '://' + host + (bma.port ? (':' + bma.port) : '');
};
Peer.prototype.getServer = function() {
var bma = this.bma || this.getBMA();
var host = this.getHost();
Peer.prototype.getServer = function(bma) {
bma = bma || this.bma || this.getBMA();
var host = this.getHost(bma);
return host + (host && bma.port ? (':' + bma.port) : '');
};
......
......@@ -556,7 +556,7 @@ angular.module('cesium.bma.services', ['ngApi', 'cesium.http.services', 'cesium.
};
};
exports.node.parseEndPoint = function(endpoint) {
exports.node.parseEndPoint = function(endpoint, epPrefix) {
// Try BMA
var matches = exports.regexp.BMA_ENDPOINT.exec(endpoint);
if (matches) {
......@@ -621,6 +621,23 @@ angular.module('cesium.bma.services', ['ngApi', 'cesium.http.services', 'cesium.
"useWs2p": true
};
}
// Use generic match
if (epPrefix) {
matches = exact(epPrefix + REGEX_ENDPOINT_PARAMS).exec(endpoint);
if (matches) {
return {
"dns": matches[2] || '',
"ipv4": matches[4] || '',
"ipv6": matches[6] || '',
"port": matches[8] || 80,
"useSsl": matches[8] && matches[8] == 443,
"path": matches[10],
"useBma": false
};
}
}
};
exports.copy = function(otherNode) {
......
<!-- Buttons section -->
<ng-if ng-if=":state:enable && extensionPoint === 'buttons'">
<ng-if ng-if=":state:enable">
<a class="button button-text button-small ink"
ui-sref="app.blockchain_search" >
<i class="icon ion-android-search"></i>
......
......@@ -5,6 +5,7 @@
</div>
</ion-header-bar>
<ion-content scroll="false">
<div class="list" ng-class="{'has-header': titleKey}">
<div class="item item-text-wrap" ng-repeat="item in items">
<div class="item-label" ng-if="item.label">{{item.label | translate}}</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment