@signalk/app-dock 0.1.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/.github/workflows/ci.yml +11 -0
- package/.github/workflows/publish.yml +33 -0
- package/.prettierignore +6 -0
- package/.prettierrc +6 -0
- package/LICENSE +190 -0
- package/README.md +83 -0
- package/eslint.config.js +55 -0
- package/package.json +40 -0
- package/plugin/index.js +180 -0
- package/public/540.js +2 -0
- package/public/540.js.LICENSE.txt +9 -0
- package/public/805.js +1 -0
- package/public/app-icon.svg +29 -0
- package/public/config.html +469 -0
- package/public/dock.css +412 -0
- package/public/dock.js +456 -0
- package/public/icon-settings.svg +21 -0
- package/public/index.html +41 -0
- package/public/main.js +1 -0
- package/public/remoteEntry.js +1 -0
- package/src/configpanel/PluginConfigurationPanel.js +441 -0
- package/src/configpanel/index.js +1 -0
- package/test/plugin.test.js +394 -0
- package/webpack.config.js +39 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: Publish to npm
|
|
2
|
+
on:
|
|
3
|
+
release:
|
|
4
|
+
types: [created]
|
|
5
|
+
|
|
6
|
+
permissions:
|
|
7
|
+
id-token: write # Required for OIDC
|
|
8
|
+
contents: read
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v6
|
|
15
|
+
- uses: actions/setup-node@v6
|
|
16
|
+
with:
|
|
17
|
+
node-version: '24.x'
|
|
18
|
+
registry-url: 'https://registry.npmjs.org'
|
|
19
|
+
|
|
20
|
+
- name: Install
|
|
21
|
+
run: |
|
|
22
|
+
npm install
|
|
23
|
+
|
|
24
|
+
- name: Publish
|
|
25
|
+
run: |
|
|
26
|
+
npm install -g npm@latest
|
|
27
|
+
npm --version
|
|
28
|
+
if [[ "$tag" == *beta* ]];
|
|
29
|
+
then
|
|
30
|
+
npm publish --provenance --access public --tag beta
|
|
31
|
+
else
|
|
32
|
+
npm publish --provenance --access public
|
|
33
|
+
fi
|
package/.prettierignore
ADDED
package/.prettierrc
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding any notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2025 Signal K
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# signalk-app-dock
|
|
2
|
+
|
|
3
|
+
A macOS-style app dock for switching between Signal K webapps on touch screens.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **macOS dock magnification** -- icons scale up with parabolic falloff as your finger moves along the dock
|
|
10
|
+
- **Frosted glass pill** with spring bounce animation, positioned on any screen edge
|
|
11
|
+
- **Lazy loading** -- apps load only when first tapped (important for Raspberry Pi and low-power devices)
|
|
12
|
+
- **Double-tap corner** to reveal the dock -- works on touch and mouse, no conflict with OS gestures or browser fullscreen
|
|
13
|
+
- **Mouse edge hover** to reveal on desktop
|
|
14
|
+
- **Autostart** -- optionally load a default app immediately on open
|
|
15
|
+
- **keep-alive or destroy** iframe lifecycle
|
|
16
|
+
- **Active dot indicator**, label tooltip, haptic feedback
|
|
17
|
+
- **Embedded config panel** in the admin UI with webapp discovery, drag-to-reorder, and live preview
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
cd ~/.signalk
|
|
23
|
+
npm install signalk-app-dock
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Restart Signal K, enable in **Plugin Config > App Dock**, click **Discover Installed Webapps**.
|
|
27
|
+
|
|
28
|
+
Open: `http://your-sk-server:3000/signalk-app-dock/`
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
**Double-tap** the configured screen corner (default: bottom-right) to open the dock. Tap an app icon to switch. The dock auto-dismisses after selection, or tap the backdrop to close it.
|
|
33
|
+
|
|
34
|
+
On desktop, move the mouse to the screen edge corresponding to the dock position.
|
|
35
|
+
|
|
36
|
+
## Configuration
|
|
37
|
+
|
|
38
|
+
Open **Plugin Config > App Dock** in the admin UI. The embedded configurator provides:
|
|
39
|
+
|
|
40
|
+
- **Discover** button to find all installed webapps (including Admin UI with a Settings gear icon)
|
|
41
|
+
- **Drag-to-reorder** the app list
|
|
42
|
+
- **Enable/disable** individual apps
|
|
43
|
+
- **Autostart** flag (play button) -- set one app to load automatically on open
|
|
44
|
+
- **Live dock preview**
|
|
45
|
+
|
|
46
|
+
### Settings
|
|
47
|
+
|
|
48
|
+
| Setting | Default | Description |
|
|
49
|
+
| -------------------- | -------------- | ------------------------------------------- |
|
|
50
|
+
| `position` | `bottom` | Dock edge: `bottom`, `top`, `left`, `right` |
|
|
51
|
+
| `triggerCorner` | `bottom-right` | Which corner activates double-tap |
|
|
52
|
+
| `iframeMode` | `keep-alive` | `keep-alive` or `destroy` |
|
|
53
|
+
| `iconSize` | `56` | Base icon size in px |
|
|
54
|
+
| `magnification` | `true` | Enable macOS-style magnification effect |
|
|
55
|
+
| `magnificationScale` | `1.7` | Max icon scale (1.0-2.5) |
|
|
56
|
+
|
|
57
|
+
## Development
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
cd ~/.signalk
|
|
61
|
+
npm link /path/to/signalk-app-dock
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Edit files in `public/`, reload the browser. No build step needed for the dock itself.
|
|
65
|
+
|
|
66
|
+
To rebuild the config panel (after changing `src/configpanel/`):
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npm run build:config
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Scripts
|
|
73
|
+
|
|
74
|
+
| Command | Description |
|
|
75
|
+
| ---------------------- | --------------------------------- |
|
|
76
|
+
| `npm test` | Run tests |
|
|
77
|
+
| `npm run format` | Prettier + ESLint fix |
|
|
78
|
+
| `npm run lint` | ESLint check |
|
|
79
|
+
| `npm run build:config` | Rebuild the admin UI config panel |
|
|
80
|
+
|
|
81
|
+
## License
|
|
82
|
+
|
|
83
|
+
Apache-2.0
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const prettier = require('eslint-config-prettier')
|
|
2
|
+
|
|
3
|
+
module.exports = [
|
|
4
|
+
{ ignores: ['src/**', 'public/remoteEntry.js', 'public/540.js', 'public/805.js', 'public/main.js'] },
|
|
5
|
+
{
|
|
6
|
+
files: ['plugin/**/*.js', 'test/**/*.js'],
|
|
7
|
+
languageOptions: {
|
|
8
|
+
ecmaVersion: 2022,
|
|
9
|
+
sourceType: 'commonjs',
|
|
10
|
+
globals: {
|
|
11
|
+
require: 'readonly',
|
|
12
|
+
module: 'readonly',
|
|
13
|
+
exports: 'readonly',
|
|
14
|
+
__dirname: 'readonly',
|
|
15
|
+
__filename: 'readonly',
|
|
16
|
+
process: 'readonly',
|
|
17
|
+
console: 'readonly',
|
|
18
|
+
setTimeout: 'readonly',
|
|
19
|
+
clearTimeout: 'readonly',
|
|
20
|
+
setInterval: 'readonly',
|
|
21
|
+
clearInterval: 'readonly',
|
|
22
|
+
globalThis: 'readonly'
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
rules: {
|
|
26
|
+
'no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
|
|
27
|
+
'no-undef': 'error'
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
files: ['public/dock.js'],
|
|
32
|
+
languageOptions: {
|
|
33
|
+
ecmaVersion: 2022,
|
|
34
|
+
sourceType: 'script',
|
|
35
|
+
globals: {
|
|
36
|
+
window: 'readonly',
|
|
37
|
+
document: 'readonly',
|
|
38
|
+
navigator: 'readonly',
|
|
39
|
+
fetch: 'readonly',
|
|
40
|
+
console: 'readonly',
|
|
41
|
+
setTimeout: 'readonly',
|
|
42
|
+
clearTimeout: 'readonly',
|
|
43
|
+
requestAnimationFrame: 'readonly',
|
|
44
|
+
Promise: 'readonly',
|
|
45
|
+
Set: 'readonly',
|
|
46
|
+
Infinity: 'readonly'
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
rules: {
|
|
50
|
+
'no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
|
|
51
|
+
'no-undef': 'error'
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
prettier
|
|
55
|
+
]
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@signalk/app-dock",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "macOS-style configurable app dock for switching between SignalK webapps on touch screens",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"signalk-node-server-plugin",
|
|
7
|
+
"signalk-webapp",
|
|
8
|
+
"signalk-plugin-configurator",
|
|
9
|
+
"signalk-category-instruments"
|
|
10
|
+
],
|
|
11
|
+
"signalk-plugin-enabled-by-default": true,
|
|
12
|
+
"signalk": {
|
|
13
|
+
"displayName": "App Dock",
|
|
14
|
+
"appIcon": "./app-icon.svg"
|
|
15
|
+
},
|
|
16
|
+
"main": "plugin/index.js",
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build:config": "webpack",
|
|
19
|
+
"prepublishOnly": "webpack",
|
|
20
|
+
"format": "prettier --write '**/*.{js,json,md,css,html}' && eslint --fix .",
|
|
21
|
+
"lint": "eslint .",
|
|
22
|
+
"test": "node --test test/plugin.test.js"
|
|
23
|
+
},
|
|
24
|
+
"author": "",
|
|
25
|
+
"license": "Apache-2.0",
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=18"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@babel/core": "^7.29.0",
|
|
31
|
+
"@babel/preset-react": "^7.28.5",
|
|
32
|
+
"babel-loader": "^10.1.1",
|
|
33
|
+
"eslint": "^10.1.0",
|
|
34
|
+
"eslint-config-prettier": "^10.1.8",
|
|
35
|
+
"prettier": "^3.8.1",
|
|
36
|
+
"react": "^19.2.4",
|
|
37
|
+
"webpack": "^5.105.4",
|
|
38
|
+
"webpack-cli": "^7.0.2"
|
|
39
|
+
}
|
|
40
|
+
}
|
package/plugin/index.js
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
module.exports = (app) => {
|
|
4
|
+
let pluginSettings = {}
|
|
5
|
+
let resolvedApps = []
|
|
6
|
+
|
|
7
|
+
function getWebapps() {
|
|
8
|
+
return (app.webapps || [])
|
|
9
|
+
.filter((w) => w.name !== 'signalk-app-dock' && w.name !== '@signalk/server-admin-ui')
|
|
10
|
+
.map((w) => ({
|
|
11
|
+
name: w.name,
|
|
12
|
+
label: w.signalk?.displayName || w.name,
|
|
13
|
+
url: `/${w.name}/`,
|
|
14
|
+
icon: w.signalk?.appIcon ? `/${w.name}/${w.signalk.appIcon.replace(/^\.\//, '')}` : null
|
|
15
|
+
}))
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const plugin = {
|
|
19
|
+
id: 'signalk-app-dock',
|
|
20
|
+
name: 'App Dock',
|
|
21
|
+
|
|
22
|
+
start(settings) {
|
|
23
|
+
pluginSettings = settings
|
|
24
|
+
|
|
25
|
+
setTimeout(() => {
|
|
26
|
+
const discovered = getWebapps()
|
|
27
|
+
if (discovered.length === 0) return
|
|
28
|
+
|
|
29
|
+
const configured = settings.apps || []
|
|
30
|
+
const configuredUrls = new Set(configured.map((a) => a.url))
|
|
31
|
+
|
|
32
|
+
const merged = [...configured]
|
|
33
|
+
let added = false
|
|
34
|
+
for (const w of discovered) {
|
|
35
|
+
if (!configuredUrls.has(w.url)) {
|
|
36
|
+
merged.push({ enabled: true, url: w.url, label: '', icon: '', color: '' })
|
|
37
|
+
added = true
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const discoveredByUrl = {}
|
|
42
|
+
discovered.forEach((d) => {
|
|
43
|
+
discoveredByUrl[d.url] = d
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
resolvedApps = merged
|
|
47
|
+
.filter((a) => a.enabled !== false)
|
|
48
|
+
.map((a) => {
|
|
49
|
+
const match = discoveredByUrl[a.url]
|
|
50
|
+
return {
|
|
51
|
+
label: a.label || (match && match.label) || a.url,
|
|
52
|
+
url: a.url,
|
|
53
|
+
icon: a.icon || (match && match.icon) || null,
|
|
54
|
+
color: a.color || null,
|
|
55
|
+
autostart: a.autostart || false
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
if (added) {
|
|
60
|
+
app.savePluginOptions({ ...settings, apps: merged }, (err) => {
|
|
61
|
+
if (err) app.error('Failed to save discovered apps: ' + err.message)
|
|
62
|
+
else app.debug('Auto-discovered new webapps, saved to config')
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
app.debug('Dock apps: %s', resolvedApps.map((a) => a.label).join(', '))
|
|
67
|
+
}, 5000)
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
stop() {},
|
|
71
|
+
|
|
72
|
+
registerWithRouter(router) {
|
|
73
|
+
router.get('/settings', (req, res) => {
|
|
74
|
+
res.json({
|
|
75
|
+
...pluginSettings,
|
|
76
|
+
apps: resolvedApps
|
|
77
|
+
})
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
router.get('/webapps', (req, res) => {
|
|
81
|
+
res.json(getWebapps())
|
|
82
|
+
})
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
schema: {
|
|
86
|
+
type: 'object',
|
|
87
|
+
description:
|
|
88
|
+
'Open /signalk-app-dock/config.html for the visual configurator with discover button and drag-to-reorder.',
|
|
89
|
+
required: [],
|
|
90
|
+
properties: {
|
|
91
|
+
position: {
|
|
92
|
+
type: 'string',
|
|
93
|
+
title: 'Dock position',
|
|
94
|
+
enum: ['bottom', 'top', 'left', 'right'],
|
|
95
|
+
default: 'bottom'
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
triggerCorner: {
|
|
99
|
+
type: 'string',
|
|
100
|
+
title: 'Double-tap corner',
|
|
101
|
+
description: 'Screen corner that activates the dock on double-tap',
|
|
102
|
+
enum: ['bottom-right', 'bottom-left', 'top-right', 'top-left'],
|
|
103
|
+
default: 'bottom-right'
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
iframeMode: {
|
|
107
|
+
type: 'string',
|
|
108
|
+
title: 'iFrame lifecycle',
|
|
109
|
+
description:
|
|
110
|
+
'keep-alive: load once and hide/show (faster switching, more RAM). ' +
|
|
111
|
+
'destroy: reload on every switch (slower, minimal RAM).',
|
|
112
|
+
enum: ['keep-alive', 'destroy'],
|
|
113
|
+
default: 'keep-alive'
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
iconSize: {
|
|
117
|
+
type: 'number',
|
|
118
|
+
title: 'Icon size (px)',
|
|
119
|
+
default: 56
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
magnification: {
|
|
123
|
+
type: 'boolean',
|
|
124
|
+
title: 'Enable dock magnification effect',
|
|
125
|
+
default: true
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
magnificationScale: {
|
|
129
|
+
type: 'number',
|
|
130
|
+
title: 'Magnification scale (1.0 = none, 2.5 = maximum)',
|
|
131
|
+
default: 1.7
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
apps: {
|
|
135
|
+
type: 'array',
|
|
136
|
+
title: 'Dock Apps',
|
|
137
|
+
description:
|
|
138
|
+
'Installed webapps are added here automatically. Reorder, disable, or override labels/icons as needed.',
|
|
139
|
+
items: {
|
|
140
|
+
type: 'object',
|
|
141
|
+
required: ['url'],
|
|
142
|
+
properties: {
|
|
143
|
+
enabled: {
|
|
144
|
+
type: 'boolean',
|
|
145
|
+
title: 'Enabled',
|
|
146
|
+
default: true
|
|
147
|
+
},
|
|
148
|
+
autostart: {
|
|
149
|
+
type: 'boolean',
|
|
150
|
+
title: 'Autostart',
|
|
151
|
+
description: 'Load this app automatically when the dock page opens',
|
|
152
|
+
default: false
|
|
153
|
+
},
|
|
154
|
+
url: {
|
|
155
|
+
type: 'string',
|
|
156
|
+
title: 'URL'
|
|
157
|
+
},
|
|
158
|
+
label: {
|
|
159
|
+
type: 'string',
|
|
160
|
+
title: 'Label override'
|
|
161
|
+
},
|
|
162
|
+
icon: {
|
|
163
|
+
type: 'string',
|
|
164
|
+
title: 'Icon override',
|
|
165
|
+
description: 'Emoji or image path'
|
|
166
|
+
},
|
|
167
|
+
color: {
|
|
168
|
+
type: 'string',
|
|
169
|
+
title: 'Background color'
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
default: []
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return plugin
|
|
180
|
+
}
|
package/public/540.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 540.js.LICENSE.txt */
|
|
2
|
+
"use strict";(self.webpackChunksignalk_app_dock=self.webpackChunksignalk_app_dock||[]).push([[540],{869(e,t){var n=Symbol.for("react.transitional.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),u=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),i=Symbol.for("react.consumer"),s=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),l=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),d=Symbol.iterator,h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,b={};function m(e,t,n){this.props=e,this.context=t,this.refs=b,this.updater=n||h}function v(){}function S(e,t,n){this.props=e,this.context=t,this.refs=b,this.updater=n||h}m.prototype.isReactComponent={},m.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},m.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},v.prototype=m.prototype;var E=S.prototype=new v;E.constructor=S,_(E,m.prototype),E.isPureReactComponent=!0;var g=Array.isArray;function k(){}var w={H:null,A:null,T:null,S:null},H=Object.prototype.hasOwnProperty;function j(e,t,r){var o=r.ref;return{$$typeof:n,type:e,key:t,ref:void 0!==o?o:null,props:r}}function C(e){return"object"==typeof e&&null!==e&&e.$$typeof===n}var R=/\/+/g;function $(e,t){return"object"==typeof e&&null!==e&&null!=e.key?(n=""+e.key,r={"=":"=0",":":"=2"},"$"+n.replace(/[=:]/g,function(e){return r[e]})):t.toString(36);var n,r}function T(e,t,o,u,c){var i=typeof e;"undefined"!==i&&"boolean"!==i||(e=null);var s,a,f=!1;if(null===e)f=!0;else switch(i){case"bigint":case"string":case"number":f=!0;break;case"object":switch(e.$$typeof){case n:case r:f=!0;break;case p:return T((f=e._init)(e._payload),t,o,u,c)}}if(f)return c=c(e),f=""===u?"."+$(e,0):u,g(c)?(o="",null!=f&&(o=f.replace(R,"$&/")+"/"),T(c,t,o,"",function(e){return e})):null!=c&&(C(c)&&(s=c,a=o+(null==c.key||e&&e.key===c.key?"":(""+c.key).replace(R,"$&/")+"/")+f,c=j(s.type,a,s.props)),t.push(c)),1;f=0;var l,y=""===u?".":u+":";if(g(e))for(var h=0;h<e.length;h++)f+=T(u=e[h],t,o,i=y+$(u,h),c);else if("function"==typeof(h=null===(l=e)||"object"!=typeof l?null:"function"==typeof(l=d&&l[d]||l["@@iterator"])?l:null))for(e=h.call(e),h=0;!(u=e.next()).done;)f+=T(u=u.value,t,o,i=y+$(u,h++),c);else if("object"===i){if("function"==typeof e.then)return T(function(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch("string"==typeof e.status?e.then(k,k):(e.status="pending",e.then(function(t){"pending"===e.status&&(e.status="fulfilled",e.value=t)},function(t){"pending"===e.status&&(e.status="rejected",e.reason=t)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}(e),t,o,u,c);throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.")}return f}function x(e,t,n){if(null==e)return e;var r=[],o=0;return T(e,r,"","",function(e){return t.call(n,e,o++)}),r}function A(e){if(-1===e._status){var t=e._result;(t=t()).then(function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)},function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)}),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var O="function"==typeof reportError?reportError:function(e){if("object"==typeof window&&"function"==typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"==typeof e&&null!==e&&"string"==typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"==typeof process&&"function"==typeof process.emit)return void process.emit("uncaughtException",e);console.error(e)},I={map:x,forEach:function(e,t,n){x(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return x(e,function(){t++}),t},toArray:function(e){return x(e,function(e){return e})||[]},only:function(e){if(!C(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};t.Activity=y,t.Children=I,t.Component=m,t.Fragment=o,t.Profiler=c,t.PureComponent=S,t.StrictMode=u,t.Suspense=f,t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,t.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},t.cache=function(e){return function(){return e.apply(null,arguments)}},t.cacheSignal=function(){return null},t.cloneElement=function(e,t,n){if(null==e)throw Error("The argument must be a React element, but you passed "+e+".");var r=_({},e.props),o=e.key;if(null!=t)for(u in void 0!==t.key&&(o=""+t.key),t)!H.call(t,u)||"key"===u||"__self"===u||"__source"===u||"ref"===u&&void 0===t.ref||(r[u]=t[u]);var u=arguments.length-2;if(1===u)r.children=n;else if(1<u){for(var c=Array(u),i=0;i<u;i++)c[i]=arguments[i+2];r.children=c}return j(e.type,o,r)},t.createContext=function(e){return(e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider=e,e.Consumer={$$typeof:i,_context:e},e},t.createElement=function(e,t,n){var r,o={},u=null;if(null!=t)for(r in void 0!==t.key&&(u=""+t.key),t)H.call(t,r)&&"key"!==r&&"__self"!==r&&"__source"!==r&&(o[r]=t[r]);var c=arguments.length-2;if(1===c)o.children=n;else if(1<c){for(var i=Array(c),s=0;s<c;s++)i[s]=arguments[s+2];o.children=i}if(e&&e.defaultProps)for(r in c=e.defaultProps)void 0===o[r]&&(o[r]=c[r]);return j(e,u,o)},t.createRef=function(){return{current:null}},t.forwardRef=function(e){return{$$typeof:a,render:e}},t.isValidElement=C,t.lazy=function(e){return{$$typeof:p,_payload:{_status:-1,_result:e},_init:A}},t.memo=function(e,t){return{$$typeof:l,type:e,compare:void 0===t?null:t}},t.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),o=w.S;null!==o&&o(n,r),"object"==typeof r&&null!==r&&"function"==typeof r.then&&r.then(k,O)}catch(e){O(e)}finally{null!==t&&null!==n.types&&(t.types=n.types),w.T=t}},t.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},t.use=function(e){return w.H.use(e)},t.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},t.useCallback=function(e,t){return w.H.useCallback(e,t)},t.useContext=function(e){return w.H.useContext(e)},t.useDebugValue=function(){},t.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},t.useEffect=function(e,t){return w.H.useEffect(e,t)},t.useEffectEvent=function(e){return w.H.useEffectEvent(e)},t.useId=function(){return w.H.useId()},t.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},t.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},t.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},t.useMemo=function(e,t){return w.H.useMemo(e,t)},t.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},t.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},t.useRef=function(e){return w.H.useRef(e)},t.useState=function(e){return w.H.useState(e)},t.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},t.useTransition=function(){return w.H.useTransition()},t.version="19.2.4"},540(e,t,n){e.exports=n(869)}}]);
|
package/public/805.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunksignalk_app_dock=self.webpackChunksignalk_app_dock||[]).push([[805],{805(e,t,a){a.r(t),a.d(t,{default:()=>s});var l=a(231);const n={root:{fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',color:"#333",padding:"16px 0"},sectionTitle:{fontSize:13,fontWeight:600,color:"#888",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:10,marginTop:24},btn:{display:"inline-flex",alignItems:"center",gap:8,padding:"8px 16px",border:"none",borderRadius:6,fontSize:13,fontWeight:600,cursor:"pointer"},btnPrimary:{background:"#3b82f6",color:"#fff"},btnSave:{background:"#10b981",color:"#fff"},btnDanger:{background:"#ef4444",color:"#fff",padding:"4px 10px",fontSize:11},status:{marginTop:8,fontSize:12,minHeight:18},item:{display:"flex",alignItems:"center",gap:10,padding:"8px 12px",background:"#f8f9fa",border:"1px solid #e0e0e0",borderRadius:8,marginBottom:6,cursor:"grab"},itemDisabled:{opacity:.4},dragOver:{borderColor:"#3b82f6",background:"#eef4ff"},handle:{color:"#bbb",fontSize:16,cursor:"grab",userSelect:"none",flexShrink:0,width:18,textAlign:"center"},iconBox:{width:36,height:36,borderRadius:8,display:"flex",alignItems:"center",justifyContent:"center",background:"#e2e8f0",overflow:"hidden",flexShrink:0,fontSize:18},iconImg:{width:"100%",height:"100%",objectFit:"contain",padding:5},info:{flex:1,minWidth:0},name:{fontSize:13,fontWeight:600,color:"#333"},url:{fontSize:10,color:"#999",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},toggle:{flexShrink:0},checkbox:{width:16,height:16,cursor:"pointer",accentColor:"#3b82f6"},preview:{display:"flex",alignItems:"flex-end",justifyContent:"center",gap:6,padding:"12px 18px",background:"rgba(30,30,32,0.85)",border:"1px solid rgba(255,255,255,0.18)",borderRadius:18,margin:"16px auto",width:"fit-content"},actions:{display:"flex",gap:10,alignItems:"center",marginTop:16},empty:{textAlign:"center",padding:"30px 16px",color:"#999",fontSize:13},fieldRow:{display:"flex",alignItems:"center",gap:12,marginBottom:10},label:{fontSize:13,fontWeight:500,color:"#555",width:160,flexShrink:0},select:{padding:"6px 10px",borderRadius:6,border:"1px solid #ccc",fontSize:13,background:"#fff",color:"#333"},input:{padding:"6px 10px",borderRadius:6,border:"1px solid #ccc",fontSize:13,width:80,background:"#fff",color:"#333"},checkboxField:{width:16,height:16,accentColor:"#3b82f6"},hint:{fontSize:11,color:"#aaa",marginLeft:8}};function o({icon:e,label:t,color:a,size:o}){const i=o||36,r={...n.iconBox,width:i,height:i,borderRadius:.22*i,...a?{background:a}:{}},c=e||"";return c.startsWith("/")||c.startsWith("http")?l.createElement("div",{style:r},l.createElement("img",{src:c,alt:t,style:{...n.iconImg,padding:.12*i},onError:e=>{e.target.style.display="none",e.target.parentNode.textContent=(t||"??").slice(0,2).toUpperCase()}})):l.createElement("div",{style:r},c||(t||"??").slice(0,2).toUpperCase())}function i({label:e,value:t,options:a,onChange:o,hint:i}){return l.createElement("div",{style:n.fieldRow},l.createElement("span",{style:n.label},e),l.createElement("select",{style:n.select,value:t,onChange:e=>o(e.target.value)},a.map(e=>l.createElement("option",{key:e.value,value:e.value},e.label))),i&&l.createElement("span",{style:n.hint},i))}function r({label:e,value:t,onChange:a,hint:o}){return l.createElement("div",{style:n.fieldRow},l.createElement("span",{style:n.label},e),l.createElement("input",{style:n.input,type:"number",value:t,onChange:e=>a(Number(e.target.value))}),o&&l.createElement("span",{style:n.hint},o))}function c({label:e,checked:t,onChange:a,hint:o}){return l.createElement("div",{style:n.fieldRow},l.createElement("span",{style:n.label},e),l.createElement("input",{type:"checkbox",style:n.checkboxField,checked:t,onChange:e=>a(e.target.checked)}),o&&l.createElement("span",{style:n.hint},o))}function s({configuration:e,save:t}){const a=e||{},[s,d]=(0,l.useState)(()=>a.apps||[]),[p,u]=(0,l.useState)(a.position||"bottom"),[g,m]=(0,l.useState)(a.triggerCorner||"bottom-right"),[b,f]=(0,l.useState)(a.iframeMode||"keep-alive"),[h,v]=(0,l.useState)(a.iconSize||56),[y,k]=(0,l.useState)(!1!==a.magnification),[E,S]=(0,l.useState)(a.magnificationScale||1.7),[x,C]=(0,l.useState)(""),[w,D]=(0,l.useState)(!1),[z,R]=(0,l.useState)(!1),[I,T]=(0,l.useState)(null),[A,B]=(0,l.useState)(null),W=(0,l.useRef)(s);W.current=s;const F=(0,l.useCallback)(e=>({position:p,triggerCorner:g,iframeMode:b,iconSize:h,magnification:y,magnificationScale:E,apps:e}),[p,g,b,h,y,E]),M=(0,l.useCallback)(()=>{t(F(s)),C("Saved!"),D(!1)},[s,F,t]),N=()=>B(null),$=()=>{T(null),B(null)},O=s.filter(e=>!1!==e.enabled);return l.createElement("div",{style:n.root},l.createElement("div",{style:n.sectionTitle},"Dock Settings"),l.createElement(i,{label:"Dock position",value:p,onChange:u,options:[{value:"bottom",label:"Bottom"},{value:"top",label:"Top"},{value:"left",label:"Left"},{value:"right",label:"Right"}]}),l.createElement(i,{label:"Double-tap corner",value:g,onChange:m,options:[{value:"bottom-right",label:"Bottom-right"},{value:"bottom-left",label:"Bottom-left"},{value:"top-right",label:"Top-right"},{value:"top-left",label:"Top-left"}]}),l.createElement(i,{label:"iFrame lifecycle",value:b,onChange:f,options:[{value:"keep-alive",label:"Keep-alive (faster switching, more RAM)"},{value:"destroy",label:"Destroy (reload each time, less RAM)"}]}),l.createElement(r,{label:"Icon size",value:h,onChange:v,hint:"px"}),l.createElement(c,{label:"Magnification effect",checked:y,onChange:k}),y&&l.createElement(r,{label:"Magnification scale",value:E,onChange:S,hint:"1.0 - 2.5"}),l.createElement("div",{style:n.sectionTitle},"Webapps"),l.createElement("button",{style:{...n.btn,...n.btnPrimary,...z?{opacity:.6}:{}},onClick:async()=>{R(!0),C(""),D(!1);try{const e=await fetch("/skServer/webapps"),t=(await e.json()).filter(e=>"signalk-app-dock"!==e.name).map(e=>"@signalk/server-admin-ui"===e.name?{name:e.name,label:"Settings",url:"/admin/",icon:"/signalk-app-dock/icon-settings.svg",isAdmin:!0}:{name:e.name,label:e.signalk?.displayName||e.name,url:`/${e.name}/`,icon:e.signalk?.appIcon?`/${e.name}/${e.signalk.appIcon}`:null});if(0===t.length)return C("No webapps found. Is the server fully started?"),D(!0),void R(!1);const a=W.current,l=new Set(a.map(e=>e.url));let n=0;const o=[...a];for(const e of t)l.has(e.url)||(o.push({enabled:!0,autostart:!1,url:e.url,label:e.label||"",icon:e.icon||"",color:e.isAdmin?"#78788c":""}),n++);d(o),C(n>0?`Found ${t.length} webapps, added ${n} new.`:`All ${t.length} webapps already in list.`),D(!1)}catch(e){C("Discovery failed: "+e.message),D(!0)}R(!1)},disabled:z},z?"Discovering…":"Discover Installed Webapps"),x&&l.createElement("div",{style:{...n.status,color:w?"#ef4444":"#10b981"}},x),l.createElement("div",{style:n.sectionTitle},"Dock Apps (drag to reorder)"),0===s.length?l.createElement("div",{style:n.empty},"No apps yet. Click Discover above."):l.createElement("div",null,s.map((e,t)=>l.createElement("div",{key:e.url+t,draggable:!0,onDragStart:()=>(e=>T(e))(t),onDragOver:e=>((e,t)=>{e.preventDefault(),B(t)})(e,t),onDragLeave:N,onDrop:e=>((e,t)=>{if(e.preventDefault(),B(null),null!==I&&I!==t){const e=[...s],[a]=e.splice(I,1);e.splice(t,0,a),d(e)}T(null)})(e,t),onDragEnd:$,style:{...n.item,...!1===e.enabled?n.itemDisabled:{},...A===t?n.dragOver:{},...I===t?{opacity:.4}:{}}},l.createElement("span",{style:n.handle},"≡"),l.createElement(o,{icon:e.icon,label:e.label||e.url,color:e.color}),l.createElement("div",{style:n.info},l.createElement("div",{style:n.name},e.label||e.url),l.createElement("div",{style:n.url},e.url)),l.createElement("div",{style:n.toggle,title:"Enabled"},l.createElement("input",{type:"checkbox",checked:!1!==e.enabled,onChange:()=>(e=>d(s.map((t,a)=>a===e?{...t,enabled:!t.enabled}:t)))(t),style:n.checkbox})),l.createElement("div",{style:{...n.toggle,cursor:"pointer",fontSize:16,opacity:e.autostart?1:.25},onClick:()=>(e=>d(s.map((t,a)=>a===e?{...t,autostart:!t.autostart}:{...t,autostart:!1})))(t),title:e.autostart?"Autostart: ON (click to disable)":"Click to set as autostart app"},"▶"),l.createElement("button",{style:{...n.btn,...n.btnDanger},onClick:()=>(e=>d(s.filter((t,a)=>a!==e)))(t)},"Remove")))),O.length>0&&l.createElement(l.Fragment,null,l.createElement("div",{style:n.sectionTitle},"Preview"),l.createElement("div",{style:n.preview},O.map((e,t)=>l.createElement(o,{key:t,icon:e.icon,label:e.label||e.url,color:e.color,size:40})))),l.createElement("div",{style:n.actions},l.createElement("button",{style:{...n.btn,...n.btnSave},onClick:M},"Save Configuration")))}}}]);
|