From 0268efbf3fdc0274ac68bff66d771e63e2f180ce Mon Sep 17 00:00:00 2001 From: Lorenzo Mangani Date: Wed, 20 Mar 2024 11:07:32 +0100 Subject: [PATCH 1/9] Use go 1.23 --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9ff69d2..87f4f8b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,7 +21,7 @@ jobs: - name: Setup Go environment uses: actions/setup-go@v3 with: - go-version: '1.19' + go-version: '1.23' - name: Install dependencies run: | From cdadfee1f7de600de441e5de9edb1bc52aaa3837 Mon Sep 17 00:00:00 2001 From: Lorenzo Mangani Date: Wed, 20 Mar 2024 11:56:21 +0100 Subject: [PATCH 2/9] Update release.yml --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 87f4f8b..dee0b26 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,7 +21,7 @@ jobs: - name: Setup Go environment uses: actions/setup-go@v3 with: - go-version: '1.23' + go-version: '1.22' - name: Install dependencies run: | From 0fd9831337019f0904d1459bfafa520f40be60f2 Mon Sep 17 00:00:00 2001 From: Lorenzo Mangani Date: Wed, 20 Mar 2024 13:10:01 +0100 Subject: [PATCH 3/9] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7e946ec..461431f 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,8 @@ Grafana 10+ Flow Diagram Visualization plugin ### Installation Allow and Install the unsigned plugin, ie: ``` - - GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=qxip-flow-panel - - GF_INSTALL_PLUGINS=https://github.com/metrico/grafana-flow/releases/download/v10.0.8/qxip-flow-panel-10.0.8.zip;qxip-flow-panel" +- GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=qxip-flow-panel +- GF_INSTALL_PLUGINS=https://github.com/metrico/grafana-flow/releases/download/v10.0.10/qxip-flow-panel-10.0.10.zip;qxip-flow-panel" ``` ### Panel Options From 57e85d51229eabdef9a13b180ca646b5bae47cd5 Mon Sep 17 00:00:00 2001 From: Lorenzo Mangani Date: Wed, 20 Mar 2024 14:20:48 +0100 Subject: [PATCH 4/9] Update package.json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3663379..149929c 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "10.0.11", "description": "Test plugin to lern dev enveroument", "scripts": { - "build": "cd ./ngx-flow && npm run build:component && cd .. && webpack -c ./.config/webpack/webpack.config.ts --env production", + "build": "webpack -c ./.config/webpack/webpack.config.ts --env production", "dev": "webpack -w -c ./.config/webpack/webpack.config.ts --env development", "test": "jest --watch --onlyChanged", "test:ci": "jest --passWithNoTests --maxWorkers 4", @@ -72,4 +72,4 @@ "web-component-load": "^1.0.1" }, "packageManager": "npm@8.19.3" -} \ No newline at end of file +} From 2816484ac79caec554449f0400a98502a14d0db7 Mon Sep 17 00:00:00 2001 From: Alexey Oplachko Date: Wed, 20 Mar 2024 16:51:24 +0200 Subject: [PATCH 5/9] chore: updated workflow to include installation of dependencies for angular plugin --- .github/workflows/ci.yml | 5 +++++ .github/workflows/release.yml | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 97bcbf1..de6eaa8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,10 +20,15 @@ jobs: with: node-version: 16 # cache: 'npm' + - name: Install dependencies run: | npm install # npm ci + - name: Install Angular dependencies + run: | + cd ngx-flow + npm install - name: Check types run: npm run typecheck - name: Lint diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dee0b26..8fb76b4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,7 +27,11 @@ jobs: run: | npm install # npm ci - + - name: Install Angular dependencies + run: | + cd ngx-flow + npm install + # npm ci - name: Build and test frontend run: npm run build From 3903d2f3f600e7dd5e4e6addb6d7f1c936b577d0 Mon Sep 17 00:00:00 2001 From: Alexey Oplachko Date: Wed, 20 Mar 2024 16:54:00 +0200 Subject: [PATCH 6/9] chore: updated npm run build script to include build of angular plugin --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 149929c..1c70170 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "10.0.11", "description": "Test plugin to lern dev enveroument", "scripts": { - "build": "webpack -c ./.config/webpack/webpack.config.ts --env production", + "build": "cd ./ngx-flow && npm run build:component && cd .. && webpack -c ./.config/webpack/webpack.config.ts --env production", "dev": "webpack -w -c ./.config/webpack/webpack.config.ts --env development", "test": "jest --watch --onlyChanged", "test:ci": "jest --passWithNoTests --maxWorkers 4", From 8ee1f0ff8ca13fe72521e1e9add60c4971e06e45 Mon Sep 17 00:00:00 2001 From: Alexey Oplachko Date: Wed, 20 Mar 2024 17:24:51 +0200 Subject: [PATCH 7/9] chore: added Build angular frontend step --- .github/workflows/ci.yml | 4 +++- .github/workflows/release.yml | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index de6eaa8..10c1765 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,9 @@ jobs: run: npm run lint - name: Unit tests run: npm run test:ci - - name: Build frontend + - name: Build Angular frontend + run: npm run build:component + - name: Build and test frontend run: npm run build - name: Check for backend diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8fb76b4..6d5d0cc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,6 +32,8 @@ jobs: cd ngx-flow npm install # npm ci + - name: Build Angular frontend + run: npm run build:component - name: Build and test frontend run: npm run build From d2c096a2f1d42b28004069ad9a8ab8e8e858b2ed Mon Sep 17 00:00:00 2001 From: Alexey Oplachko Date: Wed, 20 Mar 2024 17:25:50 +0200 Subject: [PATCH 8/9] chore: separated "build" script into "build:component" for Angular and "build" to combine it with React --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1c70170..0114624 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,8 @@ "version": "10.0.11", "description": "Test plugin to lern dev enveroument", "scripts": { - "build": "cd ./ngx-flow && npm run build:component && cd .. && webpack -c ./.config/webpack/webpack.config.ts --env production", + "build:component": "cd ./ngx-flow && npm run build:component", + "build": "webpack -c ./.config/webpack/webpack.config.ts --env production", "dev": "webpack -w -c ./.config/webpack/webpack.config.ts --env development", "test": "jest --watch --onlyChanged", "test:ci": "jest --passWithNoTests --maxWorkers 4", @@ -72,4 +73,4 @@ "web-component-load": "^1.0.1" }, "packageManager": "npm@8.19.3" -} +} \ No newline at end of file From acd8fd560b3515a2dd5bdb22e4856fb41d50b8d1 Mon Sep 17 00:00:00 2001 From: Alexey Oplachko Date: Thu, 21 Mar 2024 17:02:21 +0200 Subject: [PATCH 9/9] fix: #59 added hash as a key to ensure that flow opens correct modal 100% of the time. --- .../ngx-flow/src/lib/ngx-flow.component.ts | 1 + .../src/tab-flow/tab-flow.component.html | 6 +++--- src/components/SimplePanel.tsx | 15 +++++++++------ src/helpers/hash.ts | 19 +++++++++++++++++++ 4 files changed, 32 insertions(+), 9 deletions(-) create mode 100644 src/helpers/hash.ts diff --git a/ngx-flow/projects/ngx-flow/src/lib/ngx-flow.component.ts b/ngx-flow/projects/ngx-flow/src/lib/ngx-flow.component.ts index f316a0c..c42e7d1 100644 --- a/ngx-flow/projects/ngx-flow/src/lib/ngx-flow.component.ts +++ b/ngx-flow/projects/ngx-flow/src/lib/ngx-flow.component.ts @@ -110,6 +110,7 @@ export class NgxFlowComponent implements OnInit { srcAlias: SRC, typeItem: "SIP", + hash: i.hash } } diff --git a/ngx-flow/projects/ngx-flow/src/tab-flow/tab-flow.component.html b/ngx-flow/projects/ngx-flow/src/tab-flow/tab-flow.component.html index 33ec959..0618532 100644 --- a/ngx-flow/projects/ngx-flow/src/tab-flow/tab-flow.component.html +++ b/ngx-flow/projects/ngx-flow/src/tab-flow/tab-flow.component.html @@ -80,7 +80,7 @@

