Skip to content

Commit

Permalink
implemented JSON viewer only with files (#556)
Browse files Browse the repository at this point in the history
* [Th2-4830] Hide next/prev buttons in verificationTable and add button to reset width of columns (#547)

* hide next/prev btns and add resetWidth btn

* bump version

* deleted comments

* changed button to same style as others

* changed buttons styling

* updated readme (#552)

* implemented JSON viewer only with files

* added ability to request files from shared folder

* added styling to load file from server

* moved from axios to fetch

* Moved api requests to ApiSchema

* changed return on error

* bump version

* [TH2-5125] Add opening workspace with event from query parameters (#557)

* TH2-4996: UI: Cannot show event if its scope contains # symbol (#558)

* TH2-4996: UI: Cannot show event if its scope contains # symbol

* bump version

* TH2-4993: UI doesn't provide the list of available books (#559)

* [TH2-4979] UI doesn't update scopes list when I update time range (#560)

* [TH2-4978] UI skips a message that should be highlighted in the messa… (#561)

[TH2-4978] UI skips a message that should be highlighted in the message box when the event is clicked

* [TH2-5155] Add ability to turn back to the attached message (#562)

* bump version (#563)

* [TH2-5158] Outline searched messages (#564)

* [TH2-5164] Raw message in ASCII display mode has incorrect character if the content is in UTF8 (#566)

* [TH2-4909] Add sorting for list of event-scopes in UI (#565)

* added local file upload and basic functions for server load

* bump version to 5.2

---------

Co-authored-by: Osinkin Roman <[email protected]>
Co-authored-by: Petr Zlydenko <[email protected]>
  • Loading branch information
3 people authored Feb 19, 2024
1 parent bd81a31 commit 2f0c4c9
Show file tree
Hide file tree
Showing 40 changed files with 1,356 additions and 94 deletions.
36 changes: 17 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Report-viewer

![](https://img.shields.io/github/package-json/v/th2-net/th2-rpt-viewer)
![](https://img.shields.io/github/workflow/status/th2-net/th2-rpt-viewer/build%20&%20publish%20release%20image%20to%20ghcr.io)

![](https://img.shields.io/github/package-json/v/th2-net/th2-rpt-viewer/version-5.1)
![](https://img.shields.io/github/actions/workflow/status/th2-net/th2-rpt-viewer/build-release.yml?branch=version-5.1)
This is a web app that displays the stored test data (events and messages) using `report-data-provider`.

# API
Expand All @@ -14,29 +13,28 @@ This app needs `report-data-provider 5.1.0 (or newer)` backend component to func
To include this component in your schema, a following yml file needs to be created

```
apiVersion: th2.exactpro.com/v1
apiVersion: th2.exactpro.com/v2
kind: Th2CoreBox
metadata:
name: report-data-viewer
name: rpt-data-viewer
spec:
image-name: ghcr.io/th2-net/th2-rpt-viewer
image-version: 3.0.0 // change this line if you want to use a newer version
imageName: ghcr.io/th2-net/th2-rpt-viewer
imageVersion: 5.1.19 // change this line if you want to use a newer version
type: th2-rpt-viewer
extended-settings:
chart-cfg:
ref: schema-stable
path: custom-component
service:
enabled: false
targetPort: 80
nodePort: '31276'
extendedSettings:
resources:
limits:
memory: 15Mi
cpu: 200m
cpu: 50m
memory: 50Mi
requests:
memory: 10Mi
cpu: 20m
cpu: 50m
memory: 50Mi
service:
enabled: true
clusterIP:
- name: gui
containerPort: 8080
port: 8080
```

Expand Down
32 changes: 20 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "th2-rpt-viewer",
"version": "5.2.5",
"version": "5.2.6",
"description": "",
"main": "index.tsx",
"private": true,
Expand Down
Binary file modified screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions src/api/ApiSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ import { IndexedDB } from './indexedDb';
import { MatchMessageParams } from './message';
import { DirectionalStreamInfo } from '../models/StreamInfo';
import { Book } from '../models/Books';
import { Tree } from '../models/JSONSchema';

export default interface ApiSchema {
events: EventApiSchema;
messages: MessageApiSchema;
books: BooksApiSchema;
sse: SSESchema;
jsonViewer: JSONViewerApiSchema;
indexedDb: IndexedDB;
}

Expand Down Expand Up @@ -106,6 +108,11 @@ export interface BooksApiSchema {
getBookScope: (bookId: string, abortSignal?: AbortSignal) => Promise<string[]>;
}

export interface JSONViewerApiSchema {
getLinks: (dir?: string) => Promise<string[]>;
getFile: (directory: string, file: string) => Promise<Tree>;
}

export interface SSESchema {
getEventSource: (config: EventSourceConfig) => EventSource;
getEventsTreeSource: (
Expand Down
47 changes: 47 additions & 0 deletions src/api/JSONViewer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import notificationsStore from '../stores/NotificationsStore';
import { JSONViewerApiSchema } from './ApiSchema';

const directoriesURL = '/resources/';

const JSONViewerHttpApi: JSONViewerApiSchema = {
getLinks: async (dir?: string) => {
const res = await fetch(`${directoriesURL}${dir || ''}`, {
cache: 'reload',
headers: {
Accept: 'application/json, text/plain, */*',
},
});
if (res.ok) {
const text = await res.text();
const links: string[] = [];
let tempText = text.slice();
const linkStartInf = `a href="`;
let linkStart = tempText.indexOf(linkStartInf);
while (linkStart > -1) {
tempText = tempText.slice(linkStart + linkStartInf.length);
const linkEnd = tempText.indexOf(`"`);
const link = tempText.slice(0, linkEnd);
links.push(link);
linkStart = tempText.indexOf(linkStartInf);
}
return links;
}
notificationsStore.handleRequestError(res);
return [];
},
getFile: async (directory: string, file: string) => {
const res = await fetch(`${directoriesURL}/${directory}/${file}`, {
headers: {
Accept: 'application/json, text/plain, */*',
},
});

if (res.ok) {
return res.json();
}
notificationsStore.handleRequestError(res);
return {};
},
};

export default JSONViewerHttpApi;
2 changes: 1 addition & 1 deletion src/api/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import fetch from '../helpers/fetchRetry';
const eventHttpApi: EventApiSchema = {
getEvent: async (id, signal?, queryParams = {}) => {
const params = createURLSearchParams(queryParams);
const res = await fetch(`backend/event/${id}?${params}`, {
const res = await fetch(`backend/event/${encodeURIComponent(id)}?${params}`, {
signal,
});

Expand Down
2 changes: 2 additions & 0 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import eventHttpApi from './event';
import messageHttpApi from './message';
import sseApi from './sse';
import booksHttpApi from './books';
import JSONViewerHttpApi from './JSONViewer';

const envName =
process.env.NODE_ENV === 'development'
Expand All @@ -31,6 +32,7 @@ const api: ApiSchema = {
messages: messageHttpApi,
books: booksHttpApi,
sse: sseApi,
jsonViewer: JSONViewerHttpApi,
indexedDb: new IndexedDB(envName),
};

Expand Down
Loading

0 comments on commit 2f0c4c9

Please sign in to comment.