@openremote/or-gauge 1.8.0-snapshot.20250723094757 → 1.8.0-snapshot.20250725070921

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/lib/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference path="../@types/gaugeJS.d.ts" />
2
1
  import { LitElement } from "lit";
3
2
  import { Asset, Attribute, AttributeRef } from "@openremote/model";
4
3
  import { GaugeOptions } from "gaugeJS";
@@ -40,7 +39,7 @@ export declare class OrGauge extends LitElement {
40
39
  height: number;
41
40
  }): boolean;
42
41
  getLabelSize(width: number): "s" | "m" | "l" | "xl";
43
- render(): import("lit-html").TemplateResult<1>;
42
+ render(): import("lit").TemplateResult<1>;
44
43
  loadData(attrRef: AttributeRef): Promise<void>;
45
44
  getDefaultConfig(): OrGaugeConfig;
46
45
  }
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var __decorate=this&&this.__decorate||function(t,e,i,s){var a,o=arguments.length,r=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var n=t.length-1;n>=0;n--)(a=t[n])&&(r=(o<3?a(r):o>3?a(e,i,r):a(e,i))||r);return o>3&&r&&Object.defineProperty(e,i,r),r},__awaiter=this&&this.__awaiter||function(t,e,i,s){return new(i||(i=Promise))((function(a,o){function r(t){try{l(s.next(t))}catch(t){o(t)}}function n(t){try{l(s.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?a(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,n)}l((s=s.apply(t,e||[])).next())}))};import{css,html,LitElement}from"lit";import{customElement,property,query,state}from"lit/decorators.js";import{AssetModelUtil}from"@openremote/model";import{Gauge}from"gaugeJS";import manager,{Util}from"@openremote/core";import{i18next}from"@openremote/or-translate";import{debounce}from"lodash";import{getAssetDescriptorIconTemplate}from"@openremote/or-icon";const styling=css`
1
+ var __decorate=this&&this.__decorate||function(t,e,i,a){var s,n=arguments.length,o=n<3?e:null===a?a=Object.getOwnPropertyDescriptor(e,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,a);else for(var r=t.length-1;r>=0;r--)(s=t[r])&&(o=(n<3?s(o):n>3?s(e,i,o):s(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o},__awaiter=this&&this.__awaiter||function(t,e,i,a){return new(i||(i=Promise))(function(s,n){function o(t){try{h(a.next(t))}catch(t){n(t)}}function r(t){try{h(a.throw(t))}catch(t){n(t)}}function h(t){var e;t.done?s(t.value):((e=t.value)instanceof i?e:new i(function(t){t(e)})).then(o,r)}h((a=a.apply(t,e||[])).next())})};import{css as t,html as e,LitElement as i}from"lit";import{customElement as a,property as s,query as n,state as o}from"lit/decorators.js";import{AssetModelUtil as r}from"@openremote/model";import{Gauge as h}from"gaugeJS";import l,{Util as u}from"@openremote/core";import{i18next as d}from"@openremote/or-translate";import{debounce as p}from"lodash";import{getAssetDescriptorIconTemplate as g}from"@openremote/or-icon";let styling=t`
2
2
  :host {
3
3
  display: flex;
4
4
  align-items: center;
@@ -71,24 +71,24 @@ var __decorate=this&&this.__decorate||function(t,e,i,s){var a,o=arguments.length
71
71
  .main-number.unknown, .main-number-unit.unknown {
72
72
  font-size: unset;
73
73
  }
74
- `;let OrGauge=class extends LitElement{static get styles(){return[styling]}constructor(){super(),this.decimals=0,this.loading=!1,this.config||(this.config=this.getDefaultConfig()),this.updateComplete.then((()=>{this.resizeObserver=new ResizeObserver(debounce((t=>{const e=t[0].contentRect;this.gaugeSize={width:e.width,height:e.height},this.updateComplete.then((()=>{this.setupGauge()}))}),200)),this.resizeObserver.observe(this._wrapperElem)}))}willUpdate(t){if(t.has("assetAttribute")){const t=this.assetAttribute[1],e=AssetModelUtil.getAttributeDescriptor(t.name,this.asset.type);this.unit=Util.resolveUnits(Util.getAttributeUnits(t,e,this.asset.type)),this.value=null!=t.value?t.value:NaN}}updated(t){var e,i,s,a;t.has("value")&&(null===(e=this.gauge)||void 0===e||e.set(null!=this.value?this.value:NaN)),t.has("attrRef")&&(this.attrRef?this.loadData(this.attrRef):(this.assetAttribute=void 0,this.value=void 0)),t.has("min")&&null!=this.min&&this.gauge&&(this.gauge.setMinValue(this.min),this.gauge.set(null!=this.value?this.value:NaN)),t.has("max")&&null!=this.max&&this.gauge&&(this.gauge.maxValue=this.max,this.gauge.set(null!=this.value?this.value:NaN)),t.has("thresholds")&&this.thresholds&&(this.config.options.staticZones=[],this.thresholds.sort(((t,e)=>t[0]<e[0]?-1:1)).forEach(((t,e)=>{var i,s,a;const o=t[0],r=this.thresholds[e+1]?this.thresholds[e+1][0]:this.max,n={strokeStyle:t[1],min:this.min&&o&&this.min>o?this.min:this.max&&o&&this.max<o?this.max:o,max:this.max&&r&&this.max<r?this.max:this.min&&r&&this.min>r?this.min:r};null===(a=null===(s=null===(i=this.config)||void 0===i?void 0:i.options)||void 0===s?void 0:s.staticZones)||void 0===a||a.push(n)})),this.min&&(null===(s=null===(i=this.config)||void 0===i?void 0:i.options)||void 0===s?void 0:s.staticZones)&&(this.config.options.staticZones[0].min=this.min),this.gauge&&this.gauge.setOptions(null===(a=this.config)||void 0===a?void 0:a.options))}setupGauge(){var t;this.gauge=new Gauge(this._gaugeElem),this.gauge.setOptions(null===(t=this.config)||void 0===t?void 0:t.options),this.gauge.maxValue=this.max?this.max:100,this.gauge.setMinValue(this.min?this.min:0),this.gauge.animationSpeed=1,this.gauge.set(null!=this.value?this.value:NaN),null==this.value&&this.attrRef&&this.loadData(this.attrRef)}getGaugeWidth(t,e=!0){if(!t)return"unset";const i=t.width,s=1.5*(e?t.height-this._detailsElem.clientHeight:t.height);return Math.min(i,s)+"px"}shouldShowLabel(t){return t.width>70&&t.height>100}getLabelSize(t){return t<120?"s":t<240?"m":t<320?"l":"xl"}render(){const t=null!=this.value?+this.value.toFixed(this.decimals):NaN,e=!this.gaugeSize||this.shouldShowLabel(this.gaugeSize),i=e&&this.gaugeSize?this.getLabelSize(this.gaugeSize.width):"unknown",s=this.getGaugeWidth(this.gaugeSize,e);return html`
74
+ `,OrGauge=class extends i{static get styles(){return[styling]}constructor(){super(),this.decimals=0,this.loading=!1,this.config||(this.config=this.getDefaultConfig()),this.updateComplete.then(()=>{this.resizeObserver=new ResizeObserver(p(t=>{let e=t[0].contentRect;this.gaugeSize={width:e.width,height:e.height},this.updateComplete.then(()=>{this.setupGauge()})},200)),this.resizeObserver.observe(this._wrapperElem)})}willUpdate(t){if(t.has("assetAttribute")){let t=this.assetAttribute[1],e=r.getAttributeDescriptor(t.name,this.asset.type);this.unit=u.resolveUnits(u.getAttributeUnits(t,e,this.asset.type)),this.value=null!=t.value?t.value:NaN}}updated(t){var e,i,a,s;t.has("value")&&(null==(e=this.gauge)||e.set(null!=this.value?this.value:NaN)),t.has("attrRef")&&(this.attrRef?this.loadData(this.attrRef):(this.assetAttribute=void 0,this.value=void 0)),t.has("min")&&null!=this.min&&this.gauge&&(this.gauge.setMinValue(this.min),this.gauge.set(null!=this.value?this.value:NaN)),t.has("max")&&null!=this.max&&this.gauge&&(this.gauge.maxValue=this.max,this.gauge.set(null!=this.value?this.value:NaN)),t.has("thresholds")&&this.thresholds&&(this.config.options.staticZones=[],this.thresholds.sort((t,e)=>t[0]<e[0]?-1:1).forEach((t,e)=>{var i,a,s;let n=t[0],o=this.thresholds[e+1]?this.thresholds[e+1][0]:this.max,r={strokeStyle:t[1],min:this.min&&n&&this.min>n?this.min:this.max&&n&&this.max<n?this.max:n,max:this.max&&o&&this.max<o?this.max:this.min&&o&&this.min>o?this.min:o};null==(s=null==(a=null==(i=this.config)?void 0:i.options)?void 0:a.staticZones)||s.push(r)}),this.min&&(null==(a=null==(i=this.config)?void 0:i.options)?void 0:a.staticZones)&&(this.config.options.staticZones[0].min=this.min),this.gauge&&this.gauge.setOptions(null==(s=this.config)?void 0:s.options))}setupGauge(){var t;this.gauge=new h(this._gaugeElem),this.gauge.setOptions(null==(t=this.config)?void 0:t.options),this.gauge.maxValue=this.max?this.max:100,this.gauge.setMinValue(this.min?this.min:0),this.gauge.animationSpeed=1,this.gauge.set(null!=this.value?this.value:NaN),null==this.value&&this.attrRef&&this.loadData(this.attrRef)}getGaugeWidth(t,e=!0){return t?Math.min(t.width,(e?t.height-this._detailsElem.clientHeight:t.height)*1.5)+"px":"unset"}shouldShowLabel(t){return t.width>70&&t.height>100}getLabelSize(t){return t<120?"s":t<240?"m":t<320?"l":"xl"}render(){let t=null!=this.value?+this.value.toFixed(this.decimals):NaN,i=!this.gaugeSize||this.shouldShowLabel(this.gaugeSize),a=i&&this.gaugeSize?this.getLabelSize(this.gaugeSize.width):"unknown",s=this.getGaugeWidth(this.gaugeSize,i);return e`
75
75
  <div style="position: relative; height: 100%; width: 100%;">
76
76
  <div id="chart-wrapper" style="display: ${this.loading?"none":"flex"};">
77
77
  <div id="chart-container" style="flex: 0 0 0; width: ${s};">
78
78
  <canvas id="chart"></canvas>
79
79
  </div>
80
80
  <div id="details-container">
81
- ${e?html`
81
+ ${i?e`
82
82
  <div class="mainvalue-wrapper">
83
- <span class="main-number-icon">${this.asset?getAssetDescriptorIconTemplate(AssetModelUtil.getAssetDescriptor(this.asset.type)):""}</span>
84
- <span class="main-number ${i}">${t}</span>
85
- <span class="main-number-unit ${i}">${this.unit?this.unit:""}</span>
83
+ <span class="main-number-icon">${this.asset?g(r.getAssetDescriptor(this.asset.type)):""}</span>
84
+ <span class="main-number ${a}">${t}</span>
85
+ <span class="main-number-unit ${a}">${this.unit?this.unit:""}</span>
86
86
  </div>
87
87
  `:void 0}
88
88
  </div>
89
89
  </div>
90
90
  </div>
91
- ${this.loading?html`
92
- <span>${i18next.t("loading")}</span>
91
+ ${this.loading?e`
92
+ <span>${d.t("loading")}</span>
93
93
  `:void 0}
94
- `}loadData(t){return __awaiter(this,void 0,void 0,(function*(){const e=(yield manager.rest.api.AssetResource.queryAssets({ids:[t.id]})).data,i=[t].map((t=>{const i=e.findIndex((e=>e.id===t.id)),s=i>=0?e[i]:void 0;return s&&s.attributes?[i,s.attributes[t.name]]:void 0})).filter((t=>!!t));this.asset=e[0],this.assetAttribute=i[0]}))}getDefaultConfig(){return{attributeRef:void 0,options:{angle:0,lineWidth:.4,radiusScale:1,pointer:{length:.5,strokeWidth:.035,color:"#000000"},staticZones:[],limitMax:!0,limitMin:!0,colorStart:"#000000",colorStop:"#707070",strokeColor:"#ABCDEF",generateGradient:!1,highDpiSupport:!0}}}};__decorate([property({type:Object})],OrGauge.prototype,"attrRef",void 0),__decorate([property({type:Object})],OrGauge.prototype,"asset",void 0),__decorate([property({type:Object})],OrGauge.prototype,"assetAttribute",void 0),__decorate([property()],OrGauge.prototype,"value",void 0),__decorate([property()],OrGauge.prototype,"decimals",void 0),__decorate([property()],OrGauge.prototype,"unit",void 0),__decorate([property()],OrGauge.prototype,"min",void 0),__decorate([property()],OrGauge.prototype,"max",void 0),__decorate([property()],OrGauge.prototype,"thresholds",void 0),__decorate([property()],OrGauge.prototype,"config",void 0),__decorate([property({type:String})],OrGauge.prototype,"realm",void 0),__decorate([state()],OrGauge.prototype,"loading",void 0),__decorate([state()],OrGauge.prototype,"gauge",void 0),__decorate([state()],OrGauge.prototype,"gaugeSize",void 0),__decorate([query("#chart")],OrGauge.prototype,"_gaugeElem",void 0),__decorate([query("#chart-wrapper")],OrGauge.prototype,"_wrapperElem",void 0),__decorate([query("#details-container")],OrGauge.prototype,"_detailsElem",void 0),OrGauge=__decorate([customElement("or-gauge")],OrGauge);export{OrGauge};
94
+ `}loadData(t){return __awaiter(this,void 0,void 0,function*(){let e=(yield l.rest.api.AssetResource.queryAssets({ids:[t.id]})).data,i=[t].map(t=>{let i=e.findIndex(e=>e.id===t.id),a=i>=0?e[i]:void 0;return a&&a.attributes?[i,a.attributes[t.name]]:void 0}).filter(t=>!!t);this.asset=e[0],this.assetAttribute=i[0]})}getDefaultConfig(){return{attributeRef:void 0,options:{angle:0,lineWidth:.4,radiusScale:1,pointer:{length:.5,strokeWidth:.035,color:"#000000"},staticZones:[],limitMax:!0,limitMin:!0,colorStart:"#000000",colorStop:"#707070",strokeColor:"#ABCDEF",generateGradient:!1,highDpiSupport:!0}}}};__decorate([s({type:Object})],OrGauge.prototype,"attrRef",void 0),__decorate([s({type:Object})],OrGauge.prototype,"asset",void 0),__decorate([s({type:Object})],OrGauge.prototype,"assetAttribute",void 0),__decorate([s()],OrGauge.prototype,"value",void 0),__decorate([s()],OrGauge.prototype,"decimals",void 0),__decorate([s()],OrGauge.prototype,"unit",void 0),__decorate([s()],OrGauge.prototype,"min",void 0),__decorate([s()],OrGauge.prototype,"max",void 0),__decorate([s()],OrGauge.prototype,"thresholds",void 0),__decorate([s()],OrGauge.prototype,"config",void 0),__decorate([s({type:String})],OrGauge.prototype,"realm",void 0),__decorate([o()],OrGauge.prototype,"loading",void 0),__decorate([o()],OrGauge.prototype,"gauge",void 0),__decorate([o()],OrGauge.prototype,"gaugeSize",void 0),__decorate([n("#chart")],OrGauge.prototype,"_gaugeElem",void 0),__decorate([n("#chart-wrapper")],OrGauge.prototype,"_wrapperElem",void 0),__decorate([n("#details-container")],OrGauge.prototype,"_detailsElem",void 0),OrGauge=__decorate([a("or-gauge")],OrGauge);export{OrGauge};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openremote/or-gauge",
3
- "version": "1.8.0-snapshot.20250723094757",
3
+ "version": "1.8.0-snapshot.20250725070921",
4
4
  "description": "OpenRemote gauge",
5
5
  "customElements": "custom-elements.json",
6
6
  "main": "dist/umd/index.bundle.js",
@@ -13,21 +13,21 @@
13
13
  "scripts": {
14
14
  "analyze": "npx cem analyze --config ../custom-elements-manifest.config.mjs",
15
15
  "test": "echo \"No tests\" && exit 0",
16
- "prepack": "npx webpack"
16
+ "prepack": "npx rspack"
17
17
  },
18
18
  "author": "OpenRemote",
19
19
  "license": "AGPL-3.0-or-later",
20
20
  "dependencies": {
21
- "@openremote/core": "1.8.0-snapshot.20250723094757",
22
- "@openremote/or-components": "1.8.0-snapshot.20250723094757",
23
- "@openremote/or-icon": "1.8.0-snapshot.20250723094757",
24
- "@openremote/or-mwc-components": "1.8.0-snapshot.20250723094757",
25
- "@openremote/or-translate": "1.8.0-snapshot.20250723094757",
21
+ "@openremote/core": "1.8.0-snapshot.20250725070921",
22
+ "@openremote/or-components": "1.8.0-snapshot.20250725070921",
23
+ "@openremote/or-icon": "1.8.0-snapshot.20250725070921",
24
+ "@openremote/or-mwc-components": "1.8.0-snapshot.20250725070921",
25
+ "@openremote/or-translate": "1.8.0-snapshot.20250725070921",
26
26
  "gaugeJS": "^1.3.7",
27
27
  "lit": "^2.0.2"
28
28
  },
29
29
  "devDependencies": {
30
- "@openremote/util": "1.8.0-snapshot.20250723094757"
30
+ "@openremote/util": "1.8.0-snapshot.20250725070921"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public"
@@ -1,26 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2017 Google LLC
4
- * SPDX-License-Identifier: BSD-3-Clause
5
- */
6
-
7
- /**
8
- * @license
9
- * Copyright 2019 Google LLC
10
- * SPDX-License-Identifier: BSD-3-Clause
11
- */
12
-
13
- /**
14
- * @license
15
- * Copyright 2021 Google LLC
16
- * SPDX-License-Identifier: BSD-3-Clause
17
- */
18
-
19
- /**
20
- * @license
21
- * Lodash <https://lodash.com/>
22
- * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
23
- * Released under MIT license <https://lodash.com/license>
24
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
25
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
26
- */
@@ -1,26 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2017 Google LLC
4
- * SPDX-License-Identifier: BSD-3-Clause
5
- */
6
-
7
- /**
8
- * @license
9
- * Copyright 2019 Google LLC
10
- * SPDX-License-Identifier: BSD-3-Clause
11
- */
12
-
13
- /**
14
- * @license
15
- * Copyright 2021 Google LLC
16
- * SPDX-License-Identifier: BSD-3-Clause
17
- */
18
-
19
- /**
20
- * @license
21
- * Lodash <https://lodash.com/>
22
- * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
23
- * Released under MIT license <https://lodash.com/license>
24
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
25
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
26
- */
@@ -1,53 +0,0 @@
1
- /*!
2
- * Platform.js v1.3.6
3
- * Copyright 2014-2020 Benjamin Tan
4
- * Copyright 2011-2013 John-David Dalton
5
- * Available under MIT license
6
- */
7
-
8
- /**
9
- * @license
10
- * Copyright 2017 Google LLC
11
- * SPDX-License-Identifier: BSD-3-Clause
12
- */
13
-
14
- /**
15
- * @license
16
- * Copyright 2019 Google LLC
17
- * SPDX-License-Identifier: BSD-3-Clause
18
- */
19
-
20
- /**
21
- * @license
22
- * Copyright 2021 Google LLC
23
- * SPDX-License-Identifier: BSD-3-Clause
24
- */
25
-
26
- /**
27
- * @license
28
- * Lodash <https://lodash.com/>
29
- * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
30
- * Released under MIT license <https://lodash.com/license>
31
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
32
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
33
- */
34
-
35
- /**
36
- * [js-sha256]{@link https://github.com/emn178/js-sha256}
37
- *
38
- * @version 0.11.0
39
- * @author Chen, Yi-Cyuan [emn178@gmail.com]
40
- * @copyright Chen, Yi-Cyuan 2014-2024
41
- * @license MIT
42
- */
43
-
44
- /**!
45
- * url-search-params-polyfill
46
- *
47
- * @author Jerry Bendy (https://github.com/jerrybendy)
48
- * @licence MIT
49
- */
50
-
51
- //! moment.js
52
-
53
- //! moment.js locale configuration