Use base10 for sizes in frontend (#1133)
* Use base10 for sizes in frontend * Simplify renderSize
This commit is contained in:
parent
6dca2f1c03
commit
93573d0bfe
@ -95,35 +95,13 @@ export class ConfigDetails extends LiteElement {
|
||||
>`;
|
||||
}
|
||||
};
|
||||
|
||||
const renderSize = (valueBytes?: number | null, fallbackValue?: number) => {
|
||||
const bytesPerGB = 1073741824;
|
||||
|
||||
const renderSize = (valueBytes?: number | null) => {
|
||||
// Eventually we will want to set this to the selected locale
|
||||
const formatter = new Intl.NumberFormat(undefined, {
|
||||
style: "unit",
|
||||
unit: "gigabyte",
|
||||
unitDisplay: "narrow",
|
||||
});
|
||||
|
||||
if (valueBytes) {
|
||||
const sizeGB = Math.floor(valueBytes / bytesPerGB);
|
||||
return formatter.format(sizeGB);
|
||||
}
|
||||
|
||||
if (typeof fallbackValue === "number") {
|
||||
let value = "";
|
||||
if (fallbackValue === Infinity) {
|
||||
value = msg("Unlimited");
|
||||
} else if (fallbackValue === 0) {
|
||||
value = formatter.format(0);
|
||||
} else {
|
||||
const sizeGB = Math.floor(fallbackValue / bytesPerGB);
|
||||
value = formatter.format(sizeGB);
|
||||
}
|
||||
return html`<span class="text-neutral-400"
|
||||
>${value} ${msg("(default)")}</span
|
||||
>`;
|
||||
return html`<sl-format-bytes
|
||||
value=${valueBytes}
|
||||
display="narrow"
|
||||
></sl-format-bytes>`;
|
||||
}
|
||||
|
||||
return html`<span class="text-neutral-400"
|
||||
@ -205,7 +183,7 @@ export class ConfigDetails extends LiteElement {
|
||||
)}
|
||||
${this.renderSetting(
|
||||
msg("Crawl Size Limit"),
|
||||
renderSize(crawlConfig?.maxCrawlSize, Infinity)
|
||||
renderSize(crawlConfig?.maxCrawlSize)
|
||||
)}
|
||||
${this.renderSetting(msg("Crawler Instances"), crawlConfig?.scale)}
|
||||
</btrix-desc-list>
|
||||
|
@ -215,7 +215,7 @@ const DEFAULT_BEHAVIORS = [
|
||||
"autofetch",
|
||||
"siteSpecific",
|
||||
];
|
||||
const BYTES_PER_GB = 1073741824;
|
||||
const BYTES_PER_GB = 1e9;
|
||||
|
||||
@localized()
|
||||
export class CrawlConfigEditor extends LiteElement {
|
||||
|
Loading…
Reference in New Issue
Block a user