@openremote/or-map 1.8.0-snapshot.20250725074716 → 1.8.0-snapshot.20250725120001
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/@types/maplibre-gl-geocoder.d.ts +2 -2
- package/README.md +113 -113
- package/dist/umd/index.bundle.js +915 -915
- package/dist/umd/index.bundle.js.map +1 -1
- package/dist/umd/index.js +915 -915
- package/dist/umd/index.js.map +1 -1
- package/dist/umd/index.orbundle.js +974 -974
- package/dist/umd/index.orbundle.js.map +1 -1
- package/lib/index.js +519 -39
- package/lib/mapbox-url-utils.js +66 -1
- package/lib/mapwidget.js +885 -1
- package/lib/markers/or-map-marker-asset.js +178 -1
- package/lib/markers/or-map-marker.js +335 -80
- package/lib/or-map-asset-card.js +167 -18
- package/lib/style.js +242 -235
- package/lib/util.js +100 -1
- package/package.json +8 -8
package/lib/or-map-asset-card.js
CHANGED
|
@@ -1,18 +1,167 @@
|
|
|
1
|
-
var __decorate=this&&this.__decorate
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { html, LitElement } from "lit";
|
|
8
|
+
import { customElement, property } from "lit/decorators.js";
|
|
9
|
+
import { classMap } from 'lit-html/directives/class-map.js';
|
|
10
|
+
import { AssetModelUtil } from "@openremote/model";
|
|
11
|
+
import manager, { subscribe, Util } from "@openremote/core";
|
|
12
|
+
import "@openremote/or-icon";
|
|
13
|
+
import { mapAssetCardStyle } from "./style";
|
|
14
|
+
import { InputType } from "@openremote/or-mwc-components/or-mwc-input";
|
|
15
|
+
import { getMarkerIconAndColorFromAssetType } from "./util";
|
|
16
|
+
import { getMarkerConfigAttributeName } from "./markers/or-map-marker-asset";
|
|
17
|
+
export class OrMapAssetCardLoadAssetEvent extends CustomEvent {
|
|
18
|
+
constructor(assetId) {
|
|
19
|
+
super(OrMapAssetCardLoadAssetEvent.NAME, {
|
|
20
|
+
bubbles: true,
|
|
21
|
+
composed: true,
|
|
22
|
+
detail: assetId
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
OrMapAssetCardLoadAssetEvent.NAME = "or-map-asset-card-load-asset";
|
|
27
|
+
export const DefaultConfig = {
|
|
28
|
+
default: {
|
|
29
|
+
exclude: ["notes"]
|
|
30
|
+
},
|
|
31
|
+
assetTypes: {}
|
|
32
|
+
};
|
|
33
|
+
let OrMapAssetCard = class OrMapAssetCard extends subscribe(manager)(LitElement) {
|
|
34
|
+
constructor() {
|
|
35
|
+
super(...arguments);
|
|
36
|
+
this.useAssetColor = true;
|
|
37
|
+
}
|
|
38
|
+
static get styles() {
|
|
39
|
+
return mapAssetCardStyle;
|
|
40
|
+
}
|
|
41
|
+
shouldUpdate(_changedProperties) {
|
|
42
|
+
if (_changedProperties.has("assetId")) {
|
|
43
|
+
this.title = "";
|
|
44
|
+
this.assetIds = this.assetId && this.assetId.length > 0 ? [this.assetId] : undefined;
|
|
45
|
+
if (_changedProperties.size === 1) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return super.shouldUpdate(_changedProperties);
|
|
50
|
+
}
|
|
51
|
+
_onEvent(event) {
|
|
52
|
+
if (event.eventType === "asset") {
|
|
53
|
+
const assetEvent = event;
|
|
54
|
+
switch (assetEvent.cause) {
|
|
55
|
+
case "READ" /* AssetEventCause.READ */:
|
|
56
|
+
case "CREATE" /* AssetEventCause.CREATE */:
|
|
57
|
+
case "UPDATE" /* AssetEventCause.UPDATE */:
|
|
58
|
+
this.asset = assetEvent.asset;
|
|
59
|
+
break;
|
|
60
|
+
case "DELETE" /* AssetEventCause.DELETE */:
|
|
61
|
+
this.asset = undefined;
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (event.eventType === "attribute") {
|
|
66
|
+
if (this.asset) {
|
|
67
|
+
this.asset = Util.updateAsset(this.asset, event);
|
|
68
|
+
this.requestUpdate();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
getCardConfig() {
|
|
73
|
+
let cardConfig = this.config || DefaultConfig;
|
|
74
|
+
if (!this.asset) {
|
|
75
|
+
return cardConfig.default;
|
|
76
|
+
}
|
|
77
|
+
return cardConfig.assetTypes && cardConfig.assetTypes.hasOwnProperty(this.asset.type) ? cardConfig.assetTypes[this.asset.type] : cardConfig.default;
|
|
78
|
+
}
|
|
79
|
+
render() {
|
|
80
|
+
if (!this.asset) {
|
|
81
|
+
return html ``;
|
|
82
|
+
}
|
|
83
|
+
const icon = this.getIcon();
|
|
84
|
+
const color = this.getColor();
|
|
85
|
+
const styleStr = color ? "--internal-or-map-asset-card-header-color: #" + color + ";" : "";
|
|
86
|
+
const cardConfig = this.getCardConfig();
|
|
87
|
+
const attributes = Object.values(this.asset.attributes).filter((attr) => attr.name !== "location" /* WellknownAttributes.LOCATION */);
|
|
88
|
+
const includedAttributes = cardConfig && cardConfig.include ? cardConfig.include : undefined;
|
|
89
|
+
const excludedAttributes = cardConfig && cardConfig.exclude ? cardConfig.exclude : [];
|
|
90
|
+
const attrs = attributes.filter((attr) => (!includedAttributes || includedAttributes.indexOf(attr.name) >= 0)
|
|
91
|
+
&& (!excludedAttributes || excludedAttributes.indexOf(attr.name) < 0)
|
|
92
|
+
&& (!attr.meta || !attr.meta.hasOwnProperty("showOnDashboard" /* WellknownMetaItems.SHOWONDASHBOARD */) || !!Util.getMetaValue("showOnDashboard" /* WellknownMetaItems.SHOWONDASHBOARD */, attr)))
|
|
93
|
+
.sort(Util.sortByString((listItem) => listItem.name));
|
|
94
|
+
const highlightedAttr = getMarkerConfigAttributeName(this.markerconfig, this.asset.type);
|
|
95
|
+
return html `
|
|
96
|
+
<div id="card-container" style="${styleStr}">
|
|
97
|
+
<div id="header">
|
|
98
|
+
${icon ? html `<or-icon icon="${icon}"></or-icon>` : ``}
|
|
99
|
+
<span id="title">${this.asset.name}</span>
|
|
100
|
+
</div>
|
|
101
|
+
<div id="attribute-list">
|
|
102
|
+
<ul>
|
|
103
|
+
${attrs.map((attr) => {
|
|
104
|
+
if (!this.asset || !this.asset.type) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const descriptors = AssetModelUtil.getAttributeAndValueDescriptors(this.asset.type, attr.name, attr);
|
|
108
|
+
if (descriptors && descriptors.length) {
|
|
109
|
+
const label = Util.getAttributeLabel(attr, descriptors[0], this.asset.type, true);
|
|
110
|
+
const value = Util.getAttributeValueAsString(attr, descriptors[0], this.asset.type, false, "-");
|
|
111
|
+
const classes = { highlighted: highlightedAttr === attr.name };
|
|
112
|
+
return html `<li class="${classMap(classes)}"><span class="attribute-name">${label}</span><span class="attribute-value">${value}</span></li>`;
|
|
113
|
+
}
|
|
114
|
+
})}
|
|
115
|
+
</ul>
|
|
116
|
+
</div>
|
|
117
|
+
${cardConfig && cardConfig.hideViewAsset ? html `` : html `
|
|
118
|
+
<div id="footer">
|
|
119
|
+
<or-mwc-input .type="${InputType.BUTTON}" label="viewAsset" @or-mwc-input-changed="${(e) => { e.preventDefault(); this._loadAsset(this.asset.id); }}"></or-mwc-input>
|
|
120
|
+
</div>
|
|
121
|
+
`}
|
|
122
|
+
</div>
|
|
123
|
+
`;
|
|
124
|
+
}
|
|
125
|
+
_loadAsset(assetId) {
|
|
126
|
+
this.dispatchEvent(new OrMapAssetCardLoadAssetEvent(assetId));
|
|
127
|
+
}
|
|
128
|
+
getIcon() {
|
|
129
|
+
var _a;
|
|
130
|
+
if (this.asset) {
|
|
131
|
+
const descriptor = AssetModelUtil.getAssetDescriptor(this.asset.type);
|
|
132
|
+
const icon = (_a = getMarkerIconAndColorFromAssetType(descriptor)) === null || _a === void 0 ? void 0 : _a.icon;
|
|
133
|
+
return icon ? icon : undefined;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
getColor() {
|
|
137
|
+
var _a;
|
|
138
|
+
if (this.asset) {
|
|
139
|
+
const descriptor = AssetModelUtil.getAssetDescriptor(this.asset.type);
|
|
140
|
+
const color = (_a = getMarkerIconAndColorFromAssetType(descriptor)) === null || _a === void 0 ? void 0 : _a.color;
|
|
141
|
+
if (color) {
|
|
142
|
+
// check if range
|
|
143
|
+
return (typeof color === 'string') ? color : color[0].colour;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
__decorate([
|
|
149
|
+
property({ type: String, reflect: true, attribute: true })
|
|
150
|
+
], OrMapAssetCard.prototype, "assetId", void 0);
|
|
151
|
+
__decorate([
|
|
152
|
+
property({ type: Object, attribute: true })
|
|
153
|
+
], OrMapAssetCard.prototype, "asset", void 0);
|
|
154
|
+
__decorate([
|
|
155
|
+
property({ type: Object })
|
|
156
|
+
], OrMapAssetCard.prototype, "config", void 0);
|
|
157
|
+
__decorate([
|
|
158
|
+
property({ type: Object })
|
|
159
|
+
], OrMapAssetCard.prototype, "markerconfig", void 0);
|
|
160
|
+
__decorate([
|
|
161
|
+
property({ type: Boolean, attribute: true })
|
|
162
|
+
], OrMapAssetCard.prototype, "useAssetColor", void 0);
|
|
163
|
+
OrMapAssetCard = __decorate([
|
|
164
|
+
customElement("or-map-asset-card")
|
|
165
|
+
], OrMapAssetCard);
|
|
166
|
+
export { OrMapAssetCard };
|
|
167
|
+
//# sourceMappingURL=or-map-asset-card.js.map
|