iobroker.ring 1.2.8 → 3.0.0-beta.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.
- package/LICENSE +6 -6
- package/README.md +72 -21
- package/admin/admin.d.ts +93 -0
- package/admin/index_m.html +124 -207
- package/admin/style.css +32 -0
- package/admin/words.js +189 -208
- package/build/lib/constants.js +253 -0
- package/build/lib/constants.js.map +1 -0
- package/build/lib/lastAction.js +11 -0
- package/build/lib/lastAction.js.map +1 -0
- package/build/lib/ownRingDevice.js +410 -0
- package/build/lib/ownRingDevice.js.map +1 -0
- package/build/lib/ringApiClient.js +109 -0
- package/build/lib/ringApiClient.js.map +1 -0
- package/build/lib/services/file-service.js +50 -0
- package/build/lib/services/file-service.js.map +1 -0
- package/build/lib/tools.js +99 -0
- package/build/lib/tools.js.map +1 -0
- package/build/main.js +249 -0
- package/build/main.js.map +1 -0
- package/io-package.json +249 -251
- package/package.json +68 -41
- package/.eslintignore +0 -5
- package/.eslintrc.js +0 -39
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -33
- package/.github/dependabot.yml +0 -8
- package/.github/tsconfig.check.json +0 -15
- package/.github/tsconfig.json +0 -39
- package/.github/workflows/test-and-release.yml +0 -143
- package/.github/workflows/test-only.yml +0 -75
- package/docs/ring_admin_tab1.png +0 -0
- package/docs/ring_admin_tab2.png +0 -0
- package/docs/ring_objects.png +0 -0
- package/lib/datapoints.js +0 -344
- package/lib/ringapiclient.js +0 -436
- package/ring.js +0 -883
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2022 Thorsten Stueben <thorsten@stueben.de>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
9
9
|
copies of the Software, and to permit persons to whom the Software is
|
|
10
10
|
furnished to do so, subject to the following conditions:
|
|
11
11
|
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
14
|
|
|
15
15
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
16
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
17
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
|
|
10
10
|
[](https://nodei.co/npm/iobroker.ring/)
|
|
11
11
|
|
|
12
|
-
Requires
|
|
12
|
+
Requires Admin v4 and recommends ``node 16.x``.
|
|
13
13
|
|
|
14
|
-
The Ring adapter works with Ring devices like the Ring Video Doorbell and Ring Cam and shows if somenone rings the doorbell or if motion is detected. The Ring Video Doorbell or Cam sends a videostream if a motion or doorbell ist detected or you use the SIP Information for a SIP Video Conference with your SIP client.
|
|
15
|
-
Unfortunately the snapshot and livestream function does not work properly. Unfortunately I have no influence on it. Please consider this before you create an issue.
|
|
16
|
-
The adapter will not provide all ring devices because the used API do not includes all ring devices.
|
|
14
|
+
The Ring adapter works with Ring devices like the Ring Video Doorbell and Ring Cam and shows if somenone rings the doorbell or if motion is detected. The Ring Video Doorbell or Cam sends a videostream if a motion or doorbell ist detected or you use the SIP Information for a SIP Video Conference with your SIP client.
|
|
15
|
+
Unfortunately the snapshot and livestream function does not work properly. Unfortunately I have no influence on it. Please consider this before you create an issue.
|
|
16
|
+
The adapter will not provide all ring devices because the used API do not includes all ring devices.
|
|
17
17
|
|
|
18
18
|
You can use for example the Blink SIP client on [http://icanblink.com/](http://icanblink.com/). To get video working go into Blink's Preferences and under "Accounts", switch the tab to "Media" and deselect "Encrypt audio and video" under "RTP Options". Be careful the SIP information expire after a few seconds!
|
|
19
|
-
Hopefully I will able to support a video stream soon. Unfortunatly [ring.com](https://ring.com) does not have an official API that support this feature.
|
|
20
|
-
If you press the livestreamrequest button you get new SIP Information for building up a SIP Video Call session. If you are using the [ring.com](https://ring.com) cloud you find under history a http link to your last motion / door bell recorded video.
|
|
19
|
+
Hopefully I will able to support a video stream soon. Unfortunatly [ring.com](https://ring.com) does not have an official API that support this feature.
|
|
20
|
+
If you press the livestreamrequest button you get new SIP Information for building up a SIP Video Call session. If you are using the [ring.com](https://ring.com) cloud you find under history a http link to your last motion / door bell recorded video.
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
## Install & Configuration
|
|
@@ -53,20 +53,34 @@ You can use special variables for your livestream and snapshort path and filenam
|
|
|
53
53
|
|
|
54
54
|
## Example
|
|
55
55
|
|
|
56
|
-
An example to get changes if a motion or door ring is detected:
|
|
56
|
+
An example to get changes if a motion or door ring is detected:
|
|
57
57
|
```
|
|
58
58
|
on({id: "ring.0.doorbell_4711.kind"/*Kind*/}, (obj) => {
|
|
59
59
|
if(obj.state.val == 'ding') console.log("Someone is at the door");
|
|
60
60
|
if(obj.state.val == 'motion') console.log("Motion detected");
|
|
61
61
|
});
|
|
62
62
|
```
|
|
63
|
-
|
|
64
63
|
## Changelog
|
|
65
|
-
|
|
66
64
|
<!--
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
Placeholder for the next version (at the beginning of the line):
|
|
66
|
+
### **WORK IN PROGRESS**
|
|
69
67
|
-->
|
|
68
|
+
### 3.0.0-beta.4 (2022-05-14)
|
|
69
|
+
* (theimo1221) Changes in io-package.json for release workflow
|
|
70
|
+
|
|
71
|
+
### 3.0.0-beta.3 (2022-05-14)
|
|
72
|
+
* (theimo1221) Rewrite V3 (Breaking Changes listed below)
|
|
73
|
+
* (theimo1221) Update packages
|
|
74
|
+
* (theimo1221) Fix in github release workflow
|
|
75
|
+
|
|
76
|
+
### 2.0.0-beta.3 (2022-02-08)
|
|
77
|
+
* (theimo1221) Fix adapter checker issues
|
|
78
|
+
|
|
79
|
+
### 2.0.0-beta.0 (2022-02-05)
|
|
80
|
+
* (theimo1221) Update packages
|
|
81
|
+
* (theimo1221) Add JS-Controller 4.0 dependency
|
|
82
|
+
* (theimo1221) On ding --> First take snapshot then livestream
|
|
83
|
+
|
|
70
84
|
### 1.2.8 (2021-10-14)
|
|
71
85
|
* (theimo1221) Update packages
|
|
72
86
|
|
|
@@ -117,7 +131,7 @@ on({id: "ring.0.doorbell_4711.kind"/*Kind*/}, (obj) => {
|
|
|
117
131
|
* (Stübi) Fixed error of missing objects
|
|
118
132
|
|
|
119
133
|
### 1.1.2 (02.05.2020)
|
|
120
|
-
* (Stübi) Fixed health info like missing battery status (Issue #22, Issue #25)
|
|
134
|
+
* (Stübi) Fixed health info like missing battery status (Issue #22, Issue #25)
|
|
121
135
|
* (Stübi) Change error handling
|
|
122
136
|
* (Stübi) Providing Stick Up Cam (BETA)
|
|
123
137
|
* (Stübi) Using variables in the filename of the livestream or snapshot
|
|
@@ -128,12 +142,12 @@ on({id: "ring.0.doorbell_4711.kind"/*Kind*/}, (obj) => {
|
|
|
128
142
|
|
|
129
143
|
### 1.1.0 (01.05.2020)
|
|
130
144
|
* (Stübi) Node 10 is now required, Node 12 recommended. If you use Node 8 or less, the adapter will stop immediately.
|
|
131
|
-
* (Stübi) Tested with js-controller 3. I recommend using js-controller 3 or higher because of sentry logging and more features in the future
|
|
145
|
+
* (Stübi) Tested with js-controller 3. I recommend using js-controller 3 or higher because of sentry logging and more features in the future
|
|
132
146
|
* (Stübi) Snapshot link will be shown as https or http in state (Issue #18)
|
|
133
147
|
* (Stübi) Livestream link added and a request button added to get new livestream
|
|
134
148
|
* (Stübi) Old snapshots and livestreams can be deleted on the filesystem
|
|
135
149
|
* (Stübi) Sentry logging added
|
|
136
|
-
* (Stübi) Small improvements and bugfixing
|
|
150
|
+
* (Stübi) Small improvements and bugfixing
|
|
137
151
|
* (Stübi) Add a Two-Factor Auth (2fa) description (Issue #14, Issue #13, Issue #19)
|
|
138
152
|
|
|
139
153
|
### 1.0.7 (24.12.2019)
|
|
@@ -144,7 +158,7 @@ on({id: "ring.0.doorbell_4711.kind"/*Kind*/}, (obj) => {
|
|
|
144
158
|
* (Stübi) New feature (BETA): Now you can make snapshots in jpg and a livestream in mp4 format. Unfortunately the snapshot / livestream does not work always!
|
|
145
159
|
|
|
146
160
|
### 1.0.5 (18.04.2019)
|
|
147
|
-
* (Stübi) Bugfixing
|
|
161
|
+
* (Stübi) Bugfixing
|
|
148
162
|
* (Stübi) Using new API. With this API livestreaming and snapshots are possible (work still in progress and not supported in this version)
|
|
149
163
|
* (Stübi) Fixed an error with js-controller 2.0. You need at least this version with js-controller 2.0
|
|
150
164
|
* (Stübi) two face authentication
|
|
@@ -176,10 +190,47 @@ on({id: "ring.0.doorbell_4711.kind"/*Kind*/}, (obj) => {
|
|
|
176
190
|
### 0.1.0 (14.12.2018)
|
|
177
191
|
* (Stübi) First Version
|
|
178
192
|
|
|
193
|
+
### V3 Rewrite Breaking Changes
|
|
194
|
+
1. The Device Names got extended by their description (e.g. from `Device 1234567` to `Device 1234567 ("Floodlight Garden")`)
|
|
195
|
+
2. Snapshot/Livestream Data is now in a respective channel, containing the other data points.
|
|
196
|
+
3. The snapshot/livestream object got changed from type meta to state with type file.
|
|
197
|
+
4. Events (Motion, Ding, etc.) are now in a respective channel.
|
|
198
|
+
5. Due to `ring-api` dropping the support for node before `v16.x` this adapter recommends `node v16.x`
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
### Scripts in `package.json`
|
|
202
|
+
Several npm scripts are predefined for your convenience. You can run them using `npm run <scriptname>`
|
|
203
|
+
| Script name | Description |
|
|
204
|
+
|-------------|-------------|
|
|
205
|
+
| `build:ts` | Compile the TypeScript sources. |
|
|
206
|
+
| `watch:ts` | Compile the TypeScript sources and watch for changes. |
|
|
207
|
+
| `watch` | Shortcut for `npm run watch:ts` |
|
|
208
|
+
| `test:ts` | Executes the tests you defined in `*.test.ts` files. |
|
|
209
|
+
| `test:package` | Ensures your `package.json` and `io-package.json` are valid. |
|
|
210
|
+
| `test:unit` | Tests the adapter startup with unit tests (fast, but might require module mocks to work). |
|
|
211
|
+
| `test:integration` | Tests the adapter startup with an actual instance of ioBroker. |
|
|
212
|
+
| `test` | Performs a minimal test run on package files and your tests. |
|
|
213
|
+
| `check` | Performs a type-check on your code (without compiling anything). |
|
|
214
|
+
| `coverage` | Generates code coverage using your test files. |
|
|
215
|
+
| `lint` | Runs `ESLint` to check your code for formatting errors and potential bugs. |
|
|
216
|
+
| `release` | Creates a new release, see [`@alcalzone/release-script`](https://github.com/AlCalzone/release-script#usage) for more details. |
|
|
217
|
+
|
|
218
|
+
### Writing tests
|
|
219
|
+
When done right, testing code is invaluable, because it gives you the
|
|
220
|
+
confidence to change your code while knowing exactly if and when
|
|
221
|
+
something breaks. A good read on the topic of test-driven development
|
|
222
|
+
is https://hackernoon.com/introduction-to-test-driven-development-tdd-61a13bc92d92.
|
|
223
|
+
Although writing tests before the code might seem strange at first, but it has very
|
|
224
|
+
clear upsides.
|
|
225
|
+
|
|
226
|
+
The template provides you with basic tests for the adapter startup and package files.
|
|
227
|
+
It is recommended that you add your own tests into the mix.
|
|
228
|
+
|
|
229
|
+
|
|
179
230
|
## License
|
|
180
|
-
|
|
231
|
+
MIT License
|
|
181
232
|
|
|
182
|
-
Copyright (c)
|
|
233
|
+
Copyright (c) 2022 Thorsten <thorsten@stueben.de> / <https://github.com/schmupu>
|
|
183
234
|
|
|
184
235
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
185
236
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -188,13 +239,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
188
239
|
copies of the Software, and to permit persons to whom the Software is
|
|
189
240
|
furnished to do so, subject to the following conditions:
|
|
190
241
|
|
|
191
|
-
The above copyright notice and this permission notice shall be included in
|
|
192
|
-
|
|
242
|
+
The above copyright notice and this permission notice shall be included in all
|
|
243
|
+
copies or substantial portions of the Software.
|
|
193
244
|
|
|
194
245
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
195
246
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
196
247
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
197
248
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
198
249
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
199
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
200
|
-
|
|
250
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
251
|
+
SOFTWARE.
|
package/admin/admin.d.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
declare let systemDictionary: Record<string, Record<string, string>>;
|
|
2
|
+
|
|
3
|
+
declare let load: (settings: Record<string, unknown>, onChange: (hasChanges: boolean) => void) => void;
|
|
4
|
+
declare let save: (callback: (settings: Record<string, unknown>) => void) => void;
|
|
5
|
+
|
|
6
|
+
// make load and save exist on the window object
|
|
7
|
+
interface Window {
|
|
8
|
+
load: typeof load;
|
|
9
|
+
save: typeof save;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare const instance: number;
|
|
13
|
+
declare const adapter: string;
|
|
14
|
+
/** Translates text */
|
|
15
|
+
declare function _(text: string, arg1?: string, arg2?: string, arg3?: string): string;
|
|
16
|
+
declare const socket: ioBrokerSocket;
|
|
17
|
+
declare function sendTo(
|
|
18
|
+
instance: any | null,
|
|
19
|
+
command: string,
|
|
20
|
+
message: any,
|
|
21
|
+
callback: (result: SendToResult) => void | Promise<void>,
|
|
22
|
+
): void;
|
|
23
|
+
|
|
24
|
+
interface SendToResult {
|
|
25
|
+
error?: string | Error;
|
|
26
|
+
result?: any;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// tslint:disable-next-line:class-name
|
|
30
|
+
interface ioBrokerSocket {
|
|
31
|
+
emit(
|
|
32
|
+
command: "subscribeObjects",
|
|
33
|
+
pattern: string,
|
|
34
|
+
callback?: (err?: string) => void | Promise<void>,
|
|
35
|
+
): void;
|
|
36
|
+
emit(
|
|
37
|
+
command: "subscribeStates",
|
|
38
|
+
pattern: string,
|
|
39
|
+
callback?: (err?: string) => void | Promise<void>,
|
|
40
|
+
): void;
|
|
41
|
+
emit(
|
|
42
|
+
command: "unsubscribeObjects",
|
|
43
|
+
pattern: string,
|
|
44
|
+
callback?: (err?: string) => void | Promise<void>,
|
|
45
|
+
): void;
|
|
46
|
+
emit(
|
|
47
|
+
command: "unsubscribeStates",
|
|
48
|
+
pattern: string,
|
|
49
|
+
callback?: (err?: string) => void | Promise<void>,
|
|
50
|
+
): void;
|
|
51
|
+
|
|
52
|
+
emit(
|
|
53
|
+
event: "getObjectView",
|
|
54
|
+
view: "system",
|
|
55
|
+
type: "device",
|
|
56
|
+
options: ioBroker.GetObjectViewParams,
|
|
57
|
+
callback: (
|
|
58
|
+
err: string | undefined,
|
|
59
|
+
result?: any,
|
|
60
|
+
) => void | Promise<void>,
|
|
61
|
+
): void;
|
|
62
|
+
emit(
|
|
63
|
+
event: "getStates",
|
|
64
|
+
callback: (
|
|
65
|
+
err: string | undefined,
|
|
66
|
+
result?: Record<string, any>,
|
|
67
|
+
) => void,
|
|
68
|
+
): void;
|
|
69
|
+
emit(
|
|
70
|
+
event: "getState",
|
|
71
|
+
id: string,
|
|
72
|
+
callback: (err: string | undefined, result?: ioBroker.State) => void,
|
|
73
|
+
): void;
|
|
74
|
+
emit(
|
|
75
|
+
event: "setState",
|
|
76
|
+
id: string,
|
|
77
|
+
state: unknown,
|
|
78
|
+
callback: (err: string | undefined, result?: any) => void,
|
|
79
|
+
): void;
|
|
80
|
+
|
|
81
|
+
on(event: "objectChange", handler: ioBroker.ObjectChangeHandler): void;
|
|
82
|
+
on(event: "stateChange", handler: ioBroker.StateChangeHandler): void;
|
|
83
|
+
removeEventHandler(
|
|
84
|
+
event: "objectChange",
|
|
85
|
+
handler: ioBroker.ObjectChangeHandler,
|
|
86
|
+
): void;
|
|
87
|
+
removeEventHandler(
|
|
88
|
+
event: "stateChange",
|
|
89
|
+
handler: ioBroker.StateChangeHandler,
|
|
90
|
+
): void;
|
|
91
|
+
|
|
92
|
+
// TODO: other events
|
|
93
|
+
}
|
package/admin/index_m.html
CHANGED
|
@@ -1,252 +1,169 @@
|
|
|
1
1
|
<html>
|
|
2
2
|
|
|
3
3
|
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<!-- Materialze style -->
|
|
6
|
-
<link rel="stylesheet" type="text/css" href="../../css/adapter.css" />
|
|
7
|
-
<link rel="stylesheet" type="text/css" href="../../lib/css/materialize.css">
|
|
8
|
-
|
|
9
|
-
<script type="text/javascript" src="../../lib/js/jquery-3.2.1.min.js"></script>
|
|
10
|
-
<script type="text/javascript" src="../../socket.io/socket.io.js"></script>
|
|
11
|
-
|
|
12
|
-
<script type="text/javascript" src="../../js/translate.js"></script>
|
|
13
|
-
<script type="text/javascript" src="../../lib/js/materialize.js"></script>
|
|
14
|
-
<script type="text/javascript" src="../../js/adapter-settings.js"></script>
|
|
15
|
-
<script type="text/javascript" src="words.js"></script>
|
|
16
|
-
|
|
17
|
-
<!-- you have to define 2 functions in the global scope: -->
|
|
18
|
-
<script type="text/javascript">
|
|
19
|
-
var convertComma = null;
|
|
20
|
-
var secret = null;
|
|
21
|
-
|
|
22
|
-
function encrypt(key, value) {
|
|
23
|
-
var result = '';
|
|
24
|
-
for (var i = 0; i < value.length; ++i) {
|
|
25
|
-
result += String.fromCharCode(key[i % key.length].charCodeAt(0) ^ value.charCodeAt(i));
|
|
26
|
-
}
|
|
27
|
-
return result;
|
|
28
|
-
}
|
|
29
4
|
|
|
30
|
-
|
|
5
|
+
<!-- Load ioBroker scripts and styles-->
|
|
6
|
+
<link rel="stylesheet" type="text/css" href="../../css/adapter.css"/>
|
|
7
|
+
<link rel="stylesheet" type="text/css" href="../../lib/css/materialize.css">
|
|
31
8
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
result += String.fromCharCode(key[i % key.length].charCodeAt(0) ^ value.charCodeAt(i));
|
|
35
|
-
}
|
|
36
|
-
return result;
|
|
37
|
-
}
|
|
9
|
+
<script type="text/javascript" src="../../lib/js/jquery-3.2.1.min.js"></script>
|
|
10
|
+
<script type="text/javascript" src="../../socket.io/socket.io.js"></script>
|
|
38
11
|
|
|
39
|
-
|
|
12
|
+
<script type="text/javascript" src="../../js/translate.js"></script>
|
|
13
|
+
<script type="text/javascript" src="../../lib/js/materialize.js"></script>
|
|
14
|
+
<script type="text/javascript" src="../../js/adapter-settings.js"></script>
|
|
40
15
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
16
|
+
<!-- Load our own files -->
|
|
17
|
+
<link rel="stylesheet" type="text/css" href="style.css"/>
|
|
18
|
+
<script type="text/javascript" src="words.js"></script>
|
|
45
19
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
onChange();
|
|
49
|
-
});
|
|
50
|
-
} else {
|
|
51
|
-
$value.val(value).on('change', function () {
|
|
52
|
-
onChange();
|
|
53
|
-
}).keyup(function () {
|
|
54
|
-
// Check that only numbers entered
|
|
55
|
-
if ($(this).hasClass('number')) {
|
|
56
|
-
var val = $(this).val();
|
|
57
|
-
if (val) {
|
|
58
|
-
var newVal = '';
|
|
59
|
-
for (var i = 0; i < val.length; i++) {
|
|
60
|
-
if ((val[i] >= '0' && val[i] <= '9') || val[i] === '-' || val[i] === '+' || val[i] === '.' || val[i] === ',') {
|
|
61
|
-
if (val[i] === '.' && convertComma === true) val[i] = ',';
|
|
62
|
-
if (val[i] === ',' && convertComma === false) val[i] = '.';
|
|
63
|
-
newVal += val[i];
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (val != newVal) {
|
|
68
|
-
$(this).val(newVal);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
$(this).trigger('change');
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function load(settings, onChange) {
|
|
78
|
-
|
|
79
|
-
// works only with newest admin adapter
|
|
80
|
-
if (typeof systemConfig !== 'undefined') {
|
|
81
|
-
convertComma = systemConfig.common.isFloatComma;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (settings.saveLastValue === undefined) {
|
|
85
|
-
settings.saveLastValue = false;
|
|
86
|
-
}
|
|
87
|
-
if (settings.writeNulls === undefined) settings.writeNulls = true;
|
|
20
|
+
<script type="text/javascript">
|
|
21
|
+
var secret = null;
|
|
88
22
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
setValue(key, settings[key], onChange);
|
|
23
|
+
function encrypt(key, value) {
|
|
24
|
+
var result = '';
|
|
25
|
+
for (var i = 0; i < value.length; ++i) {
|
|
26
|
+
result += String.fromCharCode(key[i % key.length].charCodeAt(0) ^ value.charCodeAt(i));
|
|
94
27
|
}
|
|
28
|
+
return result;
|
|
95
29
|
}
|
|
96
30
|
|
|
31
|
+
function decrypt(key, value) {
|
|
97
32
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
function save(callback) {
|
|
103
|
-
var settings = {};
|
|
104
|
-
$('.value').each(function () {
|
|
105
|
-
var $this = $(this);
|
|
106
|
-
var id = $this.attr('id');
|
|
107
|
-
|
|
108
|
-
if ($this.attr('type') === 'checkbox') {
|
|
109
|
-
settings[id] = $this.prop('checked');
|
|
110
|
-
} else {
|
|
111
|
-
settings[id] = $this.data('crypt') && $this.val() ? encrypt(secret, $this.val()) : $this.val();
|
|
33
|
+
var result = '';
|
|
34
|
+
for (var i = 0; i < value.length; ++i) {
|
|
35
|
+
result += String.fromCharCode(key[i % key.length].charCodeAt(0) ^ value.charCodeAt(i));
|
|
112
36
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
/*
|
|
116
|
-
if ($('#password').val() !== $('#password_confirm').val()) {
|
|
117
|
-
showMessage(_('Password confirmation is not equal with password'));
|
|
118
|
-
return;
|
|
37
|
+
return result;
|
|
119
38
|
}
|
|
120
|
-
*/
|
|
121
|
-
|
|
122
39
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
40
|
+
// This will be called by the admin adapter when the settings page loads
|
|
41
|
+
function load(settings, onChange) {
|
|
42
|
+
// example: select elements with id=key and class=value and insert value
|
|
43
|
+
if (!settings) return;
|
|
44
|
+
secret = (systemConfig.native ? systemConfig.native.secret : '') || 'Zgfr56gFe87jJOM';
|
|
45
|
+
|
|
46
|
+
$('.value').each(function () {
|
|
47
|
+
var $key = $(this);
|
|
48
|
+
var id = $key.attr('id');
|
|
49
|
+
if ($key.attr('type') === 'checkbox') {
|
|
50
|
+
// do not call onChange direct, because onChange could expect some arguments
|
|
51
|
+
$key.prop('checked', settings[id])
|
|
52
|
+
.on('change', () => onChange())
|
|
53
|
+
;
|
|
54
|
+
} else {
|
|
55
|
+
var value = settings[id];
|
|
56
|
+
if (value && $key.attr('data-crypt') == "1") {
|
|
57
|
+
value = decrypt(secret, value);
|
|
58
|
+
}
|
|
59
|
+
// do not call onChange direct, because onChange could expect some arguments
|
|
60
|
+
$key.val(value)
|
|
61
|
+
.on('change', () => onChange())
|
|
62
|
+
.on('keyup', () => onChange())
|
|
63
|
+
;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
onChange(false);
|
|
67
|
+
// reinitialize all the Materialize labels on the page if you are dynamically adding inputs:
|
|
68
|
+
if (M) M.updateTextFields();
|
|
69
|
+
}
|
|
130
70
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
71
|
+
// This will be called by the admin adapter when the user presses the save button
|
|
72
|
+
function save(callback) {
|
|
73
|
+
// example: select elements with class=value and build settings object
|
|
74
|
+
var obj = {};
|
|
75
|
+
$('.value').each(function () {
|
|
76
|
+
var $this = $(this);
|
|
77
|
+
if ($this.attr('type') === 'checkbox') {
|
|
78
|
+
obj[$this.attr('id')] = $this.prop('checked');
|
|
79
|
+
} else if ($this.attr('type') === 'number') {
|
|
80
|
+
obj[$this.attr('id')] = parseFloat($this.val());
|
|
81
|
+
} else {
|
|
82
|
+
obj[$this.attr('id')] = $this.data('crypt') && $this.val() ? encrypt(secret, $this.val()) : $this.val();
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
callback(obj);
|
|
86
|
+
}
|
|
87
|
+
</script>
|
|
134
88
|
|
|
135
|
-
.marg {
|
|
136
|
-
margin-top: 5em;
|
|
137
|
-
}
|
|
138
|
-
</style>
|
|
139
89
|
</head>
|
|
140
90
|
|
|
141
91
|
<body>
|
|
142
|
-
<!-- you have to put your config page in a div with id adapter-container -->
|
|
143
|
-
<div class="m adapter-container">
|
|
144
|
-
|
|
145
|
-
<div class="row">
|
|
146
|
-
<div class="col s12">
|
|
147
|
-
<ul class="tabs">
|
|
148
|
-
<li class="tab col s2"><a href="#tab-login" class="translate active">Login</a></li>
|
|
149
|
-
<li class="tab col s2"><a href="#tab-snapshot" class="translate active">Snapshot</a></li>
|
|
150
|
-
</ul>
|
|
151
|
-
</div>
|
|
152
|
-
|
|
153
|
-
<div id="tab-login" class="col s12 page">
|
|
154
92
|
|
|
93
|
+
<div class="m adapter-container">
|
|
155
94
|
|
|
156
|
-
|
|
157
|
-
|
|
95
|
+
<div class="row">
|
|
96
|
+
<div class="input-field col s6">
|
|
158
97
|
<img src="ring.png" class="logo">
|
|
159
|
-
</div>
|
|
160
|
-
</div>
|
|
161
|
-
|
|
162
|
-
<!-- div class="row">
|
|
163
|
-
<div class="input-field col s8 m8 l3">
|
|
164
|
-
<select id="api" class="value">
|
|
165
|
-
<option value="ring-api-client">ring-api-client</option>
|
|
166
|
-
<option value="ring-api">ring-api</option>
|
|
167
|
-
<option value="doorbot">doorbot</option>
|
|
168
|
-
</select>
|
|
169
|
-
<label class="translate" for="api">API</label>
|
|
170
|
-
</div>
|
|
171
|
-
</div -->
|
|
172
|
-
|
|
173
|
-
<div class="row">
|
|
174
|
-
<div class="col s12">
|
|
175
|
-
<p class="translate">ringdescription</p>
|
|
176
|
-
</div>
|
|
177
|
-
</div>
|
|
178
|
-
|
|
179
|
-
<div class="row">
|
|
180
|
-
<div class="input-field col s12 m6 l4">
|
|
181
|
-
<input id="email" type="text" size="30" class="value" />
|
|
182
|
-
<label class="translate" for="email">Email</label>
|
|
183
|
-
</div>
|
|
184
98
|
</div>
|
|
99
|
+
</div>
|
|
185
100
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
<
|
|
189
|
-
|
|
190
|
-
|
|
101
|
+
<div class="row">
|
|
102
|
+
<div class="col s12">
|
|
103
|
+
<ul class="tabs">
|
|
104
|
+
<li class="tab col s2"><a href="#tab-login" class="translate active">Login</a></li>
|
|
105
|
+
<li class="tab col s2"><a href="#tab-snapshot" class="translate active">Snapshot</a></li>
|
|
106
|
+
</ul>
|
|
191
107
|
</div>
|
|
192
|
-
|
|
108
|
+
</div>
|
|
109
|
+
<div id="tab-login" class="col s12 page">
|
|
193
110
|
<div class="row">
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
</div -->
|
|
198
|
-
<div class="input-field col s12 m6 l16">
|
|
199
|
-
<input id="refreshtoken" type="text" size="30" class="value" />
|
|
200
|
-
<label class="translate" for="refreshtoken">Refreshtoken (Two Face Auth)</label>
|
|
201
|
-
</div>
|
|
111
|
+
<div class="col s12">
|
|
112
|
+
<p class="translate">ringdescription</p>
|
|
113
|
+
</div>
|
|
202
114
|
</div>
|
|
203
115
|
|
|
204
116
|
<div class="row">
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
117
|
+
<!-- div class="input-field col s12">
|
|
118
|
+
<input class="value" id="twofaceauth" type="checkbox" />
|
|
119
|
+
<label for="twofaceauth" class="translate">Set two face auth (once)</label>
|
|
120
|
+
</div -->
|
|
121
|
+
<div class="input-field col s12 m6 l16">
|
|
122
|
+
<input id="refreshtoken" type="text" size="30" class="value"/>
|
|
123
|
+
<label class="translate" for="refreshtoken">Refreshtoken (Two Face Auth)</label>
|
|
124
|
+
</div>
|
|
209
125
|
</div>
|
|
210
126
|
|
|
211
|
-
|
|
127
|
+
</div>
|
|
212
128
|
|
|
213
|
-
|
|
129
|
+
<div id="tab-snapshot" class="col s12 page">
|
|
214
130
|
<div class="row">
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
</div>
|
|
219
|
-
<div class="row">
|
|
220
|
-
<div class="col s12 m4 l1">
|
|
221
|
-
<input class="value number" id="recordtime_livestream" min="0" max="60" type="number" />
|
|
222
|
-
<label class="translate" for="recordtime_livestream">Livestream recordtime in sec.</label>
|
|
223
|
-
</div>
|
|
131
|
+
<div class="input-field col s6">
|
|
132
|
+
<img src="ring.png" class="logo">
|
|
133
|
+
</div>
|
|
224
134
|
</div>
|
|
225
135
|
<div class="row">
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
136
|
+
<div class="col s12 m4 l1">
|
|
137
|
+
<input class="value number" id="recordtime_livestream" min="0" max="60" type="number"/>
|
|
138
|
+
<label class="translate" for="recordtime_livestream">Livestream recordtime in sec.</label>
|
|
139
|
+
</div>
|
|
230
140
|
</div>
|
|
231
141
|
<div class="row">
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
<label for="del_old_snapshot" class="translate">Delete old Snapshots</label>
|
|
142
|
+
<div class="input-field col s12 m6 l4">
|
|
143
|
+
<input id="path" type="text" size="30" class="value"/>
|
|
144
|
+
<label class="translate" for="path">Path</label>
|
|
145
|
+
</div>
|
|
237
146
|
</div>
|
|
238
147
|
<div class="row">
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
148
|
+
<div class="input-field col s12 m6 l4">
|
|
149
|
+
<input id="filename_snapshot" type="text" size="30" class="value"/>
|
|
150
|
+
<label class="translate" for="filename_snapshot">Filename Snapshot</label>
|
|
151
|
+
<input class="value" id="del_old_snapshot" type="checkbox"/>
|
|
152
|
+
<label for="del_old_snapshot" class="translate">Delete old Snapshots</label>
|
|
153
|
+
</div>
|
|
154
|
+
<div class="row">
|
|
155
|
+
<div class="input-field col s12 m6 l4">
|
|
156
|
+
<input id="filename_livestream" type="text" size="30" class="value"/>
|
|
157
|
+
<label class="translate" for="filename_livestream">Filename Livestream</label>
|
|
158
|
+
<input class="value" id="del_old_livestream" type="checkbox"/>
|
|
159
|
+
<label for="del_old_livestream" class="translate">Delete old Livestreams</label>
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
245
162
|
</div>
|
|
246
|
-
</div>
|
|
247
|
-
|
|
248
163
|
</div>
|
|
249
|
-
|
|
164
|
+
|
|
165
|
+
</div>
|
|
166
|
+
|
|
250
167
|
</body>
|
|
251
168
|
|
|
252
|
-
</html>
|
|
169
|
+
</html>
|