mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-29 11:26:25 -05:00
Adding statistics page for Archives.
This commit is contained in:
parent
ad59d67171
commit
2c8f765f2b
7 changed files with 224 additions and 2 deletions
|
|
@ -7,6 +7,7 @@ import {
|
|||
fetchDomains,
|
||||
filesSearch,
|
||||
getArchive,
|
||||
getArchiveStatistics,
|
||||
getChannel,
|
||||
getConfigs,
|
||||
getDomain,
|
||||
|
|
@ -1151,6 +1152,29 @@ export const useVideoStatistics = () => {
|
|||
return {statistics, fetchStatistics}
|
||||
}
|
||||
|
||||
export const useArchiveStatistics = () => {
|
||||
const [statistics, setStatistics] = useState(null);
|
||||
|
||||
const fetchStatistics = async () => {
|
||||
try {
|
||||
let stats = await getArchiveStatistics();
|
||||
stats.archives.sum_size = humanFileSize(stats.archives.sum_size);
|
||||
stats.archives.max_size = humanFileSize(stats.archives.max_size);
|
||||
stats.historical.average_size = humanFileSize(stats.historical.average_size);
|
||||
setStatistics(stats);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
setStatistics(undefined); // Display error.
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
fetchStatistics();
|
||||
}, []);
|
||||
|
||||
return {statistics, fetchStatistics}
|
||||
}
|
||||
|
||||
export const useInventory = (inventoryId) => {
|
||||
const [byCategory, setByCategory] = useState();
|
||||
const [bySubcategory, setBySubcategory] = useState();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue