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