From 0ec6393e0aec304df3d91646df7c3f14b351ebb5 Mon Sep 17 00:00:00 2001 From: Xinos Date: Thu, 17 Aug 2023 15:17:02 +0700 Subject: [PATCH] Revert "Zfs getStats method" This reverts commit 8368b531852ed332eb9c103b42834d9ef5e1f452. --- public/locales/en/common.json | 4 +- src/widgets/openmediavault/component.jsx | 3 - .../openmediavault/methods/zfs_get_stats.jsx | 80 ------------------- 3 files changed, 1 insertion(+), 86 deletions(-) delete mode 100644 src/widgets/openmediavault/methods/zfs_get_stats.jsx diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 6d9b76a7..dc4fcd00 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -708,8 +708,6 @@ "running": "Running", "stopped": "Stopped", "passed": "Passed", - "failed": "Failed", - "zfsHits": "Hits", - "zfsMisses": "Misses" + "failed": "Failed" } } diff --git a/src/widgets/openmediavault/component.jsx b/src/widgets/openmediavault/component.jsx index b71d936f..bd34a750 100644 --- a/src/widgets/openmediavault/component.jsx +++ b/src/widgets/openmediavault/component.jsx @@ -1,7 +1,6 @@ import ServicesGetStatus from "./methods/services_get_status"; import SmartGetList from "./methods/smart_get_list"; import DownloaderGetDownloadList from "./methods/downloader_get_downloadlist"; -import ZfsGetStats from "./methods/zfs_get_stats"; export default function Component({ service }) { switch (service.widget.method) { @@ -11,8 +10,6 @@ export default function Component({ service }) { return ; case "downloader.getDownloadList": return ; - case "zfs.getStats": - return ; default: return null; } diff --git a/src/widgets/openmediavault/methods/zfs_get_stats.jsx b/src/widgets/openmediavault/methods/zfs_get_stats.jsx deleted file mode 100644 index ec8b7a25..00000000 --- a/src/widgets/openmediavault/methods/zfs_get_stats.jsx +++ /dev/null @@ -1,80 +0,0 @@ -import dynamic from "next/dynamic"; -import { useState, useEffect } from "react"; -import { useTranslation } from "next-i18next"; - -import Error from "../../glances/components/error"; -import Container from "../../glances/components/container"; -import Block from "../../glances/components/block"; - -import useWidgetAPI from "utils/proxy/use-widget-api"; - -const ChartDual = dynamic(() => import("../../glances/components/chart_dual"), { ssr: false }); - -const POINTS_LIMIT = 15; - -export default function Component({ service }) { - const { t } = useTranslation(); - const { widget } = service; - - const [dataPoints, setDataPoints] = useState(new Array(POINTS_LIMIT).fill({ value: 0 }, 0, POINTS_LIMIT)); - - const { data, error } = useWidgetAPI(widget, null, { - refreshInterval: 5000, - }); - - useEffect(() => { - if (data?.response) { - const { hits, misses } = data.response; - const a = parseInt(hits, 10); - const b = parseInt(misses, 10); - - setDataPoints((prevDataPoints) => { - const newDataPoints = [...prevDataPoints, { a, b }]; - if (newDataPoints.length > POINTS_LIMIT) { - newDataPoints.shift(); - } - return newDataPoints; - }); - } - }, [data]); - - if (error) { - return ( - - - - ); - } - - if (!data) { - return ( - - - - - ); - } - - const { hits, misses, hitsMisses, ratio } = data.response; - const hitsRatio = Math.round(ratio); - const missesRatio = 100 - hitsRatio; - - return ( - - value} - /> - - -
{`${t("resources.total")}: ${hitsMisses}`}
- -
{`${t("openmediavault.zfsHits")}: ${hits} (${hitsRatio}%)`}
-
- - -
{`${t("openmediavault.zfsMisses")}: ${misses} (${missesRatio}%)`}
-
-
- ); -}