Skip to content

Commit

Permalink
fix: Fix log collection form
Browse files Browse the repository at this point in the history
Signed-off-by: leoliu <leoliu@yunify.com>
  • Loading branch information
leoliu committed Aug 14, 2020
1 parent ef0585a commit b6b2461
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 110 deletions.
5 changes: 3 additions & 2 deletions src/actions/log.collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
* along with KubeSphere Console. If not, see <https://www.gnu.org/licenses/>.
*/

import React from 'react'
import { cloneDeep } from 'lodash'
import { Modal, Notify } from 'components/Base'
import EnableForm from 'components/Forms/LoggingCollection/Status'
import ESForm from 'src/components/Forms/Elasticsearch/Settings'
import KafkaForm from 'src/components/Forms/KafkaForm/Settings'
import FluentdForm from 'src/components/Forms/Fluentd/Settings'
import React from 'react'

export default {
'log.collection.active.switch': {
Expand Down Expand Up @@ -58,7 +59,7 @@ export default {
}
const { type } = store.detail
const EditForm = EditFormMap[type] || null
const data = store.detail.config
const data = cloneDeep(store.detail.config)

const modal = Modal.open({
onOk: async params => {
Expand Down
29 changes: 5 additions & 24 deletions src/components/Forms/Elasticsearch/Settings/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ import classnames from 'classnames'

import { Input } from '@pitrix/lego-ui'
import { Form } from 'components/Base'
import { UrlInput, InputPassword } from 'components/Inputs'

import { PATTERN_ES_USER_NAME, PATTERN_ES_PASSWORD } from 'utils/constants'
import { UrlInput } from 'components/Inputs'

import fromStyles from 'src/components/Base/Form/index.scss'

Expand All @@ -44,28 +42,11 @@ export default class BaseInfo extends React.Component {
</div>

<Form.Item
desc={t('LOG_COLLECTION_ES_USER_TIPS')}
label={`${t('User Name')} (${t('optional')})`}
rules={[
{ pattern: PATTERN_ES_USER_NAME, message: t('Invalid name') },
]}
>
<Input name="HTTP_User" autoComplete="nope" />
</Form.Item>
<Form.Item
label={`${t('Password')} (${t('optional')})`}
rules={[
{
pattern: PATTERN_ES_PASSWORD,
message: t('Passwords must be at least 6 characters long'),
},
]}
label={t('Index Prefix')}
desc={t('LOG_COLLECTION_ES_INDEX_TIPS')}
rules={[{ required: true, message: t('Please input value') }]}
>
<InputPassword
name="HTTP_Password"
placeholder={t('Please input password')}
autoComplete="new-password"
/>
<Input name="logstashPrefix" defaultValue="ks-logstash-log" />
</Form.Item>
</div>
)
Expand Down
29 changes: 0 additions & 29 deletions src/components/Modals/LogCollectionCreate/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,35 +38,6 @@ export default {
get description() {
return t('ES_DESC')
},
validator(callback) {
const formData = this._formData || {}
const { HTTP_User, HTTP_Password } = formData
if (Boolean(HTTP_User) === Boolean(HTTP_Password)) {
return callback()
}

if (HTTP_User) {
this.setState({
errors: [
{
message: t('Please input password'),
field: 'HTTP_Password',
},
],
})
}

if (HTTP_Password) {
this.setState({
errors: [
{
message: t('Please input user name'),
field: 'HTTP_User',
},
],
})
}
},
},
kafka: {
ICON: KaFkaICON,
Expand Down
6 changes: 3 additions & 3 deletions src/locales/en/logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default {
'Exact Query': 'Exact Query',
'Fuzzy Query': 'Fuzzy Query',
'Hide help information': 'Hide help information',
'Index Prefix': 'Index Prefix',
Keyword: 'Keyword',
'Log Collections': 'Log Collections',
'Log Collector': 'Log Collector',
Expand Down Expand Up @@ -85,7 +86,6 @@ export default {
'The system will collect the stdout and stderr logs from each container and send them to one or more target services.',
LOG_COLLECTION_ENABLE_TIPS:
'The new status takes about 1 minute to take effect.',
LOG_COLLECTION_FLUENTD_USER_TIPS: 'Username for authentication',
LOG_COLLECTION_FLUENTD_URL_TIPS:
'Enter the address of the Fluentd that receives the log.',
EMPTY_LOG_COLLECTIONS:
Expand All @@ -96,8 +96,8 @@ export default {

LOG_COLLECTION_ES_URL_TIPS:
'The built-in Elasticsearch service is used by default. You can change it to use an Elasticsearch service deployed by your own either within or out of the cluster.',
LOG_COLLECTION_ES_USER_TIPS:
'If your elasticsearch has the built-in local authentication feature in x-pack, set a username and password.',
LOG_COLLECTION_ES_INDEX_TIPS:
'The indexes are built with prefix and the date, for example: {prefix}-2020.01.01',
'Search Log by': 'Search Log by {field}',
'KeyWord Log Query Tip':
'Please enter the keyword to find the log. You can also find the error log by keywords such as “Error”, “Fail”, “Fatal”, “Exception” and “Warning”.',
Expand Down
6 changes: 3 additions & 3 deletions src/locales/es/logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default {
'Exact Query': 'Consulta exacta',
'Fuzzy Query': 'Consulta difusa',
'Hide help information': 'Ocultar información de ayuda',
'Index Prefix': 'Index Prefix',
Keyword: 'Palabra clave',
'Log Collections': 'Colecciones de logs',
'Log Collector': 'Colector de logs',
Expand Down Expand Up @@ -86,7 +87,6 @@ export default {
'El sistema recopilará los registros stdout y stderr de cada contenedor y los enviará a uno o más servicios de destino.',
LOG_COLLECTION_ENABLE_TIPS:
'El nuevo estado tarda aproximadamente 1 minuto en surtir efecto.',
LOG_COLLECTION_FLUENTD_USER_TIPS: 'Nombre de usuario para autenticación',
LOG_COLLECTION_FLUENTD_URL_TIPS:
'Introduce la dirección del Fluentd que recibe los logs.',
EMPTY_LOG_COLLECTIONS:
Expand All @@ -96,8 +96,8 @@ export default {
URL_SYNTAX_ERROR: 'Error de sintaxis de URL',
LOG_COLLECTION_ES_URL_TIPS:
'El servicio incorporado Elasticsearch se usa de manera predeterminada. Puedes cambiarlo para usar un servicio Elasticsearch implementado por tí mismo dentro o fuera del clúster.',
LOG_COLLECTION_ES_USER_TIPS:
'Si su elasticsearch tiene la función de autenticación local incorporada en x-pack, configura un nombre de usuario y contraseña.',
LOG_COLLECTION_ES_INDEX_TIPS:
'The indexes are built with prefix and the date, for example: {prefix}-2020.01.01',
'Search Log by': 'Buscar logs por {field}',
'KeyWord Log Query Tip':
'Introduce la palabra clave para encontrar el log. También puedes encontrar el log de errores por palabras clave como "Error", "Fail", "Fatal", "Exception" y "Warning".',
Expand Down
6 changes: 3 additions & 3 deletions src/locales/tc/logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,9 @@ export default {
'Please input path': '請輸入地址',
LOG_COLLECTION_ES_URL_TIPS:
'預設使用系統部署的 Elasticsearch,也可以輸入外部或者單獨部署的 Elasticsearch 地址',
LOG_COLLECTION_ES_USER_TIPS:
'如果您的 Elasticsearch 開啟了 X-Pack 内置的本地身份驗證功能,請設置用戶名稱和密碼。',
LOG_COLLECTION_ES_INDEX_TIPS:
'默认按日期分类建立索引,例:索引前缀-2020.01.01',
LOG_COLLECTION_FLUENTD_URL_TIPS: '輸入接收紀錄的 Fluentd 的地址',
LOG_COLLECTION_FLUENTD_USER_TIPS: '用於身份驗證的用戶名稱',

'Refresh Interval': '刷新頻率',
'Recently Updated': '最近刷新',
Expand All @@ -112,6 +111,7 @@ export default {
'Log Collector': '紀錄接收者',
Activate: '啟用',
'Real-Time Data': '實時數據',
'Index Prefix': '索引前缀',

TOOLBOX_SHIFT_TIPS: ' 👻 Shift + 鼠標左鍵 可以在新視窗中打開',
'Hide help information': '不再顯示幫助資訊',
Expand Down
6 changes: 3 additions & 3 deletions src/locales/zh/logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,9 @@ export default {
'Please input path': '请输入地址',
LOG_COLLECTION_ES_URL_TIPS:
'默认使用系统部署的 Elasticsearch,也可以输入外部或者单独部署的 Elasticsearch 地址',
LOG_COLLECTION_ES_USER_TIPS:
'如果您的 Elasticsearch 开启了 X-Pack 内置的本地身份验证功能,请设置用户名和密码。',
LOG_COLLECTION_ES_INDEX_TIPS:
'默认按日期分类建立索引,例:索引前缀-2020.01.01',
LOG_COLLECTION_FLUENTD_URL_TIPS: '输入接收日志的 Fluentd 的地址',
LOG_COLLECTION_FLUENTD_USER_TIPS: '用于身份验证的用户名',

'Refresh Interval': '刷新频率',
'Recently Updated': '最近刷新',
Expand All @@ -110,6 +109,7 @@ export default {
'Log Collector': '日志接收者',
Activate: '激活',
'Real-Time Data': '实时数据',
'Index Prefix': '索引前缀',

'Resource Name & Type': '资源名称与类型',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,21 @@ import styles from './index.scss'
export default class Configuration extends React.Component {
render() {
const detail = get(this.props.detailStore, 'detail', {})
const { HTTP_User, HTTP_Password, type, address } = detail
const { address, config = {} } = detail

return (
<Panel>
<Attributes className={styles.attributes}>
<Attributes.Item
className={styles.item}
key="address"
name={t('Address')}
value={address}
/>
{type === 'es' && (
<div>
<Attributes.Item
className={styles.item}
key="user"
name={t('Username')}
value={HTTP_User}
/>
<Attributes.Item
key="password"
name={t('Password')}
value={HTTP_Password}
className={styles.item}
/>
</div>
)}
<Attributes.Item
className={styles.item}
name={t('Index Prefix')}
value={config.logstashPrefix}
/>
</Attributes>
</Panel>
)
Expand Down
16 changes: 0 additions & 16 deletions src/pages/clusters/containers/LogCollections/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,6 @@ export default {
get description() {
return t('ES_DESC')
},
validator(callback) {
const formData = this._formData || {}
const { HTTP_User, HTTP_Password } = formData
if (HTTP_User && !HTTP_Password) {
this.setState({
errors: [
{
message: t('Please input password'),
field: 'HTTP_Password',
},
],
})
} else {
callback()
}
},
},
kafka: {
ICON: KaFkaICON,
Expand Down
6 changes: 6 additions & 0 deletions src/pages/clusters/containers/LogCollections/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
right: 12px;
}

.pane {
border-radius: $border-radius;
box-shadow: $card-shadow;
background-color: $white;
}

.item {
display: flex;
padding: 20px;
Expand Down
9 changes: 3 additions & 6 deletions src/stores/logging/collection/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@ import Base from 'stores/base'

const collectionDefaultSetting = {
es: {
Logstash_Format: 'On',
Replace_Dots: 'on',
Retry_Limit: 'False',
Type: 'flb_type',
Time_Key: '@timestamp',
Logstash_Prefix: 'logstash',
logstashFormat: true,
timeKey: '@timestamp',
logstashPrefix: 'ks-logstash-log',
},
}

Expand Down
3 changes: 0 additions & 3 deletions src/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,6 @@ export const PATTERN_EMAIL = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/
export const PATTERN_IP = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/
export const PATTERN_IP_MASK = /^[1-9][0-9]*$/
export const PATTERN_IMAGE_TAG = /^(.*?)([0-9a-zA-Z/]*)(:[-.\w]*[0-9a-zA-Z])*$/
// https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-user.html#_path_parameters_76
export const PATTERN_ES_USER_NAME = /^\b.{1,1024}\b$/
export const PATTERN_ES_PASSWORD = /.{6,}/

export const PATTERN_UTC_TIME = /^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]+Z/

Expand Down

0 comments on commit b6b2461

Please sign in to comment.