mirror of
https://github.com/Ravinou/borgwarehouse
synced 2024-06-10 09:52:22 +02:00
feat: add a disabled option in repo alert settings
This commit is contained in:
parent
a0fa965527
commit
3c4624a686
|
@ -6,6 +6,7 @@ import {
|
|||
IconInfoCircle,
|
||||
IconChevronDown,
|
||||
IconChevronUp,
|
||||
IconBellOff,
|
||||
} from '@tabler/icons-react';
|
||||
import timestampConverter from '../../helpers/functions/timestampConverter';
|
||||
import StorageBar from '../UI/StorageBar/StorageBar';
|
||||
|
@ -53,22 +54,33 @@ export default function Repo(props) {
|
|||
setDisplayDetails(boolean);
|
||||
};
|
||||
|
||||
//Status indicator
|
||||
const statusIndicator = () => {
|
||||
return props.status
|
||||
? classes.statusIndicatorGreen
|
||||
: classes.statusIndicatorRed;
|
||||
};
|
||||
|
||||
//Alert indicator
|
||||
const alertIndicator = () => {
|
||||
if (props.alert === 0) {
|
||||
return (
|
||||
<div className={classes.alertIcon}>
|
||||
<IconBellOff size={16} color='grey' />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{displayDetails ? (
|
||||
<>
|
||||
<div className={classes.RepoOpen}>
|
||||
<div className={classes.openFlex}>
|
||||
{props.status ? (
|
||||
<div
|
||||
className={classes.statusIndicatorGreen}
|
||||
></div>
|
||||
) : (
|
||||
<div
|
||||
className={classes.statusIndicatorRed}
|
||||
></div>
|
||||
)}
|
||||
<div className={statusIndicator()} />
|
||||
<div className={classes.alias}>{props.alias}</div>
|
||||
{alertIndicator()}
|
||||
{props.comment && (
|
||||
<div className={classes.comment}>
|
||||
<IconInfoCircle size={16} color='grey' />
|
||||
|
@ -141,16 +153,9 @@ export default function Repo(props) {
|
|||
<>
|
||||
<div className={classes.RepoClose}>
|
||||
<div className={classes.closeFlex}>
|
||||
{props.status ? (
|
||||
<div
|
||||
className={classes.statusIndicatorGreen}
|
||||
></div>
|
||||
) : (
|
||||
<div
|
||||
className={classes.statusIndicatorRed}
|
||||
></div>
|
||||
)}
|
||||
<div className={statusIndicator()} />
|
||||
<div className={classes.alias}>{props.alias}</div>
|
||||
{alertIndicator()}
|
||||
{props.comment && (
|
||||
<div className={classes.comment}>
|
||||
<IconInfoCircle size={16} color='#637381' />
|
||||
|
|
|
@ -148,6 +148,15 @@
|
|||
}
|
||||
}
|
||||
|
||||
/* Alert icon */
|
||||
|
||||
.alertIcon {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
/* GENERAL */
|
||||
.alias {
|
||||
font-weight: bold;
|
||||
|
|
|
@ -116,6 +116,7 @@ export default function RepoList() {
|
|||
alias={repo.alias}
|
||||
status={repo.status}
|
||||
lastSave={repo.lastSave}
|
||||
alert={repo.alert}
|
||||
repositoryName={repo.repositoryName}
|
||||
storageSize={repo.storageSize}
|
||||
storageUsed={repo.storageUsed}
|
||||
|
|
|
@ -23,6 +23,7 @@ export default function RepoManage(props) {
|
|||
} = useForm({ mode: 'onChange' });
|
||||
//List of possible times for alerts
|
||||
const alertOptions = [
|
||||
{ value: 0, label: 'Disabled' },
|
||||
{ value: 3600, label: '1 hour' },
|
||||
{ value: 21600, label: '6 hours' },
|
||||
{ value: 43200, label: '12 hours' },
|
||||
|
@ -471,7 +472,7 @@ export default function RepoManage(props) {
|
|||
x.value ===
|
||||
targetRepo.alert
|
||||
)
|
||||
: alertOptions[3]
|
||||
: alertOptions[4]
|
||||
}
|
||||
control={control}
|
||||
render={({
|
||||
|
|
|
@ -102,6 +102,7 @@ export default async function handler(req, res) {
|
|||
for (let index in newRepoList) {
|
||||
if (
|
||||
!newRepoList[index].status &&
|
||||
newRepoList[index].alert !== 0 &&
|
||||
(!newRepoList[index].lastStatusAlertSend ||
|
||||
date - newRepoList[index].lastStatusAlertSend > 90000)
|
||||
) {
|
||||
|
|
|
@ -19,7 +19,7 @@ export default async function handler(req, res) {
|
|||
const { alias, sshPublicKey, size, comment, alert, lanCommand } =
|
||||
req.body;
|
||||
//We check that we receive data for each variable. Only "comment" and "lanCommand" are optional in the form.
|
||||
if (!alias || !sshPublicKey || !size || !alert) {
|
||||
if (!alias || !sshPublicKey || !size || (!alert && alert !== 0)) {
|
||||
//If a variable is empty.
|
||||
res.status(422).json({
|
||||
message: 'Unexpected data',
|
||||
|
|
|
@ -19,7 +19,7 @@ export default async function handler(req, res) {
|
|||
const { alias, sshPublicKey, size, comment, alert, lanCommand } =
|
||||
req.body;
|
||||
//We check that we receive data for each variable. Only "comment" and "lanCommand" are optional in the form.
|
||||
if (!alias || !sshPublicKey || !size || !alert) {
|
||||
if (!alias || !sshPublicKey || !size || (!alert && alert !== 0)) {
|
||||
//If a variable is empty.
|
||||
res.status(422).json({
|
||||
message: 'Unexpected data',
|
||||
|
|
Loading…
Reference in a new issue