diff --git a/lib/logging/addon/components/logging/new-edit/component.js b/lib/logging/addon/components/logging/new-edit/component.js index 8827ffc42..e6bac7bb8 100644 --- a/lib/logging/addon/components/logging/new-edit/component.js +++ b/lib/logging/addon/components/logging/new-edit/component.js @@ -107,7 +107,7 @@ export default Component.extend(NewOrEdit, { set(model, 'outputTags', get(model, `${targetType}.outputTags`)); set(model, 'dockerRoot', get(model, `${targetType}.dockerRoot`)); - const formatConfig = get(model, `${targetType}.config`) + const formatConfig = get(model, `${targetType}.config`).clone() if (targetType === 'elasticsearch') { Object.assign(formatConfig, {endpoint: this.formatUrl(formatConfig.endpoint)}) } diff --git a/lib/logging/addon/components/logging/target-elasticsearch/component.js b/lib/logging/addon/components/logging/target-elasticsearch/component.js index afc841c52..814e730e7 100644 --- a/lib/logging/addon/components/logging/target-elasticsearch/component.js +++ b/lib/logging/addon/components/logging/target-elasticsearch/component.js @@ -1,12 +1,13 @@ import Component from '@ember/component'; import es from 'logging/mixins/target-elasticsearch'; -import { get, computed, setProperties } from '@ember/object'; +import { get, computed, setProperties, set } from '@ember/object'; import { alias } from '@ember/object/computed' export default Component.extend(es, { showAdvanced: false, config: alias('model.config'), sslVerify: alias('model.config.sslVerify'), + endpointError: false, didInsertElement() { this.$('#elasticsearch-endpoint').focus() @@ -35,4 +36,14 @@ export default Component.extend(es, { const ps = get(this, 'pageScope'); return ps === 'cluster' ? '${clusterName}-${dateFormat}' : '${clusterName}_${projectName}-${dateFormat}'; }.property('pageScope'), + + actions: { + alertMessage(value='') { + if (value.startsWith('https:') || value.startsWith('http:')) { + set(this, 'endpointError', false) + } else { + set(this, 'endpointError', true) + } + }, + }, }); diff --git a/lib/logging/addon/components/logging/target-elasticsearch/template.hbs b/lib/logging/addon/components/logging/target-elasticsearch/template.hbs index a32a7390c..81993e803 100644 --- a/lib/logging/addon/components/logging/target-elasticsearch/template.hbs +++ b/lib/logging/addon/components/logging/target-elasticsearch/template.hbs @@ -10,9 +10,14 @@ classNames="form-control" placeholder=(t 'loggingPage.endpointPlaceholder') id="elasticsearch-endpoint" + focus-out="alertMessage" }} -

{{t 'loggingPage.elasticsearch.endpointHelpText'}}

+ {{#if endpointError}} +

{{t 'loggingPage.elasticsearch.endpointErrorText'}}

+ {{else}} +

{{t 'loggingPage.elasticsearch.endpointHelpText'}}

+ {{/if}}

{{t 'loggingPage.elasticsearch.xpack.header'}} {{t 'loggingPage.elasticsearch.xpack.headerOptional'}}

diff --git a/lib/logging/translations/en-us.yaml b/lib/logging/translations/en-us.yaml index 435f37a57..a46584fe0 100644 --- a/lib/logging/translations/en-us.yaml +++ b/lib/logging/translations/en-us.yaml @@ -85,6 +85,7 @@ loggingPage: elasticsearch: header: Elasticsearch Configuration endpointHelpText: Copy your endpoint from Elastic Cloud, or input the reachable endpoint of your self-hosted Elacticsearch. + endpointErrorText: Endpoint should starts with "http:" or "https:". xpack: header: X-Pack Security headerOptional: (optional)