Merge pull request #1295 from vincent99/master

Missed a file..
This commit is contained in:
Vincent Fiduccia 2017-08-10 09:59:18 -07:00 committed by GitHub
commit 304cdd2c3a
1 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,74 @@
import Ember from 'ember';
import Util from 'ui/utils/util';
export default Ember.Mixin.create({
intl: Ember.inject.service(),
endpointsMap: function() {
var out = {};
(this.get('publicEndpoints')||[]).forEach((endpoint) => {
if ( !endpoint.publicPort )
{
// Skip nulls
return;
}
let key = endpoint.get('portProto');
let ary = out[key]
if ( !ary ) {
ary = [];
out[key] = ary;
}
out[key].push(endpoint);
});
return out;
}.property('publicEndpoints.@each.{ipAddress,publicPort}'),
endpointsByPort: function() {
var out = [];
var map = this.get('endpointsMap');
Object.keys(map).forEach((key) => {
out.push({
port: parseInt(key,10),
endpoints: map[key]
});
});
return out;
}.property('endpointsMap'),
endpointPorts: Ember.computed.mapBy('endpointsByPort','publicPort'),
displayEndpoints: function() {
let parts = [];
this.get('endpointsByPort').forEach((obj) => {
let endpoint = obj.endpoints.get('firstObject');
if ( endpoint ) {
if ( endpoint.get('isMaybeHttp') ) {
parts.push('<span>' +
'<a target="_blank" rel="nofollow noopener" href="'+ Util.escapeHtml(endpoint.get('linkEndpoint')) +'">' +
Util.escapeHtml(endpoint.get('displayEndpoint')) +
'</a>' +
'</span>');
} else {
parts.push('<span>' + Util.escapeHtml(endpoint.get('displayEndpoint')) + '</span>');
}
}
});
let pub = parts.join(" / ");
if ( pub )
{
return pub.htmlSafe();
}
else
{
return '';
}
}.property('endpointsByPort.@each.{port,endpoints}', 'intl.locale'),
});