Merge pull request #3186 from n313893254/20640

Make sure FluentServer.weight is int
This commit is contained in:
Westly Wright 2019-08-05 08:58:44 -07:00 committed by GitHub
commit 40dafd6052
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 119 additions and 51 deletions

View File

@ -51,8 +51,8 @@ alertPage:
helpText: The value set in the Notifier is used by default. You can override this with another value. helpText: The value set in the Notifier is used by default. You can override this with another value.
expression: expression:
label: Expression label: Expression
noData: No metic graph data. noData: No metric graph data.
error: Failed to fetch metic graph data. error: Failed to fetch metric graph data.
placeholder: Input Expression placeholder: Input Expression
removeAlert: Remove this Alert removeAlert: Remove this Alert
alertRule: Alert Rule alertRule: Alert Rule

View File

@ -16,7 +16,8 @@
<div class="col span-12"> <div class="col span-12">
<div class="row"> <div class="row">
<div class="col span-12"> <div class="col span-12">
<label class="acc-label" for="">{{t "loggingPage.fluentd.endpoint.label"}} <label class="acc-label" for="">
{{t "loggingPage.fluentd.endpoint.label"}}
{{#if (eq idx 0)}} {{#if (eq idx 0)}}
{{field-required}} {{field-required}}
{{/if}} {{/if}}
@ -29,13 +30,16 @@
focus-out=(action "alertMessage" idx) focus-out=(action "alertMessage" idx)
}} }}
{{#if (and endpointError (eq idx index))}} {{#if (and endpointError (eq idx index))}}
<span class="text-error text-small">{{t endpointErrorText}}</span> <span class="text-error text-small">
{{t endpointErrorText}}
</span>
{{/if}} {{/if}}
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col span-12"> <div class="col span-12">
<label class="acc-label" for="">{{t "loggingPage.fluentd.sharedKey.label"}} <label class="acc-label" for="">
{{t "loggingPage.fluentd.sharedKey.label"}}
</label> </label>
{{input {{input
type="password" type="password"
@ -47,7 +51,8 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col span-6"> <div class="col span-6">
<label class="acc-label" for="">{{t "loggingPage.fluentd.username.label"}} <label class="acc-label" for="">
{{t "loggingPage.fluentd.username.label"}}
</label> </label>
{{input {{input
type="text" type="text"
@ -57,7 +62,8 @@
}} }}
</div> </div>
<div class="col span-6"> <div class="col span-6">
<label class="acc-label" for="">{{t "loggingPage.fluentd.password.label"}} <label class="acc-label" for="">
{{t "loggingPage.fluentd.password.label"}}
</label> </label>
{{input {{input
type="password" type="password"
@ -69,7 +75,9 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col span-12 pt-0"> <div class="col span-12 pt-0">
<label class="acc-label" for="">{{t "loggingPage.fluentd.hostname.label"}}</label> <label class="acc-label" for="">
{{t "loggingPage.fluentd.hostname.label"}}
</label>
{{input {{input
type="text" type="text"
value=item.hostname value=item.hostname
@ -80,9 +88,11 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col span-12"> <div class="col span-12">
<label class="acc-label" for="">{{t "loggingPage.fluentd.weight.label"}} <label class="acc-label" for="">
{{t "loggingPage.fluentd.weight.label"}}
</label> </label>
{{input-integer class="form-control input-sm public" {{input-int
class="form-control input-sm public"
min="0" min="0"
value=item.weight value=item.weight
placeholder=(t "loggingPage.fluentd.weight.placeholder") placeholder=(t "loggingPage.fluentd.weight.placeholder")
@ -91,7 +101,11 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col span-12 pt-0" style="margin-top: 43px;"> <div class="col span-12 pt-0" style="margin-top: 43px;">
{{input type="checkbox" classNames="form-control" checked=item.standby}} {{input
type="checkbox"
classNames="form-control"
checked=item.standby
}}
{{t "loggingPage.fluentd.standby.label"}} {{t "loggingPage.fluentd.standby.label"}}
</div> </div>
</div> </div>
@ -100,24 +114,40 @@
{{/each}} {{/each}}
<div> <div>
<button class="btn bg-link icon-btn p-0" {{action "add"}}> <button class="btn bg-link icon-btn p-0" {{action "add"}}>
<span class="darken"><i class="icon icon-plus text-small"/></span> <span class="darken">
<span>{{t "loggingPage.fluentd.addServer"}}</span> <i class="icon icon-plus text-small"/>
</span>
<span>
{{t "loggingPage.fluentd.addServer"}}
</span>
</button> </button>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col span-6 pt-0" style="margin-top: 43px;"> <div class="col span-6 pt-0" style="margin-top: 43px;">
{{input type="checkbox" classNames="form-control" checked=config.compress}} {{input
type="checkbox"
classNames="form-control"
checked=config.compress
}}
{{t "loggingPage.fluentd.compress.label"}} {{t "loggingPage.fluentd.compress.label"}}
<p class="text-info text-small" style="margin-left: 25px;">{{t "loggingPage.fluentd.compress.helpText"}}</p> <p class="text-info text-small" style="margin-left: 25px;">
{{t "loggingPage.fluentd.compress.helpText"}}
</p>
</div> </div>
<div class="col span-6 pt-0" style="margin-top: 43px;"> <div class="col span-6 pt-0" style="margin-top: 43px;">
{{input type="checkbox" classNames="form-control" checked=config.enableTls}} {{input
type="checkbox"
classNames="form-control"
checked=config.enableTls
}}
{{t "loggingPage.fluentd.enableTls.label"}} {{t "loggingPage.fluentd.enableTls.label"}}
{{#if config.enableTls}} {{#if config.enableTls}}
<div class="clearfix"> <div class="clearfix">
<label class="acc-label pt-5">{{t "loggingPage.fluentd.certificate.label"}}</label> <label class="acc-label pt-5">
{{t "loggingPage.fluentd.certificate.label"}}
</label>
</div> </div>
{{input-text-file {{input-text-file
classNames="box" classNames="box"
@ -134,4 +164,7 @@
</div> </div>
</section> </section>
{{logging/form-log-format logPreview=logPreview model=model}} {{logging/form-log-format
logPreview=logPreview
model=model
}}

View File

@ -0,0 +1,33 @@
import { set, get } from '@ember/object';
import layout from './template';
import InputInteger from 'shared/components/input-integer/component';
import { sanitize } from 'shared/components/input-integer/component';
export default InputInteger.extend({
layout,
_elementValueDidChange() {
let val = this.element.value;
let cur = val;
val = sanitize(val);
let num = parseInt(val, 10);
let max = parseInt(get(this, 'max'), 10);
let min = parseInt(get(this, 'min'), 10);
if ( !isNaN(num) && !isNaN(max) && num > max ) {
val = `${ max }`;
}
if ( !isNaN(min) && (isNaN(num) || num < min ) ) {
val = `${ min }`;
}
if ( cur !== val ) {
this.element.value = val;
}
set(this, 'value', val && parseInt(val, 10))
},
});

View File

@ -0,0 +1 @@
{{yield}}

View File

@ -3,7 +3,7 @@ import TextField from '@ember/component/text-field';
import { isMobile } from 'ui/utils/platform'; import { isMobile } from 'ui/utils/platform';
import layout from './template'; import layout from './template';
function sanitize(val) { export function sanitize(val) {
val = (`${ val }`).trim().replace(/[^0-9-]/g, ''); val = (`${ val }`).trim().replace(/[^0-9-]/g, '');
val = val.substr(0, 1) + val.substr(1).replace('-', ''); val = val.substr(0, 1) + val.substr(1).replace('-', '');

View File

@ -0,0 +1 @@
export { default } from 'shared/components/input-int/component';