zavadil-react-common 1.1.27 → 1.1.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ import { CacheStats } from 'zavadil-ts-common';
2
+ export type CacheStatsControlProps = {
3
+ name: string;
4
+ stats: CacheStats;
5
+ };
6
+ declare function CacheStatsControl({ name, stats }: CacheStatsControlProps): import("react/jsx-runtime").JSX.Element;
7
+ export default CacheStatsControl;
@@ -0,0 +1,6 @@
1
+ import { JavaHeapStats } from "zavadil-ts-common";
2
+ export type WorkerJavaHeapControlProps = {
3
+ stats: JavaHeapStats;
4
+ };
5
+ declare function JavaHeapControl({ stats }: WorkerJavaHeapControlProps): import("react/jsx-runtime").JSX.Element;
6
+ export default JavaHeapControl;
@@ -0,0 +1,5 @@
1
+ export type QueueStateControlProps = {
2
+ state: string;
3
+ };
4
+ declare function QueueStateControl({ state }: QueueStateControlProps): import("react/jsx-runtime").JSX.Element;
5
+ export default QueueStateControl;
@@ -0,0 +1,7 @@
1
+ import { QueueStats } from 'zavadil-ts-common';
2
+ export type QueueStatsControlProps = {
3
+ name: string;
4
+ stats: QueueStats;
5
+ };
6
+ declare function QueueStatsControl({ name, stats }: QueueStatsControlProps): import("react/jsx-runtime").JSX.Element;
7
+ export default QueueStatsControl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zavadil-react-common",
3
- "version": "1.1.27",
3
+ "version": "1.1.28",
4
4
  "description": "Common types for React Typescript UI apps.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "peerDependencies": {
30
30
  "react": "^18.3.1",
31
- "zavadil-ts-common": "^1.1.24",
31
+ "zavadil-ts-common": "^1.1.26",
32
32
  "bootstrap": "^5.3.0",
33
33
  "react-bootstrap": "^2.10.5",
34
34
  "react-dom": "^18.2.0",
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import {ProgressBar} from "react-bootstrap";
3
+ import {CacheStats} from 'zavadil-ts-common';
4
+
5
+ export type CacheStatsControlProps = {
6
+ name: string;
7
+ stats: CacheStats;
8
+ }
9
+
10
+ function CacheStatsControl({name, stats}: CacheStatsControlProps) {
11
+ return (
12
+ <div className="d-flex align-items-center gap-2">
13
+ <pre>{name}</pre>
14
+ <pre>[{stats.cachedItems} / {stats.capacity}]</pre>
15
+ <div className="flex-grow-1">
16
+ <ProgressBar
17
+ now={stats.cachedItems}
18
+ min={0}
19
+ max={stats.capacity}
20
+ />
21
+ </div>
22
+ </div>
23
+ );
24
+ }
25
+
26
+ export default CacheStatsControl;
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import {Badge, ProgressBar} from "react-bootstrap";
3
+ import {ByteUtil, JavaHeapStats} from "zavadil-ts-common";
4
+
5
+ export type WorkerJavaHeapControlProps = {
6
+ stats: JavaHeapStats;
7
+ };
8
+
9
+ function JavaHeapControl({stats}: WorkerJavaHeapControlProps) {
10
+ const size = stats.heapSize;
11
+ const max = stats.heapMaxSize;
12
+ const free = stats.heapFreeSize;
13
+ const used = size - free;
14
+
15
+ return (
16
+ <div className="d-flex align-items-center gap-2">
17
+ <pre>Java Heap</pre>
18
+ <pre>[{ByteUtil.formatByteSize(size)} / {ByteUtil.formatByteSize(max)}]</pre>
19
+ <pre>Used:</pre>
20
+ <Badge className="bg-warning text-bg-warning">
21
+ {ByteUtil.formatByteSize(used)}
22
+ </Badge>
23
+ <pre>Free:</pre>
24
+ <Badge className="bg-success text-white">
25
+ {ByteUtil.formatByteSize(free)}
26
+ </Badge>
27
+ <div className="flex-grow-1">
28
+ <ProgressBar min={0} max={max}>
29
+ <ProgressBar variant="warning" min={0} now={used} max={max}/>
30
+ <ProgressBar variant="success" min={0} now={free} max={max}/>
31
+ </ProgressBar>
32
+ </div>
33
+ </div>
34
+ );
35
+ }
36
+
37
+ export default JavaHeapControl;
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import {Badge} from "react-bootstrap";
3
+
4
+ export type QueueStateControlProps = {
5
+ state: string;
6
+ }
7
+
8
+ const STATE_COLORS = new Map<string, string>([
9
+ ['Idle', 'secondary'],
10
+ ['Processing', 'success'],
11
+ ['Loading', 'warn'],
12
+ ]);
13
+
14
+ function QueueStateControl({state}: QueueStateControlProps) {
15
+ const color = STATE_COLORS.get(state) || 'primary';
16
+ return <Badge className={`bg-${color} text-white`}>{state}</Badge>
17
+ }
18
+
19
+ export default QueueStateControl;
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import {ProgressBar} from "react-bootstrap";
3
+ import {QueueStats} from 'zavadil-ts-common';
4
+ import QueueStateControl from "./QueueStateControl";
5
+
6
+ export type QueueStatsControlProps = {
7
+ name: string;
8
+ stats: QueueStats;
9
+ }
10
+
11
+ function QueueStatsControl({name, stats}: QueueStatsControlProps) {
12
+ return (
13
+ <div className="d-flex align-items-center gap-2">
14
+ <pre>{name}</pre>
15
+ <pre>[{stats.loaded} / {stats.remaining}]</pre>
16
+ <QueueStateControl state={stats.state}/>
17
+ <div className="flex-grow-1">
18
+ <ProgressBar
19
+ now={stats.loaded}
20
+ min={0}
21
+ max={stats.remaining > 0 ? stats.remaining : 1}
22
+ />
23
+ </div>
24
+ </div>
25
+ );
26
+ }
27
+
28
+ export default QueueStatsControl;