iobroker.sql 4.0.4 → 4.1.3
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 +96 -14
- package/admin/custom/assets/Components-nTLElZ7y.js +1 -0
- package/admin/custom/assets/DataBrowser-CyjKP_L-.js +1 -0
- package/admin/custom/assets/_virtual_mf-localSharedImportMap___mfe_internal__SqlComponentsSet__mf_owner__1-BKlHk-3o.js +1 -0
- package/admin/custom/assets/_virtual_mf___mfe_internal__SqlComponentsSet__mf_owner__1__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-1_ecMmwM.js +1243 -0
- package/admin/custom/assets/_virtual_mf___mfe_internal__SqlComponentsSet__mf_owner__1__loadShare___mf_0_iobroker_mf_1_json_mf_2_config__loadShare__.js-BJcL2b_b.js +1494 -0
- package/admin/custom/assets/_virtual_mf___mfe_internal__SqlComponentsSet__mf_owner__1__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-DOWbo5mU.js +9 -0
- package/admin/custom/assets/hostInit-CJsaB1F7.js +1 -0
- package/admin/custom/assets/index-D4ovp6PK.js +1 -0
- package/admin/custom/assets/lib-B-9Z42f0.js +3 -0
- package/admin/custom/assets/mf-entry-bootstrap-0-9382e792.js +41 -0
- package/admin/custom/assets/rolldown-runtime-C0FnF6B9.js +1 -0
- package/admin/custom/assets/virtualExposes-C4J_LR3_.js +1 -0
- package/admin/custom/assets/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__SqlComponentsSet__customComponents_js-C7xpzcn4.js +1 -0
- package/admin/custom/assets/virtual_mf-exposes___mfe_internal__SqlComponentsSet__customComponents_js-DBI8_iGe.js +2 -0
- package/admin/custom/assets/vite-preload-helper-B7qeedMF.js +1 -0
- package/admin/custom/customComponents.js +12 -0
- package/admin/custom/i18n/de.json +30 -0
- package/admin/custom/i18n/en.json +30 -0
- package/admin/custom/i18n/es.json +30 -0
- package/admin/custom/i18n/fr.json +30 -0
- package/admin/custom/i18n/it.json +30 -0
- package/admin/custom/i18n/nl.json +30 -0
- package/admin/custom/i18n/pl.json +30 -0
- package/admin/custom/i18n/pt.json +30 -0
- package/admin/custom/i18n/ru.json +30 -0
- package/admin/custom/i18n/zh-cn.json +30 -0
- package/admin/custom/mf-manifest.json +1 -0
- package/admin/i18n/{de/translations.json → de.json} +7 -1
- package/admin/i18n/{en/translations.json → en.json} +7 -1
- package/admin/i18n/{es/translations.json → es.json} +7 -1
- package/admin/i18n/{fr/translations.json → fr.json} +7 -1
- package/admin/i18n/{it/translations.json → it.json} +7 -1
- package/admin/i18n/{nl/translations.json → nl.json} +7 -1
- package/admin/i18n/{pl/translations.json → pl.json} +7 -1
- package/admin/i18n/{pt/translations.json → pt.json} +7 -1
- package/admin/i18n/{ru/translations.json → ru.json} +7 -1
- package/admin/i18n/{zh-cn/translations.json → zh-cn.json} +7 -1
- package/admin/jsonConfig.json +14 -0
- package/admin/jsonCustom.json +18 -0
- package/build/lib/errors.js +115 -0
- package/build/lib/errors.js.map +1 -0
- package/build/lib/mssql.js +22 -0
- package/build/lib/mssql.js.map +1 -1
- package/build/lib/mysql.js +22 -0
- package/build/lib/mysql.js.map +1 -1
- package/build/lib/postgresql.js +22 -0
- package/build/lib/postgresql.js.map +1 -1
- package/build/lib/sqlite.js +22 -0
- package/build/lib/sqlite.js.map +1 -1
- package/build/main.js +375 -99
- package/build/main.js.map +1 -1
- package/io-package.json +40 -40
- package/package.json +14 -7
- package/build/lib/aggregate.js +0 -1490
- package/build/lib/aggregate.js.map +0 -1
package/README.md
CHANGED
|
@@ -60,7 +60,7 @@ SQLite DB must not be installed extra. It is just a file on disk, but to install
|
|
|
60
60
|
sudo apt-get install build-essential
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
For windows install node.js with "Automatically install the necessary tools..."-option and then reinstall the adapter, e.g:
|
|
63
|
+
For windows install node.js with the "Automatically install the necessary tools..."-option and then reinstall the adapter, e.g:
|
|
64
64
|
|
|
65
65
|
```bash
|
|
66
66
|
cd /opt/iobroker
|
|
@@ -355,6 +355,74 @@ Example if your database is called 'iobroker':
|
|
|
355
355
|
| MS-SQL | `SELECT * FROM iobroker.dbo.datapoints ...` |
|
|
356
356
|
| MySQL | `SELECT * FROM iobroker.datapoints ...` |
|
|
357
357
|
|
|
358
|
+
## Data browser
|
|
359
|
+
The instance settings contain a tab **Data browser**: on the left all datapoints that have data in the
|
|
360
|
+
database, on the right the stored values of the selected one. The values can be paged through, edited,
|
|
361
|
+
deleted and new ones can be inserted. The tab needs a running instance.
|
|
362
|
+
|
|
363
|
+
The component is a JSON-Config `custom` component. Its sources are in `src-admin`, the built bundle in
|
|
364
|
+
`admin/custom` is committed:
|
|
365
|
+
|
|
366
|
+
```bash
|
|
367
|
+
npm run npm:admin # install the dependencies of the component (only once)
|
|
368
|
+
npm run build:admin # clean, build and copy into admin/custom
|
|
369
|
+
cd src-admin && npm start # development server on http://localhost:4173
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
The datapoint list comes from the message **getDatapoints**, which can also be used from scripts:
|
|
373
|
+
|
|
374
|
+
```js
|
|
375
|
+
sendTo('sql.0', 'getDatapoints', {}, result => {
|
|
376
|
+
// [{id: 'system.adapter.admin.0.memRss', index: 1, type: 'Number'}, ...]
|
|
377
|
+
console.log(JSON.stringify(result.result));
|
|
378
|
+
});
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
It returns every datapoint of the `datapoints` table - including the ones whose logging is disabled -
|
|
382
|
+
sorted by ID. In contrast to `getDpOverview`, it does not determine the first timestamp of every
|
|
383
|
+
datapoint and answers immediately.
|
|
384
|
+
|
|
385
|
+
## Read raw values
|
|
386
|
+
`getHistory` is made for charts: it aggregates, interpolates, rounds and adds the values directly before and
|
|
387
|
+
after the requested range. To see and page through the stored rows exactly as they are in the database, use
|
|
388
|
+
**getRawEntries**:
|
|
389
|
+
|
|
390
|
+
```js
|
|
391
|
+
sendTo(
|
|
392
|
+
'sql.0',
|
|
393
|
+
'getRawEntries',
|
|
394
|
+
{
|
|
395
|
+
id: 'system.adapter.admin.0.memRss',
|
|
396
|
+
start: Date.now() - 3600000, // optional, inclusive
|
|
397
|
+
end: Date.now(), // optional, inclusive
|
|
398
|
+
limit: 100, // optional, default 100, maximum 2000
|
|
399
|
+
offset: 0, // optional, default 0
|
|
400
|
+
sort: 'desc', // optional, 'desc' (newest first, default) or 'asc'
|
|
401
|
+
},
|
|
402
|
+
result => {
|
|
403
|
+
if (result.error) {
|
|
404
|
+
console.error(result.error);
|
|
405
|
+
} else {
|
|
406
|
+
// total = number of all entries matching start/end, so a table can page through them
|
|
407
|
+
console.log(`${result.result.length} of ${result.total} entries`);
|
|
408
|
+
// [{ts: 1589458809352, val: 51.5, ack: 1, q: 0, from: 'system.adapter.admin.0'}, ...]
|
|
409
|
+
console.log(JSON.stringify(result.result));
|
|
410
|
+
}
|
|
411
|
+
},
|
|
412
|
+
);
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
The answer additionally contains `id`, `index` (the ID in the `datapoints` table), `type`
|
|
416
|
+
(`Number`, `String` or `Boolean`), `table` (`ts_number`, `ts_string` or `ts_bool`) and the used
|
|
417
|
+
`limit`, `offset` and `sort`.
|
|
418
|
+
|
|
419
|
+
The values are returned as they come from the database and are **not** converted: `ack` and boolean values
|
|
420
|
+
are `0`/`1` in most databases, and `val` of a string datapoint is the stored string. `from` is `null` if no
|
|
421
|
+
source was stored.
|
|
422
|
+
|
|
423
|
+
Like `update`, `delete` and `storeState`, this works for datapoints whose logging is disabled too, as long as
|
|
424
|
+
they still have entries in the database. If the datapoint is unknown, the answer contains an `error`.
|
|
425
|
+
|
|
358
426
|
## storeState
|
|
359
427
|
|
|
360
428
|
If you want to write other data into the SQL database, you can use the build
|
|
@@ -461,6 +529,10 @@ Time could be ms since epoch or ans string, that could be converted by JavaScrip
|
|
|
461
529
|
|
|
462
530
|
Values will be deleted including defined limits. `ts >= start AND ts <= end`
|
|
463
531
|
|
|
532
|
+
All three commands accept one single data point as object too, e.g. `sendTo('sql.0', 'deleteAll', {id: 'mbus.0.counter.xxx'}, result => ...)`.
|
|
533
|
+
In this case, the answer is sent after the deletion was executed and it is either `{success: true}` or `{error: "..."}`.
|
|
534
|
+
With an array, the answer is sent immediately and does not tell anything about the single deletions.
|
|
535
|
+
|
|
464
536
|
## change state
|
|
465
537
|
If you want to change entry's value, quality or acknowledge flag in the database, you can use the build in system function **update**:
|
|
466
538
|
|
|
@@ -546,23 +618,33 @@ sendTo('sql.0', 'getEnabledDPs', {}, function (result) {
|
|
|
546
618
|
-->
|
|
547
619
|
|
|
548
620
|
## Changelog
|
|
621
|
+
### 4.1.3 (2026-08-27)
|
|
622
|
+
* (@GermanBluefox) Connection errors are logged with the real reason again: Node reports a failed TCP connect as an `AggregateError` whose own message is empty, so the log only showed the word `AggregateError` instead of e.g. `connect ECONNREFUSED 127.0.0.1:3306`
|
|
623
|
+
* (@GermanBluefox) The reconnect loop no longer repeats the same connection error every 30 seconds: the first occurrence is logged as error, repetitions go to debug and once an hour a reminder is logged
|
|
624
|
+
|
|
625
|
+
### 4.1.2 (2026-08-27)
|
|
626
|
+
* (@GermanBluefox) Fixed `enableHistory` being answered with `success: true` but silently doing nothing when it arrived while the adapter was still starting up: the adapter subscribed to object changes only after it had read the logging settings, so a message that landed in that gap activated no logging
|
|
627
|
+
* (@joltcoke) Fixed average and total returning null for every interval that contains a null value: parseFloat(null) is NaN and poisoned the sum of the whole interval (thanks to @joltcoke, ioBroker/ioBroker.sql#526). As the result was NaN and not null, ignoreNull could not act on it either
|
|
628
|
+
* (@joltcoke) Fixed min returning a wrong value if the interval contains a null, minmax losing the minimum if the interval starts with a null, and percentile/quantile counting a null as 0
|
|
629
|
+
|
|
630
|
+
### 4.1.0 (2026-08-26)
|
|
631
|
+
* (@ipod86) Added a button to the datapoint settings to delete all logged values of this datapoint
|
|
632
|
+
* (@GermanBluefox) The messages `delete`, `deleteRange` and `deleteAll` now report errors back to the caller instead of always answering with success
|
|
633
|
+
* (@GermanBluefox) The messages `delete`, `deleteRange` and `deleteAll` work now also for datapoints whose logging is disabled
|
|
634
|
+
* (@GermanBluefox) The messages `delete`, `deleteRange` and `deleteAll` delete the counter values of a numeric datapoint (table `ts_counter`) too
|
|
635
|
+
* (@GermanBluefox) Fixed `NaN` as a result of the aggregation `percentile` with 100 or `quantile` with 1
|
|
636
|
+
* (@GermanBluefox) Fixed the last value of the `integralTotal` aggregation: it was interpolated onto the start instead of the end of the requested range
|
|
637
|
+
* (@GermanBluefox) Added the message `getRawEntries` to read the stored values of one datapoint page by page (with the total number of entries) for tools that show or edit the raw data
|
|
638
|
+
* (@GermanBluefox) The message `update` works now also for datapoints whose logging is disabled and reports errors back to the caller
|
|
639
|
+
* (@GermanBluefox) `storeState` uses the data type stored in the database for known datapoints instead of deriving it from the value
|
|
640
|
+
* (@GermanBluefox) Added the tab `Data browser` to the instance settings: show, edit, delete and insert the stored values of a datapoint
|
|
641
|
+
* (@GermanBluefox) Added the message `getDatapoints` that returns all datapoints of the database immediately
|
|
642
|
+
|
|
549
643
|
### 4.0.4 (2026-08-11)
|
|
550
644
|
* (@GermanBluefox) Fixed that nothing was stored for datapoints with an `aliasId`: the adapter subscribed to the alias name instead of the real state ID, so no state change ever arrived
|
|
551
645
|
|
|
552
646
|
### 4.0.3 (2026-08-11)
|
|
553
|
-
* (@GermanBluefox) Corrected small configuration error
|
|
554
|
-
|
|
555
|
-
### 4.0.2 (2026-08-10)
|
|
556
|
-
* (@GermanBluefox) Fixed empty charts for the aggregation `onchange` ("raw" in e-charts): it was run through the interval aggregation and returned only `null` values
|
|
557
|
-
* (@GermanBluefox) The MySQL and phpMyAdmin docker containers are no longer enabled by default: instances without the docker settings in their config (e.g. after an update from 3.x) reported "Docker is not installed"
|
|
558
|
-
|
|
559
|
-
### 4.0.1 (2026-08-07)
|
|
560
|
-
* (@GermanBluefox) Fixed MySQL error "Can't create more than max_prepared_stmt_count statements": every query allocated a server-side prepared statement
|
|
561
|
-
* (@GermanBluefox) Batches of more than 500 values are no longer sent as one multi-statement query
|
|
562
|
-
|
|
563
|
-
### 4.0.0 (2026-08-04)
|
|
564
|
-
* (@GermanBluefox) Migrated to TypeScript
|
|
565
|
-
* (@GermanBluefox) Node.js 22 is now needed at a minimum!
|
|
647
|
+
* (@GermanBluefox) Corrected a small configuration error
|
|
566
648
|
|
|
567
649
|
[Older changelogs can be found there](CHANGELOG_OLD.md)
|
|
568
650
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./DataBrowser-CyjKP_L-.js";var t={DataBrowser:e};export{t as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./_virtual_mf___mfe_internal__SqlComponentsSet__mf_owner__1__loadShare___mf_0_iobroker_mf_1_json_mf_2_config__loadShare__.js-BJcL2b_b.js";import{$t as t,An as n,B as r,Br as i,Bt as a,Dn as o,En as s,F as c,H as l,I as u,In as d,Nn as f,On as p,Ot as m,P as h,Rr as g,Sn as _,Tt as v,Ut as y,Vt as b,Wt as x,Xt as S,Zt as C,_ as w,cn as T,fn as E,hi as D,jt as O,ln as k,lt as A,pt as j,qt as M,rn as N,tn as P,u as F,un as I,wn as L,xn as R,zn as z,zr as B,zt as V}from"./_virtual_mf___mfe_internal__SqlComponentsSet__mf_owner__1__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-1_ecMmwM.js";D();var H={root:{display:`flex`,width:`100%`,height:`calc(100vh - 220px)`,minHeight:400,gap:8},list:{width:320,minWidth:220,display:`flex`,flexDirection:`column`,overflow:`hidden`},filterField:{padding:8,flexShrink:0},listItems:{overflowY:`auto`,flexGrow:1,minHeight:0},data:{flexGrow:1,display:`flex`,flexDirection:`column`,overflow:`hidden`},toolbar:{display:`flex`,alignItems:`center`,flexWrap:`nowrap`,gap:8,padding:8,overflow:`hidden`,flexShrink:0},title:{display:`flex`,flexDirection:`column`,flexGrow:1,minWidth:60,overflow:`hidden`},titleId:{fontWeight:`bold`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},titleName:{fontSize:`smaller`,opacity:.7,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},dateField:{width:200,flexShrink:0},table:{overflowY:`auto`,flexGrow:1,minHeight:0},nowrap:{whiteSpace:`nowrap`},pageInfo:{whiteSpace:`nowrap`,flexShrink:0},grow:{flexGrow:1}},U=e=>({"& input::-webkit-calendar-picker-indicator":{filter:e.palette.mode===`dark`?`invert(1)`:`none`,cursor:`pointer`}});function W(e){let t=new Date(e);if(isNaN(t.getTime()))return String(e);let n=(e,t)=>e.toString().padStart(t||2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}.${n(t.getMilliseconds(),3)}`}function G(e){let t=e=>e.toString().padStart(2,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`}function K(e){let t=e=>e.toString().padStart(2,`0`);return`${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}`}function q(e){if(!e)return;let t=new Date(e).getTime();return isNaN(t)?void 0:t}var J=class extends e{constructor(e){super(e),this.state={...this.state,points:null,names:{},filter:``,selected:null,rows:[],total:0,page:0,rowsPerPage:100,sort:`desc`,start:``,end:``,checked:[],loadingPoints:!1,loadingRows:!1,errorText:``,entryDialog:null,confirmText:``,confirmAction:null}}async componentDidMount(){await super.componentDidMount(),this.props.alive&&await this.loadDatapoints()}async componentDidUpdate(e){this.props.alive&&!e.alive&&!this.state.points&&await this.loadDatapoints()}get instance(){return`${this.props.oContext.adapterName}.${this.props.oContext.instance}`}async sendToInstance(e,t){let n=await this.props.oContext.socket.sendTo(this.instance,e,t);if(n!=null&&n.error)throw Error(n.error);return n}async loadDatapoints(){this.setState({loadingPoints:!0,errorText:``});try{let e=await this.sendToInstance(`getDatapoints`,{}),t=(e==null?void 0:e.result)||[];this.setState({points:t,loadingPoints:!1},()=>void this.loadNames(t))}catch(e){this.setState({loadingPoints:!1,points:[],errorText:e.message})}}async loadNames(e){if(e.length)try{let t=await this.props.oContext.socket.getObjectsById(e.map(e=>e.id)),n={};for(let r of e){let e=t==null?void 0:t[r.id],i=e?w.getObjectNameFromObj(e,null,{language:F.getLanguage()}):``;i&&i!==r.id&&(n[r.id]=i)}this.setState({names:n})}catch(e){console.warn(`Cannot read the names of the objects: ${e.message}`)}}async loadRows(){let e=this.state.selected;if(e){this.setState({loadingRows:!0,errorText:``});try{let t=await this.sendToInstance(`getRawEntries`,{id:e.id,start:q(this.state.start),end:q(this.state.end),limit:this.state.rowsPerPage,offset:this.state.page*this.state.rowsPerPage,sort:this.state.sort});this.setState({rows:(t==null?void 0:t.result)||[],total:(t==null?void 0:t.total)||0,checked:[],loadingRows:!1})}catch(e){this.setState({rows:[],total:0,loadingRows:!1,errorText:e.message})}}}selectDatapoint(e){this.setState({selected:e,page:0,rows:[],total:0,checked:[]},()=>void this.loadRows())}parseValue(e){var t,n;if(e===``)return null;if(((t=this.state.selected)==null?void 0:t.type)===`Number`){let t=parseFloat(e.replace(`,`,`.`));return isNaN(t)?0:t}return((n=this.state.selected)==null?void 0:n.type)===`Boolean`?e===`true`||e===`1`:e}async saveEntry(){let e=this.state.entryDialog,t=this.state.selected;if(!e||!t)return;let n=parseInt(e.ts,10);if(!n){this.setState({errorText:`Invalid timestamp`});return}let r={ts:n,val:this.parseValue(e.val),ack:e.ack,q:parseInt(e.q,10)||0};this.setState({entryDialog:null,loadingRows:!0});try{e.original?await this.sendToInstance(`update`,{id:t.id,state:r}):await this.sendToInstance(`storeState`,{id:t.id,state:r})}catch(e){this.setState({errorText:e.message})}await this.loadRows()}async deleteEntries(e){let t=this.state.selected;if(!(!t||!e.length)){this.setState({loadingRows:!0});try{e.length===1?await this.sendToInstance(`delete`,{id:t.id,ts:e[0]}):await this.sendToInstance(`delete`,e.map(e=>({id:t.id,ts:e})))}catch(e){this.setState({errorText:e.message})}await this.loadRows()}}renderDatapoints(){let e=this.state.filter.toLowerCase(),t=(this.state.points||[]).filter(t=>{var n;return!e||t.id.toLowerCase().includes(e)||((n=this.state.names[t.id])==null?void 0:n.toLowerCase().includes(e))});return i(d,{style:H.list,children:[B(M,{variant:`standard`,style:H.filterField,value:this.state.filter,onChange:e=>this.setState({filter:e.target.value}),placeholder:F.t(`sql_filter`),slotProps:{input:{startAdornment:B(L,{position:`start`,children:B(m,{})}),endAdornment:this.state.filter?B(L,{position:`end`,children:B(_,{size:`small`,onClick:()=>this.setState({filter:``}),children:B(u,{})})}):null}}}),this.state.loadingPoints?B(s,{}):null,i(o,{dense:!0,style:H.listItems,children:[t.map(e=>{var t;return B(p,{selected:((t=this.state.selected)==null?void 0:t.id)===e.id,onClick:()=>this.selectDatapoint(e),sx:e=>({"&.Mui-selected":{backgroundColor:e.palette.primary.main,color:e.palette.primary.contrastText,"& .MuiListItemText-secondary":{color:e.palette.primary.contrastText,opacity:.8},"&:hover":{backgroundColor:e.palette.primary.dark}}}),children:B(n,{primary:e.id,secondary:i(g,{children:[this.state.names[e.id]?B(`b`,{children:this.state.names[e.id]}):null,this.state.names[e.id]?` `:``,`[${e.type||`?`}]`]}),slotProps:{primary:{style:{wordBreak:`break-all`}},secondary:{style:{wordBreak:`break-word`}}}})},e.id)}),!t.length&&!this.state.loadingPoints?B(C,{style:{padding:16,opacity:.7},children:F.t(this.state.filter?`sql_no_data`:`sql_no_datapoints`)}):null]})]})}renderToolbar(){var e,t;let{page:n,rowsPerPage:a,total:o}=this.state,s=o?n*a+1:0,l=Math.min((n+1)*a,o);return i(`div`,{style:H.toolbar,children:[i(`div`,{style:H.title,children:[B(S,{title:((e=this.state.selected)==null?void 0:e.id)||``,children:B(`span`,{style:H.titleId,children:(t=this.state.selected)==null?void 0:t.id})}),this.state.selected&&this.state.names[this.state.selected.id]?B(`span`,{style:H.titleName,children:this.state.names[this.state.selected.id]}):null]}),B(S,{title:F.t(`sql_range_start`),children:B(M,{variant:`outlined`,size:`small`,style:H.dateField,sx:U,type:`datetime-local`,value:this.state.start,onChange:e=>this.setState({start:e.target.value,page:0},()=>void this.loadRows())})}),B(S,{title:F.t(`sql_range_end`),children:B(M,{variant:`outlined`,size:`small`,style:H.dateField,sx:U,type:`datetime-local`,value:this.state.end,onChange:e=>this.setState({end:e.target.value,page:0},()=>void this.loadRows())})}),B(z,{variant:`outlined`,size:`small`,value:a,onChange:e=>this.setState({rowsPerPage:Number(e.target.value),page:0},()=>void this.loadRows()),children:[50,100,500,1e3].map(e=>B(f,{value:e,children:e},e))}),B(S,{title:F.t(this.state.sort===`desc`?`sql_sort_desc`:`sql_sort_asc`),children:B(_,{size:`small`,onClick:()=>this.setState({sort:this.state.sort===`desc`?`asc`:`desc`,page:0},()=>void this.loadRows()),children:this.state.sort===`desc`?B(A,{}):B(j,{})})}),B(C,{style:H.pageInfo,children:F.t(`sql_page`,s.toString(),l.toString(),o.toString())}),B(_,{size:`small`,disabled:!n,onClick:()=>this.setState({page:n-1},()=>void this.loadRows()),children:B(h,{})}),B(_,{size:`small`,disabled:l>=o,onClick:()=>this.setState({page:n+1},()=>void this.loadRows()),children:B(c,{})}),B(S,{title:F.t(`sql_refresh`),children:B(_,{size:`small`,onClick:()=>void this.loadRows(),children:B(v,{})})}),B(S,{title:F.t(`sql_add`),children:B(_,{size:`small`,color:`primary`,onClick:()=>this.setState({entryDialog:{original:null,ts:Date.now().toString(),val:``,ack:!0,q:`0`}}),children:B(O,{})})}),B(S,{title:F.t(`sql_delete_selected`),children:B(`span`,{children:B(_,{size:`small`,disabled:!this.state.checked.length,onClick:()=>this.setState({confirmText:F.t(`sql_confirm_delete`,this.state.checked.length.toString()),confirmAction:()=>void this.deleteEntries(this.state.checked)}),children:B(r,{})})})})]})}renderTable(){return i(`div`,{style:H.table,children:[i(V,{size:`small`,stickyHeader:!0,children:[B(y,{children:i(x,{children:[B(b,{padding:`checkbox`,children:B(N,{indeterminate:!!this.state.checked.length&&this.state.checked.length<this.state.rows.length,checked:!!this.state.rows.length&&this.state.checked.length===this.state.rows.length,onChange:e=>this.setState({checked:e.target.checked?this.state.rows.map(e=>e.ts):[]})})}),B(b,{children:F.t(`sql_time`)}),B(b,{children:F.t(`sql_value`)}),B(b,{children:F.t(`sql_ack`)}),B(b,{children:F.t(`sql_quality`)}),B(b,{children:F.t(`sql_from`)}),B(b,{})]})}),B(a,{children:this.state.rows.map(e=>i(x,{hover:!0,children:[B(b,{padding:`checkbox`,children:B(N,{checked:this.state.checked.includes(e.ts),onChange:t=>this.setState({checked:t.target.checked?[...this.state.checked,e.ts]:this.state.checked.filter(t=>t!==e.ts)})})}),B(b,{style:H.nowrap,children:B(S,{title:e.ts.toString(),children:B(`span`,{children:W(e.ts)})})}),B(b,{style:{wordBreak:`break-all`},children:e.val===null||e.val===void 0?B(`span`,{style:{opacity:.5},children:`null`}):e.val.toString()}),B(b,{children:e.ack?`✓`:``}),B(b,{children:e.q??``}),B(b,{style:{opacity:.7},children:e.from||``}),i(b,{padding:`none`,children:[B(_,{size:`small`,onClick:()=>this.setState({entryDialog:{original:e,ts:e.ts.toString(),val:e.val===null||e.val===void 0?``:e.val.toString(),ack:!!e.ack,q:(e.q??0).toString()}}),children:B(l,{fontSize:`small`})}),B(_,{size:`small`,onClick:()=>this.setState({confirmText:F.t(`sql_confirm_delete_one`,W(e.ts)),confirmAction:()=>void this.deleteEntries([e.ts])}),children:B(r,{fontSize:`small`})})]})]},e.ts))})]}),!this.state.rows.length&&!this.state.loadingRows?B(C,{style:{padding:16,opacity:.7},children:F.t(`sql_no_data`)}):null]})}renderTimeSelector(e){let t=parseInt(e.ts,10),n=!isNaN(t),r=!!e.original,a=(r,i)=>{let a=new Date(n?t:Date.now()),o=G(a),s=K(a),c=a.getMilliseconds();if(r===`date`){if(!i)return;o=i}else if(r===`time`){if(!i)return;s=i.length===5?`${i}:00`:i}else c=Math.min(999,Math.max(0,parseInt(i,10)||0));let l=new Date(`${o}T${s}.${c.toString().padStart(3,`0`)}`).getTime();isNaN(l)||this.setState({entryDialog:{...e,ts:l.toString()}})};return i(`div`,{children:[i(`div`,{style:{display:`flex`,gap:8,alignItems:`center`},children:[B(M,{label:F.t(`sql_date`),type:`date`,value:n?G(new Date(t)):``,disabled:r,style:{flexGrow:1},sx:U,slotProps:{inputLabel:{shrink:!0}},onChange:e=>a(`date`,e.target.value)}),B(M,{label:F.t(`sql_time`),type:`time`,value:n?K(new Date(t)):``,disabled:r,style:{flexGrow:1},sx:U,slotProps:{inputLabel:{shrink:!0},htmlInput:{step:1}},onChange:e=>a(`time`,e.target.value)}),B(M,{label:F.t(`sql_ms`),type:`number`,value:n?new Date(t).getMilliseconds():``,disabled:r,style:{width:100},slotProps:{inputLabel:{shrink:!0},htmlInput:{min:0,max:999}},onChange:e=>a(`ms`,e.target.value)})]}),B(C,{variant:`caption`,style:{opacity:.7},children:n?`${W(t)} · ${t}`:``})]})}renderEntryDialog(){var e;let t=this.state.entryDialog;return t?i(T,{open:!0,maxWidth:`sm`,fullWidth:!0,onClose:()=>this.setState({entryDialog:null}),children:[B(E,{children:F.t(t.original?`sql_save`:`sql_add`)}),i(I,{style:{display:`flex`,flexDirection:`column`,gap:16,paddingTop:8},children:[this.renderTimeSelector(t),((e=this.state.selected)==null?void 0:e.type)===`Boolean`?i(z,{value:t.val===`true`||t.val===`1`?`true`:`false`,onChange:e=>this.setState({entryDialog:{...t,val:e.target.value}}),children:[B(f,{value:`true`,children:`true`}),B(f,{value:`false`,children:`false`})]}):B(M,{label:F.t(`sql_value`),value:t.val,autoFocus:!0,onChange:e=>this.setState({entryDialog:{...t,val:e.target.value}})}),i(`div`,{style:{display:`flex`,alignItems:`center`,gap:16},children:[B(N,{checked:t.ack,onChange:e=>this.setState({entryDialog:{...t,ack:e.target.checked}})}),B(C,{children:F.t(`sql_ack`)}),B(M,{label:F.t(`sql_quality`),value:t.q,type:`number`,onChange:e=>this.setState({entryDialog:{...t,q:e.target.value}})})]})]}),i(k,{children:[B(P,{variant:`contained`,color:`primary`,onClick:()=>void this.saveEntry(),children:F.t(`sql_save`)}),B(P,{variant:`outlined`,onClick:()=>this.setState({entryDialog:null}),children:F.t(`sql_cancel`)})]})]}):null}renderConfirmDialog(){return this.state.confirmAction?i(T,{open:!0,onClose:()=>this.setState({confirmText:``,confirmAction:null}),children:[B(E,{children:F.t(`sql_delete`)}),B(I,{children:this.state.confirmText}),i(k,{children:[B(P,{variant:`contained`,color:`error`,startIcon:B(r,{}),onClick:()=>{let e=this.state.confirmAction;this.setState({confirmText:``,confirmAction:null},()=>e==null?void 0:e())},children:F.t(`sql_delete`)}),B(P,{variant:`outlined`,onClick:()=>this.setState({confirmText:``,confirmAction:null}),children:F.t(`sql_cancel`)})]})]}):null}renderItem(){return this.props.alive?i(t,{style:H.root,children:[this.renderDatapoints(),i(d,{style:H.data,children:[this.state.errorText?B(R,{severity:`error`,style:{flexShrink:0},onClose:()=>this.setState({errorText:``}),children:this.state.errorText}):null,this.state.selected?i(g,{children:[this.renderToolbar(),this.state.loadingRows?B(s,{}):null,this.renderTable()]}):B(C,{style:{padding:16,opacity:.7},children:F.t(`sql_select_datapoint`)})]}),this.renderEntryDialog(),this.renderConfirmDialog()]}):B(R,{severity:`info`,children:F.t(`sql_instance_not_alive`)})}};export{J as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./vite-preload-helper-B7qeedMF.js";var t={react:async()=>await e(()=>import(`./_virtual_mf___mfe_internal__SqlComponentsSet__mf_owner__1__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-1_ecMmwM.js`).then(e=>(e._i(),e.gi)),[],import.meta.url),"react/jsx-runtime":async()=>await e(()=>import(`./_virtual_mf___mfe_internal__SqlComponentsSet__mf_owner__1__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-1_ecMmwM.js`).then(e=>e.Vr),[],import.meta.url),"react-dom":async()=>await e(()=>import(`./_virtual_mf___mfe_internal__SqlComponentsSet__mf_owner__1__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-1_ecMmwM.js`).then(e=>(e.Jr(),e.qr)),[],import.meta.url),"react-dom/client":async()=>await e(()=>import(`./_virtual_mf___mfe_internal__SqlComponentsSet__mf_owner__1__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-DOWbo5mU.js`).then(e=>e.n),[],import.meta.url),"@mui/material":async()=>await e(()=>import(`./_virtual_mf___mfe_internal__SqlComponentsSet__mf_owner__1__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-1_ecMmwM.js`).then(e=>e.Vn),[],import.meta.url),"@mui/icons-material":async()=>await e(()=>import(`./_virtual_mf___mfe_internal__SqlComponentsSet__mf_owner__1__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-1_ecMmwM.js`).then(e=>e.Ft),[],import.meta.url),"@iobroker/gui-components":async()=>await e(()=>import(`./_virtual_mf___mfe_internal__SqlComponentsSet__mf_owner__1__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-1_ecMmwM.js`).then(e=>e.b),[],import.meta.url),"@iobroker/json-config":async()=>await e(()=>import(`./_virtual_mf___mfe_internal__SqlComponentsSet__mf_owner__1__loadShare___mf_0_iobroker_mf_1_json_mf_2_config__loadShare__.js-BJcL2b_b.js`).then(e=>e.n),[],import.meta.url)},n={react:{name:`react`,version:`19.2.8`,scope:[`default`],loaded:!1,materialize:!0,eager:!1,from:`SqlComponentsSet`,canLiveRebind:!0,async get(){n.react.loaded=!0;let{react:e}=t,r={...await e()};return r.__esModule!==!0&&Object.defineProperty(r,"__esModule",{value:!0,enumerable:!1}),function(){return r}},shareConfig:{singleton:!0,requiredVersion:`*`,strictVersion:!1,eager:!1}},"react/jsx-runtime":{name:`react/jsx-runtime`,version:`19.2.8`,scope:[`default`],loaded:!1,materialize:!0,eager:!1,from:`SqlComponentsSet`,canLiveRebind:!0,async get(){n[`react/jsx-runtime`].loaded=!0;let{"react/jsx-runtime":e}=t,r={...await e()};return r.__esModule!==!0&&Object.defineProperty(r,"__esModule",{value:!0,enumerable:!1}),function(){return r}},shareConfig:{singleton:!0,requiredVersion:`*`,strictVersion:!1,eager:!1}},"react-dom":{name:`react-dom`,version:`19.2.8`,scope:[`default`],loaded:!1,materialize:!0,eager:!1,from:`SqlComponentsSet`,canLiveRebind:!0,async get(){n[`react-dom`].loaded=!0;let{"react-dom":e}=t,r={...await e()};return r.__esModule!==!0&&Object.defineProperty(r,"__esModule",{value:!0,enumerable:!1}),function(){return r}},shareConfig:{singleton:!0,requiredVersion:`*`,strictVersion:!1,eager:!1}},"react-dom/client":{name:`react-dom/client`,version:`19.2.8`,scope:[`default`],loaded:!1,materialize:!0,eager:!1,from:`SqlComponentsSet`,canLiveRebind:!0,async get(){n[`react-dom/client`].loaded=!0;let{"react-dom/client":e}=t,r={...await e()};return r.__esModule!==!0&&Object.defineProperty(r,"__esModule",{value:!0,enumerable:!1}),function(){return r}},shareConfig:{singleton:!0,requiredVersion:`*`,strictVersion:!1,eager:!1}},"@mui/material":{name:`@mui/material`,version:`9.3.1`,scope:[`default`],loaded:!1,materialize:!0,eager:!1,from:`SqlComponentsSet`,canLiveRebind:!0,async get(){n[`@mui/material`].loaded=!0;let{"@mui/material":e}=t,r={...await e()};return r.__esModule!==!0&&Object.defineProperty(r,"__esModule",{value:!0,enumerable:!1}),function(){return r}},shareConfig:{singleton:!0,requiredVersion:`*`,strictVersion:!1,eager:!1}},"@mui/icons-material":{name:`@mui/icons-material`,version:`9.3.1`,scope:[`default`],loaded:!1,materialize:!0,eager:!1,from:`SqlComponentsSet`,canLiveRebind:!0,async get(){n[`@mui/icons-material`].loaded=!0;let{"@mui/icons-material":e}=t,r={...await e()};return r.__esModule!==!0&&Object.defineProperty(r,"__esModule",{value:!0,enumerable:!1}),function(){return r}},shareConfig:{singleton:!0,requiredVersion:`*`,strictVersion:!1,eager:!1}},"@iobroker/gui-components":{name:`@iobroker/gui-components`,version:`10.2.0`,scope:[`default`],loaded:!1,materialize:!0,eager:!1,from:`SqlComponentsSet`,canLiveRebind:!0,async get(){n[`@iobroker/gui-components`].loaded=!0;let{"@iobroker/gui-components":e}=t,r={...await e()};return r.__esModule!==!0&&Object.defineProperty(r,"__esModule",{value:!0,enumerable:!1}),function(){return r}},shareConfig:{singleton:!0,requiredVersion:`*`,strictVersion:!1,eager:!1}},"@iobroker/json-config":{name:`@iobroker/json-config`,version:`9.0.23`,scope:[`default`],loaded:!1,materialize:!0,eager:!1,from:`SqlComponentsSet`,canLiveRebind:!0,async get(){n[`@iobroker/json-config`].loaded=!0;let{"@iobroker/json-config":e}=t,r={...await e()};return r.__esModule!==!0&&Object.defineProperty(r,"__esModule",{value:!0,enumerable:!1}),function(){return r}},shareConfig:{singleton:!0,requiredVersion:`*`,strictVersion:!1,eager:!1}}},r=[];export{r as usedRemotes,n as usedShared};
|