mirror of https://github.com/rancher/ui.git
Elasticsearch Endpoint should use default protocol ports when port is not given
https://github.com/rancher/rancher/issues/13114
This commit is contained in:
parent
db1c209b78
commit
fdc8a7a46c
|
|
@ -3,6 +3,7 @@ import { inject as service } from '@ember/service';
|
|||
import { get, set } from '@ember/object';
|
||||
import { reads } from '@ember/object/computed';
|
||||
import NewOrEdit from 'ui/mixins/new-or-edit';
|
||||
import parseUri from 'shared/utils/parse-uri';
|
||||
|
||||
export default Ember.Component.extend(NewOrEdit, {
|
||||
scope: service(),
|
||||
|
|
@ -36,6 +37,19 @@ export default Ember.Component.extend(NewOrEdit, {
|
|||
&& get(this, 'targetType') === 'none';
|
||||
}.property('originalModel.{id,targetType}', 'targetType'),
|
||||
|
||||
formatUrl: function(url) {
|
||||
const urlParser = parseUri(url) || {}
|
||||
if (!urlParser.port) {
|
||||
if (urlParser.protocol === 'http') {
|
||||
return `${urlParser.protocol}://${urlParser.host}:80`
|
||||
}
|
||||
if (urlParser.protocol === 'https') {
|
||||
return `${urlParser.protocol}://${urlParser.host}:443`
|
||||
}
|
||||
}
|
||||
return url
|
||||
},
|
||||
|
||||
actions: {
|
||||
save(cb) {
|
||||
const targetType = get(this, 'targetType');
|
||||
|
|
@ -91,7 +105,13 @@ export default Ember.Component.extend(NewOrEdit, {
|
|||
}
|
||||
set(model, 'outputFlushInterval', get(model, `${targetType}.outputFlushInterval`));
|
||||
set(model, 'outputTags', get(model, `${targetType}.outputTags`));
|
||||
set(model, `${targetType}Config`, get(model, `${targetType}.config`));
|
||||
|
||||
const formatConfig = get(model, `${targetType}.config`)
|
||||
if (targetType === 'elasticsearch') {
|
||||
Object.assign(formatConfig, {endpoint: this.formatUrl(formatConfig.endpoint)})
|
||||
}
|
||||
|
||||
set(model, `${targetType}Config`, formatConfig);
|
||||
this._super(cb);
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue