Browse Source

[WebUI] Show message size in IEC (base 1024) units

tags/3.8.0
moisseev 4 months ago
parent
commit
5210699735
3 changed files with 25 additions and 6 deletions
  1. 3
    0
      .eslintrc.json
  2. 3
    3
      interface/js/app/history.js
  3. 19
    3
      interface/js/app/libft.js

+ 3
- 0
.eslintrc.json View File

"globals": { "globals": {
"define": false "define": false
}, },
"parserOptions": {
"ecmaVersion": 2016
},
"plugins": [ "plugins": [
"@stylistic" "@stylistic"
], ],

+ 3
- 3
interface/js/app/history.js View File



/* global FooTable */ /* global FooTable */


define(["jquery", "app/common", "app/libft", "d3", "footable"],
($, common, libft, d3) => {
define(["jquery", "app/common", "app/libft", "footable"],
($, common, libft) => {
"use strict"; "use strict";
const ui = {}; const ui = {};
let prevVersion = null; let prevVersion = null;
title: "Message size", title: "Message size",
breakpoints: "xs sm", breakpoints: "xs sm",
style: {width: 120, maxWidth: 120}, style: {width: 120, maxWidth: 120},
formatter: d3.format(".3~s")
formatter: libft.formatBytesIEC
}, { }, {
name: "scan_time", name: "scan_time",
title: "Scan time", title: "Scan time",

+ 19
- 3
interface/js/app/libft.js View File

/* global FooTable */ /* global FooTable */


define(["jquery", "app/common", "d3", "footable"],
($, common, d3) => {
define(["jquery", "app/common", "footable"],
($, common) => {
"use strict"; "use strict";
const ui = {}; const ui = {};




// Public functions // Public functions


ui.formatBytesIEC = function (bytes) {
// FooTable represents data as text even column type is "number".
if (!Number.isInteger(Number(bytes)) || bytes < 0) return "NaN";

const base = 1024;
const exponent = Math.floor(Math.log(bytes) / Math.log(base));

if (exponent > 8) return "∞";

const value = parseFloat((bytes / (base ** exponent)).toPrecision(3));
let unit = "BKMGTPEZY"[exponent];
if (exponent) unit += "iB";

return value + " " + unit;
};

ui.columns_v2 = function (table) { ui.columns_v2 = function (table) {
return [{ return [{
name: "id", name: "id",
title: "Msg size", title: "Msg size",
breakpoints: "xs sm md", breakpoints: "xs sm md",
style: {minwidth: 50}, style: {minwidth: 50},
formatter: d3.format(".3~s")
formatter: ui.formatBytesIEC
}, { }, {
name: "time_real", name: "time_real",
title: "Scan time", title: "Scan time",

Loading…
Cancel
Save