Build out frontend for viewing server backups
This commit is contained in:
parent
44ff99e83d
commit
ad9194a65c
2 changed files with 53 additions and 7 deletions
|
@ -7,6 +7,7 @@ import { httpErrorToHuman } from '@/api/http';
|
||||||
import Can from '@/components/elements/Can';
|
import Can from '@/components/elements/Can';
|
||||||
import CreateBackupButton from '@/components/server/backups/CreateBackupButton';
|
import CreateBackupButton from '@/components/server/backups/CreateBackupButton';
|
||||||
import FlashMessageRender from '@/components/FlashMessageRender';
|
import FlashMessageRender from '@/components/FlashMessageRender';
|
||||||
|
import BackupRow from '@/components/server/backups/BackupRow';
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
const { uuid } = useServer();
|
const { uuid } = useServer();
|
||||||
|
@ -40,13 +41,11 @@ export default () => {
|
||||||
</p>
|
</p>
|
||||||
:
|
:
|
||||||
<div>
|
<div>
|
||||||
{
|
{backups.map((backup, index) => <BackupRow
|
||||||
backups.map(backup => (
|
key={backup.uuid}
|
||||||
<div key={backup.uuid}>
|
backup={backup}
|
||||||
{backup.uuid}
|
className={index !== (backups.length - 1) ? 'mb-2' : undefined}
|
||||||
</div>
|
/>)}
|
||||||
))
|
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
<Can action={'backup.create'}>
|
<Can action={'backup.create'}>
|
||||||
|
|
47
resources/scripts/components/server/backups/BackupRow.tsx
Normal file
47
resources/scripts/components/server/backups/BackupRow.tsx
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { ServerBackup } from '@/api/server/backups/getServerBackups';
|
||||||
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
|
import { faArchive } from '@fortawesome/free-solid-svg-icons/faArchive';
|
||||||
|
import format from 'date-fns/format';
|
||||||
|
import distanceInWordsToNow from 'date-fns/distance_in_words_to_now'
|
||||||
|
import Spinner from '@/components/elements/Spinner';
|
||||||
|
import { faCloudDownloadAlt } from '@fortawesome/free-solid-svg-icons/faCloudDownloadAlt';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
backup: ServerBackup;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ({ backup, className }: Props) => {
|
||||||
|
return (
|
||||||
|
<div className={`grey-row-box flex items-center ${className}`}>
|
||||||
|
<div className={'mr-4'}>
|
||||||
|
<FontAwesomeIcon icon={faArchive} className={'text-neutral-300'}/>
|
||||||
|
</div>
|
||||||
|
<div className={'flex-1'}>
|
||||||
|
<p className={'text-sm mb-1'}>{backup.name}</p>
|
||||||
|
<p className={'text-xs text-neutral-400 font-mono'}>{backup.uuid}</p>
|
||||||
|
</div>
|
||||||
|
<div className={'ml-4 text-center'}>
|
||||||
|
<p
|
||||||
|
title={format(backup.createdAt, 'ddd, MMMM Do, YYYY HH:mm:ss Z')}
|
||||||
|
className={'text-sm'}
|
||||||
|
>
|
||||||
|
{distanceInWordsToNow(backup.createdAt, { includeSeconds: true, addSuffix: true })}
|
||||||
|
</p>
|
||||||
|
<p className={'text-2xs text-neutral-500 uppercase mt-1'}>Created</p>
|
||||||
|
</div>
|
||||||
|
<div className={'ml-6'} style={{ marginRight: '-0.5rem' }}>
|
||||||
|
{!backup.completedAt ?
|
||||||
|
<div title={'Backup is in progress'} className={'p-2'}>
|
||||||
|
<Spinner size={'tiny'}/>
|
||||||
|
</div>
|
||||||
|
:
|
||||||
|
<a href={'#'} className={'text-sm text-neutral-300 p-2 transition-colors duration-250 hover:text-cyan-400'}>
|
||||||
|
<FontAwesomeIcon icon={faCloudDownloadAlt}/>
|
||||||
|
</a>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
Loading…
Reference in a new issue