Fix translation for watcher email (#28451) (#28555)

This commit is contained in:
Nox911 2019-01-14 10:44:43 +03:00 committed by GitHub
parent e734e244d6
commit 93b452e9c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 9 deletions

View file

@ -13,9 +13,11 @@ import { http } from '../../../../../services/http_service';
import emailBody from './email.html';
import emailInfluencersBody from './email-influencers.html';
import { watch } from './watch.js';
import { i18n } from '@kbn/i18n';
const compiledEmailBody = _.template(emailBody);
const compiledEmailInfluencersBody = _.template(emailInfluencersBody);
const emailSection = {
send_email: {
@ -23,7 +25,7 @@ const emailSection = {
email: {
profile: 'standard',
to: [],
subject: 'ML Watcher Alert',
subject: i18n.translate('xpack.ml.newJob.simple.watcher.email.mlWatcherAlertSubjectTitle', { defaultMessage: 'ML Watcher Alert' }),
body: {
html: ''
}
@ -96,7 +98,28 @@ class CreateWatchService {
// create the html by adding the variables to the compiled email body.
emailSection.send_email.email.body.html = compiledEmailBody({
serverAddress: chrome.getAppUrl(),
influencersSection: ((this.config.includeInfluencers === true) ? emailInfluencersBody : '')
influencersSection: ((this.config.includeInfluencers === true) ?
compiledEmailInfluencersBody({
topInfluencersLabel: i18n.translate('xpack.ml.newJob.simple.watcher.email.topInfluencersLabel', {
defaultMessage: 'Top influencers:'
})
}) : ''
),
elasticStackMachineLearningAlertLabel: i18n.translate(
'xpack.ml.newJob.simple.watcher.email.elasticStackMachineLearningAlertLabel', {
defaultMessage: 'Elastic Stack Machine Learning Alert'
}
),
jobLabel: i18n.translate('xpack.ml.newJob.simple.watcher.email.jobLabel', { defaultMessage: 'Job' }),
timeLabel: i18n.translate('xpack.ml.newJob.simple.watcher.email.timeLabel', { defaultMessage: 'Time' }),
anomalyScoreLabel: i18n.translate('xpack.ml.newJob.simple.watcher.email.anomalyScoreLabel', {
defaultMessage: 'Anomaly score'
}),
openInAnomalyExplorerLinkText: i18n.translate('xpack.ml.newJob.simple.watcher.email.openInAnomalyExplorerLinkText', {
defaultMessage: 'Click here to open in Anomaly Explorer.'
}),
topRecordsLabel: i18n.translate('xpack.ml.newJob.simple.watcher.email.topRecordsLabel', { defaultMessage: 'Top records:' }),
});
// add email section to watch

View file

@ -1,5 +1,5 @@
<strong>
{{i18n 'xpack.ml.newJob.simple.emailInfluencers.topInfluencersLabel' '{"defaultMessage": "Top influencers:"'}}
<%= topInfluencersLabel %>
</strong>
<br />
{{#ctx.payload.aggregations.influencer_results.top_influencer_hits.hits.hits}}

View file

@ -1,29 +1,29 @@
<html>
<body>
<strong>
{{i18n 'xpack.ml.newJob.simple.email.elasticStackMachineLearningAlertLabel' '{"defaultMessage": "Elastic Stack Machine Learning Alert"'}}
<%= elasticStackMachineLearningAlertLabel %>
</strong>
<br />
<br />
<strong>
{{i18n 'xpack.ml.newJob.simple.email.jobLabel' '{"defaultMessage": "Job"'}}
<%= jobLabel %>
</strong>: {{ctx.payload.aggregations.bucket_results.top_bucket_hits.hits.hits.0._source.job_id}}
<br />
<strong>
{{i18n 'xpack.ml.newJob.simple.email.timeLabel' '{"defaultMessage": "Time"'}}
<%= timeLabel %>
</strong>: {{ctx.payload.aggregations.bucket_results.top_bucket_hits.hits.hits.0.fields.timestamp_iso8601.0}}
<br />
<strong>
{{i18n 'xpack.ml.newJob.simple.email.anomalyScoreLabel' '{"defaultMessage": "Anomaly score"'}}
<%= anomalyScoreLabel %>
</strong>: {{ctx.payload.aggregations.bucket_results.top_bucket_hits.hits.hits.0.fields.score.0}}
<br />
<br />
<a href="<%= serverAddress %>#/explorer/?_g=(ml:(jobIds:!('{{ctx.payload.aggregations.bucket_results.top_bucket_hits.hits.hits.0._source.job_id}}')),refreshInterval:(display:Off,pause:!f,value:0),time:(from:'{{ctx.payload.aggregations.bucket_results.top_bucket_hits.hits.hits.0.fields.start.0}}',mode:absolute,to:'{{ctx.payload.aggregations.bucket_results.top_bucket_hits.hits.hits.0.fields.end.0}}'))&_a=(filters:!(),mlAnomaliesTable:(intervalValue:auto,thresholdValue:0),mlExplorerSwimlane:(selectedLane:Overall,selectedTime:{{ctx.payload.aggregations.bucket_results.top_bucket_hits.hits.hits.0.fields.timestamp_epoch.0}},selectedType:overall),query:(query_string:(analyze_wildcard:!t,query:'*')))">
{{i18n 'xpack.ml.newJob.simple.email.openInAnomalyExplorerLinkText' '{"defaultMessage": "Click here to open in Anomaly Explorer."'}}
<%= openInAnomalyExplorerLinkText %>
</a>
<br />
<br />
@ -31,7 +31,7 @@
<%= influencersSection %>
<strong>
{{i18n 'xpack.ml.newJob.simple.email.topRecordsLabel' '{"defaultMessage": "Top records:"'}}
<%= topRecordsLabel %>
</strong>
<br />
{{#ctx.payload.aggregations.record_results.top_record_hits.hits.hits}}