-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEAT: Storage API & Frontend (#3409)
* Get storage output stats for each camera * Add storage route * Add storage route * Add storage page * Cleanup * Add stats and show more storage * Add tests for mb abbrev util fun * Rewrite storage logic to use storage maintainer and segment sizes * Include storage maintainer for http * Use correct format * Remove utils * Fix tests * Remove total from equation * Multiply by 100 to get percent * Add basic storage info * Fix storage stats * Fix endpoint and ui * Fix formatting
- Loading branch information
Showing
9 changed files
with
172 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import { h, Fragment } from 'preact'; | ||
import ActivityIndicator from '../components/ActivityIndicator'; | ||
import Heading from '../components/Heading'; | ||
import { useWs } from '../api/ws'; | ||
import useSWR from 'swr'; | ||
import { Table, Tbody, Thead, Tr, Th, Td } from '../components/Table'; | ||
|
||
const emptyObject = Object.freeze({}); | ||
|
||
export default function Storage() { | ||
const { data: storage } = useSWR('recordings/storage'); | ||
|
||
const { | ||
value: { payload: stats }, | ||
} = useWs('stats'); | ||
const { data: initialStats } = useSWR('stats'); | ||
|
||
const { service } = stats || initialStats || emptyObject; | ||
|
||
return ( | ||
<div className="space-y-4 p-2 px-4"> | ||
<Heading>Storage</Heading> | ||
|
||
{(!service || !storage) ? ( | ||
<div> | ||
<ActivityIndicator /> | ||
</div> | ||
) : ( | ||
<Fragment> | ||
<Heading size="lg">Overview</Heading> | ||
<div data-testid="detectors" className="grid grid-cols-1 md:grid-cols-2 gap-4"> | ||
<div className="dark:bg-gray-800 shadow-md hover:shadow-lg rounded-lg transition-shadow"> | ||
<div className="text-lg flex justify-between p-4">Data</div> | ||
<div className="p-2"> | ||
<Table className="w-full"> | ||
<Thead> | ||
<Tr> | ||
<Th>Location</Th> | ||
<Th>Used MB</Th> | ||
<Th>Total MB</Th> | ||
</Tr> | ||
</Thead> | ||
<Tbody> | ||
<Tr> | ||
<Td>Snapshots & Recordings</Td> | ||
<Td>{service['storage']['/media/frigate/recordings']['used']}</Td> | ||
<Td>{service['storage']['/media/frigate/recordings']['total']}</Td> | ||
</Tr> | ||
</Tbody> | ||
</Table> | ||
</div> | ||
</div> | ||
<div className="dark:bg-gray-800 shadow-md hover:shadow-lg rounded-lg transition-shadow"> | ||
<div className="text-lg flex justify-between p-4">Memory</div> | ||
<div className="p-2"> | ||
<Table className="w-full"> | ||
<Thead> | ||
<Tr> | ||
<Th>Location</Th> | ||
<Th>Used MB</Th> | ||
<Th>Total MB</Th> | ||
</Tr> | ||
</Thead> | ||
<Tbody> | ||
<Tr> | ||
<Td>/dev/shm</Td> | ||
<Td>{service['storage']['/dev/shm']['used']}</Td> | ||
<Td>{service['storage']['/dev/shm']['total']}</Td> | ||
</Tr> | ||
<Tr> | ||
<Td>/tmp/cache</Td> | ||
<Td>{service['storage']['/tmp/cache']['used']}</Td> | ||
<Td>{service['storage']['/tmp/cache']['total']}</Td> | ||
</Tr> | ||
</Tbody> | ||
</Table> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<Heading size="lg">Cameras</Heading> | ||
<div data-testid="detectors" className="grid grid-cols-1 3xl:grid-cols-3 md:grid-cols-2 gap-4"> | ||
{Object.entries(storage).map(([name, camera]) => ( | ||
<div key={name} className="dark:bg-gray-800 shadow-md hover:shadow-lg rounded-lg transition-shadow"> | ||
<div className="text-lg flex justify-between p-4">{name}</div> | ||
<div className="p-2"> | ||
<Table className="w-full"> | ||
<Thead> | ||
<Tr> | ||
<Th>Usage</Th> | ||
<Th>Stream Bandwidth</Th> | ||
</Tr> | ||
</Thead> | ||
<Tbody> | ||
<Tr> | ||
<Td>{Math.round(camera['usage_percent'] ?? 0)}%</Td> | ||
<Td>{camera['bandwidth']} MB/hr</Td> | ||
</Tr> | ||
</Tbody> | ||
</Table> | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
</Fragment> | ||
)} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters