1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2024-11-26 21:25:18 +01:00

Publish another checkbox

This commit is contained in:
Philipp Heckel 2022-04-01 11:34:53 -04:00
parent 00520a7a38
commit 2c8b258ae7
2 changed files with 15 additions and 8 deletions

View file

@ -15,7 +15,7 @@ const DialogFooter = (props) => {
}}> }}>
<DialogContentText sx={{ <DialogContentText sx={{
margin: '0px', margin: '0px',
paddingTop: '8px', paddingTop: '12px',
}}> }}>
{props.status} {props.status}
</DialogContentText> </DialogContentText>

View file

@ -2,7 +2,7 @@ import * as React from 'react';
import {useEffect, useRef, useState} from 'react'; import {useEffect, useRef, useState} from 'react';
import {NotificationItem} from "./Notifications"; import {NotificationItem} from "./Notifications";
import theme from "./theme"; import theme from "./theme";
import {Chip, FormControl, InputLabel, Link, Select, useMediaQuery} from "@mui/material"; import {Checkbox, Chip, FormControl, FormControlLabel, InputLabel, Link, Select, useMediaQuery} from "@mui/material";
import TextField from "@mui/material/TextField"; import TextField from "@mui/material/TextField";
import priority1 from "../img/priority-1.svg"; import priority1 from "../img/priority-1.svg";
import priority2 from "../img/priority-2.svg"; import priority2 from "../img/priority-2.svg";
@ -18,14 +18,11 @@ import IconButton from "@mui/material/IconButton";
import InsertEmoticonIcon from '@mui/icons-material/InsertEmoticon'; import InsertEmoticonIcon from '@mui/icons-material/InsertEmoticon';
import {Close} from "@mui/icons-material"; import {Close} from "@mui/icons-material";
import MenuItem from "@mui/material/MenuItem"; import MenuItem from "@mui/material/MenuItem";
import {basicAuth, formatBytes, shortUrl, splitNoEmpty, splitTopicUrl, validTopicUrl} from "../app/utils"; import {basicAuth, formatBytes, shortUrl, splitTopicUrl, validTopicUrl} from "../app/utils";
import Box from "@mui/material/Box"; import Box from "@mui/material/Box";
import Icon from "./Icon"; import Icon from "./Icon";
import DialogFooter from "./DialogFooter"; import DialogFooter from "./DialogFooter";
import api from "../app/Api"; import api from "../app/Api";
import Divider from "@mui/material/Divider";
import EditIcon from '@mui/icons-material/Edit';
import CheckIcon from '@mui/icons-material/Check';
import userManager from "../app/UserManager"; import userManager from "../app/UserManager";
const SendDialog = (props) => { const SendDialog = (props) => {
@ -41,6 +38,7 @@ const SendDialog = (props) => {
const [filenameEdited, setFilenameEdited] = useState(false); const [filenameEdited, setFilenameEdited] = useState(false);
const [email, setEmail] = useState(""); const [email, setEmail] = useState("");
const [delay, setDelay] = useState(""); const [delay, setDelay] = useState("");
const [publishAnother, setPublishAnother] = useState(false);
const [showTopicUrl, setShowTopicUrl] = useState(props.topicUrl === ""); const [showTopicUrl, setShowTopicUrl] = useState(props.topicUrl === "");
const [showClickUrl, setShowClickUrl] = useState(false); const [showClickUrl, setShowClickUrl] = useState(false);
@ -110,8 +108,11 @@ const SendDialog = (props) => {
const request = api.publishXHR(baseUrl, topic, body, headers, progressFn); const request = api.publishXHR(baseUrl, topic, body, headers, progressFn);
setSendRequest(request); setSendRequest(request);
await request; await request;
if (!publishAnother) {
props.onClose();
} else {
setStatusText("Message published"); setStatusText("Message published");
//props.onClose(); }
} catch (e) { } catch (e) {
console.log("error", e); console.log("error", e);
setStatusText("An error occurred"); setStatusText("An error occurred");
@ -350,6 +351,12 @@ const SendDialog = (props) => {
{sendRequest && <Button onClick={() => sendRequest.abort()}>Cancel sending</Button>} {sendRequest && <Button onClick={() => sendRequest.abort()}>Cancel sending</Button>}
{!sendRequest && {!sendRequest &&
<> <>
<FormControlLabel
label="Publish another"
sx={{marginRight: 2}}
control={
<Checkbox size="small" checked={publishAnother} onChange={(ev) => setPublishAnother(ev.target.checked)} />
} />
<Button onClick={props.onClose}>Cancel</Button> <Button onClick={props.onClose}>Cancel</Button>
<Button onClick={handleSubmit} disabled={!sendButtonEnabled}>Send</Button> <Button onClick={handleSubmit} disabled={!sendButtonEnabled}>Send</Button>
</> </>