@nice2dev/ui-iot 1.0.10
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/README.md +139 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +453 -0
- package/dist/index.mjs +1727 -0
- package/dist/style.css +1 -0
- package/package.json +67 -0
package/README.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# @nice2dev/ui-iot
|
|
2
|
+
|
|
3
|
+
Nice2Dev IoT Components β Device dashboards, edge management, and protocol configuration for React applications.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **NiceIoTDashboard** - IoT device dashboard
|
|
8
|
+
- Device monitoring and status
|
|
9
|
+
- Real-time telemetry visualization
|
|
10
|
+
- Alarm management
|
|
11
|
+
- Customizable widgets
|
|
12
|
+
|
|
13
|
+
- **NiceEdgeManager** - Edge node management
|
|
14
|
+
- Node inventory and monitoring
|
|
15
|
+
- Container/module deployment
|
|
16
|
+
- Resource metrics
|
|
17
|
+
- Sync and configuration
|
|
18
|
+
|
|
19
|
+
- **NiceProtocolConfig** - Protocol configuration
|
|
20
|
+
- MQTT broker configuration
|
|
21
|
+
- CoAP resources
|
|
22
|
+
- Modbus TCP/RTU register mapping
|
|
23
|
+
- OPC-UA node browser
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install @nice2dev/ui-iot
|
|
29
|
+
# or
|
|
30
|
+
pnpm add @nice2dev/ui-iot
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
### IoT Dashboard
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
import { NiceIoTDashboard } from '@nice2dev/ui-iot';
|
|
39
|
+
import '@nice2dev/ui-iot/style.css';
|
|
40
|
+
|
|
41
|
+
function App() {
|
|
42
|
+
return (
|
|
43
|
+
<NiceIoTDashboard
|
|
44
|
+
devices={[
|
|
45
|
+
{
|
|
46
|
+
id: '1',
|
|
47
|
+
name: 'Temperature Sensor',
|
|
48
|
+
type: 'sensor',
|
|
49
|
+
status: 'online',
|
|
50
|
+
protocol: 'mqtt',
|
|
51
|
+
connectionInfo: { host: 'mqtt.example.com' },
|
|
52
|
+
capabilities: [
|
|
53
|
+
{
|
|
54
|
+
id: 'temp',
|
|
55
|
+
type: 'temperature',
|
|
56
|
+
name: 'Temperature',
|
|
57
|
+
dataType: 'float',
|
|
58
|
+
unit: 'Β°C',
|
|
59
|
+
readable: true,
|
|
60
|
+
writable: false,
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
]}
|
|
65
|
+
onDeviceSelect={(device) => console.log('Selected:', device)}
|
|
66
|
+
onCommand={async (deviceId, capabilityId, value) => {
|
|
67
|
+
// Send command to device
|
|
68
|
+
}}
|
|
69
|
+
/>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Edge Manager
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
import { NiceEdgeManager } from '@nice2dev/ui-iot';
|
|
78
|
+
import '@nice2dev/ui-iot/style.css';
|
|
79
|
+
|
|
80
|
+
function App() {
|
|
81
|
+
return (
|
|
82
|
+
<NiceEdgeManager
|
|
83
|
+
nodes={[
|
|
84
|
+
{
|
|
85
|
+
id: '1',
|
|
86
|
+
name: 'Edge Gateway 1',
|
|
87
|
+
type: 'gateway',
|
|
88
|
+
status: 'running',
|
|
89
|
+
hardware: { cpu: 'ARM Cortex-A72', cores: 4, memoryMB: 4096, storageMB: 32768, architecture: 'arm64' },
|
|
90
|
+
software: {
|
|
91
|
+
os: 'Linux',
|
|
92
|
+
osVersion: '5.15',
|
|
93
|
+
runtime: 'Docker',
|
|
94
|
+
runtimeVersion: '24.0',
|
|
95
|
+
agent: 'Nice2Dev Edge',
|
|
96
|
+
agentVersion: '1.0.0',
|
|
97
|
+
},
|
|
98
|
+
connectivity: { cloudConnected: true, localNetwork: '192.168.1.0/24' },
|
|
99
|
+
deployedModules: [],
|
|
100
|
+
},
|
|
101
|
+
]}
|
|
102
|
+
onModuleDeploy={async (nodeId, module) => {
|
|
103
|
+
// Deploy module to edge node
|
|
104
|
+
}}
|
|
105
|
+
/>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Protocol Configuration
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
import { NiceProtocolConfig } from '@nice2dev/ui-iot';
|
|
114
|
+
import '@nice2dev/ui-iot/style.css';
|
|
115
|
+
|
|
116
|
+
function App() {
|
|
117
|
+
return (
|
|
118
|
+
<NiceProtocolConfig
|
|
119
|
+
protocol="mqtt"
|
|
120
|
+
onSave={(config) => console.log('Save:', config)}
|
|
121
|
+
onTest={async (config) => {
|
|
122
|
+
// Test connection
|
|
123
|
+
return { success: true, message: 'Connected successfully' };
|
|
124
|
+
}}
|
|
125
|
+
/>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Supported Protocols
|
|
131
|
+
|
|
132
|
+
- **MQTT** - Message Queuing Telemetry Transport
|
|
133
|
+
- **CoAP** - Constrained Application Protocol
|
|
134
|
+
- **Modbus TCP/RTU** - Industrial protocol
|
|
135
|
+
- **OPC-UA** - Open Platform Communications Unified Architecture
|
|
136
|
+
|
|
137
|
+
## License
|
|
138
|
+
|
|
139
|
+
See LICENSE file.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("react"),I=[{type:"device-list",label:"Device List",icon:"π"},{type:"device-status",label:"Device Status",icon:"π’"},{type:"telemetry-chart",label:"Telemetry Chart",icon:"π"},{type:"gauge",label:"Gauge",icon:"β±οΈ"},{type:"map",label:"Device Map",icon:"πΊοΈ"},{type:"alarms",label:"Alarms",icon:"π¨"},{type:"control-panel",label:"Control Panel",icon:"ποΈ"},{type:"topology",label:"Network Topology",icon:"π"},{type:"kpi",label:"KPI Card",icon:"π―"},{type:"camera-feed",label:"Camera Feed",icon:"πΉ"}];function R({devices:s=[],widgets:t=[],alarms:a=[],onDeviceSelect:n,onWidgetChange:c,onCommand:i,onAlarmAcknowledge:l,fetchTelemetry:d,className:k=""}){const[u,C]=o.useState(t),[x,v]=o.useState(null),[m,b]=o.useState("dashboard"),[p,N]=o.useState(!1),[j,w]=o.useState(""),h=o.useCallback(r=>{C(_=>{const g=r(_);return c==null||c(g),g})},[c]),y=o.useCallback(r=>{var g;const _={id:crypto.randomUUID(),type:r,title:((g=I.find(M=>M.type===r))==null?void 0:g.label)||r,position:{x:0,y:O(u),width:4,height:3},config:{}};h(M=>[...M,_])},[u,h]),D=o.useCallback(r=>{v(r),n==null||n(r)},[n]),f=o.useCallback(r=>{l==null||l(r)},[l]),B=s.filter(r=>!j||r.name.toLowerCase().includes(j.toLowerCase())||r.type.toLowerCase().includes(j.toLowerCase())),S=a.filter(r=>!r.cleared),P=S.filter(r=>r.severity==="critical"||r.severity==="high");return e.jsxs("div",{className:`nice-iot-dashboard ${k}`,children:[e.jsxs("header",{className:"nice-iot-dashboard__header",children:[e.jsx("h1",{children:"IoT Dashboard"}),e.jsxs("div",{className:"nice-iot-dashboard__stats",children:[e.jsxs("span",{className:"nice-iot-dashboard__stat",children:[e.jsx("span",{className:"nice-iot-dashboard__stat-icon",children:"π±"}),s.length," Devices"]}),e.jsxs("span",{className:"nice-iot-dashboard__stat nice-iot-dashboard__stat--online",children:[e.jsx("span",{className:"nice-iot-dashboard__stat-icon",children:"π’"}),s.filter(r=>r.status==="online").length," Online"]}),e.jsxs("span",{className:"nice-iot-dashboard__stat nice-iot-dashboard__stat--offline",children:[e.jsx("span",{className:"nice-iot-dashboard__stat-icon",children:"β«"}),s.filter(r=>r.status==="offline").length," Offline"]}),P.length>0&&e.jsxs("span",{className:"nice-iot-dashboard__stat nice-iot-dashboard__stat--alarms",children:[e.jsx("span",{className:"nice-iot-dashboard__stat-icon",children:"π¨"}),P.length," Alarms"]})]}),e.jsxs("nav",{className:"nice-iot-dashboard__nav",children:[e.jsx("button",{className:m==="dashboard"?"active":"",onClick:()=>b("dashboard"),children:"Dashboard"}),e.jsx("button",{className:m==="devices"?"active":"",onClick:()=>b("devices"),children:"Devices"}),e.jsxs("button",{className:m==="alarms"?"active":"",onClick:()=>b("alarms"),children:["Alarms ",S.length>0&&`(${S.length})`]})]}),e.jsx("div",{className:"nice-iot-dashboard__actions",children:m==="dashboard"&&e.jsx("button",{onClick:()=>N(!p),children:p?"β Done":"βοΈ Edit"})})]}),m==="dashboard"&&e.jsxs("div",{className:"nice-iot-dashboard__main",children:[p&&e.jsxs("aside",{className:"nice-iot-dashboard__palette",children:[e.jsx("h4",{children:"Add Widget"}),I.map(r=>e.jsxs("button",{className:"nice-iot-dashboard__palette-item",onClick:()=>y(r.type),children:[e.jsx("span",{children:r.icon}),e.jsx("span",{children:r.label})]},r.type))]}),e.jsxs("div",{className:"nice-iot-dashboard__grid",children:[u.map(r=>e.jsx(q,{widget:r,devices:s,alarms:a,isEditing:p,onCommand:i,onDelete:()=>h(_=>_.filter(g=>g.id!==r.id))},r.id)),u.length===0&&e.jsx("div",{className:"nice-iot-dashboard__empty",children:p?"Add widgets from the palette":"No widgets configured. Click Edit to add widgets."})]})]}),m==="devices"&&e.jsxs("div",{className:"nice-iot-dashboard__devices",children:[e.jsx("div",{className:"nice-iot-dashboard__devices-toolbar",children:e.jsx("input",{type:"search",placeholder:"Search devices...",value:j,onChange:r=>w(r.target.value)})}),e.jsx("div",{className:"nice-iot-dashboard__device-grid",children:B.map(r=>e.jsx(Q,{device:r,isSelected:(x==null?void 0:x.id)===r.id,onSelect:()=>D(r)},r.id))}),x&&e.jsx(W,{device:x,onCommand:i,onClose:()=>v(null)})]}),m==="alarms"&&e.jsx("div",{className:"nice-iot-dashboard__alarms",children:e.jsxs("table",{className:"nice-iot-dashboard__alarm-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Severity"}),e.jsx("th",{children:"Device"}),e.jsx("th",{children:"Message"}),e.jsx("th",{children:"Time"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Actions"})]})}),e.jsx("tbody",{children:S.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"nice-iot-dashboard__no-alarms",children:"No active alarms"})}):S.map(r=>{const _=s.find(g=>g.id===r.deviceId);return e.jsxs("tr",{className:`nice-iot-dashboard__alarm-row nice-iot-dashboard__alarm-row--${r.severity}`,children:[e.jsx("td",{children:e.jsx("span",{className:`nice-iot-dashboard__severity nice-iot-dashboard__severity--${r.severity}`,children:r.severity})}),e.jsx("td",{children:(_==null?void 0:_.name)||r.deviceId}),e.jsx("td",{children:r.message}),e.jsx("td",{children:r.timestamp.toLocaleString()}),e.jsx("td",{children:r.acknowledged?"Acknowledged":"Active"}),e.jsx("td",{children:!r.acknowledged&&e.jsx("button",{onClick:()=>f(r.id),children:"Acknowledge"})})]},r.id)})})]})})]})}function O(s){return s.length===0?0:Math.max(...s.map(t=>t.position.y+t.position.height))}function T(s){switch(s){case"online":return"#28a745";case"offline":return"#6c757d";case"warning":return"#ffc107";case"error":return"#dc3545";case"maintenance":return"#17a2b8";default:return"#6c757d"}}function q({widget:s,devices:t,alarms:a,isEditing:n,onCommand:c,onDelete:i}){const l=I.find(d=>d.type===s.type);return e.jsxs("div",{className:`nice-iot-dashboard__widget nice-iot-dashboard__widget--${s.type}`,style:{gridColumn:`span ${s.position.width}`,gridRow:`span ${s.position.height}`},children:[e.jsxs("div",{className:"nice-iot-dashboard__widget-header",children:[e.jsx("span",{className:"nice-iot-dashboard__widget-icon",children:l==null?void 0:l.icon}),e.jsx("span",{className:"nice-iot-dashboard__widget-title",children:s.title}),n&&e.jsx("button",{className:"nice-iot-dashboard__widget-delete",onClick:i,children:"Γ"})]}),e.jsx("div",{className:"nice-iot-dashboard__widget-content",children:e.jsx(G,{widget:s,devices:t,alarms:a,onCommand:c})})]})}function G({widget:s,devices:t,alarms:a,onCommand:n}){switch(s.type){case"device-list":return e.jsx("div",{className:"nice-iot-dashboard__device-list",children:t.slice(0,10).map(i=>e.jsxs("div",{className:"nice-iot-dashboard__device-list-item",children:[e.jsx("span",{className:"nice-iot-dashboard__device-status",style:{background:T(i.status)}}),e.jsx("span",{children:i.name}),e.jsx("span",{className:"nice-iot-dashboard__device-type",children:i.type})]},i.id))});case"device-status":return e.jsx("div",{className:"nice-iot-dashboard__status-grid",children:["online","offline","warning","error"].map(i=>{const l=t.filter(d=>d.status===i).length;return e.jsxs("div",{className:"nice-iot-dashboard__status-card",children:[e.jsx("span",{className:"nice-iot-dashboard__status-indicator",style:{background:T(i)}}),e.jsx("span",{className:"nice-iot-dashboard__status-count",children:l}),e.jsx("span",{className:"nice-iot-dashboard__status-label",children:i})]},i)})});case"telemetry-chart":return e.jsxs("div",{className:"nice-iot-dashboard__chart-placeholder",children:[e.jsx("span",{children:"π"}),e.jsx("span",{children:"Telemetry Chart"}),e.jsx("small",{children:"Configure device and capability"})]});case"gauge":return e.jsx("div",{className:"nice-iot-dashboard__gauge",children:e.jsxs("svg",{viewBox:"0 0 100 60",children:[e.jsx("path",{d:"M 10 55 A 40 40 0 0 1 90 55",fill:"none",stroke:"#e0e0e0",strokeWidth:"8"}),e.jsx("path",{d:"M 10 55 A 40 40 0 0 1 90 55",fill:"none",stroke:"#0066cc",strokeWidth:"8",strokeDasharray:"63 126"}),e.jsx("text",{x:"50",y:"50",textAnchor:"middle",fontSize:"14",fontWeight:"bold",children:"50%"})]})});case"map":return e.jsxs("div",{className:"nice-iot-dashboard__map-placeholder",children:[e.jsx("span",{children:"πΊοΈ"}),e.jsx("span",{children:"Device Map"}),e.jsxs("small",{children:[t.filter(i=>i.location).length," devices with location"]})]});case"alarms":const c=a.filter(i=>!i.cleared).slice(0,5);return e.jsx("div",{className:"nice-iot-dashboard__alarm-list",children:c.length===0?e.jsx("div",{className:"nice-iot-dashboard__alarm-empty",children:"No active alarms"}):c.map(i=>e.jsxs("div",{className:`nice-iot-dashboard__alarm-item nice-iot-dashboard__alarm-item--${i.severity}`,children:[e.jsx("span",{className:"nice-iot-dashboard__alarm-severity",children:i.severity}),e.jsx("span",{className:"nice-iot-dashboard__alarm-message",children:i.message})]},i.id))});case"control-panel":return e.jsxs("div",{className:"nice-iot-dashboard__control-placeholder",children:[e.jsx("span",{children:"ποΈ"}),e.jsx("span",{children:"Control Panel"}),e.jsx("small",{children:"Configure device controls"})]});case"kpi":return e.jsxs("div",{className:"nice-iot-dashboard__kpi",children:[e.jsx("div",{className:"nice-iot-dashboard__kpi-value",children:t.length}),e.jsx("div",{className:"nice-iot-dashboard__kpi-label",children:"Total Devices"})]});default:return e.jsx("div",{className:"nice-iot-dashboard__widget-placeholder",children:s.type})}}function Q({device:s,isSelected:t,onSelect:a}){return e.jsxs("div",{className:`nice-iot-dashboard__device-card ${t?"nice-iot-dashboard__device-card--selected":""}`,onClick:a,children:[e.jsxs("div",{className:"nice-iot-dashboard__device-card-header",children:[e.jsx("span",{className:"nice-iot-dashboard__device-status",style:{background:T(s.status)}}),e.jsx("span",{className:"nice-iot-dashboard__device-name",children:s.name})]}),e.jsxs("div",{className:"nice-iot-dashboard__device-card-body",children:[e.jsxs("div",{className:"nice-iot-dashboard__device-info",children:[e.jsxs("span",{children:["Type: ",s.type]}),e.jsxs("span",{children:["Protocol: ",s.protocol]})]}),s.lastSeen&&e.jsxs("div",{className:"nice-iot-dashboard__device-lastseen",children:["Last seen: ",s.lastSeen.toLocaleString()]}),e.jsxs("div",{className:"nice-iot-dashboard__device-capabilities",children:[s.capabilities.slice(0,3).map(n=>e.jsx("span",{className:"nice-iot-dashboard__capability-badge",children:n.name},n.id)),s.capabilities.length>3&&e.jsxs("span",{className:"nice-iot-dashboard__capability-more",children:["+",s.capabilities.length-3]})]})]})]})}function W({device:s,onCommand:t,onClose:a}){return e.jsxs("aside",{className:"nice-iot-dashboard__device-detail",children:[e.jsxs("div",{className:"nice-iot-dashboard__device-detail-header",children:[e.jsx("h3",{children:s.name}),e.jsx("button",{onClick:a,children:"Γ"})]}),e.jsxs("div",{className:"nice-iot-dashboard__device-detail-content",children:[e.jsxs("section",{children:[e.jsx("h4",{children:"Status"}),e.jsxs("div",{className:"nice-iot-dashboard__detail-row",children:[e.jsx("span",{children:"Status:"}),e.jsx("span",{className:"nice-iot-dashboard__status-badge",style:{background:T(s.status)},children:s.status})]}),s.lastSeen&&e.jsxs("div",{className:"nice-iot-dashboard__detail-row",children:[e.jsx("span",{children:"Last Seen:"}),e.jsx("span",{children:s.lastSeen.toLocaleString()})]})]}),e.jsxs("section",{children:[e.jsx("h4",{children:"Connection"}),e.jsxs("div",{className:"nice-iot-dashboard__detail-row",children:[e.jsx("span",{children:"Protocol:"}),e.jsx("span",{children:s.protocol})]}),s.connectionInfo.host&&e.jsxs("div",{className:"nice-iot-dashboard__detail-row",children:[e.jsx("span",{children:"Host:"}),e.jsxs("span",{children:[s.connectionInfo.host,":",s.connectionInfo.port]})]})]}),s.metadata&&e.jsxs("section",{children:[e.jsx("h4",{children:"Metadata"}),s.metadata.manufacturer&&e.jsxs("div",{className:"nice-iot-dashboard__detail-row",children:[e.jsx("span",{children:"Manufacturer:"}),e.jsx("span",{children:s.metadata.manufacturer})]}),s.metadata.model&&e.jsxs("div",{className:"nice-iot-dashboard__detail-row",children:[e.jsx("span",{children:"Model:"}),e.jsx("span",{children:s.metadata.model})]})]}),e.jsxs("section",{children:[e.jsx("h4",{children:"Capabilities"}),e.jsx("div",{className:"nice-iot-dashboard__capabilities-list",children:s.capabilities.map(n=>e.jsxs("div",{className:"nice-iot-dashboard__capability-item",children:[e.jsx("span",{className:"nice-iot-dashboard__capability-name",children:n.name}),e.jsx("span",{className:"nice-iot-dashboard__capability-type",children:n.type}),n.writable&&t&&e.jsx("button",{className:"nice-iot-dashboard__capability-control",onClick:()=>t(s.id,n.id,!0),children:"Control"})]},n.id))})]})]})]})}const V=[{name:"MQTT Broker",image:"eclipse-mosquitto:latest"},{name:"Node-RED",image:"nodered/node-red:latest"},{name:"InfluxDB",image:"influxdb:latest"},{name:"Grafana",image:"grafana/grafana:latest"},{name:"Telegraf",image:"telegraf:latest"},{name:"Protocol Adapter",image:"nice2dev/protocol-adapter:latest"}];function H({nodes:s=[],modules:t=[],onNodeSelect:a,onModuleDeploy:n,onModuleAction:c,onNodeSync:i,className:l=""}){const[d,k]=o.useState(null),[u,C]=o.useState("nodes"),[x,v]=o.useState(!1),[m,b]=o.useState({name:"",image:"",status:"pending"}),p=o.useCallback(h=>{k(h),a==null||a(h)},[a]),N=o.useCallback(async()=>{!d||!m.name||!m.image||(await(n==null?void 0:n(d.id,m)),v(!1),b({name:"",image:"",status:"pending"}))},[d,m,n]),j=o.useCallback(async(h,y)=>{d&&await(c==null?void 0:c(d.id,h,y))},[d,c]),w=o.useCallback(async()=>{d&&await(i==null?void 0:i(d.id))},[d,i]);return e.jsxs("div",{className:`nice-edge-manager ${l}`,children:[e.jsxs("header",{className:"nice-edge-manager__header",children:[e.jsx("h1",{children:"Edge Manager"}),e.jsxs("nav",{className:"nice-edge-manager__nav",children:[e.jsxs("button",{className:u==="nodes"?"active":"",onClick:()=>C("nodes"),children:["Nodes (",s.length,")"]}),e.jsx("button",{className:u==="modules"?"active":"",onClick:()=>C("modules"),children:"Modules"})]})]}),e.jsxs("div",{className:"nice-edge-manager__main",children:[u==="nodes"&&e.jsx("div",{className:"nice-edge-manager__nodes",children:e.jsxs("div",{className:"nice-edge-manager__node-grid",children:[s.map(h=>e.jsx(Y,{node:h,isSelected:(d==null?void 0:d.id)===h.id,onSelect:()=>p(h)},h.id)),s.length===0&&e.jsx("div",{className:"nice-edge-manager__empty",children:"No edge nodes configured"})]})}),u==="modules"&&d&&e.jsxs("div",{className:"nice-edge-manager__modules",children:[e.jsxs("div",{className:"nice-edge-manager__modules-header",children:[e.jsxs("h3",{children:["Modules on ",d.name]}),e.jsx("button",{className:"nice-edge-manager__deploy-btn",onClick:()=>v(!0),children:"+ Deploy Module"})]}),e.jsxs("div",{className:"nice-edge-manager__module-grid",children:[d.deployedModules.map(h=>e.jsx(z,{module:h,onAction:y=>j(h.id,y)},h.id)),d.deployedModules.length===0&&e.jsx("div",{className:"nice-edge-manager__empty",children:"No modules deployed on this node"})]})]}),u==="modules"&&!d&&e.jsx("div",{className:"nice-edge-manager__no-selection",children:"Select a node from the Nodes tab to manage modules"}),d&&e.jsx(J,{node:d,onSync:w,onClose:()=>k(null)})]}),x&&e.jsx(X,{config:m,templates:V,onChange:b,onDeploy:N,onClose:()=>v(!1)})]})}function F(s){switch(s){case"running":return"#28a745";case"stopped":return"#6c757d";case"updating":return"#ffc107";case"error":return"#dc3545";case"unreachable":return"#868e96";default:return"#6c757d"}}function U(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:s<1024*1024*1024?`${(s/1024/1024).toFixed(1)} MB`:`${(s/1024/1024/1024).toFixed(2)} GB`}function K(s){const t=Math.floor(s/86400),a=Math.floor(s%86400/3600),n=Math.floor(s%3600/60);return t>0?`${t}d ${a}h`:a>0?`${a}h ${n}m`:`${n}m`}function Y({node:s,isSelected:t,onSelect:a}){return e.jsxs("div",{className:`nice-edge-manager__node-card ${t?"nice-edge-manager__node-card--selected":""}`,onClick:a,children:[e.jsxs("div",{className:"nice-edge-manager__node-header",children:[e.jsx("span",{className:"nice-edge-manager__node-status",style:{background:F(s.status)}}),e.jsx("span",{className:"nice-edge-manager__node-name",children:s.name}),e.jsx("span",{className:"nice-edge-manager__node-type",children:s.type})]}),e.jsxs("div",{className:"nice-edge-manager__node-body",children:[e.jsxs("div",{className:"nice-edge-manager__node-info",children:[e.jsxs("span",{children:["π₯οΈ ",s.hardware.cpu]}),e.jsxs("span",{children:["πΎ ",(s.hardware.memoryMB/1024).toFixed(1)," GB"]})]}),e.jsx("div",{className:"nice-edge-manager__node-metrics",children:s.metrics&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-edge-manager__metric",children:[e.jsx("span",{className:"nice-edge-manager__metric-label",children:"CPU"}),e.jsx("div",{className:"nice-edge-manager__metric-bar",children:e.jsx("div",{className:"nice-edge-manager__metric-fill",style:{width:`${s.metrics.cpuUsage}%`}})}),e.jsxs("span",{className:"nice-edge-manager__metric-value",children:[s.metrics.cpuUsage.toFixed(0),"%"]})]}),e.jsxs("div",{className:"nice-edge-manager__metric",children:[e.jsx("span",{className:"nice-edge-manager__metric-label",children:"MEM"}),e.jsx("div",{className:"nice-edge-manager__metric-bar",children:e.jsx("div",{className:"nice-edge-manager__metric-fill",style:{width:`${s.metrics.memoryUsage}%`}})}),e.jsxs("span",{className:"nice-edge-manager__metric-value",children:[s.metrics.memoryUsage.toFixed(0),"%"]})]})]})}),e.jsxs("div",{className:"nice-edge-manager__node-modules",children:[s.deployedModules.length," modules deployed"]})]})]})}function z({module:s,onAction:t}){const a={running:"#28a745",stopped:"#6c757d",error:"#dc3545",pending:"#ffc107"};return e.jsxs("div",{className:"nice-edge-manager__module-card",children:[e.jsxs("div",{className:"nice-edge-manager__module-header",children:[e.jsx("span",{className:"nice-edge-manager__module-status",style:{background:a[s.status]||"#6c757d"}}),e.jsx("span",{className:"nice-edge-manager__module-name",children:s.name}),e.jsxs("span",{className:"nice-edge-manager__module-version",children:["v",s.version]})]}),e.jsxs("div",{className:"nice-edge-manager__module-body",children:[e.jsx("div",{className:"nice-edge-manager__module-image",children:s.image}),s.resources&&e.jsxs("div",{className:"nice-edge-manager__module-resources",children:[s.resources.cpuLimit&&e.jsxs("span",{children:["CPU: ",s.resources.cpuLimit]}),s.resources.memoryLimitMB&&e.jsxs("span",{children:["RAM: ",s.resources.memoryLimitMB," MB"]})]}),s.ports&&s.ports.length>0&&e.jsxs("div",{className:"nice-edge-manager__module-ports",children:["Ports: ",s.ports.map(n=>`${n.host}:${n.container}`).join(", ")]})]}),e.jsxs("div",{className:"nice-edge-manager__module-actions",children:[s.status==="running"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>t("stop"),children:"Stop"}),e.jsx("button",{onClick:()=>t("restart"),children:"Restart"})]}),s.status==="stopped"&&e.jsx("button",{onClick:()=>t("start"),children:"Start"}),e.jsx("button",{className:"nice-edge-manager__module-remove",onClick:()=>t("remove"),children:"Remove"})]})]})}function J({node:s,onSync:t,onClose:a}){return e.jsxs("aside",{className:"nice-edge-manager__detail",children:[e.jsxs("div",{className:"nice-edge-manager__detail-header",children:[e.jsx("h3",{children:s.name}),e.jsxs("div",{className:"nice-edge-manager__detail-actions",children:[e.jsx("button",{onClick:t,children:"π Sync"}),e.jsx("button",{onClick:a,children:"Γ"})]})]}),e.jsxs("div",{className:"nice-edge-manager__detail-content",children:[e.jsxs("section",{children:[e.jsx("h4",{children:"Status"}),e.jsxs("div",{className:"nice-edge-manager__detail-row",children:[e.jsx("span",{children:"Status:"}),e.jsx("span",{className:"nice-edge-manager__status-badge",style:{background:F(s.status)},children:s.status})]}),s.metrics&&e.jsxs("div",{className:"nice-edge-manager__detail-row",children:[e.jsx("span",{children:"Uptime:"}),e.jsx("span",{children:K(s.metrics.uptime)})]})]}),e.jsxs("section",{children:[e.jsx("h4",{children:"Hardware"}),e.jsxs("div",{className:"nice-edge-manager__detail-row",children:[e.jsx("span",{children:"CPU:"}),e.jsxs("span",{children:[s.hardware.cpu," (",s.hardware.cores," cores)"]})]}),e.jsxs("div",{className:"nice-edge-manager__detail-row",children:[e.jsx("span",{children:"Memory:"}),e.jsxs("span",{children:[(s.hardware.memoryMB/1024).toFixed(1)," GB"]})]}),e.jsxs("div",{className:"nice-edge-manager__detail-row",children:[e.jsx("span",{children:"Storage:"}),e.jsxs("span",{children:[(s.hardware.storageMB/1024).toFixed(1)," GB"]})]}),e.jsxs("div",{className:"nice-edge-manager__detail-row",children:[e.jsx("span",{children:"Architecture:"}),e.jsx("span",{children:s.hardware.architecture})]})]}),e.jsxs("section",{children:[e.jsx("h4",{children:"Software"}),e.jsxs("div",{className:"nice-edge-manager__detail-row",children:[e.jsx("span",{children:"OS:"}),e.jsxs("span",{children:[s.software.os," ",s.software.osVersion]})]}),e.jsxs("div",{className:"nice-edge-manager__detail-row",children:[e.jsx("span",{children:"Runtime:"}),e.jsxs("span",{children:[s.software.runtime," ",s.software.runtimeVersion]})]}),e.jsxs("div",{className:"nice-edge-manager__detail-row",children:[e.jsx("span",{children:"Agent:"}),e.jsxs("span",{children:[s.software.agent," v",s.software.agentVersion]})]})]}),e.jsxs("section",{children:[e.jsx("h4",{children:"Connectivity"}),e.jsxs("div",{className:"nice-edge-manager__detail-row",children:[e.jsx("span",{children:"Cloud:"}),e.jsx("span",{children:s.connectivity.cloudConnected?"β Connected":"β Disconnected"})]}),e.jsxs("div",{className:"nice-edge-manager__detail-row",children:[e.jsx("span",{children:"Network:"}),e.jsx("span",{children:s.connectivity.localNetwork})]}),s.connectivity.publicIP&&e.jsxs("div",{className:"nice-edge-manager__detail-row",children:[e.jsx("span",{children:"Public IP:"}),e.jsx("span",{children:s.connectivity.publicIP})]}),s.connectivity.lastSync&&e.jsxs("div",{className:"nice-edge-manager__detail-row",children:[e.jsx("span",{children:"Last Sync:"}),e.jsx("span",{children:s.connectivity.lastSync.toLocaleString()})]})]}),s.metrics&&e.jsxs("section",{children:[e.jsx("h4",{children:"Resource Usage"}),e.jsxs("div",{className:"nice-edge-manager__resource-chart",children:[e.jsxs("div",{className:"nice-edge-manager__resource-item",children:[e.jsx("span",{children:"CPU"}),e.jsx("div",{className:"nice-edge-manager__resource-bar",children:e.jsx("div",{className:"nice-edge-manager__resource-fill",style:{width:`${s.metrics.cpuUsage}%`}})}),e.jsxs("span",{children:[s.metrics.cpuUsage.toFixed(1),"%"]})]}),e.jsxs("div",{className:"nice-edge-manager__resource-item",children:[e.jsx("span",{children:"Memory"}),e.jsx("div",{className:"nice-edge-manager__resource-bar",children:e.jsx("div",{className:"nice-edge-manager__resource-fill",style:{width:`${s.metrics.memoryUsage}%`}})}),e.jsxs("span",{children:[s.metrics.memoryUsage.toFixed(1),"%"]})]}),e.jsxs("div",{className:"nice-edge-manager__resource-item",children:[e.jsx("span",{children:"Disk"}),e.jsx("div",{className:"nice-edge-manager__resource-bar",children:e.jsx("div",{className:"nice-edge-manager__resource-fill",style:{width:`${s.metrics.diskUsage}%`}})}),e.jsxs("span",{children:[s.metrics.diskUsage.toFixed(1),"%"]})]})]}),e.jsxs("div",{className:"nice-edge-manager__network-stats",children:[e.jsxs("span",{children:["β ",U(s.metrics.networkIn)]}),e.jsxs("span",{children:["β ",U(s.metrics.networkOut)]})]})]})]})]})}function X({config:s,templates:t,onChange:a,onDeploy:n,onClose:c}){return e.jsx("div",{className:"nice-edge-manager__dialog-overlay",children:e.jsxs("div",{className:"nice-edge-manager__dialog",children:[e.jsxs("div",{className:"nice-edge-manager__dialog-header",children:[e.jsx("h3",{children:"Deploy Module"}),e.jsx("button",{onClick:c,children:"Γ"})]}),e.jsxs("div",{className:"nice-edge-manager__dialog-content",children:[e.jsxs("div",{className:"nice-edge-manager__field",children:[e.jsx("label",{children:"Template (optional)"}),e.jsxs("select",{value:"",onChange:i=>{const l=t.find(d=>d.image===i.target.value);l&&a({...s,name:l.name,image:l.image})},children:[e.jsx("option",{value:"",children:"Select a template..."}),t.map(i=>e.jsx("option",{value:i.image,children:i.name},i.image))]})]}),e.jsxs("div",{className:"nice-edge-manager__field",children:[e.jsx("label",{children:"Module Name"}),e.jsx("input",{type:"text",value:s.name||"",onChange:i=>a({...s,name:i.target.value}),placeholder:"e.g., my-module"})]}),e.jsxs("div",{className:"nice-edge-manager__field",children:[e.jsx("label",{children:"Container Image"}),e.jsx("input",{type:"text",value:s.image||"",onChange:i=>a({...s,image:i.target.value}),placeholder:"e.g., nginx:latest"})]}),e.jsxs("div",{className:"nice-edge-manager__field",children:[e.jsx("label",{children:"Version"}),e.jsx("input",{type:"text",value:s.version||"1.0.0",onChange:i=>a({...s,version:i.target.value})})]})]}),e.jsxs("div",{className:"nice-edge-manager__dialog-footer",children:[e.jsx("button",{onClick:c,children:"Cancel"}),e.jsx("button",{className:"nice-edge-manager__deploy-confirm",onClick:n,children:"Deploy"})]})]})})}const A={broker:"localhost",port:1883,clientId:`nice2dev-${Date.now()}`,useTLS:!1,keepAlive:60,cleanSession:!0,topics:[]},L={host:"localhost",port:5683,useDTLS:!1,resources:[]},$={type:"tcp",host:"localhost",port:502,slaveId:1,timeout:1e3,registers:[]},E={endpointUrl:"opc.tcp://localhost:4840",securityMode:"None",authentication:"anonymous",applicationName:"Nice2Dev IoT Client",nodes:[]};function Z({protocol:s="mqtt",config:t,onSave:a,onTest:n,className:c=""}){const[i,l]=o.useState(s),[d,k]=o.useState((t==null?void 0:t.type)==="mqtt"?{...A,...t.config}:A),[u,C]=o.useState((t==null?void 0:t.type)==="coap"?{...L,...t.config}:L),[x,v]=o.useState((t==null?void 0:t.type)==="modbus"?{...$,...t.config}:$),[m,b]=o.useState((t==null?void 0:t.type)==="opcua"?{...E,...t.config}:E),[p,N]=o.useState(null),[j,w]=o.useState(!1),h=o.useCallback(()=>{switch(i){case"mqtt":return d;case"coap":return u;case"modbus-tcp":case"modbus-rtu":return x;case"opcua":return m;default:return d}},[i,d,u,x,m]),y=o.useCallback(()=>{a==null||a(h())},[h,a]),D=o.useCallback(async()=>{if(n){w(!0),N(null);try{const f=await n(h());N(f)}catch(f){N({success:!1,message:String(f)})}finally{w(!1)}}},[h,n]);return e.jsxs("div",{className:`nice-protocol-config ${c}`,children:[e.jsxs("header",{className:"nice-protocol-config__header",children:[e.jsx("h2",{children:"Protocol Configuration"}),e.jsxs("div",{className:"nice-protocol-config__protocol-selector",children:[e.jsx("label",{children:"Protocol:"}),e.jsxs("select",{value:i,onChange:f=>l(f.target.value),children:[e.jsx("option",{value:"mqtt",children:"MQTT"}),e.jsx("option",{value:"coap",children:"CoAP"}),e.jsx("option",{value:"modbus-tcp",children:"Modbus TCP"}),e.jsx("option",{value:"modbus-rtu",children:"Modbus RTU"}),e.jsx("option",{value:"opcua",children:"OPC-UA"})]})]})]}),e.jsxs("div",{className:"nice-protocol-config__content",children:[i==="mqtt"&&e.jsx(ee,{config:d,onChange:k}),i==="coap"&&e.jsx(se,{config:u,onChange:C}),(i==="modbus-tcp"||i==="modbus-rtu")&&e.jsx(ae,{config:x,type:i==="modbus-rtu"?"rtu":"tcp",onChange:v}),i==="opcua"&&e.jsx(ie,{config:m,onChange:b})]}),p&&e.jsxs("div",{className:`nice-protocol-config__test-result nice-protocol-config__test-result--${p.success?"success":"error"}`,children:[p.success?"β":"β"," ",p.message]}),e.jsxs("footer",{className:"nice-protocol-config__footer",children:[e.jsx("button",{className:"nice-protocol-config__test-btn",onClick:D,disabled:j||!n,children:j?"Testing...":"π Test Connection"}),e.jsx("button",{className:"nice-protocol-config__save-btn",onClick:y,children:"πΎ Save"})]})]})}function ee({config:s,onChange:t}){return e.jsxs("div",{className:"nice-protocol-config__section",children:[e.jsx("h3",{children:"MQTT Configuration"}),e.jsxs("div",{className:"nice-protocol-config__grid",children:[e.jsxs("div",{className:"nice-protocol-config__field",children:[e.jsx("label",{children:"Broker"}),e.jsx("input",{type:"text",value:s.broker,onChange:a=>t({...s,broker:a.target.value}),placeholder:"localhost"})]}),e.jsxs("div",{className:"nice-protocol-config__field",children:[e.jsx("label",{children:"Port"}),e.jsx("input",{type:"number",value:s.port,onChange:a=>t({...s,port:parseInt(a.target.value,10)||1883})})]}),e.jsxs("div",{className:"nice-protocol-config__field",children:[e.jsx("label",{children:"Client ID"}),e.jsx("input",{type:"text",value:s.clientId,onChange:a=>t({...s,clientId:a.target.value})})]}),e.jsx("div",{className:"nice-protocol-config__field",children:e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:s.useTLS,onChange:a=>t({...s,useTLS:a.target.checked})}),"Use TLS"]})}),e.jsxs("div",{className:"nice-protocol-config__field",children:[e.jsx("label",{children:"Username"}),e.jsx("input",{type:"text",value:s.username||"",onChange:a=>t({...s,username:a.target.value})})]}),e.jsxs("div",{className:"nice-protocol-config__field",children:[e.jsx("label",{children:"Password"}),e.jsx("input",{type:"password",value:s.password||"",onChange:a=>t({...s,password:a.target.value})})]}),e.jsxs("div",{className:"nice-protocol-config__field",children:[e.jsx("label",{children:"Keep Alive (seconds)"}),e.jsx("input",{type:"number",value:s.keepAlive,onChange:a=>t({...s,keepAlive:parseInt(a.target.value,10)||60})})]}),e.jsx("div",{className:"nice-protocol-config__field",children:e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:s.cleanSession,onChange:a=>t({...s,cleanSession:a.target.checked})}),"Clean Session"]})})]}),e.jsx("h4",{children:"Topics"}),e.jsxs("div",{className:"nice-protocol-config__topics",children:[s.topics.map((a,n)=>e.jsxs("div",{className:"nice-protocol-config__topic-row",children:[e.jsx("input",{type:"text",value:a.pattern,onChange:c=>{const i=[...s.topics];i[n]={...i[n],pattern:c.target.value},t({...s,topics:i})},placeholder:"e.g., sensors/+/data"}),e.jsxs("select",{value:a.qos,onChange:c=>{const i=[...s.topics];i[n]={...i[n],qos:parseInt(c.target.value,10)},t({...s,topics:i})},children:[e.jsx("option",{value:0,children:"QoS 0"}),e.jsx("option",{value:1,children:"QoS 1"}),e.jsx("option",{value:2,children:"QoS 2"})]}),e.jsxs("select",{value:a.direction,onChange:c=>{const i=[...s.topics];i[n]={...i[n],direction:c.target.value},t({...s,topics:i})},children:[e.jsx("option",{value:"subscribe",children:"Subscribe"}),e.jsx("option",{value:"publish",children:"Publish"}),e.jsx("option",{value:"both",children:"Both"})]}),e.jsx("button",{onClick:()=>{const c=s.topics.filter((i,l)=>l!==n);t({...s,topics:c})},children:"Γ"})]},n)),e.jsx("button",{onClick:()=>{t({...s,topics:[...s.topics,{pattern:"",qos:0,direction:"subscribe",payloadFormat:"json"}]})},children:"+ Add Topic"})]})]})}function se({config:s,onChange:t}){return e.jsxs("div",{className:"nice-protocol-config__section",children:[e.jsx("h3",{children:"CoAP Configuration"}),e.jsxs("div",{className:"nice-protocol-config__grid",children:[e.jsxs("div",{className:"nice-protocol-config__field",children:[e.jsx("label",{children:"Host"}),e.jsx("input",{type:"text",value:s.host,onChange:a=>t({...s,host:a.target.value})})]}),e.jsxs("div",{className:"nice-protocol-config__field",children:[e.jsx("label",{children:"Port"}),e.jsx("input",{type:"number",value:s.port,onChange:a=>t({...s,port:parseInt(a.target.value,10)||5683})})]}),e.jsx("div",{className:"nice-protocol-config__field",children:e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:s.useDTLS,onChange:a=>t({...s,useDTLS:a.target.checked})}),"Use DTLS"]})}),e.jsx("div",{className:"nice-protocol-config__field",children:e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:s.observe||!1,onChange:a=>t({...s,observe:a.target.checked})}),"Enable Observe"]})})]}),e.jsx("h4",{children:"Resources"}),e.jsxs("div",{className:"nice-protocol-config__resources",children:[s.resources.map((a,n)=>e.jsxs("div",{className:"nice-protocol-config__resource-row",children:[e.jsx("input",{type:"text",value:a.path,onChange:c=>{const i=[...s.resources];i[n]={...i[n],path:c.target.value},t({...s,resources:i})},placeholder:"/sensors/temperature"}),e.jsx("button",{onClick:()=>{const c=s.resources.filter((i,l)=>l!==n);t({...s,resources:c})},children:"Γ"})]},n)),e.jsx("button",{onClick:()=>{t({...s,resources:[...s.resources,{path:"",methods:["GET"],mediaType:"application/json",observable:!1}]})},children:"+ Add Resource"})]})]})}function ae({config:s,type:t,onChange:a}){return e.jsxs("div",{className:"nice-protocol-config__section",children:[e.jsxs("h3",{children:["Modbus ",t.toUpperCase()," Configuration"]}),e.jsxs("div",{className:"nice-protocol-config__grid",children:[t==="tcp"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-protocol-config__field",children:[e.jsx("label",{children:"Host"}),e.jsx("input",{type:"text",value:s.host||"",onChange:n=>a({...s,host:n.target.value})})]}),e.jsxs("div",{className:"nice-protocol-config__field",children:[e.jsx("label",{children:"Port"}),e.jsx("input",{type:"number",value:s.port||502,onChange:n=>a({...s,port:parseInt(n.target.value,10)||502})})]})]}),t==="rtu"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-protocol-config__field",children:[e.jsx("label",{children:"Serial Port"}),e.jsx("input",{type:"text",value:s.serialPort||"",onChange:n=>a({...s,serialPort:n.target.value}),placeholder:"COM1 or /dev/ttyUSB0"})]}),e.jsxs("div",{className:"nice-protocol-config__field",children:[e.jsx("label",{children:"Baud Rate"}),e.jsxs("select",{value:s.baudRate||9600,onChange:n=>a({...s,baudRate:parseInt(n.target.value,10)}),children:[e.jsx("option",{value:9600,children:"9600"}),e.jsx("option",{value:19200,children:"19200"}),e.jsx("option",{value:38400,children:"38400"}),e.jsx("option",{value:57600,children:"57600"}),e.jsx("option",{value:115200,children:"115200"})]})]}),e.jsxs("div",{className:"nice-protocol-config__field",children:[e.jsx("label",{children:"Parity"}),e.jsxs("select",{value:s.parity||"none",onChange:n=>a({...s,parity:n.target.value}),children:[e.jsx("option",{value:"none",children:"None"}),e.jsx("option",{value:"even",children:"Even"}),e.jsx("option",{value:"odd",children:"Odd"})]})]})]}),e.jsxs("div",{className:"nice-protocol-config__field",children:[e.jsx("label",{children:"Slave ID"}),e.jsx("input",{type:"number",value:s.slaveId,onChange:n=>a({...s,slaveId:parseInt(n.target.value,10)||1}),min:1,max:247})]}),e.jsxs("div",{className:"nice-protocol-config__field",children:[e.jsx("label",{children:"Timeout (ms)"}),e.jsx("input",{type:"number",value:s.timeout,onChange:n=>a({...s,timeout:parseInt(n.target.value,10)||1e3})})]})]}),e.jsx("h4",{children:"Registers"}),e.jsxs("table",{className:"nice-protocol-config__registers-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),e.jsx("th",{children:"Address"}),e.jsx("th",{children:"Type"}),e.jsx("th",{children:"Data Type"}),e.jsx("th",{children:"R/W"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:s.registers.map((n,c)=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("input",{type:"text",value:n.name,onChange:i=>{const l=[...s.registers];l[c]={...l[c],name:i.target.value},a({...s,registers:l})}})}),e.jsx("td",{children:e.jsx("input",{type:"number",value:n.address,onChange:i=>{const l=[...s.registers];l[c]={...l[c],address:parseInt(i.target.value,10)||0},a({...s,registers:l})}})}),e.jsx("td",{children:e.jsxs("select",{value:n.type,onChange:i=>{const l=[...s.registers];l[c]={...l[c],type:i.target.value},a({...s,registers:l})},children:[e.jsx("option",{value:"coil",children:"Coil"}),e.jsx("option",{value:"discrete",children:"Discrete"}),e.jsx("option",{value:"holding",children:"Holding"}),e.jsx("option",{value:"input",children:"Input"})]})}),e.jsx("td",{children:e.jsxs("select",{value:n.dataType,onChange:i=>{const l=[...s.registers];l[c]={...l[c],dataType:i.target.value},a({...s,registers:l})},children:[e.jsx("option",{value:"bool",children:"Bool"}),e.jsx("option",{value:"int16",children:"Int16"}),e.jsx("option",{value:"uint16",children:"UInt16"}),e.jsx("option",{value:"int32",children:"Int32"}),e.jsx("option",{value:"uint32",children:"UInt32"}),e.jsx("option",{value:"float32",children:"Float32"})]})}),e.jsxs("td",{children:[e.jsx("input",{type:"checkbox",checked:n.readable,onChange:i=>{const l=[...s.registers];l[c]={...l[c],readable:i.target.checked},a({...s,registers:l})},title:"Readable"}),e.jsx("input",{type:"checkbox",checked:n.writable,onChange:i=>{const l=[...s.registers];l[c]={...l[c],writable:i.target.checked},a({...s,registers:l})},title:"Writable"})]}),e.jsx("td",{children:e.jsx("button",{onClick:()=>{const i=s.registers.filter((l,d)=>d!==c);a({...s,registers:i})},children:"Γ"})})]},c))})]}),e.jsx("button",{onClick:()=>{a({...s,registers:[...s.registers,{name:"",address:0,type:"holding",dataType:"uint16",readable:!0,writable:!1}]})},children:"+ Add Register"})]})}function ie({config:s,onChange:t}){return e.jsxs("div",{className:"nice-protocol-config__section",children:[e.jsx("h3",{children:"OPC-UA Configuration"}),e.jsxs("div",{className:"nice-protocol-config__grid",children:[e.jsxs("div",{className:"nice-protocol-config__field nice-protocol-config__field--full",children:[e.jsx("label",{children:"Endpoint URL"}),e.jsx("input",{type:"text",value:s.endpointUrl,onChange:a=>t({...s,endpointUrl:a.target.value}),placeholder:"opc.tcp://localhost:4840"})]}),e.jsxs("div",{className:"nice-protocol-config__field",children:[e.jsx("label",{children:"Security Mode"}),e.jsxs("select",{value:s.securityMode,onChange:a=>t({...s,securityMode:a.target.value}),children:[e.jsx("option",{value:"None",children:"None"}),e.jsx("option",{value:"Sign",children:"Sign"}),e.jsx("option",{value:"SignAndEncrypt",children:"Sign and Encrypt"})]})]}),e.jsxs("div",{className:"nice-protocol-config__field",children:[e.jsx("label",{children:"Authentication"}),e.jsxs("select",{value:s.authentication,onChange:a=>t({...s,authentication:a.target.value}),children:[e.jsx("option",{value:"anonymous",children:"Anonymous"}),e.jsx("option",{value:"username",children:"Username/Password"}),e.jsx("option",{value:"certificate",children:"Certificate"})]})]}),s.authentication==="username"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-protocol-config__field",children:[e.jsx("label",{children:"Username"}),e.jsx("input",{type:"text",value:s.username||"",onChange:a=>t({...s,username:a.target.value})})]}),e.jsxs("div",{className:"nice-protocol-config__field",children:[e.jsx("label",{children:"Password"}),e.jsx("input",{type:"password",value:s.password||"",onChange:a=>t({...s,password:a.target.value})})]})]}),e.jsxs("div",{className:"nice-protocol-config__field nice-protocol-config__field--full",children:[e.jsx("label",{children:"Application Name"}),e.jsx("input",{type:"text",value:s.applicationName,onChange:a=>t({...s,applicationName:a.target.value})})]})]}),e.jsx("h4",{children:"Nodes"}),e.jsxs("div",{className:"nice-protocol-config__nodes",children:[s.nodes.map((a,n)=>e.jsxs("div",{className:"nice-protocol-config__node-row",children:[e.jsx("input",{type:"text",value:a.nodeId,onChange:c=>{const i=[...s.nodes];i[n]={...i[n],nodeId:c.target.value},t({...s,nodes:i})},placeholder:"ns=2;s=Temperature"}),e.jsx("input",{type:"text",value:a.displayName,onChange:c=>{const i=[...s.nodes];i[n]={...i[n],displayName:c.target.value},t({...s,nodes:i})},placeholder:"Display Name"}),e.jsx("button",{onClick:()=>{const c=s.nodes.filter((i,l)=>l!==n);t({...s,nodes:c})},children:"Γ"})]},n)),e.jsx("button",{onClick:()=>{t({...s,nodes:[...s.nodes,{nodeId:"",displayName:"",dataType:"Double",read:!0}]})},children:"+ Add Node"})]})]})}exports.NiceEdgeManager=H;exports.NiceIoTDashboard=R;exports.NiceProtocolConfig=Z;
|