Skip to content

armgit / core

Public Imported from GitHub
0

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

Page configs, rule editor translations

Robin Dekkersf8bcbc13032c
diff --git a/deployment/manager/shared/locales/en/or.json b/deployment/manager/shared/locales/en/or.json
index 1a23256da..3621c9e1d 100644
--- a/deployment/manager/shared/locales/en/or.json
+++ b/deployment/manager/shared/locales/en/or.json
@@ -178,6 +178,21 @@
"noLongerMatches": "No longer matches",
"logs":"Logs",
"addRemoveAttributes": "Add/remove attributes",
+ "email": "Email",
+ "push-notification":"Push notification",
+ "subject": "subject",
+ "openWebsiteUrl": "Website to be opend",
+ "openInBrowser": "Open in browser (for external websites)",
+ "buttonTextConfirm": "Text for action button",
+ "buttonTextDecline": "Text for decline button",
+ "custom": "Manual input",
+ "tenant": "Tenant",
+ "tenant_plural": "Tenants",
+ "user_plural": "Users",
+ "realmRules": "realm rules",
+ "globalRules": "global rules",
+ "recipients": "Recipients",
+ "JSON": "When-Then",
"attributeValueType": {
"PERCENTAGE": "%.2f",
"NUMBER": "%.0f",
diff --git a/deployment/manager/shared/locales/nl/or.json b/deployment/manager/shared/locales/nl/or.json
index 2edf0d584..f40a6a69b 100644
--- a/deployment/manager/shared/locales/nl/or.json
+++ b/deployment/manager/shared/locales/nl/or.json
@@ -178,6 +178,21 @@
"noLongerMatches": "Komt niet meer overeen",
"logs": "Logs",
"addRemoveAttributes": "Attributen toevoegen/verwijderen",
+ "email": "Email",
+ "push-notification":"Push notification",
+ "subject": "Onderwerp",
+ "openWebsiteUrl": "Te openen website adres",
+ "openInBrowser": "Openen in browser (voor externe websites)",
+ "buttonTextConfirm": "Tekst voor actie knop",
+ "buttonTextDecline": "Tekst voor negeerknop",
+ "custom": "Handmatig input",
+ "tenant": "Tenant",
+ "tenant_plural": "Tenants",
+ "user_plural": "Gebruikers",
+ "realmRules": "realm rules",
+ "globalRules": "global rules",
+ "recipients": "Ontvangers",
+ "JSON": "Als-Dan",
"attributeValueType": {
"PERCENTAGE": "%.2f",
"NUMBER": "%.0f",
diff --git a/ui/app/or-app/src/index.ts b/ui/app/or-app/src/index.ts
index 9eb58df25..ce86c470f 100644
--- a/ui/app/or-app/src/index.ts
+++ b/ui/app/or-app/src/index.ts
@@ -9,6 +9,8 @@ import {
TemplateResult,
unsafeCSS
} from "lit-element";
+import {unsafeHTML} from 'lit-html/directives/unsafe-html.js';
+
import {updateMetadata} from "pwa-helpers/metadata";
import i18next from "i18next";
import Navigo from "navigo";
@@ -21,7 +23,6 @@ import {AnyAction, EnhancedStore, Unsubscribe, Action} from "@reduxjs/toolkit";
import {AppStateKeyed, updatePage, updateParams} from "./app";
import {ThunkMiddleware} from "redux-thunk";
import { translate } from "@openremote/or-translate";
-
export * from "./app";
export * from "./or-header";
@@ -371,8 +372,8 @@ export class OrApp<S extends AppStateKeyed> extends LitElement {
if (!this._initialised) {
return html`<or-mwc-dialog id="app-modal"></or-mwc-dialog>`;
}
-
return html`
+ ${unsafeHTML(this._config.styles.strings)}
<or-header .logo="${this._config.logo}" .logoMobile="${this._config.logoMobile}" .config="${this._config.header}"></or-header>
<!-- Main content -->
diff --git a/ui/app/or-app/src/pages/page-assets.ts b/ui/app/or-app/src/pages/page-assets.ts
index 9d31ebad0..a1342dfa3 100644
--- a/ui/app/or-app/src/pages/page-assets.ts
+++ b/ui/app/or-app/src/pages/page-assets.ts
@@ -8,14 +8,16 @@ import moment from "moment";
import {AppStateKeyed, Page, router} from "../index";
import {EnhancedStore} from "@reduxjs/toolkit";
-export function pageAssetsProvider<S extends AppStateKeyed>(store: EnhancedStore<S>) {
+export function pageAssetsProvider<S extends AppStateKeyed>(store: EnhancedStore<S>, config?: ViewerConfig) {
return {
routes: [
"assets",
"assets/:id"
],
pageCreator: () => {
- return new PageAssets(store);
+ const page = new PageAssets(store);
+ if(config) page.config = config;
+ return page;
}
};
}
@@ -445,6 +447,9 @@ class PageAssets<S extends AppStateKeyed> extends Page<S> {
`;
}
+ @property()
+ public config?: ViewerConfig;
+
@property()
protected _assetId;
@@ -460,7 +465,7 @@ class PageAssets<S extends AppStateKeyed> extends Page<S> {
const selectedIds = [this._assetId];
return html`
<or-asset-tree id="pageAssetTree" class="${this._assetId ? "hideMobile" : ""}" .selectedIds="${selectedIds}"></or-asset-tree>
- <or-asset-viewer class="${!this._assetId ? "hideMobile" : ""}" .config="${viewerConfig}" .assetId="${this._assetId}"></or-asset-viewer>
+ <or-asset-viewer class="${!this._assetId ? "hideMobile" : ""}" .config="${this.config ? this.config : viewerConfig}" .assetId="${this._assetId}"></or-asset-viewer>
`;
}
diff --git a/ui/app/or-app/src/pages/page-insights.ts b/ui/app/or-app/src/pages/page-insights.ts
index 6739aee4c..036a36ae3 100644
--- a/ui/app/or-app/src/pages/page-insights.ts
+++ b/ui/app/or-app/src/pages/page-insights.ts
@@ -5,14 +5,16 @@ import {DefaultBoxShadow} from "@openremote/core";
import {AppStateKeyed, Page} from "../index";
import {EnhancedStore} from "@reduxjs/toolkit";
-export function pageInsightsProvider<S extends AppStateKeyed>(store: EnhancedStore<S>) {
+export function pageInsightsProvider<S extends AppStateKeyed>(store: EnhancedStore<S>, config?:DataViewerConfig) {
return {
routes: [
"insights",
"insights/:id"
],
pageCreator: () => {
- return new PageInsights(store);
+ const page = new PageInsights(store);
+ if(config) page.config = config;
+ return page;
}
};
}
@@ -30,6 +32,18 @@ const viewerConfig: DataViewerConfig = {
assetId:"5442Ite2XVp3Ky9X2y647a",
attributes: ["UVIndex"]
}]
+ },
+ "chart2": {
+ type: "chart",
+ hideOnMobile: true,
+ panelStyles: {
+ gridColumn: "1 / -1",
+ gridRowStart: "1"
+ },
+ defaults: [{
+ assetId:"5442Ite2XVp3Ky9X2y647a",
+ attributes: ["UVIndex"]
+ }]
}
}
};
@@ -73,6 +87,9 @@ class PageInsights<S extends AppStateKeyed> extends Page<S> {
`;
}
+ @property()
+ public config?: DataViewerConfig;
+
@property()
protected _assetId;
@@ -82,7 +99,7 @@ class PageInsights<S extends AppStateKeyed> extends Page<S> {
protected render(): TemplateResult | void {
return html`
- <or-data-viewer .config="${viewerConfig}"></or-data-viewer>
+ <or-data-viewer .config="${this.config ? this.config : viewerConfig}"></or-data-viewer>
`;
}
diff --git a/ui/app/or-app/src/pages/page-logs.ts b/ui/app/or-app/src/pages/page-logs.ts
index 9ddc33cf7..eb0b19233 100644
--- a/ui/app/or-app/src/pages/page-logs.ts
+++ b/ui/app/or-app/src/pages/page-logs.ts
@@ -1,16 +1,18 @@
-import {css, customElement, html} from "lit-element";
+import {css, customElement, html, property} from "lit-element";
import "@openremote/or-log-viewer";
import {ViewerConfig} from "@openremote/or-log-viewer";
import {AppStateKeyed, Page} from "../index";
import {EnhancedStore} from "@reduxjs/toolkit";
-export function pageLogsProvider<S extends AppStateKeyed>(store: EnhancedStore<S>) {
+export function pageLogsProvider<S extends AppStateKeyed>(store: EnhancedStore<S>, config?: ViewerConfig) {
return {
routes: [
"logs"
],
pageCreator: () => {
- return new PageLogs(store);
+ const page = new PageLogs(store);
+ if(config) page.config = config;
+ return page;
}
};
}
@@ -39,8 +41,9 @@ class PageLogs<S extends AppStateKeyed> extends Page<S> {
public stateChanged(state: S) {
}
- protected config: ViewerConfig = {
- };
+
+ @property()
+ public config?: ViewerConfig;
protected render() {
return html`
diff --git a/ui/app/or-app/src/pages/page-map.ts b/ui/app/or-app/src/pages/page-map.ts
index b5c59ac57..fb0c29630 100644
--- a/ui/app/or-app/src/pages/page-map.ts
+++ b/ui/app/or-app/src/pages/page-map.ts
@@ -82,14 +82,16 @@ const pageMapSlice = createSlice({
const {assetEventReceived, attributeEventReceived, setAssetSubscriptionId, setAttributeSubscriptionId} = pageMapSlice.actions;
export const pageMapReducer = pageMapSlice.reducer;
-export function pageMapProvider<S extends MapStateKeyed>(store: EnhancedStore<S>) {
+export function pageMapProvider<S extends MapStateKeyed>(store: EnhancedStore<S>, config?:ViewerConfig) {
return {
routes: [
"map",
"map/:id"
],
pageCreator: () => {
- return new PageMap(store);
+ const page = new PageMap(store);
+ if(config) page.config = config;
+ return page
}
};
}
@@ -183,6 +185,9 @@ export class PageMap<S extends MapStateKeyed> extends Page<S> {
`;
}
+ @property()
+ public config?: ViewerConfig;
+
@query("#map")
protected _map?: OrMap;
@@ -221,7 +226,7 @@ export class PageMap<S extends MapStateKeyed> extends Page<S> {
return html`
- ${this._currentAsset ? html `<or-map-asset-card .config="${mapCardConfig}" .asset="${this._currentAsset}"></or-map-asset-card>` : ``}
+ ${this._currentAsset ? html `<or-map-asset-card .config="${this.config ? this.config : mapCardConfig}" .asset="${this._currentAsset}"></or-map-asset-card>` : ``}
<or-map id="map" class="or-map">
${
diff --git a/ui/app/or-app/src/pages/page-rules.ts b/ui/app/or-app/src/pages/page-rules.ts
index ee62077e6..24e8dcf88 100644
--- a/ui/app/or-app/src/pages/page-rules.ts
+++ b/ui/app/or-app/src/pages/page-rules.ts
@@ -1,25 +1,31 @@
-import {css, customElement, html} from "lit-element";
+import {css, customElement, html, property} from "lit-element";
import "@openremote/or-rules";
import {RulesConfig} from "@openremote/or-rules";
-import {AssetType, RulesetLang} from "@openremote/model";
+import {AssetType, RulesetLang, NotificationTargetType} from "@openremote/model";
import {AppStateKeyed, Page} from "../index";
import {EnhancedStore} from "@reduxjs/toolkit";
-export function pageRulesProvider<S extends AppStateKeyed>(store: EnhancedStore<S>) {
+export function pageRulesProvider<S extends AppStateKeyed>(store: EnhancedStore<S>, config?:RulesConfig) {
return {
routes: [
"rules",
"rules/:id"
],
pageCreator: () => {
- return new PageRules(store);
+ const page = new PageRules(store);
+ if(config) page.rulesConfig = config;
+ return page
}
};
}
const rulesConfig: RulesConfig = {
controls: {
- allowedLanguages: [RulesetLang.JSON, RulesetLang.FLOW]
+ allowedLanguages: [RulesetLang.JSON, RulesetLang.FLOW, RulesetLang.GROOVY],
+ hideNotificationTargetType: {
+ "email": [NotificationTargetType.TENANT, NotificationTargetType.ASSET],
+ "push": [NotificationTargetType.TENANT, NotificationTargetType.CUSTOM],
+ }
},
descriptors: {
all: {
@@ -40,6 +46,9 @@ const rulesConfig: RulesConfig = {
@customElement("page-rules")
class PageRules<S extends AppStateKeyed> extends Page<S> {
+ @property()
+ public rulesConfig?: RulesConfig;
+
static get styles() {
// language=CSS
return css`
@@ -60,7 +69,7 @@ class PageRules<S extends AppStateKeyed> extends Page<S> {
protected render() {
return html`
- <or-rules .config="${rulesConfig}"></or-rules>
+ <or-rules .config="${this.rulesConfig ? this.rulesConfig : rulesConfig}"></or-rules>
`;
}
diff --git a/ui/component/or-data-viewer/src/index.ts b/ui/component/or-data-viewer/src/index.ts
index 96447fbf7..5499b4b87 100644
--- a/ui/component/or-data-viewer/src/index.ts
+++ b/ui/component/or-data-viewer/src/index.ts
@@ -21,7 +21,7 @@ import i18next from "i18next";
import {styleMap} from "lit-html/directives/style-map";
import {classMap} from "lit-html/directives/class-map";
-export type PanelType = "chart";
+export type PanelType = "chart" | "kpi";
export interface DefaultAssets {
assetId?: string;
@@ -205,10 +205,13 @@ export class OrDataViewer extends subscribe(manager)(translate(i18next)(LitEleme
content = html`
<or-chart id="chart" .config="${this.config.chartConfig}"></or-chart>
`;
-
}
+ if (panelConfig && panelConfig.type === "kpi") {
+ content = html`
+ <or-chart id="chart" .config="${this.config.chartConfig}"></or-chart>
+ `;
+ }
return content;
-
}
}
diff --git a/ui/component/or-rules/src/index.ts b/ui/component/or-rules/src/index.ts
index bffafaa4b..42eaa3c4d 100644
--- a/ui/component/or-rules/src/index.ts
+++ b/ui/component/or-rules/src/index.ts
@@ -50,7 +50,7 @@ export const enum ConditionType {
export const enum ActionType {
WAIT = "wait",
NOTIFICATION = "notification",
- PUSH_NOTIFICATION = "push-notification",
+ PUSH_NOTIFICATION = "push",
ATTRIBUTE = "attribute"
}
diff --git a/ui/component/or-rules/src/json-viewer/modals/or-rule-notification-modal.ts b/ui/component/or-rules/src/json-viewer/modals/or-rule-notification-modal.ts
index 150c8c15d..ff769674a 100644
--- a/ui/component/or-rules/src/json-viewer/modals/or-rule-notification-modal.ts
+++ b/ui/component/or-rules/src/json-viewer/modals/or-rule-notification-modal.ts
@@ -1,4 +1,4 @@
-import {customElement, html, LitElement, property} from "lit-element";
+import {customElement, html, LitElement, property, PropertyValues} from "lit-element";
import {
RuleActionNotification,
AssetQuery,
@@ -37,9 +37,22 @@ export class OrRuleNotificationModal extends translate(i18next)(LitElement) {
const dialog: OrMwcDialog = this.shadowRoot!.getElementById("notification-modal") as OrMwcDialog;
if(!this.shadowRoot) return
- const slot = this.shadowRoot.getElementById('notification-form-slot');
- if (dialog) {
- dialog.dialogContent = html`${slot}`;
+ const slot:HTMLSlotElement|null = this.shadowRoot.querySelector('.notification-form-slot');
+ if (dialog && slot) {
+ let container = document.createElement("div");
+ slot.assignedNodes({flatten: true}).forEach((child) => {
+ if (child instanceof HTMLElement) {
+ container.appendChild(child);
+ }
+ });
+ dialog.dialogContent = html`${container}`;
+ this.requestUpdate();
+ }
+ }
+
+ updated(changedProperties: PropertyValues){
+ if(changedProperties.has("action")){
+ this.renderDialogHTML(this.action);
}
}
@@ -73,9 +86,8 @@ export class OrRuleNotificationModal extends translate(i18next)(LitElement) {
return html`
<or-input .type="${InputType.BUTTON}" .label="${i18next.t("message")}" @click="${notificationPickerModalOpen}"></or-input>
- <or-mwc-dialog id="notification-modal" dialogTitle="${this.title}" .dialogActions="${notificationPickerModalActions}">
- <slot id="notification-form-slot"></slot>
- </or-mwc-dialog>
+ <or-mwc-dialog id="notification-modal" dialogTitle="${this.title}" .dialogActions="${notificationPickerModalActions}"> </or-mwc-dialog>
+ <slot class="notification-form-slot"></slot>
`
}
}
\ No newline at end of file
diff --git a/ui/component/or-rules/src/json-viewer/or-rule-action-notification.ts b/ui/component/or-rules/src/json-viewer/or-rule-action-notification.ts
index 246a9db3b..11ed36921 100644
--- a/ui/component/or-rules/src/json-viewer/or-rule-action-notification.ts
+++ b/ui/component/or-rules/src/json-viewer/or-rule-action-notification.ts
@@ -87,7 +87,7 @@ export class OrRuleActionNotification extends LitElement {
}
if(this.type === NotificationTargetType.USER) {
- if(this._listItems) this._listItems.forEach((user: User) => idOptions.push([user.id!, user.username!] as [string, string]));
+ if(this._listItems) this._listItems.forEach((user: User) => idOptions.push([user.id!, user.username ? user.username : user.email] as [string, string]));
}
@@ -95,7 +95,7 @@ export class OrRuleActionNotification extends LitElement {
targetTypeTemplate = html`<or-input type="${InputType.SELECT}"
.options="${targetTypes}"
value="${this.type ? this.type : targetTypes[0]}"
- label="${i18next.t("categories")}"
+ label="${i18next.t("recipients")}"
@or-input-changed="${(e: OrInputChangedEvent) => this.setActionNotificationType(e.detail.value)}"
?readonly="${this.readonly}"></or-input>
`;
@@ -123,7 +123,7 @@ export class OrRuleActionNotification extends LitElement {
let modalTemplate;
if(message) {
- if(messageType === "push-notification") {
+ if(messageType === "push") {
modalTemplate = html`
<or-rule-notification-modal title="push-notification" .action="${this.action}">
<or-rule-form-push-notification .action="${this.action}"></or-rule-form-push-notification>
@@ -253,7 +253,7 @@ export class OrRuleActionNotification extends LitElement {
case NotificationTargetType.ASSET:
const messageType = this.action.notification.message ? this.action.notification.message.type : undefined
- if(messageType === "push-notification") {
+ if(messageType === "push") {
const query = {
types: [
{
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 5f3f89e54..63d3f98c2 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
@@ -274,7 +274,7 @@ class OrRuleThenOtherwise extends translate(i18next)(LitElement) {
break;
case ActionType.NOTIFICATION:
action = action as RuleActionNotification
- if(type === "push-notification") {
+ if(type === "push") {
buttonIcon = "cellphone-message";
buttonColor = NOTIFICATION_COLOR;
} else {
@@ -450,7 +450,7 @@ class OrRuleThenOtherwise extends translate(i18next)(LitElement) {
action.action = "notification";
action.notification = {
message: {
- type: "push-notification"
+ type: "push"
}
};
} else {
diff --git a/ui/component/or-rules/src/or-rule-list.ts b/ui/component/or-rules/src/or-rule-list.ts
index 81a17ed85..0ad86b487 100644
--- a/ui/component/or-rules/src/or-rule-list.ts
+++ b/ui/component/or-rules/src/or-rule-list.ts
@@ -257,13 +257,13 @@ export class OrRuleList extends translate(i18next)(LitElement) {
<div id="wrapper" ?data-disabled="${this.disabled}">
${manager.isSuperUser() ? html`
<div class="header-ruleset-type bg-grey">
- <p>${i18next.t("realm rules")}</p>
+ <p>${i18next.t("realmRules")}</p>
<div style="flex: 1 1 0; display: flex;">
<or-input style="margin: auto;" type="${InputType.SWITCH}" @or-input-changed="${(evt: OrInputChangedEvent) => this._globalRulesets = evt.detail.value}"></or-input>
</div>
- <p>${i18next.t("global rules")}</p>
+ <p>${i18next.t("globalRules")}</p>
</div>
` : ``}