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) => {
|
||||||
const renderSize = (valueBytes?: number | null, fallbackValue?: number) => {
|
|
||||||
const bytesPerGB = 1073741824;
|
|
||||||
|
|
||||||
// Eventually we will want to set this to the selected locale
|
// 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) {
|
if (valueBytes) {
|
||||||
const sizeGB = Math.floor(valueBytes / bytesPerGB);
|
return html`<sl-format-bytes
|
||||||
return formatter.format(sizeGB);
|
value=${valueBytes}
|
||||||
}
|
display="narrow"
|
||||||
|
></sl-format-bytes>`;
|
||||||
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`<span class="text-neutral-400"
|
return html`<span class="text-neutral-400"
|
||||||
@ -205,7 +183,7 @@ export class ConfigDetails extends LiteElement {
|
|||||||
)}
|
)}
|
||||||
${this.renderSetting(
|
${this.renderSetting(
|
||||||
msg("Crawl Size Limit"),
|
msg("Crawl Size Limit"),
|
||||||
renderSize(crawlConfig?.maxCrawlSize, Infinity)
|
renderSize(crawlConfig?.maxCrawlSize)
|
||||||
)}
|
)}
|
||||||
${this.renderSetting(msg("Crawler Instances"), crawlConfig?.scale)}
|
${this.renderSetting(msg("Crawler Instances"), crawlConfig?.scale)}
|
||||||
</btrix-desc-list>
|
</btrix-desc-list>
|
||||||
|
|||||||
@ -215,7 +215,7 @@ const DEFAULT_BEHAVIORS = [
|
|||||||
"autofetch",
|
"autofetch",
|
||||||
"siteSpecific",
|
"siteSpecific",
|
||||||
];
|
];
|
||||||
const BYTES_PER_GB = 1073741824;
|
const BYTES_PER_GB = 1e9;
|
||||||
|
|
||||||
@localized()
|
@localized()
|
||||||
export class CrawlConfigEditor extends LiteElement {
|
export class CrawlConfigEditor extends LiteElement {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user