iobroker.aura 0.0.7

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.
@@ -0,0 +1,41 @@
1
+ {
2
+ "common": {
3
+ "name": "aura",
4
+ "version": "0.0.7",
5
+ "title": "Aura",
6
+ "titleLang": {
7
+ "en": "Aura Dashboard",
8
+ "de": "Aura Dashboard"
9
+ },
10
+ "desc": {
11
+ "en": "Modern visualization dashboard for ioBroker",
12
+ "de": "Modernes Visualisierungs-Dashboard für ioBroker"
13
+ },
14
+ "type": "visualization",
15
+ "license": "MIT",
16
+ "mode": "daemon",
17
+ "allowInit": true,
18
+ "webExtension": "www/",
19
+ "noIntro": true,
20
+ "singleton": true,
21
+ "authors": ["Aura"],
22
+ "keywords": ["visualization", "dashboard"]
23
+ },
24
+ "native": {},
25
+ "objects": [],
26
+ "instanceObjects": [
27
+ {
28
+ "_id": "info.connection",
29
+ "type": "state",
30
+ "common": {
31
+ "name": "If adapter connected to ioBroker",
32
+ "type": "boolean",
33
+ "role": "indicator.connected",
34
+ "read": true,
35
+ "write": false,
36
+ "def": false
37
+ },
38
+ "native": {}
39
+ }
40
+ ]
41
+ }
package/lib/main.js ADDED
@@ -0,0 +1,112 @@
1
+ 'use strict';
2
+
3
+ const utils = require('@iobroker/adapter-core');
4
+ const http = require('http');
5
+ const https = require('https');
6
+
7
+ function fetchUrl(url) {
8
+ return new Promise((resolve, reject) => {
9
+ const target = new URL(url);
10
+ const lib = target.protocol === 'https:' ? https : http;
11
+ const options = {
12
+ hostname: target.hostname,
13
+ port: target.port || (target.protocol === 'https:' ? 443 : 80),
14
+ path: target.pathname + target.search,
15
+ method: 'GET',
16
+ headers: {
17
+ 'User-Agent': 'Mozilla/5.0 (ioBroker-Aura)',
18
+ 'Accept': 'text/calendar, */*',
19
+ },
20
+ };
21
+ const req = lib.request(options, (res) => {
22
+ if ((res.statusCode === 301 || res.statusCode === 302) && res.headers.location) {
23
+ fetchUrl(res.headers.location).then(resolve).catch(reject);
24
+ return;
25
+ }
26
+ let data = '';
27
+ res.setEncoding('utf8');
28
+ res.on('data', (chunk) => (data += chunk));
29
+ res.on('end', () => resolve(data));
30
+ });
31
+ req.on('error', reject);
32
+ req.end();
33
+ });
34
+ }
35
+
36
+ class Aura extends utils.Adapter {
37
+ constructor(options = {}) {
38
+ super({
39
+ ...options,
40
+ name: 'aura',
41
+ });
42
+ this.on('ready', this.onReady.bind(this));
43
+ this.on('message', this.onMessage.bind(this));
44
+ this.on('unload', this.onUnload.bind(this));
45
+ }
46
+
47
+ onMessage(obj) {
48
+ if (!obj || obj.command !== 'fetchUrl') return;
49
+ const url = obj.message && obj.message.url;
50
+ if (!url) {
51
+ obj.callback && this.sendTo(obj.from, obj.command, { error: 'No URL provided' }, obj.callback);
52
+ return;
53
+ }
54
+ fetchUrl(url)
55
+ .then((content) => {
56
+ obj.callback && this.sendTo(obj.from, obj.command, { content }, obj.callback);
57
+ })
58
+ .catch((err) => {
59
+ obj.callback && this.sendTo(obj.from, obj.command, { error: String(err) }, obj.callback);
60
+ });
61
+ }
62
+
63
+ async onReady() {
64
+ this.log.info('aura adapter started');
65
+
66
+ // Dashboard-Konfiguration als Datenpunkt anlegen
67
+ await this.setObjectNotExistsAsync('config.dashboard', {
68
+ type: 'state',
69
+ common: {
70
+ name: 'Dashboard configuration',
71
+ type: 'string',
72
+ role: 'json',
73
+ read: true,
74
+ write: true,
75
+ def: '{"widgets":[]}',
76
+ },
77
+ native: {},
78
+ });
79
+
80
+ // Navigation-Datenpunkt: Wert auf Tab-Slug oder externe URL setzen,
81
+ // um das Tablet auf diese Seite zu navigieren.
82
+ await this.setObjectNotExistsAsync('navigate.url', {
83
+ type: 'state',
84
+ common: {
85
+ name: 'Navigate to URL or tab slug',
86
+ type: 'string',
87
+ role: 'url',
88
+ read: true,
89
+ write: true,
90
+ def: '',
91
+ },
92
+ native: {},
93
+ });
94
+
95
+ this.setState('info.connection', true, true);
96
+ this.log.info('aura ready – serving frontend from www/');
97
+ }
98
+
99
+ onUnload(callback) {
100
+ try {
101
+ callback();
102
+ } catch {
103
+ callback();
104
+ }
105
+ }
106
+ }
107
+
108
+ if (require.main !== module) {
109
+ module.exports = (options) => new Aura(options);
110
+ } else {
111
+ new Aura();
112
+ }
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "iobroker.aura",
3
+ "version": "0.0.7",
4
+ "description": "Modern visualization dashboard for ioBroker",
5
+ "main": "lib/main.js",
6
+ "license": "MIT",
7
+ "files": [
8
+ "lib/",
9
+ "www/",
10
+ "io-package.json"
11
+ ],
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/hdering/iobroker.aura"
15
+ },
16
+ "bugs": {
17
+ "url": "https://github.com/hdering/iobroker.aura/issues"
18
+ },
19
+ "scripts": {
20
+ "dev": "vite",
21
+ "build": "tsc && vite build",
22
+ "build:adapter": "tsc && cross-env VITE_BASE=/aura/ vite build",
23
+ "preview": "vite preview"
24
+ },
25
+ "dependencies": {
26
+ "@iobroker/adapter-core": "^3.2.2",
27
+ "echarts": "^6.0.0",
28
+ "echarts-for-react": "^3.0.6",
29
+ "ical.js": "^2.2.1"
30
+ },
31
+ "devDependencies": {
32
+ "@types/react": "^18.3.3",
33
+ "@types/react-dom": "^18.3.0",
34
+ "@types/react-grid-layout": "^1.3.5",
35
+ "@types/socket.io-client": "^1.4.36",
36
+ "@vitejs/plugin-react": "^4.3.1",
37
+ "autoprefixer": "^10.4.19",
38
+ "cross-env": "^10.1.0",
39
+ "lucide-react": "^1.7.0",
40
+ "postcss": "^8.4.39",
41
+ "react": "^18.3.1",
42
+ "react-dom": "^18.3.1",
43
+ "react-grid-layout": "^1.4.4",
44
+ "react-router-dom": "^7.14.0",
45
+ "recharts": "^2.12.7",
46
+ "socket.io-client": "^2.5.0",
47
+ "tailwindcss": "^3.4.6",
48
+ "typescript": "^5.5.3",
49
+ "vite": "^5.3.4",
50
+ "vitest": "^2.0.3",
51
+ "zustand": "^4.5.4"
52
+ }
53
+ }