import React from 'react'; import { Row, Col, Button, Badge, Alert } from 'react-bootstrap'; import { Card, WaitIcon, ReactTable } from '../../../components/index'; import { server } from '../../../commons/server'; import Form from '../../../forms/form'; import moment from 'moment'; const fschema = { controls: [ { property: 'iniDate', required: true, type: 'date', label: __('Period.iniDate'), size: { md: 4 }, defaultValue: new Date() }, { property: 'endDate', required: false, type: 'date', label: __('Period.endDate'), size: { md: 4 } }, { property: 'searchKey', required: false, type: 'string', max: 50, label: __('form.searchkey'), size: { sm: 4 } } ] }; const detailSchema = { controls: [ { property: 'userName', type: 'string', label: 'User Name', size: { sm: 4 } }, { property: 'workspace', type: 'string', label: 'Workspace', size: { sm: 4 } }, { property: 'exceptionMessage', type: 'string', label: 'Exception Message', size: { sm: 4 } }, { property: 'request', type: 'string', label: 'Request', size: { sm: 12 } }, { property: 'stackTrace', type: 'string', label: 'Stack Trace', size: { sm: 12 } } ] }; /** * The page controller of the public module */ export default class ErrorLog extends React.Component { constructor(props) { super(props); this.refresh = this.refresh.bind(this); this.state = { doc: {} }; } componentWillMount() { this.refreshTodayRep(); } refresh() { const self = this; const errors = self.refs.form.validate(); this.setState({ errors: errors }); if (errors) { return; } const query = { iniDate: this.state.doc.iniDate, endDate: this.state.doc.endDate, searchKey: this.state.doc.searchKey }; server.post('/api/admin/rep/errorlog', query) .then(res => { // generate new result const result = { count: res.count, list: res.list }; // set state self.setState({ values: result }); }); } refreshTodayRep() { const self = this; server.post('/api/admin/rep/todayerrorlog') .then(res => { // generate new result const result = { count: res.count, list: res.list }; // set state self.setState({ values: result }); }); } headerRender(count) { const countHTML = {count}; // create the header of the card return (

{__('Permission.ERRORLOGREP')} {count === 0 ? '' : countHTML}

); } collapseRender(item) { return (
); } profileSubtitleRender(item) { return (
{item.unitName}
{item.adminUnitName}
); } renderTableResult() { if (!this.state.values || !this.state.values.list || this.state.values.list.length < 1) { return {__('form.norecordfound')}; } const tschema = [ { title: __('datetime.date'), content: item => moment(item.errorDate).format('L LTS'), size: { md: 4 } }, { title: 'Exception Class', content: 'exceptionClass', size: { md: 4 } }, { title: 'URL', content: 'url', size: { md: 4 } } ]; return (
); } render() { const header = this.headerRender(!this.state || !this.state.values ? 0 : this.state.values.count); return (
{!this.state || !this.state.values ? : this.renderTableResult()}
); } } ErrorLog.propTypes = { route: React.PropTypes.object };