Skip to content

Commit

Permalink
Dashboard: Improve display of motion sensor devices (#2028)
Browse files Browse the repository at this point in the history
  • Loading branch information
cicoub13 authored Feb 26, 2024
1 parent 185fe8a commit ab7ffa9
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Text } from 'preact-i18n';

import RelativeTime from '../../../../device/RelativeTime';

const MotionSensorDeviceValue = ({ deviceFeature, user }) => {
const { last_value: lastValue, last_value_changed: lastValueChanged } = deviceFeature;
if (lastValue) {
return (
<span class="badge badge-info">
<Text id="dashboard.boxes.devicesInRoom.motionDetected" />
</span>
);
} else if (lastValueChanged) {
return <RelativeTime datetime={lastValueChanged} language={user ? user.language : null} futureDisabled />;
}

return <Text id="dashboard.boxes.devicesInRoom.noValue" />;
};

export default MotionSensorDeviceValue;
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { DeviceFeatureCategoriesIcon } from '../../../../../utils/consts';

import BinaryDeviceValue from './BinaryDeviceValue';
import LastSeenDeviceValue from './LastSeenDeviceValue';
import MotionSensorDeviceValue from './MotionSensorDeviceValue';
import BadgeNumberDeviceValue from './BadgeNumberDeviceValue';
import IconBinaryDeviceValue from './IconBinaryDeviceValue';
import SignalQualityDeviceValue from './SignalQualityDeviceValue';
Expand All @@ -14,7 +15,7 @@ import TextDeviceValue from './TextDeviceValue';
import NoRecentValueBadge from './NoRecentValueBadge';

const DISPLAY_BY_FEATURE_CATEGORY = {
[DEVICE_FEATURE_CATEGORIES.MOTION_SENSOR]: LastSeenDeviceValue,
[DEVICE_FEATURE_CATEGORIES.MOTION_SENSOR]: MotionSensorDeviceValue,
[DEVICE_FEATURE_CATEGORIES.PRESENCE_SENSOR]: LastSeenDeviceValue,
[DEVICE_FEATURE_CATEGORIES.OPENING_SENSOR]: IconBinaryDeviceValue,
[DEVICE_FEATURE_CATEGORIES.SIGNAL]: SignalQualityDeviceValue,
Expand Down
3 changes: 2 additions & 1 deletion front/src/config/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@
"noRecentValue": "Kein aktueller Wert",
"deviceTitle": "{{name}} - {{type}}",
"addButton": "+",
"substractButton": "-"
"substractButton": "-",
"motionDetected": "Bewegung erkannt"
},
"devices": {
"editDeviceFeaturesLabel": "Wähle die Geräte aus, die du anzeigen möchtest:",
Expand Down
3 changes: 2 additions & 1 deletion front/src/config/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@
"noRecentValue": "No recent value",
"deviceTitle": "{{name}} - {{type}}",
"addButton": "+",
"substractButton": "-"
"substractButton": "-",
"motionDetected": "Motion detected"
},
"devices": {
"editDeviceFeaturesLabel": "Select the devices you want to display:",
Expand Down
3 changes: 2 additions & 1 deletion front/src/config/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@
"noRecentValue": "Pas de valeur récente",
"deviceTitle": "{{name}} - {{type}}",
"addButton": "+",
"substractButton": "-"
"substractButton": "-",
"motionDetected": "Mouvement détecté"
},
"devices": {
"editDeviceFeaturesLabel": "Vous pouvez modifier le nom affiché ici :",
Expand Down

0 comments on commit ab7ffa9

Please sign in to comment.