@mikezimm/fps-library-v2
Version:
Library of reusable typescript/javascript functions, interfaces and constants
165 lines (164 loc) • 8.34 kB
JavaScript
/**
* CodeAnalizerComment: Updated 6 imports on 2024-09-21 23:07:24
* Update:: import { IPerformanceOp } to '@mikezimm/fps-core-v7/lib/components/molecules/Performance/IPerformance;'
* Update:: import { ILoadPerformance } to '@mikezimm/fps-core-v7/lib/components/molecules/Performance/IPerformance;'
* Update:: import { ILoadPerformanceOps } to '@mikezimm/fps-core-v7/lib/components/molecules/Performance/IPerformance;'
* Update:: import { LoadPerformanceOps } to '@mikezimm/fps-core-v7/lib/components/molecules/Performance/IPerformance;'
* Update:: import { IMinPerformanceSetting } to '@mikezimm/fps-core-v7/lib/components/molecules/Performance/IPerformance;'
* Update:: import { check4This } to '@mikezimm/fps-core-v7/lib/logic/Links/CheckSearch;'
*/
import * as React from 'react';
// import { Icon, IIconProps } from '@fluentui/react/lib/Icon';
import { LoadPerformanceOps } from '@mikezimm/fps-core-v7/lib/components/molecules/Performance/IPerformance';
import { check4This, Check4 } from '@mikezimm/fps-core-v7/lib/logic/Links/CheckSearch';
require('@mikezimm/fps-styles/dist/performance.css'); //Does not work
// window.require('./styles.css'); //Does not work
const alwaysShowNumber = -7799;
/**
*
* @param performance
* @param keysToShow
* @param minMSToShow : set this number to 99 to only show rows when ms value > 99 ms
* @returns
*/
export function createPerformanceRows(performance, keysToShow, minMSToShow = alwaysShowNumber) {
// const { fetch, analyze } = performance;
let showRows = 0;
let hideRows = 0;
const cellStyles = { paddingLeft: '10px' };
const loadRows = [
React.createElement("tr", null,
React.createElement("th", null, "Mode"),
React.createElement("th", { style: cellStyles }, "Process"),
React.createElement("th", { style: cellStyles }, "ms"),
React.createElement("th", { style: cellStyles }, "Start Time"))
];
if (!keysToShow || keysToShow.length === 0) {
keysToShow = LoadPerformanceOps;
}
/**
* 2025-02-24: Added this test and extra loop for cases where performance IS an IPerformanceOp
* Test if it has the label and startStr, if so, assume it's an IPerformanceOp and treat as such
* https://github.com/fps-solutions/Rtf-Fixer/issues/64
*
*/
const performanceAsOp = performance;
if (performanceAsOp && performanceAsOp.startStr && performanceAsOp.label) {
loadRows.push(React.createElement("tr", null,
React.createElement("td", null, performanceAsOp.mode === 1 ? 'View' : 'Edit'),
React.createElement("td", { style: cellStyles }, performanceAsOp.label),
React.createElement("td", { style: cellStyles }, performanceAsOp.ms),
React.createElement("td", { style: cellStyles }, performanceAsOp.startStr)));
}
else {
keysToShow.map((part) => {
if (part.indexOf('setting') > -1) {
const sets = performance ? performance.sets : null;
const thisPart = sets ? sets[part] : undefined;
if (thisPart) {
showRows++;
loadRows.push(React.createElement("tr", null,
React.createElement("td", null, thisPart.label),
React.createElement("td", null, `${thisPart.value}`)));
}
}
else {
const ops = performance ? performance.ops : null;
const thisPart = ops ? ops[part] : undefined;
if (thisPart) {
let time = thisPart.startStr;
if (minMSToShow === alwaysShowNumber || (thisPart.ms && thisPart.ms > minMSToShow)) {
showRows++;
loadRows.push(React.createElement("tr", null,
React.createElement("td", null, thisPart.mode === 1 ? 'View' : 'Edit'),
React.createElement("td", { style: cellStyles }, thisPart.label),
React.createElement("td", { style: cellStyles }, thisPart.ms),
React.createElement("td", { style: cellStyles }, time)));
}
else {
hideRows++;
}
}
}
});
}
return showRows > 0 ? loadRows : [];
}
// export function createCacheRows( cacheInfo: ICacheInfo ) {
export function createCacheRows(cacheInfo) {
const loadRows = [
React.createElement("tr", null,
React.createElement("th", { style: { minWidth: '150px' } }, "Property"),
React.createElement("th", { style: { minWidth: '150px' } }, "Value"))
];
const skipProps = ['wasCached', 'enableHTMLCache', 'EditorName', 'FileRef', 'size'];
Object.keys(cacheInfo).map(part => {
if (skipProps.indexOf(part) < 0 && cacheInfo[part]) {
loadRows.push(React.createElement("tr", null,
React.createElement("td", null, part),
React.createElement("td", null, cacheInfo[part])));
}
});
return loadRows;
}
/**
* USED BY: ALVFM This is used for the visitor panel, not code pane
* @param performance
* @returns
*/
export function createPerformanceTableVisitor(performance, keysToShow) {
if (check4This(Check4.tracePerformance_Eq_true) === true)
console.log(`tracePerformance createPerformanceTableVisitor ~ 92`, JSON.parse(JSON.stringify(performance)));
if (performance) {
const loadSummary = React.createElement("div", { className: 'fps-performance', style: { paddingLeft: '15px', paddingTop: '30px' } },
React.createElement("div", { className: 'fps-header-styles' }, "Load Performance: Vis"),
React.createElement("table", null, createPerformanceRows(performance, keysToShow)));
return (loadSummary);
}
else {
return (React.createElement("div", null));
}
}
/**
* USED BY: SecureScript7 loadTable >> loadSummary in \secureScript7\components\SecureScriptVisitorPanel.tsx
* @param performance
* @returns
*/
export function createPerformanceTableVisitorXtra(performance, titleAboveTable = '', keysToShow, objAboveTable = null) {
if (check4This(Check4.tracePerformance_Eq_true) === true)
console.log(`tracePerformance createPerformanceTableVisitorXtra ~ 120`, JSON.parse(JSON.stringify(performance)));
const loadSummary = React.createElement("div", { className: 'fps-performance', style: { paddingLeft: '15px', paddingTop: '30px' } },
React.createElement("div", { className: 'fps-header-styles' }, "Load Performance: Xtra"),
!titleAboveTable ? null : React.createElement("div", { style: { paddingBottom: '8px' } },
titleAboveTable,
" ",
JSON.stringify(objAboveTable)),
React.createElement("table", null, createPerformanceRows(performance, keysToShow)));
return (loadSummary);
}
/**
* USED BY: SecureScript7 loadTable >> loadSummary in \secureScript7\components\SecureScript7.tsx
* @param performance
* @param cacheOnClick
* @returns
*/
export function createPerformanceTableSmall(performance, keysToShow, cacheOnClick) {
const loadSummary = React.createElement("div", { className: 'fps-performance', style: { paddingLeft: '15px' } },
React.createElement("div", { className: 'fps-tableheading' }, "Performance Details"),
React.createElement("table", null, createPerformanceRows(performance, keysToShow)));
return (loadSummary);
}
/**
* USED BY: SecureScript7 code pane and includes cache info
* @param cache
* @param cacheOnClick
* @returns
*/
// export function createCacheTableSmall( cache: ICacheInfo, cacheOnClick: any ) {
export function createCacheTableSmall(cache, cacheOnClick) {
const loadSummary = React.createElement("div", { className: 'fps-performance', style: { paddingLeft: '15px' } },
React.createElement("div", { className: 'fps-tableheading' }, "Cache Details"),
React.createElement("table", null, createCacheRows(cache)));
return (loadSummary);
}
//# sourceMappingURL=tables.js.map