No Data

[isGroupByAlias]="_isCombineByAlias" [isSimplify]="isSimplify" [isAbsolute]="isAbsolute" - (itemClick)="onClickMessage($event.idx, $event.event, item)" + (itemClick)="onClickMessage(item.hash, $event.event, item)" >
@@ -114,8 +114,8 @@

No Data

[isGroupByAlias]="_isCombineByAlias" [isSimplify]="isSimplify" [isAbsolute]="isAbsolute" - (itemClick)="onClickMessage($event.idx, $event.event, item)" - > + (itemClick)="onClickMessage(item.hash, $event.event, item)" + > diff --git a/src/components/SimplePanel.tsx b/src/components/SimplePanel.tsx index 43caf18..c86bb08 100644 --- a/src/components/SimplePanel.tsx +++ b/src/components/SimplePanel.tsx @@ -24,6 +24,7 @@ import { Dropdown, Menu } from '@grafana/ui'; +import { hash } from 'helpers/hash'; @@ -222,7 +223,7 @@ export const SimplePanel: React.FC = ({ options, data, width, height }: a const [flowData, setFlowData] = React.useState({ actors: [], data: [] }); const [modalIsOpen, setModalIsOpen] = React.useState(false); const [modalData, setModalData] = React.useState({}); - const [modalDataFields, setModalDataFields] = React.useState([]); + const [modalDataFields, setModalDataFields] = React.useState>(); const onModalClose = () => { setModalIsOpen(false); @@ -351,9 +352,8 @@ export const SimplePanel: React.FC = ({ options, data, width, height }: a if (fields) { const [firsField]: any = fields; const sortData = formattingDataAndSortIt(fields, options.sortoption); - setModalDataFields(sortData); const outData = firsField?.values; - + const map = new Map(); if (outData) { valueLabelsName = Object.keys(outData?.[0] || {}); setFlowData({ @@ -366,6 +366,8 @@ export const SimplePanel: React.FC = ({ options, data, width, height }: a } return labelItem[optionArr] || ''; }; + const itemHash = hash(JSON.stringify(item)) + map.set(itemHash, item); return { messageID: _(options.colorGenerator) || 'Title', subTitle: options.showbody && message, @@ -375,18 +377,19 @@ export const SimplePanel: React.FC = ({ options, data, width, height }: a aboveArrow: _(options.aboveArrow) || '', belowArrow: _(options.belowArrow) || '', sourceLabel: _(options.sourceLabel) || '', - destinationLabel: _(options.destinationLabel) || '' + destinationLabel: _(options.destinationLabel) || '', + hash: itemHash } }) }) - + setModalDataFields(map); } } /* eslint-disable-next-line */ }, [data, options]); ngxFlowClickHandler = (e: any) => { - const details: any = modalDataFields[e.detail]; + const details: any = modalDataFields?.get(e.detail) if (typeof details.labels === 'object') { details.labels = JSON.stringify(details.labels); } diff --git a/src/helpers/hash.ts b/src/helpers/hash.ts new file mode 100644 index 0000000..647f7df --- /dev/null +++ b/src/helpers/hash.ts @@ -0,0 +1,19 @@ +export function hash(str: string, lenHash = 32) { + lenHash = lenHash || 32; + str = str || ""; + let ar = str.split('').map((a) => a.charCodeAt(0)), + s2alength = ar.length || 1, + i = ar.length ? ar.reduce((p, c) => p + c) : 1, + s = "", + A, + B, + k = 0, + tan = Math.tan; + while (s.length < lenHash) { + A = ar[k++ % s2alength] || 0.5; + B = ar[k++ % s2alength ^ lenHash] || 1.5 ^ lenHash; + i = i + (A ^ B) % lenHash; + s += tan(i * B / A).toString(16).split('.')[1].slice(0, 10); + } + return s.slice(0, lenHash); +}