|
@@ -1,5 +1,10 @@
|
|
|
import React from 'react';
|
|
|
import { Space, Tooltip } from 'antd';
|
|
|
+import Quota from '../pages/security/Quota';
|
|
|
+import { useEffect } from 'react';
|
|
|
+import { useDispatch } from 'react-redux';
|
|
|
+import { setQuota } from '../states/security/quotaSlice';
|
|
|
+import { getQuota } from '../API/security/quotaActions';
|
|
|
import {
|
|
|
HddOutlined,
|
|
|
WifiOutlined,
|
|
@@ -112,9 +117,39 @@ const StatusBar: React.FC<StatusBarProps> = ({
|
|
|
wifiStrength,
|
|
|
heatCapacity,
|
|
|
}) => {
|
|
|
+ const dispatch = useDispatch();
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ const fetchQuota = async () => {
|
|
|
+ try {
|
|
|
+ const response = await getQuota();
|
|
|
+ dispatch(
|
|
|
+ setQuota({
|
|
|
+ available: response.data.available,
|
|
|
+ total: response.data.total,
|
|
|
+ })
|
|
|
+ );
|
|
|
+ } catch (error) {
|
|
|
+ dispatch(
|
|
|
+ setQuota({
|
|
|
+ available: 0,
|
|
|
+ total: 0,
|
|
|
+ })
|
|
|
+ );
|
|
|
+ console.error('Failed to fetch quota:', error);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ fetchQuota();
|
|
|
+ const intervalId = setInterval(fetchQuota, 1000);
|
|
|
+
|
|
|
+ return () => clearInterval(intervalId);
|
|
|
+ }, [dispatch]);
|
|
|
+
|
|
|
return (
|
|
|
// <div className="flex justify-end p-2">
|
|
|
<Space className="h-full">
|
|
|
+ <Quota />
|
|
|
<DiskStatus status={diskStatus} />
|
|
|
<BatteryStatus level={batteryLevel} />
|
|
|
<WifiStatus strength={wifiStrength} />
|