Use externalIpAddress when available

This commit is contained in:
Vincent Fiduccia 2018-04-03 16:09:01 -07:00
parent e08481961d
commit 687c07dbd6
No known key found for this signature in database
GPG Key ID: 2B29AD6BB2BB2582
3 changed files with 23 additions and 9 deletions

View File

@ -1,5 +1,5 @@
import { computed, get } from '@ember/object';
import { alias } from '@ember/object/computed';
import { alias, or } from '@ember/object/computed';
import Resource from 'ember-api-store/models/resource';
import { download } from 'shared/utils/util';
import C from 'ui/utils/constants';
@ -88,7 +88,7 @@ var Node = Resource.extend(StateCounts, ResourceUsage, {
return out;
}.property('actionLinks.{activate,deactivate,evacuate}','links.{update,remove,config}','driver'),
displayIp: alias('ipAddress'),
displayIp: or('externalIpAddress','ipAddress'),
displayName: computed('name','nodeName','requestedHostname','id', function() {
let name = get(this,'name');

View File

@ -51,9 +51,15 @@ var PublicEndpoint = Resource.extend({
let out = '';
if ( allNodes ) {
const globalStore = get(this, 'globalStore');
const node = globalStore.all('node').findBy('clusterId', get(this,'scope.currentCluster.id'));
const nodes = globalStore.all('node').filterBy('clusterId', get(this,'scope.currentCluster.id'));
let node = nodes.findBy('externalIpAddress');
if ( node ) {
out = get(node, 'ipAddress');
out = get(node, 'externalIpAddress');
} else {
node = nodes.findBy('ipAddress');
if ( node ) {
out = get(node, 'ipAddress');
}
}
} else if ( addresses && addresses.length ) {
out = addresses[0];

View File

@ -17,11 +17,19 @@
{{else}}
<a href="{{href-to 'node' model.clusterId model.id}}">{{model.displayName}}</a>
{{/if}}
{{#if (and model.displayIp (not-eq model.displayIp model.displayName))}}
<div class="text-small text-muted">
{{#copy-inline clipboardText=model.displayIp size="small"}}
{{format-ip model.displayIp}}
{{/copy-inline}}
{{#if (or model.externalIpAddress model.ipAddress)}}
<div class="text-small text-muted clip">
{{#if model.externalIpAddress}}
{{#copy-inline clipboardText=model.externalIpAddress size="small"}}
{{format-ip model.externalIpAddress}}
{{/copy-inline}}
&nbsp;/&nbsp;
{{/if}}
{{#if model.ipAddress}}
{{#copy-inline clipboardText=model.ipAddress size="small"}}
{{format-ip model.ipAddress}}
{{/copy-inline}}
{{/if}}
</div>
{{/if}}
</td>