@inspectr/ui 0.0.1
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.
- package/LICENSE +674 -0
- package/index.d.ts +8 -0
- package/package.json +56 -0
- package/src/components/InspectrApp.jsx +113 -0
- package/src/components/RequestContent.jsx +113 -0
- package/src/components/RequestDetail.jsx +51 -0
- package/src/components/RequestDetailsPanel.jsx +52 -0
- package/src/components/RequestList.jsx +48 -0
- package/src/components/RequestListItem.jsx +52 -0
- package/src/components/ResponseContent.jsx +89 -0
- package/src/components/SSETest.jsx +22 -0
- package/src/components/SettingsPanel.jsx +93 -0
- package/src/components/index.js +10 -0
- package/src/index.js +2 -0
- package/src/styles/global.css +5 -0
- package/src/utils/getStatusClass.js +9 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// src/components/SettingsPanel.jsx
|
|
2
|
+
import React, { useState, useEffect } from "react";
|
|
3
|
+
|
|
4
|
+
const SettingsPanel = ({ sseEndpoint, setSseEndpoint, isConnected }) => {
|
|
5
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
6
|
+
const [inputValue, setInputValue] = useState(sseEndpoint);
|
|
7
|
+
|
|
8
|
+
// Load stored value on mount
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (typeof window !== "undefined") {
|
|
11
|
+
const storedEndpoint = localStorage.getItem("sseEndpoint");
|
|
12
|
+
if (!sseEndpoint && storedEndpoint) {
|
|
13
|
+
setInputValue(storedEndpoint);
|
|
14
|
+
setSseEndpoint(storedEndpoint);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}, [sseEndpoint, setSseEndpoint]);
|
|
18
|
+
|
|
19
|
+
const handleSave = () => {
|
|
20
|
+
if (typeof window !== "undefined") {
|
|
21
|
+
localStorage.setItem("sseEndpoint", inputValue);
|
|
22
|
+
}
|
|
23
|
+
setSseEndpoint(inputValue);
|
|
24
|
+
setIsOpen(false);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<div className="fixed bottom-0 left-0 w-full">
|
|
29
|
+
{/* Bottom Panel */}
|
|
30
|
+
<div
|
|
31
|
+
className="flex items-center justify-between bg-gray-200 px-4 py-2 w-full cursor-pointer select-none"
|
|
32
|
+
onClick={() => setIsOpen((prev) => !prev)} // Toggle on click
|
|
33
|
+
>
|
|
34
|
+
{/* Connection Status Indicator */}
|
|
35
|
+
<span
|
|
36
|
+
className={`px-2 py-1 rounded-full text-xs font-semibold ${
|
|
37
|
+
isConnected ? "bg-green-500" : "bg-red-500"
|
|
38
|
+
} flex items-center`}
|
|
39
|
+
>
|
|
40
|
+
<span
|
|
41
|
+
className={`w-2 h-2 rounded-full mr-1 ${
|
|
42
|
+
isConnected ? "bg-green-800" : "bg-red-800"
|
|
43
|
+
}`}
|
|
44
|
+
></span>
|
|
45
|
+
{isConnected ? "Connected" : "Disconnected"}
|
|
46
|
+
</span>
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
{/* Configuration Panel */}
|
|
50
|
+
<div
|
|
51
|
+
className={`bg-gray-100 border-t border-gray-300 transition-all duration-300 overflow-hidden ${
|
|
52
|
+
isOpen ? "max-h-40 opacity-100 py-4" : "max-h-0 opacity-0 py-0"
|
|
53
|
+
}`}
|
|
54
|
+
>
|
|
55
|
+
<div className="px-6">
|
|
56
|
+
{/* Title */}
|
|
57
|
+
|
|
58
|
+
{/* Two-column Layout */}
|
|
59
|
+
<div className="grid grid-cols-2 gap-4 items-center">
|
|
60
|
+
{/* Left Column (Empty for now) */}
|
|
61
|
+
<div><h2 className="text-lg font-semibold text-gray-800 mb-4">Configuration</h2></div>
|
|
62
|
+
|
|
63
|
+
{/* Right Column (Label + Input in the same row) */}
|
|
64
|
+
<div className="flex items-center gap-2">
|
|
65
|
+
<label className="text-gray-700 font-semibold whitespace-nowrap">
|
|
66
|
+
SSE Endpoint:
|
|
67
|
+
</label>
|
|
68
|
+
<input
|
|
69
|
+
type="text"
|
|
70
|
+
value={inputValue}
|
|
71
|
+
onChange={(e) => setInputValue(e.target.value)}
|
|
72
|
+
className="border p-2 rounded flex-1 bg-white"
|
|
73
|
+
placeholder="Enter SSE Endpoint..."
|
|
74
|
+
/>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
{/* Apply Button */}
|
|
79
|
+
<div className="flex justify-end mt-4">
|
|
80
|
+
<button
|
|
81
|
+
onClick={handleSave}
|
|
82
|
+
className="bg-green-600 text-white px-4 py-2 rounded-md"
|
|
83
|
+
>
|
|
84
|
+
Apply
|
|
85
|
+
</button>
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export default SettingsPanel;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// src/components/index.js
|
|
2
|
+
|
|
3
|
+
export { default as InspectrApp } from './InspectrApp.jsx';
|
|
4
|
+
export { default as RequestContent } from './RequestContent.jsx';
|
|
5
|
+
export { default as RequestDetail } from './RequestDetail.jsx';
|
|
6
|
+
export { default as RequestDetailsPanel } from './RequestDetailsPanel.jsx';
|
|
7
|
+
export { default as RequestList } from './RequestList.jsx';
|
|
8
|
+
export { default as RequestListItem } from './RequestListItem.jsx';
|
|
9
|
+
export { default as ResponseContent } from './ResponseContent.jsx';
|
|
10
|
+
export { default as SettingsPanel } from './SettingsPanel.jsx';
|
package/src/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// src/utils/getStatusClass.js
|
|
2
|
+
|
|
3
|
+
export const getStatusClass = (status) => {
|
|
4
|
+
if (status >= 200 && status < 300) return 'bg-green-200 text-green-800';
|
|
5
|
+
if (status >= 300 && status < 400) return 'bg-blue-200 text-blue-800';
|
|
6
|
+
if (status >= 400 && status < 500) return 'bg-orange-600 text-orange-200';
|
|
7
|
+
if (status >= 500) return 'bg-red-800 text-red-100';
|
|
8
|
+
return 'bg-gray-200 text-gray-800';
|
|
9
|
+
}
|