mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
limit send to plus where appropriate (#3080)
This commit is contained in:
parent
51fd18f56d
commit
35bd1de5ba
@ -53,7 +53,12 @@ export default function Events({ path, ...props }) {
|
|||||||
});
|
});
|
||||||
const [uploading, setUploading] = useState([]);
|
const [uploading, setUploading] = useState([]);
|
||||||
const [viewEvent, setViewEvent] = useState();
|
const [viewEvent, setViewEvent] = useState();
|
||||||
const [downloadEvent, setDownloadEvent] = useState({ id: null, has_clip: false, has_snapshot: false });
|
const [downloadEvent, setDownloadEvent] = useState({
|
||||||
|
id: null,
|
||||||
|
has_clip: false,
|
||||||
|
has_snapshot: false,
|
||||||
|
plus_id: undefined,
|
||||||
|
});
|
||||||
|
|
||||||
const eventsFetcher = useCallback((path, params) => {
|
const eventsFetcher = useCallback((path, params) => {
|
||||||
params = { ...params, include_thumbnails: 0, limit: API_LIMIT };
|
params = { ...params, include_thumbnails: 0, limit: API_LIMIT };
|
||||||
@ -123,7 +128,12 @@ export default function Events({ path, ...props }) {
|
|||||||
|
|
||||||
const onDownloadClick = (e, event) => {
|
const onDownloadClick = (e, event) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setDownloadEvent((_prev) => ({ id: event.id, has_clip: event.has_clip, has_snapshot: event.has_snapshot }));
|
setDownloadEvent((_prev) => ({
|
||||||
|
id: event.id,
|
||||||
|
has_clip: event.has_clip,
|
||||||
|
has_snapshot: event.has_snapshot,
|
||||||
|
plus_id: event.plus_id,
|
||||||
|
}));
|
||||||
downloadButton.current = e.target;
|
downloadButton.current = e.target;
|
||||||
setState({ ...state, showDownloadMenu: true });
|
setState({ ...state, showDownloadMenu: true });
|
||||||
};
|
};
|
||||||
@ -177,6 +187,10 @@ export default function Events({ path, ...props }) {
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (uploading.includes(id)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!config.plus.enabled) {
|
if (!config.plus.enabled) {
|
||||||
setState({ ...state, showDownloadMenu: false, showPlusConfig: true });
|
setState({ ...state, showDownloadMenu: false, showPlusConfig: true });
|
||||||
return;
|
return;
|
||||||
@ -202,6 +216,10 @@ export default function Events({ path, ...props }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setUploading((prev) => prev.filter((i) => i !== id));
|
setUploading((prev) => prev.filter((i) => i !== id));
|
||||||
|
|
||||||
|
if (state.showDownloadMenu && downloadEvent.id === id) {
|
||||||
|
setState({ ...state, showDownloadMenu: false });
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!config) {
|
if (!config) {
|
||||||
@ -278,11 +296,19 @@ export default function Events({ path, ...props }) {
|
|||||||
{downloadEvent.has_snapshot && !downloadEvent.plus_id && (
|
{downloadEvent.has_snapshot && !downloadEvent.plus_id && (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
icon={UploadPlus}
|
icon={UploadPlus}
|
||||||
label="Send to Frigate+"
|
label={uploading.includes(downloadEvent.id) ? 'Uploading...' : 'Send to Frigate+'}
|
||||||
value="plus"
|
value="plus"
|
||||||
onSelect={() => onSendToPlus(downloadEvent.id)}
|
onSelect={() => onSendToPlus(downloadEvent.id)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{downloadEvent.plus_id && (
|
||||||
|
<MenuItem
|
||||||
|
icon={UploadPlus}
|
||||||
|
label={'Sent to Frigate+'}
|
||||||
|
value="plus"
|
||||||
|
onSelect={() => setState({ ...state, showDownloadMenu: false })}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Menu>
|
</Menu>
|
||||||
)}
|
)}
|
||||||
{state.showDatePicker && (
|
{state.showDatePicker && (
|
||||||
@ -398,16 +424,20 @@ export default function Events({ path, ...props }) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="hidden sm:flex flex-col justify-end mr-2">
|
<div class="hidden sm:flex flex-col justify-end mr-2">
|
||||||
{event.plus_id ? (
|
{event.has_snapshot && (
|
||||||
<div className="uppercase text-xs">Sent to Frigate+</div>
|
<Fragment>
|
||||||
) : (
|
{event.plus_id ? (
|
||||||
<Button
|
<div className="uppercase text-xs">Sent to Frigate+</div>
|
||||||
color="gray"
|
) : (
|
||||||
disabled={uploading.includes(event.id)}
|
<Button
|
||||||
onClick={(e) => onSendToPlus(event.id, e)}
|
color="gray"
|
||||||
>
|
disabled={uploading.includes(event.id)}
|
||||||
{uploading.includes(event.id) ? 'Uploading...' : 'Send to Frigate+'}
|
onClick={(e) => onSendToPlus(event.id, e)}
|
||||||
</Button>
|
>
|
||||||
|
{uploading.includes(event.id) ? 'Uploading...' : 'Send to Frigate+'}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</Fragment>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
|
Loading…
Reference in New Issue
Block a user