diff --git a/assets/js/components/_content-header.js b/assets/js/components/_content-header.js index 424a91f1..991b0aa7 100644 --- a/assets/js/components/_content-header.js +++ b/assets/js/components/_content-header.js @@ -19,7 +19,7 @@ export class ContentHeader extends Component { } return ( -
+
{title} diff --git a/assets/js/components/_data-table.js b/assets/js/components/_data-table.js index c96cb453..e23833b1 100644 --- a/assets/js/components/_data-table.js +++ b/assets/js/components/_data-table.js @@ -6,7 +6,7 @@ export class DataTable extends Component { let { columns, className = "", dataTable, isSortableTable = false } = this.props; return ( - +
{columns.map((item, index) => { diff --git a/assets/js/components/_form-field.js b/assets/js/components/_form-field.js index 416fded3..e6c9688e 100644 --- a/assets/js/components/_form-field.js +++ b/assets/js/components/_form-field.js @@ -1,30 +1,56 @@ import React, {Component} from 'react'; import {Input, Checkbox} from "./index"; -import {WidgetTable} from "./widget/_widget-table"; import {Select2} from "./_select2"; import {Select} from "./_select"; import '../../styles/component/_form-field.scss'; +const COMPONENT_TYPE = { + SELECT: 'select', + SELECT_TYPE_AHEAD: 'selectTypeAhead', + CHECKBOX: 'checkbox', + NUMBER: 'number' +} + + const FormFieldComponent = ({...props}) => { let component; const {type, children, checkboxlabel } = {...props}; switch (type) { - case 'select': + case COMPONENT_TYPE.SELECT: component = break; - case 'selectTypeAhead': + case COMPONENT_TYPE.SELECT_TYPE_AHEAD: component = {children} break; - case 'checkbox': + case COMPONENT_TYPE.CHECKBOX: component = ; break; default: - component = ; + component = ; break; } return component; } +const generateErrorMessage = (componentType) => { + let errorMessage = ''; + switch (componentType) { + case COMPONENT_TYPE.SELECT: + errorMessage = 'Please select a valid value.'; + break; + case COMPONENT_TYPE.SELECT_TYPE_AHEAD: + errorMessage = 'Please select at least one option.'; + break; + case COMPONENT_TYPE.CHECKBOX: + errorMessage = 'Please check to this checkbox.'; + break; + default: + errorMessage = 'Please fill out this field.'; + break; + } + return errorMessage; +} + export class FormField extends Component { render() { const { @@ -38,7 +64,9 @@ export class FormField extends Component { isMandatory = false, isHiddenLabel = false, children, + errorMessage, errors, + type, ...rest } = this.props; @@ -51,12 +79,13 @@ export class FormField extends Component { } return ( -
+
{!isHiddenLabel && } { if (onChange) onChange(e); }} @@ -67,7 +96,7 @@ export class FormField extends Component { > {children} - {isInvalidField && Please fill out this field} + {isInvalidField && {errorMessage || generateErrorMessage(type)}}
); } diff --git a/assets/js/components/_select.js b/assets/js/components/_select.js index d75b4b43..717c00f0 100644 --- a/assets/js/components/_select.js +++ b/assets/js/components/_select.js @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'; export class Select extends Component { render() { let {className = '', hasEmpty = false, children, ...rest} = this.props; - className += ' form-control'; + className += ' form-select'; return ( + this.onChangeStatus(row.id, index, !value ? "1" : "0") + } + /> +
+ ); + }, + }, + { + formatter: ({ index }) => { + return ( +
+ +
    +
  • + +
  • +
  • + +
  • +
+
+ ); + }, + }, + ]; return ( - <> - { - this.setState({deletingAlert: null}) - }} - > - Do you want to delete this alert "{deletingAlert?.title}"? - -
- - - Create Alert - - -
-
- - - - - - - - - - - - {data && data.map((item, key) => { - return ( - - - - - - - - - ) - })} - {data.length < 1 && - - } - -
TitleTableThresholdIntervalIs Active 
{item.title}{item.from_table}{item.threshold}{item.interval_time} - - { - (item.isActive === '1') ? - : - - } - - - - - - - {(item.isActive === '1') ? - : - } - - -
-

- No Alert found -

-
-
+
+
+ { + this.setState({ isShowAlertDetailForm: true }); + }} + /> + { + this.setState({ toastContent: {} }); + }} + /> + {alertList && alertList.length > 0 ? ( + + ) : ( +
No alert found
+ )} + { + this.setState({ + deleteAlertIndex: null, + }); + }} + saveButtonAction={() => this.onConfirmDeleteAlert()} + /> + = 0} + alertList={alertList} + editAlertIndex={editAlertIndex} + tableList={tableList} + onSubmitAlertData={(toastContent) => { + this.getData(); + this.setState({ + isShowAlertDetailForm: false, + editAlertIndex: null, + toastContent, + }); + }} + onHidden={() => { + this.setState({ + isShowAlertDetailForm: false, + editAlertIndex: null, + }); + }} + />
- - ) +
+ ); } } -ReactDOM.render(, document.querySelector('#root')); - +ReactDOM.render(, document.querySelector("#root")); diff --git a/assets/js/utils.js b/assets/js/utils.js index 0ccfc49d..d01146c5 100644 --- a/assets/js/utils.js +++ b/assets/js/utils.js @@ -3,7 +3,8 @@ import moment from "moment"; export const PAGE_NAME = { dashboard: 'Dashboard', table: 'Table', - user: 'Users' + user: 'Users', + alert: 'Alert' }; export const TOAST_STATUS = { diff --git a/assets/styles/_logexplorer.scss b/assets/styles/_logexplorer.scss index 86c3cd46..349e0f7b 100644 --- a/assets/styles/_logexplorer.scss +++ b/assets/styles/_logexplorer.scss @@ -3,6 +3,12 @@ background: transparent linear-gradient(241deg, var(--bs-primary) 0%, #FFFFFF 100%) 0% 0% no-repeat padding-box; } +.content-wrapper { + background-color: #F8F9FA; + max-height: 100vh; + overflow: auto; +} + .wrapper { width: calc(100% - 254px); min-height: 100vh; diff --git a/templates/alert/form.html.twig b/templates/alert/form.html.twig deleted file mode 100644 index 61838895..00000000 --- a/templates/alert/form.html.twig +++ /dev/null @@ -1,20 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block title %}{% if alert is defined %}Update{% else %}Create{% endif %} alert{% endblock %} - -{% block stylesheets %} - {{ encore_entry_link_tags('alerts_form') }} -{% endblock %} - -{% block body %} -
-{% endblock %} - -{% block javascripts %} - {{ encore_entry_script_tags('alerts_form') }} -{% endblock %} - diff --git a/webpack.config.js b/webpack.config.js index a5866ebb..0deeab99 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -68,7 +68,6 @@ Encore .addEntry('widget_form', './assets/js/pages/widget/form.js') .addEntry('dashboard-page', './assets/js/pages/index/dashboard.js') .addEntry('alerts_list', './assets/js/pages/alerts/list.js') - .addEntry('alerts_form', './assets/js/pages/alerts/form.js') .addEntry('export_list', './assets/js/pages/export/list.js') // .addEntry('page1', './assets/page1.js') // .addEntry('page2', './assets/page2.js')