Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(boxs): Add Motion Sensor Device #2028

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading