Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

UI updates: Various UI updates (#692)

vlichtenberg77443fdffed5
diff --git a/manager/src/web/shared/locales/en/or.json b/manager/src/web/shared/locales/en/or.json
index 09838a139..795581911 100644
--- a/manager/src/web/shared/locales/en/or.json
+++ b/manager/src/web/shared/locales/en/or.json
@@ -83,7 +83,7 @@
"orWhen": "Or when",
"datetime": "Datetime",
"timer": "Timer",
- "rulesEditorAddCondition": "Add another condition",
+ "rulesEditorAddCondition": "Add condition",
"rulesEditorAddGroup": "Add group",
"rulesEditorAddAction": "Add action",
"sortBy": "Sort by",
@@ -110,6 +110,7 @@
"noAssetsFound": "No assets found",
"filterInvite": "Filter with at least 3 characters",
"location": "Location",
+ "longPressSetLoc": "Long press to set location",
"hour": "Hour",
"day": "Day",
"week": "Week",
diff --git a/manager/src/web/shared/locales/nl/or.json b/manager/src/web/shared/locales/nl/or.json
index a79da948b..f891c3176 100644
--- a/manager/src/web/shared/locales/nl/or.json
+++ b/manager/src/web/shared/locales/nl/or.json
@@ -83,9 +83,9 @@
"orWhen": "Of als",
"datetime": "Datum en tijd",
"timer": "Timer",
- "rulesEditorAddCondition": "Voeg nog een voorwaarde toe",
+ "rulesEditorAddCondition": "Voeg voorwaarde toe",
"rulesEditorAddGroup": "Groep",
- "rulesEditorAddAction": "Voeg nog een actie toe",
+ "rulesEditorAddAction": "Voeg actie toe",
"sortBy": "Sorteren op",
"assetType": "Asset type",
"creationDate": "Aangemaakt op",
@@ -109,6 +109,7 @@
"loading": "Aan het laden...",
"noAssetsFound": "Geen assets gevonden",
"location": "Locatie",
+ "longPressSetLoc": "Druk lang op de kaart om locatie in te stellen",
"hour": "Uur",
"day": "Dag",
"week": "Week",
diff --git a/ui/app/console_loader/src/pages/page-mobile-geofences.ts b/ui/app/console_loader/src/pages/page-mobile-geofences.ts
index 7224685af..7e689fb93 100644
--- a/ui/app/console_loader/src/pages/page-mobile-geofences.ts
+++ b/ui/app/console_loader/src/pages/page-mobile-geofences.ts
@@ -361,7 +361,7 @@ export class PageMobileGeofences extends Page<AppStateKeyed> {
const vectorMap = map as OrMap;
manager.console.sendProviderMessage({provider: 'geofence', action: "GET_LOCATION"}, true).then(response => {
- console.log(JSON.stringify(response));
+ console.info(JSON.stringify(response));
if (response.data) {
vectorMap.flyTo({lng: response.data.longitude, lat: response.data.latitude});
}
diff --git a/ui/app/manager/src/index.ts b/ui/app/manager/src/index.ts
index d9f863b80..b395762e2 100644
--- a/ui/app/manager/src/index.ts
+++ b/ui/app/manager/src/index.ts
@@ -224,6 +224,7 @@ fetch(configURL).then(async (result) => {
Object.entries(appConfig.realms).forEach(([name, realmConfig]) => {
const normalisedConfig = {...defaultRealm,...realmConfig};
+
let headers = DefaultHeaderConfig;
if (normalisedConfig.headers) {
@@ -241,7 +242,11 @@ fetch(configURL).then(async (result) => {
});
}
- orAppConfig.realms[name] = {...defaultRealm, header: headers,...(realmConfig as RealmAppConfig)};
+ if (normalisedConfig.language) {
+ manager.language = normalisedConfig.language;
+ }
+
+ orAppConfig.realms[name] = { ...defaultRealm, header: headers, ...(realmConfig as RealmAppConfig) };
});
}
diff --git a/ui/component/or-app/src/index.ts b/ui/component/or-app/src/index.ts
index 5b7073ddc..7560ff750 100644
--- a/ui/component/or-app/src/index.ts
+++ b/ui/component/or-app/src/index.ts
@@ -15,12 +15,11 @@ import "./or-header";
import "@openremote/or-icon";
import {updateMetadata} from "pwa-helpers/metadata";
import i18next from "i18next";
-import manager, {Auth, DefaultColor2, DefaultColor3, DefaultColor4, ManagerConfig, Util, BasicLoginResult, OREvent, normaliseConfig, Manager} from "@openremote/core";
+import manager, {Auth, DefaultColor2, DefaultColor3, DefaultColor4, ManagerConfig, Util, BasicLoginResult, normaliseConfig, Manager} from "@openremote/core";
import {DEFAULT_LANGUAGES, HeaderConfig} from "./or-header";
import {OrMwcDialog, showErrorDialog, showDialog} from "@openremote/or-mwc-components/or-mwc-dialog";
import {OrMwcSnackbar} from "@openremote/or-mwc-components/or-mwc-snackbar";
import {AnyAction, Store, Unsubscribe} from "@reduxjs/toolkit";
-import {ThunkMiddleware} from "redux-thunk";
import {AppStateKeyed, updatePage, updateRealm} from "./app";
import { InputType, OrInputChangedEvent } from "@openremote/or-mwc-components/or-mwc-input";
import { ORError } from "@openremote/core";
@@ -380,9 +379,10 @@ export class OrApp<S extends AppStateKeyed> extends LitElement {
showDialog(new OrMwcDialog()
.setHeading("language")
.setDismissAction(null)
+ .setStyles(html`<style>.selected { color: ${unsafeCSS(DefaultColor4)} }</style>`)
.setActions(Object.entries(this.appConfig!.languages || DEFAULT_LANGUAGES).map(([key, value]) => {
return {
- content: i18next.t(value),
+ content: html`<span class="${(key === manager.language) ? 'selected' : ''}">${i18next.t(value)}</span>`,
actionName: key,
action: () => {
manager.language = key;
diff --git a/ui/component/or-asset-viewer/src/index.ts b/ui/component/or-asset-viewer/src/index.ts
index 5c7fb7ec9..ba3668fcf 100644
--- a/ui/component/or-asset-viewer/src/index.ts
+++ b/ui/component/or-asset-viewer/src/index.ts
@@ -1401,6 +1401,17 @@ export class OrAssetViewer extends subscribe(manager)(translate(i18next)(LitElem
}
});
}
+
+ grid.addEventListener('scroll', (event: any) => {
+ const header = shadowRoot.querySelector('#asset-header');
+ if (header) {
+ if (event.target.scrollTop > 0) {
+ header.classList.add('scrolled')
+ } else {
+ header.classList.remove('scrolled')
+ }
+ }
+ });
}
}
}
diff --git a/ui/component/or-asset-viewer/src/or-edit-asset-panel.ts b/ui/component/or-asset-viewer/src/or-edit-asset-panel.ts
index 4fd169eb4..a330e1450 100644
--- a/ui/component/or-asset-viewer/src/or-edit-asset-panel.ts
+++ b/ui/component/or-asset-viewer/src/or-edit-asset-panel.ts
@@ -497,6 +497,10 @@ export class OrEditAssetPanel extends LitElement {
#meta-creator > or-mwc-list {
height: 100%;
}
+
+ .mdc-dialog .mdc-dialog__content {
+ padding: 0 !important;
+ }
</style>
`)
.setHeading(i18next.t("addMetaItems"))
diff --git a/ui/component/or-asset-viewer/src/style.ts b/ui/component/or-asset-viewer/src/style.ts
index 68a50d248..3d30e2f79 100644
--- a/ui/component/or-asset-viewer/src/style.ts
+++ b/ui/component/or-asset-viewer/src/style.ts
@@ -163,6 +163,7 @@ export const style = css`
flex: 0 0 auto;
align-items: center;
justify-content: space-between;
+ z-index: 1;
}
#asset-header.editmode {
@@ -170,6 +171,9 @@ export const style = css`
background-color: var(--internal-or-asset-viewer-panel-color);
border-bottom: solid 1px #e5e5e5;
}
+ #asset-header.scrolled {
+ box-shadow: rgb(0 0 0 / 15%) 0 0 5px 0;
+ }
#title {
flex: 1 1 auto;
diff --git a/ui/component/or-attribute-input/src/index.ts b/ui/component/or-attribute-input/src/index.ts
index 3eb2850c8..1dbdc6cf8 100644
--- a/ui/component/or-attribute-input/src/index.ts
+++ b/ui/component/or-attribute-input/src/index.ts
@@ -290,6 +290,10 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitE
#wrapper or-map {
min-height: 250px;
}
+
+ #wrapper .long-press-msg {
+ display: none;
+ }
#wrapper {
display: flex;
diff --git a/ui/component/or-attribute-picker/src/index.ts b/ui/component/or-attribute-picker/src/index.ts
index baf85df3b..7ece85b2d 100644
--- a/ui/component/or-attribute-picker/src/index.ts
+++ b/ui/component/or-attribute-picker/src/index.ts
@@ -145,7 +145,9 @@ export class OrAttributePicker extends OrMwcDialog {
},
{
actionName: "add",
- content: html`<or-mwc-input id="add-btn" class="button" .type="${InputType.BUTTON}" label="${i18next.t("add")}" ?disabled="${!this.selectedAttributes.length}"></or-mwc-input>`,
+ content: html`<or-mwc-input id="add-btn" class="button" label="${i18next.t("add")}"
+ .type="${InputType.BUTTON}" ?disabled="${!this.selectedAttributes.length}"
+ @click="${(ev: MouseEvent) => { if (!this.selectedAttributes.length) { ev.stopPropagation(); return false; } } }"></or-mwc-input>`,
action: () => {
if (!this.selectedAttributes.length) {
@@ -175,13 +177,11 @@ export class OrAttributePicker extends OrMwcDialog {
let selectedAttribute: ListItem | undefined = undefined;
if (!this.multiSelect && this.selectedAttributes.length === 1 && this.selectedAttributes[0].name) {
- console.log('here');
selectedAttribute = {
text: Util.getAttributeLabel(undefined, this.selectedAttributes[0], undefined, true),
value: this.selectedAttributes[0].name
};
}
- console.log(selectedAttribute);
this.content = () => html`
<div class="row" style="display: flex;height: 600px;width: 800px;border-top: 1px solid ${unsafeCSS(DefaultColor5)};">
@@ -249,7 +249,8 @@ export class OrAttributePicker extends OrMwcDialog {
selectedAsset = assetResponse.data;
if (selectedAsset) {
- this.assetAttributes = Object.values(selectedAsset.attributes!).map(attr => { return {...attr, id: selectedAsset!.id!}; });
+ this.assetAttributes = Object.values(selectedAsset.attributes!).map(attr => { return {...attr, id: selectedAsset!.id!}; })
+ .sort(Util.sortByString((attribute) => attribute.name!));
if (this.showOnlyDatapointAttrs && this.showOnlyRuleStateAttrs) {
this.assetAttributes = this.assetAttributes
diff --git a/ui/component/or-chart/src/index.ts b/ui/component/or-chart/src/index.ts
index ff2d34f80..10e2636d3 100644
--- a/ui/component/or-chart/src/index.ts
+++ b/ui/component/or-chart/src/index.ts
@@ -448,7 +448,10 @@ export class OrChart extends translate(i18next)(LitElement) {
intersect: false,
xPadding: 10,
yPadding: 10,
- titleMarginBottom: 10
+ titleMarginBottom: 10,
+ callbacks: {
+ label: (tooltipItem: any) => tooltipItem.dataset.label + ': ' + tooltipItem.formattedValue + tooltipItem.dataset.unit,
+ }
},
annotation: {
annotations: [
@@ -986,10 +989,12 @@ export class OrChart extends translate(i18next)(LitElement) {
const asset = this.assets[assetIndex];
const descriptors = AssetModelUtil.getAttributeAndValueDescriptors(asset.type, attribute.name, attribute);
const label = Util.getAttributeLabel(attribute, descriptors[0], asset.type, false);
+ const unit = Util.resolveUnits(Util.getAttributeUnits(attribute, descriptors[0], asset.type));
const colourIndex = index % this.colors.length;
let dataset = await this._loadAttributeData(asset, attribute, this.colors[colourIndex], interval, this._startOfPeriod!, this._endOfPeriod!, false, asset.name + " " + label);
(dataset as any).assetId = asset.id;
(dataset as any).attrName = attribute.name;
+ (dataset as any).unit = unit;
data.push(dataset);
dataset = await this._loadAttributeData(this.assets[assetIndex], attribute, this.colors[colourIndex], interval, predictedFromTimestamp, this._endOfPeriod!, true, asset.name + " " + label + " " + i18next.t("predicted"));
diff --git a/ui/component/or-map/src/index.ts b/ui/component/or-map/src/index.ts
index 99e0a0366..bd987fa00 100644
--- a/ui/component/or-map/src/index.ts
+++ b/ui/component/or-map/src/index.ts
@@ -296,25 +296,18 @@ export const geoJsonPointInputTemplateProvider: ValueInputProviderGenerator = (a
userLocationControl.on('geolocate', (currentLocation: GeolocationPosition) => {
setPos(new LngLat(currentLocation.coords.longitude, currentLocation.coords.latitude));
- console.log(currentLocation);
});
userLocationControl.on('outofmaxbounds', (currentLocation: GeolocationPosition) => {
setPos(new LngLat(currentLocation.coords.longitude, currentLocation.coords.latitude));
- console.log(currentLocation);
});
controls.push([userLocationControl, "bottom-left"]);
}
let content = html`
- <style>
- or-map {
- border: #e5e5e5 1px solid;
- margin: 3px 0;
- }
- </style>
<or-map id="geo-json-point-map" class="or-map" @or-map-long-press="${(ev: OrMapLongPressEvent) => {setPos(ev.detail.lngLat);}}" .center="${center}" .controls="${controls}" .showGeoCodingControl=${!readonly}>
<or-map-marker id="geo-json-point-marker" active .lng="${pos ? pos.lng : undefined}" .lat="${pos ? pos.lat : undefined}" .icon="${iconAndColor ? iconAndColor.icon : undefined}" .activeColor="${iconAndColor ? "#" + iconAndColor.color : undefined}" .colour="${iconAndColor ? "#" + iconAndColor.color : undefined}"></or-map-marker>
</or-map>
+ <span class="long-press-msg">${i18next.t('longPressSetLoc')}</span>
`;
if (compact) {
@@ -327,9 +320,16 @@ export const geoJsonPointInputTemplateProvider: ValueInputProviderGenerator = (a
.setContent(mapContent)
.setStyles(html`
<style>
+ .dialog-container {
+ flex-direction: column !important;
+ }
+ .dialog-container .long-press-msg {
+ display: block;
+ text-align: center;
+ }
or-map {
width: 600px !important;
- height: 600px !important;
+ min-height: 600px !important;
}
</style>
`)
diff --git a/ui/component/or-rules/src/json-viewer/or-rule-then-otherwise.ts b/ui/component/or-rules/src/json-viewer/or-rule-then-otherwise.ts
index cb0720ac0..8c64b36d3 100644
--- a/ui/component/or-rules/src/json-viewer/or-rule-then-otherwise.ts
+++ b/ui/component/or-rules/src/json-viewer/or-rule-then-otherwise.ts
@@ -360,11 +360,11 @@ class OrRuleThenOtherwise extends translate(i18next)(LitElement) {
${thenAllowAdd ? html`
<span class="add-button-wrapper">
${getContentWithMenuTemplate(
- html`<or-mwc-input class="plus-button" type="${InputType.BUTTON}" icon="plus"></or-mwc-input>`,
+ html`<or-mwc-input class="plus-button" type="${InputType.BUTTON}" icon="plus"
+ .label="${i18next.t("rulesEditorAddAction")}"></or-mwc-input>`,
getActionTypesMenu(this.config, this.assetInfos),
undefined,
(value) => this.addAction(value as string))}
- <span>${i18next.t("rulesEditorAddAction")}</span>
</span>
` : ``}
</or-panel>
diff --git a/ui/component/or-rules/src/json-viewer/or-rule-when.ts b/ui/component/or-rules/src/json-viewer/or-rule-when.ts
index f7707d732..3dcb41f85 100644
--- a/ui/component/or-rules/src/json-viewer/or-rule-when.ts
+++ b/ui/component/or-rules/src/json-viewer/or-rule-when.ts
@@ -95,6 +95,11 @@ const style = css`
.add-button-wrapper or-mwc-menu {
text-transform: capitalize;
}
+
+ strong {
+ margin: var(--internal-or-panel-heading-margin);
+ font-size: var(--internal-or-panel-heading-font-size);
+ }
`;
@customElement("or-rule-when")
@@ -194,11 +199,11 @@ class OrRuleWhen extends translate(i18next)(LitElement) {
addTemplate = html`
<span class="add-button-wrapper">
${getContentWithMenuTemplate(
- html`<or-mwc-input class="plus-button" type="${InputType.BUTTON}" icon="plus"></or-mwc-input>`,
+ html`<or-mwc-input class="plus-button" type="${InputType.BUTTON}" icon="plus"
+ .label="${i18next.t("rulesEditorAddCondition")}"></or-mwc-input>`,
getWhenTypesMenu(this.config, this.assetInfos),
undefined,
(value) => this.addCondition(group, value as string))}
- <span>${i18next.t("rulesEditorAddCondition")}</span>
</span>
`;
}
@@ -247,13 +252,13 @@ class OrRuleWhen extends translate(i18next)(LitElement) {
${!showAddGroup ? `` : html`
<or-panel>
+ <strong>${i18next.t(!this.rule.when.groups || this.rule.when.groups.length === 0 ? "when" : "orWhen")}...</strong>
<span class="add-button-wrapper">
${getContentWithMenuTemplate(
html`<or-mwc-input class="plus-button" type="${InputType.BUTTON}" icon="plus"></or-mwc-input>`,
getWhenTypesMenu(this.config, this.assetInfos),
undefined,
(value) => this.addGroup(this.rule!.when!, value as string))}
- <strong>${i18next.t(!this.rule.when.groups || this.rule.when.groups.length === 0 ? "when" : "orWhen")}...</strong>
</span>
</or-panel>
`}