diff --git a/Components/Repo/Repo.js b/Components/Repo/Repo.js index 1d1cb03..d06089a 100644 --- a/Components/Repo/Repo.js +++ b/Components/Repo/Repo.js @@ -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 ( +
+ +
+ ); + } + }; + return ( <> {displayDetails ? ( <>
- {props.status ? ( -
- ) : ( -
- )} +
{props.alias}
+ {alertIndicator()} {props.comment && (
@@ -141,16 +153,9 @@ export default function Repo(props) { <>
- {props.status ? ( -
- ) : ( -
- )} +
{props.alias}
+ {alertIndicator()} {props.comment && (
diff --git a/Components/Repo/Repo.module.css b/Components/Repo/Repo.module.css index 04250d0..ae972e8 100644 --- a/Components/Repo/Repo.module.css +++ b/Components/Repo/Repo.module.css @@ -148,6 +148,15 @@ } } +/* Alert icon */ + +.alertIcon { + display: flex; + flex-direction: row; + align-items: center; + margin-left: 10px; +} + /* GENERAL */ .alias { font-weight: bold; diff --git a/Containers/RepoList/RepoList.js b/Containers/RepoList/RepoList.js index 2bbf642..8e794f1 100644 --- a/Containers/RepoList/RepoList.js +++ b/Containers/RepoList/RepoList.js @@ -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} diff --git a/Containers/RepoManage/RepoManage.js b/Containers/RepoManage/RepoManage.js index 4d19db2..90370ca 100644 --- a/Containers/RepoManage/RepoManage.js +++ b/Containers/RepoManage/RepoManage.js @@ -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={({ diff --git a/pages/api/cronjob/checkStatus.js b/pages/api/cronjob/checkStatus.js index 19f394e..842aaa3 100644 --- a/pages/api/cronjob/checkStatus.js +++ b/pages/api/cronjob/checkStatus.js @@ -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) ) { diff --git a/pages/api/repo/add.js b/pages/api/repo/add.js index 0288817..3dd4770 100644 --- a/pages/api/repo/add.js +++ b/pages/api/repo/add.js @@ -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', diff --git a/pages/api/repo/id/[slug]/edit.js b/pages/api/repo/id/[slug]/edit.js index c724ef6..ea61b97 100644 --- a/pages/api/repo/id/[slug]/edit.js +++ b/pages/api/repo/id/[slug]/edit.js @@ -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',