@openremote/or-app 1.8.0-snapshot.20250725120000 → 1.8.0-snapshot.20250725123024
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 +87 -87
- package/images/logo-mobile.svg +7 -7
- package/images/logo.svg +15 -15
- package/lib/app.js +1 -38
- package/lib/index.js +67 -538
- package/lib/or-header.js +298 -496
- package/lib/page-offline.js +49 -109
- package/lib/types.js +1 -25
- package/package.json +16 -16
- package/typedoc.js +2 -2
package/lib/or-header.js
CHANGED
|
@@ -1,500 +1,302 @@
|
|
|
1
|
-
var __decorate = (
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
import manager, { DefaultBoxShadowBottom, DefaultColor1, DefaultColor2, DefaultColor3, DefaultColor4, DefaultColor5, DefaultHeaderHeight, Util, DEFAULT_LANGUAGES } from "@openremote/core";
|
|
19
|
-
import "@openremote/or-mwc-components/or-mwc-dialog";
|
|
20
|
-
import "@openremote/or-icon";
|
|
21
|
-
import { getContentWithMenuTemplate } from "@openremote/or-mwc-components/or-mwc-menu";
|
|
22
|
-
import { router, updateRealm } from "./index";
|
|
23
|
-
import { i18next } from "@openremote/or-translate";
|
|
24
|
-
export { DEFAULT_LANGUAGES };
|
|
25
|
-
function getHeaderMenuItems(items) {
|
|
26
|
-
return items.filter(hasRequiredRole).map((option) => {
|
|
27
|
-
return {
|
|
28
|
-
text: option.text,
|
|
29
|
-
value: option.value ? option.value : "",
|
|
30
|
-
icon: option.icon,
|
|
31
|
-
href: option.href
|
|
32
|
-
};
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
function hasRequiredRole(option) {
|
|
36
|
-
if (!option.roles) {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
if (Array.isArray(option.roles)) {
|
|
40
|
-
return option.roles.some((r) => manager.hasRole(r));
|
|
41
|
-
}
|
|
42
|
-
if (Util.isFunction(option.roles)) {
|
|
43
|
-
return option.roles();
|
|
44
|
-
}
|
|
45
|
-
return Object.entries(option.roles).some(([client, roles]) => roles.some((r) => manager.hasRole(r, client)));
|
|
46
|
-
}
|
|
47
|
-
function getCurrentMenuItemRef(defaultRef) {
|
|
48
|
-
const menu = window.location.hash.substr(2).split("/")[0];
|
|
49
|
-
return menu || defaultRef;
|
|
50
|
-
}
|
|
51
|
-
let OrHeader = class OrHeader extends LitElement {
|
|
52
|
-
constructor() {
|
|
53
|
-
super(...arguments);
|
|
54
|
-
this._drawerOpened = false;
|
|
55
|
-
this.alarmButton = 'bell-outline';
|
|
56
|
-
this.alarmColor = '--or-app-color3, ${unsafeCSS(DefaultColor3)}';
|
|
57
|
-
}
|
|
58
|
-
// language=CSS
|
|
59
|
-
static get styles() {
|
|
60
|
-
return css `
|
|
61
|
-
|
|
62
|
-
:host {
|
|
63
|
-
--internal-or-header-color: var(--or-header-color, var(--or-app-color1, ${unsafeCSS(DefaultColor1)}));
|
|
64
|
-
--internal-or-header-selected-color: var(--or-header-selected-color, var(--or-app-color4, ${unsafeCSS(DefaultColor4)}));
|
|
65
|
-
--internal-or-header-text-color: var(--or-header-text-color, var(--or-app-color3, inherit));
|
|
66
|
-
--internal-or-header-height: var(--or-header-height, ${unsafeCSS(DefaultHeaderHeight)});
|
|
67
|
-
--internal-or-header-logo-margin: var(--or-header-logo-margin, 0 40px 0 0);
|
|
68
|
-
--internal-or-header-logo-height: var(--or-header-logo-height, var(--internal-or-header-height, ${unsafeCSS(DefaultHeaderHeight)}));
|
|
69
|
-
--internal-or-header-item-size: var(--or-header-item-size, calc(${unsafeCSS(DefaultHeaderHeight)} - 20px));
|
|
70
|
-
--internal-or-header-drawer-color: var(--or-header-drawer-color, var(--or-app-color2, ${unsafeCSS(DefaultColor2)}));
|
|
71
|
-
--internal-or-header-drawer-text-color: var(--or-header-drawer-text-color, var(--or-app-color3, ${unsafeCSS(DefaultColor3)}));
|
|
72
|
-
--internal-or-header-drawer-item-size: var(--or-header-drawer-item-size, 30px);
|
|
73
|
-
--internal-or-header-drawer-separator-color: var(--or-header-drawer-separator-color, var(--or-app-color5, ${unsafeCSS(DefaultColor5)}));
|
|
74
|
-
|
|
75
|
-
display: block;
|
|
76
|
-
z-index: 4;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
#toolbar-top {
|
|
80
|
-
display: flex;
|
|
81
|
-
padding: 0;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
#logo-mobile {
|
|
85
|
-
margin: 8px;
|
|
86
|
-
height: calc(var(--internal-or-header-logo-height) - 16px);
|
|
87
|
-
display: block;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
#logo {
|
|
91
|
-
display: none;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
#header {
|
|
95
|
-
opacity: 1;
|
|
96
|
-
width: 100%;
|
|
97
|
-
height: var(--internal-or-header-height);
|
|
98
|
-
text-align: center;
|
|
99
|
-
background-color: var(--internal-or-header-color);
|
|
100
|
-
color: var(--internal-or-header-text-color);
|
|
101
|
-
--or-icon-fill: var(--internal-or-header-text-color);
|
|
102
|
-
--or-icon-height: calc(var(--internal-or-header-item-size) - 12px);
|
|
103
|
-
--or-icon-width: calc(var(--internal-or-header-item-size) - 12px);
|
|
104
|
-
z-index: 9999999;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
.shadow {
|
|
108
|
-
-webkit-box-shadow: ${unsafeCSS(DefaultBoxShadowBottom)};
|
|
109
|
-
-moz-box-shadow: ${unsafeCSS(DefaultBoxShadowBottom)};
|
|
110
|
-
box-shadow: ${unsafeCSS(DefaultBoxShadowBottom)};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
#drawer {
|
|
114
|
-
width: 100%;
|
|
115
|
-
position: absolute;
|
|
116
|
-
top: var(--internal-or-header-height);
|
|
117
|
-
max-height: 0;
|
|
118
|
-
height: calc(100% - var(--internal-or-header-height));
|
|
119
|
-
transition: max-height 0.25s ease-out;
|
|
120
|
-
background: var(--internal-or-header-drawer-color);
|
|
121
|
-
color: var(--internal-or-header-drawer-text-color);
|
|
122
|
-
--or-icon-fill: var(--internal-or-header-drawer-text-color);
|
|
123
|
-
--or-icon-height: calc(var(--internal-or-header-drawer-item-size) - 10px);
|
|
124
|
-
--or-icon-width: calc(var(--internal-or-header-drawer-item-size) - 10px);
|
|
125
|
-
overflow: auto;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
#drawer[opened] {
|
|
129
|
-
max-height: 10000px;
|
|
130
|
-
transition: max-height 0.75s ease-in;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
#drawer > div {
|
|
134
|
-
box-sizing: border-box;
|
|
135
|
-
width: 100%;
|
|
136
|
-
height: 100%;
|
|
137
|
-
padding: 10px 0px;
|
|
138
|
-
position: relative;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
.menu-btn {
|
|
142
|
-
background: none;
|
|
143
|
-
border: none;
|
|
144
|
-
cursor: pointer;
|
|
145
|
-
padding: 0 16px;
|
|
146
|
-
height: 100%;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
#menu-btn-mobile {
|
|
150
|
-
display: flex;
|
|
151
|
-
margin-left: auto;
|
|
152
|
-
--or-icon-height: calc(var(--internal-or-header-item-size) - 8px);
|
|
153
|
-
--or-icon-width: calc(var(--internal-or-header-item-size) - 8px);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
#menu-btn-mobile #realm-picker > span{
|
|
157
|
-
max-width: 70px;
|
|
158
|
-
text-overflow: ellipsis;
|
|
159
|
-
overflow: hidden;
|
|
160
|
-
white-space: nowrap;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
#menu-btn-desktop {
|
|
164
|
-
display: none;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
#desktop-right {
|
|
168
|
-
margin-left: auto;
|
|
169
|
-
padding-right: 10px;
|
|
170
|
-
display: none;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
.mobile-bottom-border {
|
|
174
|
-
border-top: 1px solid var(--internal-or-header-drawer-separator-color);
|
|
175
|
-
margin-top: 16px;
|
|
176
|
-
padding-top: 8px;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
.menu-item {
|
|
180
|
-
opacity: 0.7;
|
|
181
|
-
cursor: pointer;
|
|
182
|
-
text-decoration: none !important;
|
|
183
|
-
color: inherit;
|
|
184
|
-
padding: 0 20px;
|
|
185
|
-
font-size: 14px;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
.menu-item:hover,
|
|
189
|
-
.menu-item[selected] {
|
|
190
|
-
opacity: 1;
|
|
191
|
-
}
|
|
192
|
-
#desktop-left .menu-item or-icon {
|
|
193
|
-
margin-right: 10px;
|
|
194
|
-
}
|
|
195
|
-
#desktop-left .menu-item {
|
|
196
|
-
display: none;
|
|
197
|
-
line-height: calc(var(--internal-or-header-height) - 4px);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
#desktop-right .menu-item {
|
|
201
|
-
line-height: var(--internal-or-header-height);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
#drawer .menu-item {
|
|
205
|
-
display: block;
|
|
206
|
-
line-height: var(--internal-or-header-drawer-item-size);
|
|
207
|
-
margin: 6px 0;
|
|
208
|
-
padding: 8px 16px;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
#drawer .menu-item or-icon {
|
|
212
|
-
margin: 0 10px;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
#desktop-left .menu-item[selected] {
|
|
216
|
-
display: inline-block;
|
|
217
|
-
line-height: var(--internal-or-header-height);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
or-mwc-menu {
|
|
221
|
-
margin-right: 10px;
|
|
222
|
-
display: block;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
.or-language-container {
|
|
226
|
-
display: flex;
|
|
227
|
-
height: 50px;
|
|
228
|
-
align-items: center;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
#realm-picker {
|
|
232
|
-
position: relative;
|
|
233
|
-
display: flex;
|
|
234
|
-
height: 50px;
|
|
235
|
-
align-items: center;
|
|
236
|
-
cursor: pointer;
|
|
237
|
-
margin-left: 10px;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
#realm-picker > span {
|
|
241
|
-
margin-right: 2px;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/* Wide layout: when the viewport width is bigger than 768px, layout
|
|
245
|
-
changes to a wide layout. */
|
|
246
|
-
@media (min-width: 768px) {
|
|
247
|
-
#menu-btn-desktop {
|
|
248
|
-
display: block;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
#menu-btn-mobile {
|
|
252
|
-
display: none;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
#drawer {
|
|
256
|
-
display: none;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
#desktop-right {
|
|
260
|
-
display: flex;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
#desktop-left .menu-item {
|
|
264
|
-
display: inline-block;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
#desktop-left .menu-item or-icon {
|
|
268
|
-
display: none;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
#desktop-left .menu-item[selected] {
|
|
272
|
-
border-bottom: 4px solid var(--internal-or-header-selected-color);
|
|
273
|
-
line-height: calc(var(--internal-or-header-height) - 4px);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
#logo {
|
|
277
|
-
margin: var(--internal-or-header-logo-margin);
|
|
278
|
-
height: var(--internal-or-header-logo-height);
|
|
279
|
-
display: block;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
#logo-mobile {
|
|
283
|
-
display: none;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
#desktop-left ::slotted(*) {
|
|
287
|
-
display: inline-block;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
#desktop-left ::slotted(*[selected]) {
|
|
291
|
-
border-bottom: 4px solid var(--internal-or-header-selected-color);
|
|
292
|
-
line-height: calc(var(--internal-or-header-height) - 4px);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
@media (min-width: 1024px) {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
#desktop-left .menu-item or-icon{
|
|
300
|
-
display: inline-block;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
`;
|
|
304
|
-
}
|
|
305
|
-
_onRealmSelect(realm) {
|
|
306
|
-
this.store.dispatch(updateRealm(realm));
|
|
307
|
-
}
|
|
308
|
-
shouldUpdate(changedProperties) {
|
|
309
|
-
if (changedProperties.has("config")) {
|
|
310
|
-
this.activeMenu = getCurrentMenuItemRef(this.config && this.config.mainMenu && this.config.mainMenu.length > 0 ? this.config.mainMenu[0].href : undefined);
|
|
311
|
-
}
|
|
312
|
-
if (changedProperties.has("realm")) {
|
|
313
|
-
this._getAlarmButton();
|
|
314
|
-
}
|
|
315
|
-
return super.shouldUpdate(changedProperties);
|
|
316
|
-
}
|
|
317
|
-
connectedCallback() {
|
|
318
|
-
super.connectedCallback();
|
|
319
|
-
this._subscribeEvents();
|
|
320
|
-
}
|
|
321
|
-
disconnectedCallback() {
|
|
322
|
-
super.disconnectedCallback();
|
|
323
|
-
this._unsubscribeEvents();
|
|
324
|
-
}
|
|
325
|
-
_subscribeEvents() {
|
|
326
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
327
|
-
if (manager.events) {
|
|
328
|
-
this._eventSubscriptionId = yield manager.events.subscribe({
|
|
329
|
-
eventType: "alarm"
|
|
330
|
-
}, (ev) => this._getAlarmButton());
|
|
1
|
+
var __decorate=this&&this.__decorate||function(e,r,o,t){var i,a=arguments.length,n=a<3?r:null===t?t=Object.getOwnPropertyDescriptor(r,o):t;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,r,o,t);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(n=(a<3?i(n):a>3?i(r,o,n):i(r,o))||n);return a>3&&n&&Object.defineProperty(r,o,n),n},__awaiter=this&&this.__awaiter||function(e,r,o,t){return new(o||(o=Promise))(function(i,a){function n(e){try{d(t.next(e))}catch(e){a(e)}}function l(e){try{d(t.throw(e))}catch(e){a(e)}}function d(e){var r;e.done?i(e.value):((r=e.value)instanceof o?r:new o(function(e){e(r)})).then(n,l)}d((t=t.apply(e,r||[])).next())})};import{css as e,html as r,LitElement as o,unsafeCSS as t}from"lit";import{customElement as i,property as a,query as n,state as l}from"lit/decorators.js";import d,{DefaultBoxShadowBottom as s,DefaultColor1 as c,DefaultColor2 as h,DefaultColor3 as p,DefaultColor4 as m,DefaultColor5 as u,DefaultHeaderHeight as v,Util as g,DEFAULT_LANGUAGES as b}from"@openremote/core";import"@openremote/or-mwc-components/or-mwc-dialog";import"@openremote/or-icon";import{getContentWithMenuTemplate as f}from"@openremote/or-mwc-components/or-mwc-menu";import{router as x,updateRealm as w}from"./index";import{i18next as _}from"@openremote/or-translate";function getHeaderMenuItems(e){return e.filter(hasRequiredRole).map(e=>({text:e.text,value:e.value?e.value:"",icon:e.icon,href:e.href}))}function hasRequiredRole(e){return!e.roles||(Array.isArray(e.roles)?e.roles.some(e=>d.hasRole(e)):g.isFunction(e.roles)?e.roles():Object.entries(e.roles).some(([e,r])=>r.some(r=>d.hasRole(r,e))))}function getCurrentMenuItemRef(e){return window.location.hash.substr(2).split("/")[0]||e}let OrHeader=class extends o{constructor(){super(...arguments),this._drawerOpened=!1,this.alarmButton="bell-outline",this.alarmColor="--or-app-color3, ${unsafeCSS(DefaultColor3)}"}static get styles(){return e`
|
|
2
|
+
|
|
3
|
+
:host {
|
|
4
|
+
--internal-or-header-color: var(--or-header-color, var(--or-app-color1, ${t(c)}));
|
|
5
|
+
--internal-or-header-selected-color: var(--or-header-selected-color, var(--or-app-color4, ${t(m)}));
|
|
6
|
+
--internal-or-header-text-color: var(--or-header-text-color, var(--or-app-color3, inherit));
|
|
7
|
+
--internal-or-header-height: var(--or-header-height, ${t(v)});
|
|
8
|
+
--internal-or-header-logo-margin: var(--or-header-logo-margin, 0 40px 0 0);
|
|
9
|
+
--internal-or-header-logo-height: var(--or-header-logo-height, var(--internal-or-header-height, ${t(v)}));
|
|
10
|
+
--internal-or-header-item-size: var(--or-header-item-size, calc(${t(v)} - 20px));
|
|
11
|
+
--internal-or-header-drawer-color: var(--or-header-drawer-color, var(--or-app-color2, ${t(h)}));
|
|
12
|
+
--internal-or-header-drawer-text-color: var(--or-header-drawer-text-color, var(--or-app-color3, ${t(p)}));
|
|
13
|
+
--internal-or-header-drawer-item-size: var(--or-header-drawer-item-size, 30px);
|
|
14
|
+
--internal-or-header-drawer-separator-color: var(--or-header-drawer-separator-color, var(--or-app-color5, ${t(u)}));
|
|
15
|
+
|
|
16
|
+
display: block;
|
|
17
|
+
z-index: 4;
|
|
331
18
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
manager.events.unsubscribe(this._eventSubscriptionId);
|
|
337
|
-
this._eventSubscriptionId = undefined;
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
render() {
|
|
341
|
-
if (!this.config) {
|
|
342
|
-
return html ``;
|
|
343
|
-
}
|
|
344
|
-
const mainItems = this.config.mainMenu;
|
|
345
|
-
const secondaryItems = this.config.secondaryMenu;
|
|
346
|
-
return html `
|
|
347
|
-
<!-- Header -->
|
|
348
|
-
<div id="header" class="shadow">
|
|
349
|
-
<div id="toolbar-top">
|
|
350
|
-
<div><img id="logo" src="${this.logo}" /><img id="logo-mobile" src="${this.logoMobile}" /></div>
|
|
351
|
-
|
|
352
|
-
<!-- This gets hidden on a small screen-->
|
|
353
|
-
<nav id="toolbar-list">
|
|
354
|
-
<div id="desktop-left">
|
|
355
|
-
${mainItems ? mainItems.filter(hasRequiredRole).map((headerItem) => {
|
|
356
|
-
return html `
|
|
357
|
-
<a class="menu-item" @click="${(e) => this._onHeaderItemSelect(headerItem)}" ?selected="${this.activeMenu === headerItem.href}"><or-icon icon="${headerItem.icon}"></or-icon><or-translate value="${headerItem.text}"></or-translate></a>
|
|
358
|
-
`;
|
|
359
|
-
}) : ``}
|
|
360
|
-
</div>
|
|
361
|
-
</nav>
|
|
362
|
-
<div id="desktop-right">
|
|
363
|
-
<div id="alarm-btn">
|
|
364
|
-
<a class="menu-item" @click="${(e) => router.navigate('alarms')}">
|
|
365
|
-
<or-icon icon="${this.alarmButton}" style="color:var(${this.alarmColor})" title="${i18next.t("alarm.alarm_plural")}"></or-icon>
|
|
366
|
-
</a>
|
|
367
|
-
</div>
|
|
368
|
-
${this._getRealmMenu((value) => this._onRealmSelect(value))}
|
|
369
|
-
${secondaryItems ? getContentWithMenuTemplate(html `
|
|
370
|
-
<button id="menu-btn-desktop" class="menu-btn" title="Menu"><or-icon icon="dots-vertical"></or-icon></button>
|
|
371
|
-
`, getHeaderMenuItems(secondaryItems), undefined, (value) => this._onSecondaryMenuSelect(value)) : ``}
|
|
372
|
-
</div>
|
|
373
|
-
<div id="menu-btn-mobile">
|
|
374
|
-
${this._getRealmMenu((value) => this._onRealmSelect(value))}
|
|
375
|
-
<button id="menu-btn" class="menu-btn" title="Menu" @click="${this._toggleDrawer}"><or-icon icon="${this._drawerOpened ? "close" : "menu"}"></or-icon></button>
|
|
376
|
-
</div>
|
|
377
|
-
</div>
|
|
378
|
-
</div>
|
|
379
|
-
<div id="drawer" ?opened="${this._drawerOpened}" @click="${this._closeDrawer}">
|
|
380
|
-
<div>
|
|
381
|
-
<div id="mobile-top">
|
|
382
|
-
<nav id="drawer-list">
|
|
383
|
-
${mainItems ? mainItems.filter((option) => !option.hideMobile && hasRequiredRole(option)).map((headerItem) => {
|
|
384
|
-
return html `
|
|
385
|
-
<a class="menu-item" @click="${(e) => this._onHeaderItemSelect(headerItem)}" ?selected="${this.activeMenu === headerItem.href}"><or-icon icon="${headerItem.icon}"></or-icon><or-translate value="${headerItem.text}"></or-translate></a>
|
|
386
|
-
`;
|
|
387
|
-
}) : ``}
|
|
388
|
-
</nav>
|
|
389
|
-
</div>
|
|
390
|
-
|
|
391
|
-
${secondaryItems ? html `
|
|
392
|
-
<div id="mobile-bottom" class="${mainItems.length > 0 ? 'mobile-bottom-border' : ''}">
|
|
393
|
-
${secondaryItems.filter((option) => !option.hideMobile && hasRequiredRole(option)).map((headerItem) => {
|
|
394
|
-
return html `
|
|
395
|
-
<a class="menu-item" @click="${(e) => this._onHeaderItemSelect(headerItem)}" ?selected="${this.activeMenu === headerItem.href}"><or-icon icon="${headerItem.icon}"></or-icon><or-translate value="${headerItem.text}"></or-translate></a>
|
|
396
|
-
`;
|
|
397
|
-
})}
|
|
398
|
-
</div>` : ``}
|
|
399
|
-
</div>
|
|
400
|
-
</div>
|
|
401
|
-
`;
|
|
402
|
-
}
|
|
403
|
-
_getRealmMenu(callback) {
|
|
404
|
-
const currentRealm = this.realms.find((t) => t.name === this.realm);
|
|
405
|
-
let realmTemplate = html `
|
|
406
|
-
<div id="realm-picker">
|
|
407
|
-
${this.realms.length > 1 ? html `
|
|
408
|
-
<span>${currentRealm ? currentRealm.displayName : ""}</span>
|
|
409
|
-
<or-icon icon="chevron-down"></or-icon>
|
|
410
|
-
` : ``}
|
|
411
|
-
</div>
|
|
412
|
-
`;
|
|
413
|
-
if (manager.isSuperUser()) {
|
|
414
|
-
const menuItems = this.realms.map((r) => {
|
|
415
|
-
return {
|
|
416
|
-
text: r.displayName,
|
|
417
|
-
value: r.name
|
|
418
|
-
};
|
|
419
|
-
});
|
|
420
|
-
realmTemplate = html `
|
|
421
|
-
${getContentWithMenuTemplate(realmTemplate, menuItems, currentRealm ? currentRealm.name : undefined, (value) => callback(value))}
|
|
422
|
-
`;
|
|
423
|
-
}
|
|
424
|
-
return realmTemplate;
|
|
425
|
-
}
|
|
426
|
-
_getAlarmButton() {
|
|
427
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
428
|
-
let newAlarms = false;
|
|
429
|
-
if (manager.hasRole("read:alarms") || manager.hasRole("read:admin")) {
|
|
430
|
-
const response = yield manager.rest.api.AlarmResource.getAlarms({ realm: manager.displayRealm, status: "OPEN" /* Model.AlarmStatus.OPEN */ });
|
|
431
|
-
newAlarms = response.data.length > 0;
|
|
19
|
+
|
|
20
|
+
#toolbar-top {
|
|
21
|
+
display: flex;
|
|
22
|
+
padding: 0;
|
|
432
23
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
const headerItem = this.config.secondaryMenu.find((item) => item.value === value);
|
|
439
|
-
if (headerItem) {
|
|
440
|
-
this._onHeaderItemSelect(headerItem);
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
_onHeaderItemSelect(headerItem) {
|
|
444
|
-
if (headerItem.action) {
|
|
445
|
-
headerItem.action();
|
|
446
|
-
}
|
|
447
|
-
else if (headerItem.href) {
|
|
448
|
-
if (headerItem.absolute) {
|
|
449
|
-
window.location.href = headerItem.href;
|
|
24
|
+
|
|
25
|
+
#logo-mobile {
|
|
26
|
+
margin: 8px;
|
|
27
|
+
height: calc(var(--internal-or-header-logo-height) - 16px);
|
|
28
|
+
display: block;
|
|
450
29
|
}
|
|
451
|
-
|
|
452
|
-
|
|
30
|
+
|
|
31
|
+
#logo {
|
|
32
|
+
display: none;
|
|
453
33
|
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
]
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
34
|
+
|
|
35
|
+
#header {
|
|
36
|
+
opacity: 1;
|
|
37
|
+
width: 100%;
|
|
38
|
+
height: var(--internal-or-header-height);
|
|
39
|
+
text-align: center;
|
|
40
|
+
background-color: var(--internal-or-header-color);
|
|
41
|
+
color: var(--internal-or-header-text-color);
|
|
42
|
+
--or-icon-fill: var(--internal-or-header-text-color);
|
|
43
|
+
--or-icon-height: calc(var(--internal-or-header-item-size) - 12px);
|
|
44
|
+
--or-icon-width: calc(var(--internal-or-header-item-size) - 12px);
|
|
45
|
+
z-index: 9999999;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.shadow {
|
|
49
|
+
-webkit-box-shadow: ${t(s)};
|
|
50
|
+
-moz-box-shadow: ${t(s)};
|
|
51
|
+
box-shadow: ${t(s)};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
#drawer {
|
|
55
|
+
width: 100%;
|
|
56
|
+
position: absolute;
|
|
57
|
+
top: var(--internal-or-header-height);
|
|
58
|
+
max-height: 0;
|
|
59
|
+
height: calc(100% - var(--internal-or-header-height));
|
|
60
|
+
transition: max-height 0.25s ease-out;
|
|
61
|
+
background: var(--internal-or-header-drawer-color);
|
|
62
|
+
color: var(--internal-or-header-drawer-text-color);
|
|
63
|
+
--or-icon-fill: var(--internal-or-header-drawer-text-color);
|
|
64
|
+
--or-icon-height: calc(var(--internal-or-header-drawer-item-size) - 10px);
|
|
65
|
+
--or-icon-width: calc(var(--internal-or-header-drawer-item-size) - 10px);
|
|
66
|
+
overflow: auto;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
#drawer[opened] {
|
|
70
|
+
max-height: 10000px;
|
|
71
|
+
transition: max-height 0.75s ease-in;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
#drawer > div {
|
|
75
|
+
box-sizing: border-box;
|
|
76
|
+
width: 100%;
|
|
77
|
+
height: 100%;
|
|
78
|
+
padding: 10px 0px;
|
|
79
|
+
position: relative;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.menu-btn {
|
|
83
|
+
background: none;
|
|
84
|
+
border: none;
|
|
85
|
+
cursor: pointer;
|
|
86
|
+
padding: 0 16px;
|
|
87
|
+
height: 100%;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
#menu-btn-mobile {
|
|
91
|
+
display: flex;
|
|
92
|
+
margin-left: auto;
|
|
93
|
+
--or-icon-height: calc(var(--internal-or-header-item-size) - 8px);
|
|
94
|
+
--or-icon-width: calc(var(--internal-or-header-item-size) - 8px);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
#menu-btn-mobile #realm-picker > span{
|
|
98
|
+
max-width: 70px;
|
|
99
|
+
text-overflow: ellipsis;
|
|
100
|
+
overflow: hidden;
|
|
101
|
+
white-space: nowrap;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
#menu-btn-desktop {
|
|
105
|
+
display: none;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
#desktop-right {
|
|
109
|
+
margin-left: auto;
|
|
110
|
+
padding-right: 10px;
|
|
111
|
+
display: none;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.mobile-bottom-border {
|
|
115
|
+
border-top: 1px solid var(--internal-or-header-drawer-separator-color);
|
|
116
|
+
margin-top: 16px;
|
|
117
|
+
padding-top: 8px;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.menu-item {
|
|
121
|
+
opacity: 0.7;
|
|
122
|
+
cursor: pointer;
|
|
123
|
+
text-decoration: none !important;
|
|
124
|
+
color: inherit;
|
|
125
|
+
padding: 0 20px;
|
|
126
|
+
font-size: 14px;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.menu-item:hover,
|
|
130
|
+
.menu-item[selected] {
|
|
131
|
+
opacity: 1;
|
|
132
|
+
}
|
|
133
|
+
#desktop-left .menu-item or-icon {
|
|
134
|
+
margin-right: 10px;
|
|
135
|
+
}
|
|
136
|
+
#desktop-left .menu-item {
|
|
137
|
+
display: none;
|
|
138
|
+
line-height: calc(var(--internal-or-header-height) - 4px);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
#desktop-right .menu-item {
|
|
142
|
+
line-height: var(--internal-or-header-height);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
#drawer .menu-item {
|
|
146
|
+
display: block;
|
|
147
|
+
line-height: var(--internal-or-header-drawer-item-size);
|
|
148
|
+
margin: 6px 0;
|
|
149
|
+
padding: 8px 16px;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
#drawer .menu-item or-icon {
|
|
153
|
+
margin: 0 10px;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
#desktop-left .menu-item[selected] {
|
|
157
|
+
display: inline-block;
|
|
158
|
+
line-height: var(--internal-or-header-height);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
or-mwc-menu {
|
|
162
|
+
margin-right: 10px;
|
|
163
|
+
display: block;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.or-language-container {
|
|
167
|
+
display: flex;
|
|
168
|
+
height: 50px;
|
|
169
|
+
align-items: center;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
#realm-picker {
|
|
173
|
+
position: relative;
|
|
174
|
+
display: flex;
|
|
175
|
+
height: 50px;
|
|
176
|
+
align-items: center;
|
|
177
|
+
cursor: pointer;
|
|
178
|
+
margin-left: 10px;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
#realm-picker > span {
|
|
182
|
+
margin-right: 2px;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/* Wide layout: when the viewport width is bigger than 768px, layout
|
|
186
|
+
changes to a wide layout. */
|
|
187
|
+
@media (min-width: 768px) {
|
|
188
|
+
#menu-btn-desktop {
|
|
189
|
+
display: block;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
#menu-btn-mobile {
|
|
193
|
+
display: none;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
#drawer {
|
|
197
|
+
display: none;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
#desktop-right {
|
|
201
|
+
display: flex;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
#desktop-left .menu-item {
|
|
205
|
+
display: inline-block;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
#desktop-left .menu-item or-icon {
|
|
209
|
+
display: none;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
#desktop-left .menu-item[selected] {
|
|
213
|
+
border-bottom: 4px solid var(--internal-or-header-selected-color);
|
|
214
|
+
line-height: calc(var(--internal-or-header-height) - 4px);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
#logo {
|
|
218
|
+
margin: var(--internal-or-header-logo-margin);
|
|
219
|
+
height: var(--internal-or-header-logo-height);
|
|
220
|
+
display: block;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
#logo-mobile {
|
|
224
|
+
display: none;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
#desktop-left ::slotted(*) {
|
|
228
|
+
display: inline-block;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
#desktop-left ::slotted(*[selected]) {
|
|
232
|
+
border-bottom: 4px solid var(--internal-or-header-selected-color);
|
|
233
|
+
line-height: calc(var(--internal-or-header-height) - 4px);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
@media (min-width: 1024px) {
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
#desktop-left .menu-item or-icon{
|
|
241
|
+
display: inline-block;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
`}_onRealmSelect(e){this.store.dispatch(w(e))}shouldUpdate(e){return e.has("config")&&(this.activeMenu=getCurrentMenuItemRef(this.config&&this.config.mainMenu&&this.config.mainMenu.length>0?this.config.mainMenu[0].href:void 0)),e.has("realm")&&this._getAlarmButton(),super.shouldUpdate(e)}connectedCallback(){super.connectedCallback(),this._subscribeEvents()}disconnectedCallback(){super.disconnectedCallback(),this._unsubscribeEvents()}_subscribeEvents(){return __awaiter(this,void 0,void 0,function*(){d.events&&(this._eventSubscriptionId=yield d.events.subscribe({eventType:"alarm"},e=>this._getAlarmButton()))})}_unsubscribeEvents(){this._eventSubscriptionId&&(d.events.unsubscribe(this._eventSubscriptionId),this._eventSubscriptionId=void 0)}render(){if(!this.config)return r``;let e=this.config.mainMenu,o=this.config.secondaryMenu;return r`
|
|
245
|
+
<!-- Header -->
|
|
246
|
+
<div id="header" class="shadow">
|
|
247
|
+
<div id="toolbar-top">
|
|
248
|
+
<div><img id="logo" src="${this.logo}" /><img id="logo-mobile" src="${this.logoMobile}" /></div>
|
|
249
|
+
|
|
250
|
+
<!-- This gets hidden on a small screen-->
|
|
251
|
+
<nav id="toolbar-list">
|
|
252
|
+
<div id="desktop-left">
|
|
253
|
+
${e?e.filter(hasRequiredRole).map(e=>r`
|
|
254
|
+
<a class="menu-item" @click="${r=>this._onHeaderItemSelect(e)}" ?selected="${this.activeMenu===e.href}"><or-icon icon="${e.icon}"></or-icon><or-translate value="${e.text}"></or-translate></a>
|
|
255
|
+
`):""}
|
|
256
|
+
</div>
|
|
257
|
+
</nav>
|
|
258
|
+
<div id="desktop-right">
|
|
259
|
+
<div id="alarm-btn">
|
|
260
|
+
<a class="menu-item" @click="${e=>x.navigate("alarms")}">
|
|
261
|
+
<or-icon icon="${this.alarmButton}" style="color:var(${this.alarmColor})" title="${_.t("alarm.alarm_plural")}"></or-icon>
|
|
262
|
+
</a>
|
|
263
|
+
</div>
|
|
264
|
+
${this._getRealmMenu(e=>this._onRealmSelect(e))}
|
|
265
|
+
${o?f(r`
|
|
266
|
+
<button id="menu-btn-desktop" class="menu-btn" title="Menu"><or-icon icon="dots-vertical"></or-icon></button>
|
|
267
|
+
`,getHeaderMenuItems(o),void 0,e=>this._onSecondaryMenuSelect(e)):""}
|
|
268
|
+
</div>
|
|
269
|
+
<div id="menu-btn-mobile">
|
|
270
|
+
${this._getRealmMenu(e=>this._onRealmSelect(e))}
|
|
271
|
+
<button id="menu-btn" class="menu-btn" title="Menu" @click="${this._toggleDrawer}"><or-icon icon="${this._drawerOpened?"close":"menu"}"></or-icon></button>
|
|
272
|
+
</div>
|
|
273
|
+
</div>
|
|
274
|
+
</div>
|
|
275
|
+
<div id="drawer" ?opened="${this._drawerOpened}" @click="${this._closeDrawer}">
|
|
276
|
+
<div>
|
|
277
|
+
<div id="mobile-top">
|
|
278
|
+
<nav id="drawer-list">
|
|
279
|
+
${e?e.filter(e=>!e.hideMobile&&hasRequiredRole(e)).map(e=>r`
|
|
280
|
+
<a class="menu-item" @click="${r=>this._onHeaderItemSelect(e)}" ?selected="${this.activeMenu===e.href}"><or-icon icon="${e.icon}"></or-icon><or-translate value="${e.text}"></or-translate></a>
|
|
281
|
+
`):""}
|
|
282
|
+
</nav>
|
|
283
|
+
</div>
|
|
284
|
+
|
|
285
|
+
${o?r`
|
|
286
|
+
<div id="mobile-bottom" class="${e.length>0?"mobile-bottom-border":""}">
|
|
287
|
+
${o.filter(e=>!e.hideMobile&&hasRequiredRole(e)).map(e=>r`
|
|
288
|
+
<a class="menu-item" @click="${r=>this._onHeaderItemSelect(e)}" ?selected="${this.activeMenu===e.href}"><or-icon icon="${e.icon}"></or-icon><or-translate value="${e.text}"></or-translate></a>
|
|
289
|
+
`)}
|
|
290
|
+
</div>`:""}
|
|
291
|
+
</div>
|
|
292
|
+
</div>
|
|
293
|
+
`}_getRealmMenu(e){let o=this.realms.find(e=>e.name===this.realm),t=r`
|
|
294
|
+
<div id="realm-picker">
|
|
295
|
+
${this.realms.length>1?r`
|
|
296
|
+
<span>${o?o.displayName:""}</span>
|
|
297
|
+
<or-icon icon="chevron-down"></or-icon>
|
|
298
|
+
`:""}
|
|
299
|
+
</div>
|
|
300
|
+
`;if(d.isSuperUser()){let i=this.realms.map(e=>({text:e.displayName,value:e.name}));t=r`
|
|
301
|
+
${f(t,i,o?o.name:void 0,r=>e(r))}
|
|
302
|
+
`}return t}_getAlarmButton(){return __awaiter(this,void 0,void 0,function*(){let e=!1;(d.hasRole("read:alarms")||d.hasRole("read:admin"))&&(e=(yield d.rest.api.AlarmResource.getAlarms({realm:d.displayRealm,status:"OPEN"})).data.length>0),this.alarmButton=e?"bell-badge-outline":"bell-outline",this.alarmColor=e?"--or-app-color4, ${unsafeCSS(DefaultColor4)}":"--or-app-color3, ${unsafeCSS(DefaultColor3)}"})}_onSecondaryMenuSelect(e){let r=this.config.secondaryMenu.find(r=>r.value===e);r&&this._onHeaderItemSelect(r)}_onHeaderItemSelect(e){e.action?e.action():e.href&&(e.absolute?window.location.href=e.href:x.navigate(e.href))}_closeDrawer(){this._drawerOpened=!1}_toggleDrawer(){this._drawerOpened=!this._drawerOpened}};__decorate([a({type:Array})],OrHeader.prototype,"realms",void 0),__decorate([a({type:String})],OrHeader.prototype,"realm",void 0),__decorate([a({type:Object})],OrHeader.prototype,"store",void 0),__decorate([a({type:String})],OrHeader.prototype,"logo",void 0),__decorate([a({type:String})],OrHeader.prototype,"logoMobile",void 0),__decorate([a({type:Object})],OrHeader.prototype,"config",void 0),__decorate([n("div[id=mobile-bottom]")],OrHeader.prototype,"_mobileBottomDiv",void 0),__decorate([a()],OrHeader.prototype,"activeMenu",void 0),__decorate([l()],OrHeader.prototype,"_drawerOpened",void 0),__decorate([l()],OrHeader.prototype,"alarmButton",void 0),__decorate([l()],OrHeader.prototype,"alarmColor",void 0),OrHeader=__decorate([i("or-header")],OrHeader);export{b as DEFAULT_LANGUAGES,OrHeader};
|