Skip to content

armgit / core

Public Imported from GitHub
0

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

UI update: - remove unused period label css class - change unit label to have a gray-code - get unit from translation file

Vincent27a0aadb14d3
diff --git a/deployment/manager/shared/locales/en/or.json b/deployment/manager/shared/locales/en/or.json
index ddad776ec..9052bcd85 100644
--- a/deployment/manager/shared/locales/en/or.json
+++ b/deployment/manager/shared/locales/en/or.json
@@ -226,5 +226,28 @@
},
"couldNotRetrieveAttribute": "Could not retrieve attribute information",
"submit": "Submit",
- "password": "Password"
+ "password": "Password",
+ "units": {
+ "EUR": "€",
+ "GBP": "£",
+ "KILOWATT": "kW",
+ "KILOWATT_PEAK": "kWp",
+ "KILOWATT_PER_HOUR": "kWh",
+ "MILLIMETER_PER_SQUARE_METER": "mm/m²",
+ "MILLIS": "ms",
+ "SECONDS": "s",
+ "MINUTES": "min",
+ "KILOGRAM_CARBON_PER_KILOWATT_HOUR": "kg CO₂/kWh",
+ "KILOGRAM": "kg",
+ "CELSIUS": "°C",
+ "KILOMETERS_PER_HOUR": "km/h",
+ "METERS_PER_HOUR": "m/h",
+ "DEGREES": "°",
+ "PERCENTAGE": "%",
+ "METERS_PER_SECOND": "m/s",
+ "EUR_PER_KILOWATT_HOUR": "€/kWh",
+ "EUR_PER_MONTH": "€/month",
+ "GBP_PER_KILOWATT_HOUR": "£/kWh",
+ "GBP_PER_MONTH": "£/month"
+ }
}
diff --git a/ui/component/or-attribute-card/src/index.ts b/ui/component/or-attribute-card/src/index.ts
index 9dc399fca..653defeb5 100644
--- a/ui/component/or-attribute-card/src/index.ts
+++ b/ui/component/or-attribute-card/src/index.ts
@@ -2,7 +2,7 @@ import {css, customElement, html, LitElement, property, PropertyValues, query, u
import {classMap} from "lit-html/directives/class-map";
import i18next from "i18next";
import {Asset, AssetAttribute, Attribute, DatapointInterval, MetaItemType, ValueDatapoint} from "@openremote/model";
-import {manager, DefaultColor3, DefaultColor4, DefaultColor5, Util, AssetModelUtil} from "@openremote/core";
+import {manager, DefaultColor3, DefaultColor4, Util, AssetModelUtil} from "@openremote/core";
import Chart, {ChartTooltipCallback} from "chart.js";
import {getContentWithMenuTemplate, OrChartConfig} from "@openremote/or-chart";
import {InputType} from "@openremote/or-input";
@@ -93,17 +93,13 @@ const style = css`
align-items: center;
}
- .period-label {
- color: var(--or-app-color3, ${unsafeCSS(DefaultColor3)});
- }
-
.main-number {
font-size: 42px;
}
.main-number-unit {
font-size: 42px;
- color: var(--or-app-color5, ${unsafeCSS(DefaultColor5)});
+ color: var(--or-app-color3, ${unsafeCSS(DefaultColor3)});
}
.chart-wrapper {
@@ -635,9 +631,10 @@ export class OrAttributeCard extends LitElement {
const roundedVal = +value.toFixed(1); // + operator prevents str return
const attributeDescriptor = AssetModelUtil.getAttributeDescriptorFromAsset(this.attributeName!);
- const unit = Util.getMetaValue(MetaItemType.UNIT_TYPE, attr, attributeDescriptor);
+ const unitKey = Util.getMetaValue(MetaItemType.UNIT_TYPE, attr, attributeDescriptor);
+ const unit = i18next.t("units." + unitKey);
- if (!format) { return {value: roundedVal, unit: unit, formattedValue: roundedVal.toString()}; }
+ if (!format || !unitKey) { return {value: roundedVal, unit: "", formattedValue: roundedVal.toString()}; }
return {
value: roundedVal,