iobroker.agent-dvr 0.1.0 → 0.2.0
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.de.md +289 -175
- package/README.md +226 -90
- package/admin/assets/index-ulvdM37k.js +685 -0
- package/admin/i18n/de.json +3 -7
- package/admin/i18n/en.json +131 -135
- package/admin/i18n/es.json +3 -7
- package/admin/i18n/fr.json +3 -7
- package/admin/i18n/it.json +3 -7
- package/admin/i18n/nl.json +3 -7
- package/admin/i18n/pl.json +3 -7
- package/admin/i18n/pt.json +3 -7
- package/admin/i18n/ru.json +3 -7
- package/admin/i18n/uk.json +3 -7
- package/admin/i18n/zh-cn.json +3 -7
- package/admin/index_m.html +27 -0
- package/build/main.js +152 -103
- package/build/main.js.map +2 -2
- package/io-package.json +16 -17
- package/lib/web.js +52 -5
- package/package.json +1 -1
- package/www/flv.min.js +7534 -0
- package/www/index.html +382 -99
- package/admin/custom/go2rtcMapping.js +0 -169
- package/admin/jsonConfig.json +0 -822
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ioBroker jsonConfig custom component — go2rtc stream mapping table
|
|
3
|
-
* Loaded by the admin when the Dashboard tab is opened in the adapter config.
|
|
4
|
-
* Depends on: global React (provided by the admin page), props.socket (ioBroker socket).
|
|
5
|
-
*/
|
|
6
|
-
(function () {
|
|
7
|
-
'use strict';
|
|
8
|
-
|
|
9
|
-
window.customComponents = window.customComponents || {};
|
|
10
|
-
|
|
11
|
-
var e = React.createElement;
|
|
12
|
-
|
|
13
|
-
// ── Helper: normalize socket methods (Promise or callback-based) ────────
|
|
14
|
-
|
|
15
|
-
function socketGetStates(socket, pattern) {
|
|
16
|
-
try {
|
|
17
|
-
var result = socket.getStates(pattern);
|
|
18
|
-
if (result && typeof result.then === 'function') return result;
|
|
19
|
-
return new Promise(function (resolve, reject) {
|
|
20
|
-
socket.getStates(pattern, function (err, states) {
|
|
21
|
-
if (err) reject(err); else resolve(states || {});
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
} catch (ex) { return Promise.reject(ex); }
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function socketSendTo(socket, target, command, data) {
|
|
28
|
-
try {
|
|
29
|
-
var result = socket.sendTo(target, command, data);
|
|
30
|
-
if (result && typeof result.then === 'function') return result;
|
|
31
|
-
return new Promise(function (resolve) {
|
|
32
|
-
socket.sendTo(target, command, data, function (res) { resolve(res); });
|
|
33
|
-
});
|
|
34
|
-
} catch (ex) { return Promise.resolve(null); }
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// ── Component ───────────────────────────────────────────────────────────
|
|
38
|
-
|
|
39
|
-
function Go2rtcMapping(props) {
|
|
40
|
-
var useState = React.useState;
|
|
41
|
-
var useEffect = React.useEffect;
|
|
42
|
-
var useMemo = React.useMemo;
|
|
43
|
-
|
|
44
|
-
var _cameras = useState(null); // null = loading
|
|
45
|
-
var cameras = _cameras[0]; var setCameras = _cameras[1];
|
|
46
|
-
var _streams = useState([]);
|
|
47
|
-
var streams = _streams[0]; var setStreams = _streams[1];
|
|
48
|
-
var _error = useState(null);
|
|
49
|
-
var error = _error[0]; var setError = _error[1];
|
|
50
|
-
|
|
51
|
-
var instanceStr = 'agent-dvr.' + (props.instance !== undefined ? String(props.instance) : '0');
|
|
52
|
-
|
|
53
|
-
// Parse current mapping from data
|
|
54
|
-
var mapping = useMemo(function () {
|
|
55
|
-
try {
|
|
56
|
-
var raw = props.data && props.data.go2rtcMapping;
|
|
57
|
-
return raw ? JSON.parse(raw) : {};
|
|
58
|
-
} catch (_) { return {}; }
|
|
59
|
-
}, [props.data && props.data.go2rtcMapping]);
|
|
60
|
-
|
|
61
|
-
useEffect(function () {
|
|
62
|
-
if (!props.socket) { setCameras([]); return; }
|
|
63
|
-
|
|
64
|
-
// Fetch cameras from ioBroker states + go2rtc streams via sendTo in parallel
|
|
65
|
-
Promise.all([
|
|
66
|
-
socketGetStates(props.socket, instanceStr + '.cam_*.name'),
|
|
67
|
-
socketSendTo(props.socket, instanceStr, 'getGo2rtcStreams', null),
|
|
68
|
-
]).then(function (results) {
|
|
69
|
-
var states = results[0] || {};
|
|
70
|
-
var g2result = results[1];
|
|
71
|
-
|
|
72
|
-
// Build camera list from states: id pattern = agent-dvr.0.cam_xxx.name
|
|
73
|
-
var cams = [];
|
|
74
|
-
Object.entries(states).forEach(function (entry) {
|
|
75
|
-
var id = entry[0];
|
|
76
|
-
var state = entry[1];
|
|
77
|
-
var match = id.match(/\.(cam_[^.]+)\.name$/);
|
|
78
|
-
if (match && state && state.val != null) {
|
|
79
|
-
cams.push({ key: match[1], name: String(state.val) });
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
cams.sort(function (a, b) { return a.name.localeCompare(b.name); });
|
|
83
|
-
setCameras(cams);
|
|
84
|
-
|
|
85
|
-
var strs = (g2result && Array.isArray(g2result.streams)) ? g2result.streams : [];
|
|
86
|
-
setStreams(strs);
|
|
87
|
-
}).catch(function (err) {
|
|
88
|
-
setError(String(err && err.message ? err.message : err));
|
|
89
|
-
setCameras([]);
|
|
90
|
-
});
|
|
91
|
-
}, [instanceStr]);
|
|
92
|
-
|
|
93
|
-
function updateMapping(camKey, streamName) {
|
|
94
|
-
var newMapping = Object.assign({}, mapping);
|
|
95
|
-
if (streamName) {
|
|
96
|
-
newMapping[camKey] = streamName;
|
|
97
|
-
} else {
|
|
98
|
-
delete newMapping[camKey];
|
|
99
|
-
}
|
|
100
|
-
if (props.onChange) props.onChange('go2rtcMapping', JSON.stringify(newMapping));
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// Don't render if go2rtcEnabled is false
|
|
104
|
-
if (!props.data || !props.data.go2rtcEnabled) return null;
|
|
105
|
-
|
|
106
|
-
if (cameras === null) {
|
|
107
|
-
return e('div', { style: { color: '#888', fontSize: '13px', padding: '6px 0' } },
|
|
108
|
-
'Lade Kamera- und Stream-Liste…');
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (error) {
|
|
112
|
-
return e('div', { style: { color: '#ef4444', fontSize: '13px', padding: '6px 0' } },
|
|
113
|
-
'Fehler: ' + error);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
var isDark = props.themeType === 'dark';
|
|
117
|
-
var borderColor = isDark ? 'rgba(255,255,255,0.1)' : 'rgba(0,0,0,0.1)';
|
|
118
|
-
var mutedColor = isDark ? 'rgba(255,255,255,0.5)' : 'rgba(0,0,0,0.5)';
|
|
119
|
-
|
|
120
|
-
var headerStyle = {
|
|
121
|
-
textAlign: 'left', padding: '5px 10px',
|
|
122
|
-
fontSize: '12px', color: mutedColor, fontWeight: 600,
|
|
123
|
-
borderBottom: '1px solid ' + borderColor,
|
|
124
|
-
};
|
|
125
|
-
var cellStyle = { padding: '6px 10px', fontSize: '13px', verticalAlign: 'middle' };
|
|
126
|
-
var selectStyle = {
|
|
127
|
-
background: 'transparent', border: '1px solid ' + borderColor,
|
|
128
|
-
color: 'inherit', padding: '4px 8px', borderRadius: '4px',
|
|
129
|
-
fontSize: '13px', minWidth: '180px', cursor: 'pointer',
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
var rows = (cameras || []).map(function (cam) {
|
|
133
|
-
var currentStream = (typeof mapping[cam.key] === 'string') ? mapping[cam.key] : '';
|
|
134
|
-
return e('tr', { key: cam.key, style: { borderBottom: '1px solid ' + borderColor } },
|
|
135
|
-
e('td', { style: cellStyle }, cam.name),
|
|
136
|
-
e('td', { style: cellStyle },
|
|
137
|
-
e('select', {
|
|
138
|
-
value: currentStream,
|
|
139
|
-
onChange: function (ev) { updateMapping(cam.key, ev.target.value); },
|
|
140
|
-
style: selectStyle,
|
|
141
|
-
},
|
|
142
|
-
e('option', { value: '' }, '— MJPEG / Snapshot —'),
|
|
143
|
-
streams.map(function (s) { return e('option', { key: s, value: s }, s); })
|
|
144
|
-
)
|
|
145
|
-
)
|
|
146
|
-
);
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
return e('div', { style: { width: '100%', marginTop: '4px' } },
|
|
150
|
-
streams.length === 0 && e('div', {
|
|
151
|
-
style: { color: '#f97316', fontSize: '12px', marginBottom: '8px' }
|
|
152
|
-
}, '⚠ Keine go2rtc-Streams gefunden — go2rtc-URL prüfen und Adapter neu starten.'),
|
|
153
|
-
!cameras.length && e('div', {
|
|
154
|
-
style: { color: mutedColor, fontSize: '12px' }
|
|
155
|
-
}, 'Keine Kameras in ioBroker gefunden — Adapter konfiguriert und gestartet?'),
|
|
156
|
-
cameras.length > 0 && e('table', { style: { borderCollapse: 'collapse', width: '100%' } },
|
|
157
|
-
e('thead', null,
|
|
158
|
-
e('tr', null,
|
|
159
|
-
e('th', { style: headerStyle }, 'AgentDVR-Kamera'),
|
|
160
|
-
e('th', { style: headerStyle }, 'go2rtc Stream')
|
|
161
|
-
)
|
|
162
|
-
),
|
|
163
|
-
e('tbody', null, rows)
|
|
164
|
-
)
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
window.customComponents['Go2rtcMapping'] = Go2rtcMapping;
|
|
169
|
-
})();
|