Skip to content

armgit / core

Public Imported from GitHub
0

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

Improve or-language and or-history

Robin Dekkersfb89193a548b
diff --git a/.gitignore b/.gitignore
index fe7376764..8c4dd8dc2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -36,4 +36,5 @@ console/iOS/Pods
client/src/main/webapp/gwt/
client/.externalToolBuilders/
-manager/.factorypath
\ No newline at end of file
+manager/.factorypath
+.sts4-cache/
\ No newline at end of file
diff --git a/ui/app/main/index.html b/ui/app/main/index.html
index a9d1d11fc..8811e4187 100644
--- a/ui/app/main/index.html
+++ b/ui/app/main/index.html
@@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes">
<title>OpenRemote Demo</title>
<meta name="application-name" content="OpenRemote Demo">
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="apple-mobile-web-app-title" content="OpenRemote Demo">
<meta name="msapplication-TileImage" content="images/Icon-144.png">
diff --git a/ui/app/main/locales/en/app.json b/ui/app/main/locales/en/app.json
index b9d57172b..ae32ee8ef 100644
--- a/ui/app/main/locales/en/app.json
+++ b/ui/app/main/locales/en/app.json
@@ -4,13 +4,13 @@
"groupNumber": "Group number",
"lightStatus": "Status",
"lightDimLevel": "Dim level (%)",
- "nO2": "NO2 (�g/m3)",
+ "nO2": "NO2 (µg/m3)",
"ozon": "Ozone",
"relHumidity": "Relative humidity (%)",
"Temperature": "Temperature (oC)",
- "particlesPM1": "Particulates PM1 (�g/m3)",
- "particlesPM10": "Particulates PM10 (�g/m3)",
- "particlesPM2_5": "Particulates PM2.5 (�g/m3)",
+ "particlesPM1": "Particulates PM1 (µg/m3)",
+ "particlesPM10": "Particulates PM10 (µg/m3)",
+ "particlesPM2_5": "Particulates PM2.5 (µg/m3)",
"peopleCountIn": "People in",
"peopleCountOut": "People out",
"peopleCountTotal": "Total people",
@@ -104,7 +104,7 @@
"motionSensor": "Motion sensor",
"lastPresenceDetected": "Last presence",
"firstPresenceDetected": "First presence",
- "co2Level": "CO2 (�g/m3)",
+ "co2Level": "CO2 (µg/m3)",
"humidity": "Humidity (%)",
"targetTemperature": "Set temperature",
"currentTemperature": "Current temperature",
diff --git a/ui/component/or-attribute-history/src/index.ts b/ui/component/or-attribute-history/src/index.ts
index b2fbf0a74..50b712a2c 100644
--- a/ui/component/or-attribute-history/src/index.ts
+++ b/ui/component/or-attribute-history/src/index.ts
@@ -158,7 +158,7 @@ const style = css`
justify-content: space-between;
margin: var(--internal-or-attribute-history-controls-margin);
- flex-direction: column;
+ flex-direction: row;
}
#controls > * {
@@ -173,7 +173,7 @@ const style = css`
}
#ending-controls > * {
- padding: 0 5px;
+ padding: 0 3px;
}
#ending-date {
diff --git a/ui/component/or-header/src/or-language.ts b/ui/component/or-header/src/or-language.ts
index 3bb32255a..03a7616c4 100644
--- a/ui/component/or-header/src/or-language.ts
+++ b/ui/component/or-header/src/or-language.ts
@@ -1,6 +1,9 @@
import {customElement, html, css, LitElement, property} from "lit-element";
import "@openremote/or-icon";
+import i18next from "i18next";
import manager from "@openremote/core";
+import {MenuItem} from "@openremote/or-mwc-components/dist/or-mwc-menu";
+import {getContentWithMenuTemplate} from "@openremote/or-mwc-components/dist/or-mwc-menu";
// language=CSS
const style = css`
@@ -8,35 +11,33 @@ const style = css`
position: relative;
}
- .dropdown-menu {
- position: absolute;
- top: 100%;
- box-shadow: rgba(0, 0, 0, 0.3) 0 5px 5px -2px;
- width: 120px;
- background-color: white;
- right: 0;
- }
-
- span {
- display: block;
- height: 40px;
- line-height: 40px;
- }
-
- .background-close {
- display: none;
- position: fixed;
- width: 100vw;
- height: 100vh;
- top: 0;
- left: 0;
- z-index: 0;
- }
-
- .background-close.active {
- display: block;
+ .or-language-container {
+ display: flex;
+ height: 50px;
+ align-items: center;
}
`;
+interface languageOptions {
+ [key: string]: string;
+}
+
+const languageOptions: languageOptions = {
+ "en": "english",
+ "nl": "dutch",
+ "fr": "french",
+ "de": "german",
+ "es": "spanish"
+};
+
+function getLanguageMenu(): MenuItem[] {
+
+ return Object.entries(languageOptions).map(([key, value]) => {
+ return {
+ text: i18next.t(value),
+ value: key
+ };
+ });
+}
@customElement("or-language")
export class OrLanguage extends LitElement {
@@ -45,34 +46,33 @@ export class OrLanguage extends LitElement {
@property({type: Boolean})
isVisible?: boolean = false;
+ @property({type: String})
+ language: string = manager.language;
+
static styles = style;
+ firstUpdated() {
+ this.language = manager.language ? manager.language : "en";
+ }
+
protected render() {
return html`
- <or-icon icon="web" @click="${this.toggleMenu}"></or-icon>
- <div class="background-close ${this.isVisible ? "active" : ""}" @click="${this.closeMenu}"></div>
- ${this.isVisible ? html`
- <div class="dropdown-menu">
- <span @click="${() => this.changeLanguage("en")}"><or-translate value="english"></or-translate></span>
- <span @click="${() => this.changeLanguage("nl")}"><or-translate value="dutch"></or-translate></span>
- <span @click="${() => this.changeLanguage("fr")}"><or-translate value="french"></or-translate></span>
- <span @click="${() => this.changeLanguage("de")}"><or-translate value="german"></or-translate></span>
- <span @click="${() => this.changeLanguage("es")}"><or-translate value="spanish"></or-translate></span>
- </div>
- ` : ``}
+ ${getContentWithMenuTemplate(
+ html`
+ <div class="or-language-container">
+ <strong style="text-transform: uppercase;">${this.language}</strong>
+ <or-icon icon="web"></or-icon>
+ </div>
+ `,
+ getLanguageMenu(),
+ this.language,
+ (values: string | string[]) => this.changeLanguage(values as string))}
`;
}
changeLanguage(language: string) {
manager.language = language;
+ this.language = language;
this.isVisible = false;
}
-
- closeMenu() {
- this.isVisible = false;
- }
-
- toggleMenu() {
- this.isVisible = !this.isVisible;
- }
}
diff --git a/ui/component/or-header/src/style.ts b/ui/component/or-header/src/style.ts
index 6f3f75e78..e8f63714d 100644
--- a/ui/component/or-header/src/style.ts
+++ b/ui/component/or-header/src/style.ts
@@ -51,6 +51,10 @@ export const style = css`
z-index: 9999999;
}
+ slot {
+ display: flex;
+ }
+
.shadow {
-webkit-box-shadow: ${unsafeCSS(DefaultBoxShadowBottom)};
-moz-box-shadow: ${unsafeCSS(DefaultBoxShadowBottom)};
diff --git a/ui/component/or-input/src/index.ts b/ui/component/or-input/src/index.ts
index 14149053f..de567aadf 100644
--- a/ui/component/or-input/src/index.ts
+++ b/ui/component/or-input/src/index.ts
@@ -112,10 +112,13 @@ const style = css`
}
#component {
- flex: 1 1 0;
max-width: 100%;
}
-
+
+ .mdc-text-field {
+ flex: 1 1 0;
+ }
+
#menu-anchor {
max-width: 100%;
}
@@ -123,7 +126,13 @@ const style = css`
.or-input--rounded {
border-radius: 50% !important;
}
-
+
+ ::-webkit-clear-button {display: none;}
+ ::-webkit-inner-spin-button { display: none; }
+ ::-webkit-datetime-edit { padding: 0em;}
+ ::-webkit-datetime-edit-text { padding: 0; }
+
+
/* MDC TEXT FIELD AND SELECT DON'T USE THEME VARS */
.mdc-text-field--focused:not(.mdc-text-field--disabled) .mdc-floating-label {
color: var(--mdc-theme-primary);