قرینه از
				https://github.com/karl0ss/homepage.git
				synced 2025-11-04 00:10:57 +00:00 
			
		
		
		
	Add temp usage bar, fix disk percentage
This commit is contained in:
		
							والد
							
								
									868c16620f
								
							
						
					
					
						کامیت
						1e64cf02cd
					
				@ -2,6 +2,7 @@ import useSWR from "swr";
 | 
				
			|||||||
import { FaThermometerHalf } from "react-icons/fa";
 | 
					import { FaThermometerHalf } from "react-icons/fa";
 | 
				
			||||||
import { BiError } from "react-icons/bi";
 | 
					import { BiError } from "react-icons/bi";
 | 
				
			||||||
import { useTranslation } from "next-i18next";
 | 
					import { useTranslation } from "next-i18next";
 | 
				
			||||||
 | 
					import UsageBar from "./usage-bar";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default function CpuTemp({ expanded, units }) {
 | 
					export default function CpuTemp({ expanded, units }) {
 | 
				
			||||||
  const { t } = useTranslation();
 | 
					  const { t } = useTranslation();
 | 
				
			||||||
@ -44,6 +45,7 @@ export default function CpuTemp({ expanded, units }) {
 | 
				
			|||||||
  const unit = units === "imperial" ? "fahrenheit" : "celsius";
 | 
					  const unit = units === "imperial" ? "fahrenheit" : "celsius";
 | 
				
			||||||
  const mainTemp = (unit === "celsius") ? data.cputemp.main : data.cputemp.main * 5/9 + 32;
 | 
					  const mainTemp = (unit === "celsius") ? data.cputemp.main : data.cputemp.main * 5/9 + 32;
 | 
				
			||||||
  const maxTemp = (unit === "celsius") ? data.cputemp.max : data.cputemp.max * 5/9 + 32;
 | 
					  const maxTemp = (unit === "celsius") ? data.cputemp.max : data.cputemp.max * 5/9 + 32;
 | 
				
			||||||
 | 
					  const percent = Math.round((mainTemp / maxTemp) * 100);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <div className="flex-none flex flex-row items-center mr-3 py-1.5">
 | 
					    <div className="flex-none flex flex-row items-center mr-3 py-1.5">
 | 
				
			||||||
@ -73,6 +75,7 @@ export default function CpuTemp({ expanded, units }) {
 | 
				
			|||||||
            <div className="pr-1">{t("resources.max")}</div>
 | 
					            <div className="pr-1">{t("resources.max")}</div>
 | 
				
			||||||
          </span>
 | 
					          </span>
 | 
				
			||||||
        )}
 | 
					        )}
 | 
				
			||||||
 | 
					        <UsageBar percent={percent} />
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
 | 
				
			|||||||
@ -44,7 +44,8 @@ export default function Disk({ options, expanded }) {
 | 
				
			|||||||
    );
 | 
					    );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const percent = Math.round((data.drive.used / data.drive.size) * 100);
 | 
					  // data.drive.used not accurate?
 | 
				
			||||||
 | 
					  const percent = Math.round(((data.drive.size - data.drive.available) / data.drive.size) * 100);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <div className="flex-none flex flex-row items-center mr-3 py-1.5">
 | 
					    <div className="flex-none flex flex-row items-center mr-3 py-1.5">
 | 
				
			||||||
 | 
				
			|||||||
		بارگذاری…
	
	
			
			x
			
			
		
	
		مرجع در شماره جدید
	
	Block a user