UNPKG

@iobroker/adapter-react-v5

Version:

React components to develop ioBroker interfaces with react.

46 lines 2.3 kB
import React from 'react'; import { Button, DialogTitle, DialogContent, DialogActions, Dialog } from '@mui/material'; import { Check as IconOk, Cancel as IconCancel } from '@mui/icons-material'; import { SimpleCron } from '../Components/SimpleCron'; import { I18n } from '../i18n'; // Generates cron expression const styles = { dialogPaper: { height: 'calc(100% - 96px)', }, }; export class DialogSimpleCron extends React.Component { constructor(props) { super(props); let cron; if (this.props.cron && typeof this.props.cron === 'string' && this.props.cron.replace(/^["']/, '')[0] !== '{') { cron = this.props.cron.replace(/['"]/g, '').trim(); } else { cron = this.props.cron || '{}'; if (typeof cron === 'string') { cron = cron.replace(/^["']/, '').replace(/["']\n?$/, ''); } } this.state = { cron, }; } handleCancel() { this.props.onClose(); } handleOk() { this.props.onOk(this.state.cron); this.props.onClose(); } render() { return (React.createElement(Dialog, { onClose: () => { }, maxWidth: "md", fullWidth: true, sx: { '& .MuiDialog-paper': styles.dialogPaper }, open: !0, "aria-labelledby": "cron-dialog-title" }, React.createElement(DialogTitle, { id: "cron-dialog-title" }, this.props.title || I18n.t('ra_Define CRON...')), React.createElement(DialogContent, { style: { height: '100%', overflow: 'hidden' } }, React.createElement(SimpleCron, { cronExpression: this.state.cron, onChange: (cron) => this.setState({ cron }), language: I18n.getLanguage() })), React.createElement(DialogActions, null, React.createElement(Button, { variant: "contained", disabled: !this.state.cron || this.state.cron.includes('_'), onClick: () => this.handleOk(), color: "primary", startIcon: React.createElement(IconOk, null) }, this.props.ok || I18n.t('ra_Ok')), React.createElement(Button, { variant: "contained", onClick: () => this.handleCancel(), color: "grey", startIcon: React.createElement(IconCancel, null) }, this.props.cancel || I18n.t('ra_Cancel'))))); } } //# sourceMappingURL=SimpleCron.js.map