diff --git a/package.json b/package.json index 38a15a1..9dfa669 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "qxip-flow-panel", - "version": "10.0.8", + "version": "10.0.9", "description": "Test plugin to lern dev enveroument", "scripts": { "build": "webpack -c ./.config/webpack/webpack.config.ts --env production", diff --git a/src/components/SimplePanel.tsx b/src/components/SimplePanel.tsx index c48bb7d..9266214 100644 --- a/src/components/SimplePanel.tsx +++ b/src/components/SimplePanel.tsx @@ -146,17 +146,17 @@ document.addEventListener('ngx-flow-click-item', function (e: any) { }); function formattingDataAndSortIt(data: any, sortType = 'none') { - const [firstField] = data; - const unSortData = firstField.values.map((i: any, k: number) => { + const [firstField] = data || []; + const unSortData = firstField?.values?.map((i: any, k: number) => { const outData: any = {}; data.forEach((item: any) => { - outData[item.name] = item.values[k]; + outData[item.name] = item?.values?.[k]; }); if (outData?.Time && typeof outData?.labels === 'object') { outData['labels'].timestamp = outData.Time; } return outData; - }) + }) || []; if (sortType === 'none') { return unSortData; } @@ -197,18 +197,17 @@ export const SimplePanel: React.FC = ({ options, data, width, height }: a setModalDataFields(sortData); const outData = firsField?.values; - valueLabelsName = Object.keys(outData[0]); - if (outData) { + valueLabelsName = Object.keys(outData?.[0] || {}); setFlowData({ actors: [], data: sortData.map((item: any) => { const message: string = item.Line || ''; - const labelItem: any = item.labels; + const labelItem: any = item.labels || {}; const _ = (optionArr: string[] | string) => { if (optionArr instanceof Array) { return optionArr.map((option: string) => labelItem[option]).filter((a: any) => !!a).join(':'); } - return labelItem[optionArr]; + return labelItem[optionArr] || ''; }; return { messageID: _(options.colorGenerator) || 'Title',