Skip to content
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
3 changes: 3 additions & 0 deletions static/fluent/en-CA/main.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ SmartPlug = Smart Plug
Light = Light
DoorSensor = Door Sensor
MotionSensor = Motion Sensor
OccupancySensor = Occupancy Sensor
LeakSensor = Leak Sensor
PushButton = Push Button
VideoCamera = Video Camera
Expand Down Expand Up @@ -306,6 +307,8 @@ color-temperature = Colour Temperature
video-unsupported = Sorry, video is not supported in your browser.
motion = Motion
no-motion = No Motion
occupied = Occupied
unoccupied = Unoccupied
open = Open
closed = Closed
locked = Locked
Expand Down
3 changes: 3 additions & 0 deletions static/fluent/en-GB/main.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ SmartPlug = Smart Plug
Light = Light
DoorSensor = Door Sensor
MotionSensor = Motion Sensor
OccupancySensor = Occupancy Sensor
LeakSensor = Leak Sensor
PushButton = Push Button
VideoCamera = Video Camera
Expand Down Expand Up @@ -306,6 +307,8 @@ color-temperature = Colour Temperature
video-unsupported = Sorry, video is not supported in your browser.
motion = Motion
no-motion = No Motion
occupied = Occupied
unoccupied = Unoccupied
open = Open
closed = Closed
locked = Locked
Expand Down
3 changes: 3 additions & 0 deletions static/fluent/en-US/main.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ SmartPlug = Smart Plug
Light = Light
DoorSensor = Door Sensor
MotionSensor = Motion Sensor
OccupancySensor = Occupancy Sensor
LeakSensor = Leak Sensor
PushButton = Push Button
VideoCamera = Video Camera
Expand Down Expand Up @@ -307,6 +308,8 @@ color-temperature = Color Temperature
video-unsupported = Sorry, video is not supported in your browser.
motion = Motion
no-motion = No Motion
occupied = Occupied
unoccupied = Unoccupied
open = Open
closed = Closed
locked = Locked
Expand Down
37 changes: 37 additions & 0 deletions static/images/component-icons/occupancy-sensor-occupied.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions static/images/component-icons/occupancy-sensor-unoccupied.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions static/images/thing-icons/occupancy_sensor.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions static/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ require('./components/capability/lock');
require('./components/capability/motion-sensor');
require('./components/capability/multi-level-sensor');
require('./components/capability/multi-level-switch');
require('./components/capability/occupancy-sensor');
require('./components/capability/on-off-switch');
require('./components/capability/push-button');
require('./components/capability/smart-plug');
Expand Down Expand Up @@ -546,6 +547,7 @@ require('./components/property/locked');
require('./components/property/motion');
require('./components/property/number');
require('./components/property/numeric-label');
require('./components/property/occupied');
require('./components/property/on-off');
require('./components/property/open');
require('./components/property/pushed');
Expand Down
98 changes: 98 additions & 0 deletions static/js/components/capability/occupancy-sensor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/**
* OccupancySensorCapability
*
* A bubble showing an occupancy sensor icon.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
'use strict';

const BaseComponent = require('../base-component');
const fluent = require('../../fluent');

const template = document.createElement('template');
template.innerHTML = `
<style>
:host {
display: block;
contain: content;
text-align: center;
color: white;
font-size: 1.6rem;
cursor: default;
}

.webthing-occupancy-sensor-capability-icon {
width: 12.4rem;
height: 12.4rem;
border-radius: 6.4rem;
border: 0.2rem solid white;
background-size: 6.4rem;
background-repeat: no-repeat;
transform: translate(0);
background-color: #89b6d6;
background-image: url('/images/component-icons/occupancy-sensor-unoccupied.svg');
background-position: center 2rem;
}

.webthing-occupancy-sensor-capability-icon.occupied {
background-color: white;
background-image: url('/images/component-icons/occupancy-sensor-occupied.svg');
}

.webthing-occupancy-sensor-capability-label {
font-weight: bold;
text-transform: uppercase;
padding-top: 8.75rem;
font-size: 1.2rem;
}

.webthing-occupancy-sensor-capability-icon.occupied
.webthing-occupancy-sensor-capability-label {
color: #5d9bc7;
font-size: 1.4rem;
}
</style>
<div id="icon" class="webthing-occupancy-sensor-capability-icon">
<div id="label" class="webthing-occupancy-sensor-capability-label">--</div>
</div>
`;

class OccupancySensorCapability extends BaseComponent {
constructor() {
super(template);

this._icon = this.shadowRoot.querySelector('#icon');
this._label = this.shadowRoot.querySelector('#label');

this._occupied = false;
}

connectedCallback() {
this.occupied = typeof this.dataset.occupied !== 'undefined' ? this.dataset.occupied : null;
}

get occupied() {
return this._occupied;
}

set occupied(value) {
this._occupied = Boolean(value);

if (value === null) {
this._icon.classList.remove('occupied');
this._label.innerText = fluent.getMessage('ellipsis');
} else if (this._occupied) {
this._icon.classList.add('occupied');
this._label.innerText = fluent.getMessage('occupied');
} else {
this._icon.classList.remove('occupied');
this._label.innerText = fluent.getMessage('unoccupied');
}
}
}

window.customElements.define('webthing-occupancy-sensor-capability', OccupancySensorCapability);
module.exports = OccupancySensorCapability;
22 changes: 22 additions & 0 deletions static/js/components/property/occupied.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* OccupiedProperty
*
* A bubble showing an occupied or not occupied label.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
'use strict';

const StringLabelProperty = require('./string-label');

class OccupiedProperty extends StringLabelProperty {
connectedCallback() {
this.uppercase = true;
super.connectedCallback();
}
}

window.customElements.define('webthing-occupied-property', OccupiedProperty);
module.exports = OccupiedProperty;
2 changes: 2 additions & 0 deletions static/js/icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ function capabilityToIcon(capability) {
return '/images/thing-icons/door_sensor.svg';
case 'MotionSensor':
return '/images/thing-icons/motion_sensor.svg';
case 'OccupancySensor':
return '/images/thing-icons/occupancy_sensor.svg';
case 'LeakSensor':
return '/images/thing-icons/leak_sensor.svg';
case 'SmokeSensor':
Expand Down
2 changes: 2 additions & 0 deletions static/js/logs/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,8 @@ class Log {
return value ? fluent.getMessage('on') : fluent.getMessage('off');
case 'MotionProperty':
return value ? fluent.getMessage('motion') : fluent.getMessage('no-motion');
case 'OccupiedProperty':
return value ? fluent.getMessage('occupied') : fluent.getMessage('unoccupied');
case 'OpenProperty':
return value ? fluent.getMessage('open') : fluent.getMessage('closed');
case 'LeakProperty':
Expand Down
5 changes: 5 additions & 0 deletions static/js/schema-impl/capability/capabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const Lock = require('./lock');
const MotionSensor = require('./motion-sensor');
const MultiLevelSensor = require('./multi-level-sensor');
const MultiLevelSwitch = require('./multi-level-switch');
const OccupancySensor = require('./occupancy-sensor');
const OnOffSwitch = require('./on-off-switch');
const PushButton = require('./push-button');
const SmartPlug = require('./smart-plug');
Expand Down Expand Up @@ -56,6 +57,8 @@ function createThingFromCapability(capability, thingModel, description, format)
return new DoorSensor(thingModel, description, format);
case 'MotionSensor':
return new MotionSensor(thingModel, description, format);
case 'OccupancySensor':
return new OccupancySensor(thingModel, description, format);
case 'LeakSensor':
return new LeakSensor(thingModel, description, format);
case 'SmokeSensor':
Expand Down Expand Up @@ -110,6 +113,8 @@ function getClassFromCapability(capability) {
return 'door-sensor';
case 'MotionSensor':
return 'motion-sensor';
case 'OccupancySensor':
return 'occupancy-sensor';
case 'LeakSensor':
return 'leak-sensor';
case 'SmokeSensor':
Expand Down
Loading