✨ Add pihole integration (#860)
* ✨ Add pihole integration * Update src/widgets/adhole/AdHoleControls.tsx Co-authored-by: Larvey <39219859+LarveyOfficial@users.noreply.github.com> * Update src/tools/client/math.ts Co-authored-by: Meier Lukas <meierschlumpf@gmail.com> * Update src/widgets/dnshole/DnsHoleSummary.tsx Co-authored-by: Meier Lukas <meierschlumpf@gmail.com> --------- Co-authored-by: Larvey <39219859+LarveyOfficial@users.noreply.github.com> Co-authored-by: Meier Lukas <meierschlumpf@gmail.com>
This commit is contained in:
4
src/tools/client/app-properties.ts
Normal file
4
src/tools/client/app-properties.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { ConfigAppType, IntegrationField } from '../../types/app';
|
||||
|
||||
export const findAppProperty = (app: ConfigAppType, key: IntegrationField) =>
|
||||
app.integration?.properties.find((prop) => prop.field === key)?.value ?? '';
|
||||
18
src/tools/client/math.ts
Normal file
18
src/tools/client/math.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
const ranges = [
|
||||
{ divider: 1e18, suffix: 'E' },
|
||||
{ divider: 1e15, suffix: 'P' },
|
||||
{ divider: 1e12, suffix: 'T' },
|
||||
{ divider: 1e9, suffix: 'G' },
|
||||
{ divider: 1e6, suffix: 'M' },
|
||||
{ divider: 1e3, suffix: 'k' },
|
||||
];
|
||||
|
||||
export const formatNumber = (n: number, decimalPlaces: number) => {
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const range of ranges) {
|
||||
if (n < range.divider) continue;
|
||||
|
||||
return (n / range.divider).toFixed(decimalPlaces) + range.suffix;
|
||||
}
|
||||
return n.toFixed(decimalPlaces);
|
||||
};
|
||||
Reference in New Issue
Block a user