@inspectr/ui 0.0.2 → 0.0.4

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.
@@ -1,89 +0,0 @@
1
- // src/components/ResponseContent.jsx
2
- import React, { useState } from 'react';
3
- import Editor from '@monaco-editor/react';
4
-
5
- const ResponseContent = ({ request }) => {
6
- const [showResponseHeaders, setShowResponseHeaders] = useState(false);
7
-
8
- const renderTableRows = (data) =>
9
- Object.entries(data || {}).map(([key, value]) => (
10
- <tr key={key}>
11
- <td className="border border-slate-200 px-2 py-1 font-mono text-slate-500 text-xs">
12
- {key}
13
- </td>
14
- <td className="border border-slate-200 px-2 py-1 font-mono text-xs">{value}</td>
15
- </tr>
16
- ));
17
-
18
- // Check if the response body has content.
19
- const payload = request.response.payload;
20
- const isEmptyPayload =
21
- !payload ||
22
- (typeof payload === 'object' && Object.keys(payload).length === 0) ||
23
- (typeof payload === 'string' &&
24
- (payload.trim() === '' || payload.trim() === '{}'));
25
-
26
- const formatPayload = (payload) => {
27
- try {
28
- const parsed = JSON.parse(payload);
29
- return JSON.stringify(parsed, null, 2);
30
- } catch (e) {
31
- return payload;
32
- }
33
- }
34
-
35
- return (
36
- <div>
37
- {/* Response Headers Section */}
38
- <div className="mb-4">
39
- <button
40
- className="w-full p-2 text-left font-bold bg-gray-200"
41
- onClick={() => setShowResponseHeaders(!showResponseHeaders)}
42
- >
43
- Headers ({Object.keys(request.response.headers || {}).length})
44
- </button>
45
- {showResponseHeaders && (
46
- <div className="p-0">
47
- <table className="w-full border-collapse border border-gray-300">
48
- <thead>
49
- <tr className="bg-gray-100">
50
- <th className="border border-slate-200 px-2 py-1 w-1/4 text-left">Header</th>
51
- <th className="border border-slate-200 px-2 py-1 text-left">Value</th>
52
- </tr>
53
- </thead>
54
- <tbody>{renderTableRows(request.response.headers)}</tbody>
55
- </table>
56
- </div>
57
- )}
58
- </div>
59
-
60
- {/* Response Body Section */}
61
- <div>
62
- <button className="w-full p-2 text-left font-bold bg-gray-200">
63
- Response Body
64
- </button>
65
- {isEmptyPayload ? (
66
- <div className="hidden"></div>
67
- ) : (
68
- <div className="bg-white rounded-b shadow p-0 h-100">
69
- <Editor
70
- height="100%"
71
- defaultLanguage="json"
72
- value={formatPayload(payload)}
73
- options={{
74
- readOnly: true,
75
- minimap: { enabled: false },
76
- automaticLayout: true,
77
- fontFamily: '"Cascadia Code", "Jetbrains Mono", "Fira Code", "Menlo", "Consolas", monospace',
78
- tabSize: 2,
79
- scrollBeyondLastLine: false
80
- }}
81
- />
82
- </div>
83
- )}
84
- </div>
85
- </div>
86
- );
87
- };
88
-
89
- export default ResponseContent;
@@ -1,22 +0,0 @@
1
- import React from 'react';
2
- import useSSE from '../hooks/useSSE';
3
-
4
- const SSETest = () => {
5
- const { data, error } = useSSE('http://localhost:4321/api/events');
6
-
7
- console.log("test", "test")
8
-
9
- return (
10
- <div>
11
- <h1>SSE Test Component</h1>
12
- {error && <p style={{color: 'red'}}>Error: {error}</p>}
13
- {data ? (
14
- <pre>{JSON.stringify(data, null, 2)}</pre>
15
- ) : (
16
- <p>No data received yet</p>
17
- )}
18
- </div>
19
- );
20
- };
21
-
22
- export default SSETest;
@@ -1,107 +0,0 @@
1
- // src/components/SettingsPanel.jsx
2
- import React, { useState, useEffect } from "react";
3
- import logo from "../assets/inspectr_logo_small.png";
4
-
5
- const SettingsPanel = ({ sseEndpoint, setSseEndpoint, isConnected }) => {
6
- const [isOpen, setIsOpen] = useState(false);
7
- const [inputValue, setInputValue] = useState(sseEndpoint);
8
-
9
- // Load stored value on mount
10
- useEffect(() => {
11
- if (typeof window !== "undefined") {
12
- const storedEndpoint = localStorage.getItem("sseEndpoint");
13
- if (!sseEndpoint && storedEndpoint) {
14
- setInputValue(storedEndpoint);
15
- setSseEndpoint(storedEndpoint);
16
- }
17
- }
18
- }, [sseEndpoint, setSseEndpoint]);
19
-
20
- const handleSave = () => {
21
- if (typeof window !== "undefined") {
22
- localStorage.setItem("sseEndpoint", inputValue);
23
- }
24
- setSseEndpoint(inputValue);
25
- setIsOpen(false);
26
- };
27
-
28
- return (
29
- <div className="fixed bottom-0 left-0 w-full">
30
- {/* Bottom Panel */}
31
- <div
32
- className="flex items-center justify-between bg-gray-200 px-4 py-2 w-full cursor-pointer select-none"
33
- onClick={() => setIsOpen((prev) => !prev)} // Toggle on click
34
- >
35
- {/* Connection Status Indicator */}
36
- <div className="flex items-center gap-4">
37
- <span
38
- className={`px-2 py-1 rounded-full text-xs font-semibold flex items-center ${
39
- isConnected ? "bg-green-500" : "bg-red-500"
40
- }`}
41
- >
42
- <span
43
- className={`w-2 h-2 rounded-full mr-1 ${
44
- isConnected ? "bg-green-800" : "bg-red-800"
45
- }`}
46
- ></span>
47
- {isConnected ? "Connected" : "Disconnected"}
48
- </span>
49
- </div>
50
-
51
- {/* Inspectr Logo & Name */}
52
- <a
53
- href="https://github.com/thim81/inspectr"
54
- target="_blank"
55
- rel="noopener noreferrer"
56
- className="flex items-center gap-2"
57
- >
58
- <img src={logo} alt="Inspectr Logo" className="h-6" />
59
- <span className="text-gray-700 font-semibold text-sm">Inspectr</span>
60
- </a>
61
- </div>
62
-
63
- {/* Configuration Panel */}
64
- <div
65
- className={`bg-gray-100 border-t border-gray-300 transition-all duration-300 overflow-hidden ${
66
- isOpen ? "max-h-40 opacity-100 py-4" : "max-h-0 opacity-0 py-0"
67
- }`}
68
- >
69
- <div className="px-6">
70
- {/* Title */}
71
-
72
- {/* Two-column Layout */}
73
- <div className="grid grid-cols-2 gap-4 items-center">
74
- {/* Left Column (Empty for now) */}
75
- <div><h2 className="text-lg font-semibold text-gray-800 mb-4">Configuration</h2></div>
76
-
77
- {/* Right Column (Label + Input in the same row) */}
78
- <div className="flex items-center gap-2">
79
- <label className="text-gray-700 font-semibold whitespace-nowrap">
80
- SSE Endpoint:
81
- </label>
82
- <input
83
- type="text"
84
- value={inputValue}
85
- onChange={(e) => setInputValue(e.target.value)}
86
- className="border p-2 rounded flex-1 bg-white"
87
- placeholder="Enter SSE Endpoint..."
88
- />
89
- </div>
90
- </div>
91
-
92
- {/* Apply Button */}
93
- <div className="flex justify-end mt-4">
94
- <button
95
- onClick={handleSave}
96
- className="bg-green-600 text-white px-4 py-2 rounded-md"
97
- >
98
- Apply
99
- </button>
100
- </div>
101
- </div>
102
- </div>
103
- </div>
104
- );
105
- };
106
-
107
- export default SettingsPanel;
@@ -1,10 +0,0 @@
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 DELETED
@@ -1,2 +0,0 @@
1
- export * from './components/index.js';
2
- export * from './utils/getStatusClass.js';
@@ -1,5 +0,0 @@
1
- @import "tailwindcss";
2
-
3
- @theme {
4
- --font-sans: InterVariable, sans-serif;
5
- }
@@ -1,9 +0,0 @@
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
- }