From cf73d744ea7d18be05f1323a58f1ca32e3c70c72 Mon Sep 17 00:00:00 2001 From: n313893254 Date: Thu, 13 Dec 2018 15:08:59 +0800 Subject: [PATCH] After click save button in cluster logging, UI keep loading https://github.com/rancher/rancher/issues/17023 --- app/styles/_rancher.scss | 1 + app/styles/components/_logging.scss | 3 +++ .../addon/components/logging/code-block/component.js | 4 ++++ .../addon/components/logging/code-block/template.hbs | 1 + .../components/logging/form-log-format/template.hbs | 2 +- .../addon/components/logging/new-edit/component.js | 10 ++++++++++ .../components/logging/target-flentd/component.js | 2 +- .../components/logging/target-splunk/component.js | 2 +- .../addon/components/logging/targets-nav/component.js | 2 +- lib/logging/translations/en-us.yaml | 1 + lib/logging/translations/zh-hans.yaml | 1 + 11 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 app/styles/components/_logging.scss create mode 100644 lib/logging/addon/components/logging/code-block/component.js create mode 100644 lib/logging/addon/components/logging/code-block/template.hbs diff --git a/app/styles/_rancher.scss b/app/styles/_rancher.scss index f0865716b..1d5f2c2bf 100644 --- a/app/styles/_rancher.scss +++ b/app/styles/_rancher.scss @@ -59,6 +59,7 @@ @import "app/styles/components/searchable-select"; @import "app/styles/components/nav-boxes"; @import "app/styles/components/pipeline"; +@import "app/styles/components/logging"; // Vendor // Pretty much what it says. Vendor specific changes/overrides or includes. diff --git a/app/styles/components/_logging.scss b/app/styles/components/_logging.scss new file mode 100644 index 000000000..91fc38d69 --- /dev/null +++ b/app/styles/components/_logging.scss @@ -0,0 +1,3 @@ +.logging-format { + font-size: 85%; +} \ No newline at end of file diff --git a/lib/logging/addon/components/logging/code-block/component.js b/lib/logging/addon/components/logging/code-block/component.js new file mode 100644 index 000000000..e63bf750c --- /dev/null +++ b/lib/logging/addon/components/logging/code-block/component.js @@ -0,0 +1,4 @@ +import layout from './template'; +import CodeBlock from 'shared/components/code-block/component'; + +export default CodeBlock.extend({ layout, }); diff --git a/lib/logging/addon/components/logging/code-block/template.hbs b/lib/logging/addon/components/logging/code-block/template.hbs new file mode 100644 index 000000000..0ec9ae9a8 --- /dev/null +++ b/lib/logging/addon/components/logging/code-block/template.hbs @@ -0,0 +1 @@ +{{{highlighted}}} diff --git a/lib/logging/addon/components/logging/form-log-format/template.hbs b/lib/logging/addon/components/logging/form-log-format/template.hbs index 408eefbb9..b02829900 100644 --- a/lib/logging/addon/components/logging/form-log-format/template.hbs +++ b/lib/logging/addon/components/logging/form-log-format/template.hbs @@ -33,6 +33,6 @@
- {{code-block code=logPreview}} + {{logging/code-block code=logPreview language="json"}}
\ No newline at end of file diff --git a/lib/logging/addon/components/logging/new-edit/component.js b/lib/logging/addon/components/logging/new-edit/component.js index 8581d4384..32325cec2 100644 --- a/lib/logging/addon/components/logging/new-edit/component.js +++ b/lib/logging/addon/components/logging/new-edit/component.js @@ -27,6 +27,7 @@ export default Component.extend(NewOrEdit, { let targetType = get(this, 'targetType'); const pageScope = this.get('pageScope'); const model = get(this, 'model'); + const intl = get(this, 'intl') // set projectId or clusterId if (pageScope === 'project') { @@ -84,6 +85,15 @@ export default Component.extend(NewOrEdit, { } } + if (targetType === 'splunk') { + if (!get(model, 'splunk.config.token')) { + set(this, 'errors', [intl.t('loggingPage.splunk.tokenRequired')]); + cb(); + + return; + } + } + // set kafka config if (targetType === 'kafka') { let kt; diff --git a/lib/logging/addon/components/logging/target-flentd/component.js b/lib/logging/addon/components/logging/target-flentd/component.js index 4b1007902..d4dff4b4a 100644 --- a/lib/logging/addon/components/logging/target-flentd/component.js +++ b/lib/logging/addon/components/logging/target-flentd/component.js @@ -108,7 +108,7 @@ export default Component.extend({ logPreview: computed('fieldsStr', function() { const fieldsStr = get(this, 'fieldsStr'); const template = `{ - "log": "time=\"${ new Date().toString() }\" level=info msg=\"Cluster [local] condition status unknown\"\n", + "log": "time=\"${ new Date().toString() }\" level=info msg=\"Cluster [local] condition status unknown\"", "stream": "stderr", "tag": "default.var.log.containers.cattle-6b4ccb5b9d-v57vw_default_cattle-xxx.log" "docker": { diff --git a/lib/logging/addon/components/logging/target-splunk/component.js b/lib/logging/addon/components/logging/target-splunk/component.js index 7fe8edb09..043f1221e 100644 --- a/lib/logging/addon/components/logging/target-splunk/component.js +++ b/lib/logging/addon/components/logging/target-splunk/component.js @@ -35,7 +35,7 @@ export default Component.extend({ logPreview: function() { const fieldsStr = get(this, 'fieldsStr'); const template = `{ - "log": "time=\"${ new Date().toString() }\" level=info msg=\"Cluster [local] condition status unknown\"\n", + "log": "time=\"${ new Date().toString() }\" level=info msg=\"Cluster [local] condition status unknown\"", "stream": "stderr", "tag": "default.var.log.containers.cattle-6b4ccb5b9d-v57vw_default_cattle-xxx.log" "docker": { diff --git a/lib/logging/addon/components/logging/targets-nav/component.js b/lib/logging/addon/components/logging/targets-nav/component.js index 28d80e2f1..338873e28 100644 --- a/lib/logging/addon/components/logging/targets-nav/component.js +++ b/lib/logging/addon/components/logging/targets-nav/component.js @@ -67,7 +67,7 @@ export default Component.extend({ { type: 'fluentForwarder', label: 'loggingPage.targetTypes.fluentd', - css: `fluentd${ this.currentCss('fluentd') }`, + css: `fluentd${ this.currentCss('fluentd output forward') }`, available: true, disabled: false, }, diff --git a/lib/logging/translations/en-us.yaml b/lib/logging/translations/en-us.yaml index c25066271..b4e4d5b76 100644 --- a/lib/logging/translations/en-us.yaml +++ b/lib/logging/translations/en-us.yaml @@ -79,6 +79,7 @@ loggingPage: token: Token tokenPlaceholder: Your Token tokenHelpText: 'Tokens are entities that let logging agents and HTTP clients connect to the HEC input. Detail' + tokenRequired: Token is Required source: Source sourcePlaceholder: e.g. fluentd sourceHelpText: 'A default field that identifies the source of an event, that is, where the event originated. Detail' diff --git a/lib/logging/translations/zh-hans.yaml b/lib/logging/translations/zh-hans.yaml index 6b3c2bb84..01cf50529 100644 --- a/lib/logging/translations/zh-hans.yaml +++ b/lib/logging/translations/zh-hans.yaml @@ -79,6 +79,7 @@ loggingPage: token: Token tokenPlaceholder: Your Token tokenHelpText: 'Token是允许日志收集程序和HTTP客户端连接到HEC的验证信息,了解详情。' + tokenRequired: Token必须填写 source: 日志源 sourcePlaceholder: '例如: fluentd' sourceHelpText: '标识事件来源的默认字段,即事件发生的位置,了解详情。'