Skip to content

Commit

Permalink
HPCC-28507 Display file min and max skews as percentages
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremy Clements <Jeremy.Clements@lexisnexisrisk.com>
  • Loading branch information
jeclrsg committed Nov 10, 2022
1 parent b16c5f3 commit 2610a5f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 9 deletions.
8 changes: 5 additions & 3 deletions esp/src/eclwatch/DFUQueryWidget.js
Expand Up @@ -31,6 +31,8 @@ define([

"put-selector/put",

"src/Utility",

"dojo/text!../templates/DFUQueryWidget.html",

"hpcc/TargetSelectWidget",
Expand Down Expand Up @@ -63,7 +65,7 @@ define([
registry, Dialog, Menu, MenuItem, MenuSeparator, PopupMenuItem,
editor, selector, tree,
_TabContainerWidget, WsDfu, FileSpray, ESPUtil, ESPLogicalFile, ESPDFUWorkunit, DelayLoadWidget, WsTopology, Utility, Session,
put,
put, Utility,
template) {

var nlsHPCC = nlsHPCCMod.default;
Expand Down Expand Up @@ -736,13 +738,13 @@ define([
MinSkew: {
label: nlsHPCC.MinSkew, width: 60,
formatter: function (value, row) {
return value !== undefined ? value : "";
return value ? "-" + Utility.formatDecimal(value / 100) + "%" : "";
}
},
MaxSkew: {
label: nlsHPCC.MaxSkew, width: 60,
formatter: function (value, row) {
return value !== undefined ? value : "";
return value ? Utility.formatDecimal(value / 100) + "%" : "";
}
},
Modified: { label: this.i18n.ModifiedUTCGMT, width: 162 },
Expand Down
8 changes: 7 additions & 1 deletion esp/src/eclwatch/LFDetailsWidget.js
Expand Up @@ -10,6 +10,8 @@ define([

"dijit/registry",

"src/Utility",

"hpcc/_TabContainerWidget",
"hpcc/DelayLoadWidget",
"src/Clippy",
Expand Down Expand Up @@ -49,7 +51,7 @@ define([
"hpcc/TableContainer"

], function (exports, declare, lang, nlsHPCCMod, dom, domAttr, domClass, domForm,
registry,
registry, Utility,
_TabContainerWidget, DelayLoadWidget, Clippy, ESPLogicalFile, ESPDFUWorkunit, FileSpray, DataPatternsWidget, Session,
template) {

Expand Down Expand Up @@ -462,6 +464,10 @@ define([
this.updateInput("RecordSize", oldValue, this.i18n.NoPublishedSize);
} else if (name === "Cost") {
this.updateInput("FormattedCost", oldValue, Session.formatCost(newValue));
} else if (name === "MinSkew") {
domAttr.set(this.id + "MinSkew", "innerHTML", this.logicalFile.MinSkew ? Utility.formatDecimal(this.logicalFile.MinSkew) + "%" : "");
} else if (name === "MaxSkew") {
domAttr.set(this.id + "MaxSkew", "innerHTML", this.logicalFile.MaxSkew ? Utility.formatDecimal(this.logicalFile.MaxSkew) + "%" : "");
}
},

Expand Down
4 changes: 2 additions & 2 deletions esp/src/src-react/components/Files.tsx
Expand Up @@ -200,10 +200,10 @@ export const Files: React.FunctionComponent<FilesProps> = ({
}, []),
},
MinSkew: {
label: nlsHPCC.MinSkew, width: 60, formatter: React.useCallback((value, row) => value ?? "", [])
label: nlsHPCC.MinSkew, width: 60, formatter: React.useCallback((value, row) => value ? `-${Utility.formatDecimal(value / 100)}%` : "", [])
},
MaxSkew: {
label: nlsHPCC.MaxSkew, width: 60, formatter: React.useCallback((value, row) => value ?? "", [])
label: nlsHPCC.MaxSkew, width: 60, formatter: React.useCallback((value, row) => value ? `${Utility.formatDecimal(value / 100)}%` : "", [])
},
Modified: { label: nlsHPCC.ModifiedUTCGMT, width: 162 },
AtRestCost: {
Expand Down
4 changes: 2 additions & 2 deletions esp/src/src-react/components/LogicalFileSummary.tsx
Expand Up @@ -180,8 +180,8 @@ export const LogicalFileSummary: React.FunctionComponent<LogicalFileSummaryProps
"RecordCount": { label: nlsHPCC.RecordCount, type: "string", value: file?.RecordCount, readonly: true },
"IsReplicated": { label: nlsHPCC.IsReplicated, type: "checkbox", value: (file?.filePartsOnCluster() ?? []).length > 0, readonly: true },
"NumParts": { label: nlsHPCC.FileParts, type: "number", value: file?.NumParts, readonly: true },
"MinSkew": { label: nlsHPCC.MinSkew, type: "string", value: file?.Stat?.MinSkew, readonly: true },
"MaxSkew": { label: nlsHPCC.MaxSkew, type: "string", value: file?.Stat?.MaxSkew, readonly: true },
"MinSkew": { label: nlsHPCC.MinSkew, type: "string", value: `${Utility.formatDecimal(file?.Stat?.MinSkew ?? "0")}%`, readonly: true },
"MaxSkew": { label: nlsHPCC.MaxSkew, type: "string", value: `${Utility.formatDecimal(file?.Stat?.MaxSkew ?? "0")}%`, readonly: true },
"MinSkewPart": { label: nlsHPCC.MinSkewPart, type: "string", value: file?.Stat?.MinSkewPart === undefined ? "" : file?.Stat?.MinSkewPart?.toString(), readonly: true },
"MaxSkewPart": { label: nlsHPCC.MaxSkewPart, type: "string", value: file?.Stat?.MaxSkewPart === undefined ? "" : file?.Stat?.MaxSkewPart?.toString(), readonly: true },
}} onChange={(id, value) => {
Expand Down
2 changes: 1 addition & 1 deletion esp/src/src/Session.ts
Expand Up @@ -48,7 +48,7 @@ getBuildInfo().then(info => {
dojoConfig.currencyCode = info["currencyCode"] ?? "";
});

const format = d3Format(".2f");
const format = d3Format(",.2f");
export function formatCost(value?: number | string): string {
if (value !== 0 && !value) {
logger.debug(`formatCost called for a nullish value: ${value}`);
Expand Down
8 changes: 8 additions & 0 deletions esp/src/src/Utility.ts
Expand Up @@ -1061,6 +1061,14 @@ export function deleteCookie(name: string) {
document.cookie = `${name}=; domain=${window.location.hostname}; path=/; expires=${expireDate.toUTCString()}`;
}

export function formatDecimal(str): string {
const format = d3Format(",.2f");
if (isNaN(str)) {
return str;
}
return format(str);
}

export function formatNum(str): string {
if (isNaN(str)) {
return str;
Expand Down

0 comments on commit 2610a5f

Please sign in to comment.