const DeviceList = ({ children, ...props }) => ( <div class="card-columns"> {props.rooms.map((room, index) => ( <RoomCard room={room} roomIndex={index} updateValue={props.updateValue} collapseRoom={props.collapseRoom} /> ))} </div> )
removeRoom(state, houseIndex, roomIndex) { let action; // if the room already exist in DB, we set the flag to "to_delete" true. if (state.houses[houseIndex].rooms[roomIndex].id) { action = { [roomIndex]: { to_delete: { $set: true } } }; } else { // if not, we remove it action = { $splice: [[roomIndex, 1]] }; } const newState = update(state, { houses: { [houseIndex]: { rooms: action } } }); store.setState(newState); }
addRoom(state, name, houseIndex) { if (name.length === 0) { return null; } if (state.houses[houseIndex].rooms.find(room => room.name.toLowerCase() === name.toLowerCase())) { return null; } const newRoom = { name }; const newState = update(state, { houses: { [houseIndex]: { rooms: { $push: [newRoom] } } } }); store.setState(newState); }
/** * @public * @description Get rooms in a house. * @param {string} selector - Selector of the house. * @example * const rooms = await gladys.house.getRooms('my-house'); */ async function getRooms(selector) { const house = await db.House.findOne({ where: { selector, }, include: [ { model: db.Room, as: 'rooms', }, ], }); if (house === null) { throw new NotFoundError('House not found'); } const roomsPlain = house.rooms.map((room) => room.get({ plain: true })); return roomsPlain; }
var clients = io.sockets.adapter.rooms[room]; var numClients = typeof clients !== "undefined" ? clients.length : 0; if (numClients === 0) {
props.houses.map(house => ( <optgroup label={house.name}> {house.rooms.map(room => ( <option selected={room.id === props.device.room_id} value={room.id}> {room.name}
const DeviceList = ({ children, ...props }) => ( <div class="card-columns"> {props.rooms.map((room, index) => ( <RoomCard room={room} roomIndex={index} updateValue={props.updateValue} collapseRoom={props.collapseRoom} /> ))} </div> )
addRoom(state, name, houseIndex) { if (name.length === 0) { return null; } if (state.houses[houseIndex].rooms.find(room => room.name.toLowerCase() === name.toLowerCase())) { return null; } const newRoom = { name }; const newState = update(state, { houses: { [houseIndex]: { rooms: { $push: [newRoom] } } } }); store.setState(newState); }
/** * @public * @description Get rooms in a house. * @param {string} selector - Selector of the house. * @example * const rooms = await gladys.house.getRooms('my-house'); */ async function getRooms(selector) { const house = await db.House.findOne({ where: { selector, }, include: [ { model: db.Room, as: 'rooms', }, ], }); if (house === null) { throw new NotFoundError('House not found'); } const roomsPlain = house.rooms.map((room) => room.get({ plain: true })); return roomsPlain; }
removeRoom(state, houseIndex, roomIndex) { let action; // if the room already exist in DB, we set the flag to "to_delete" true. if (state.houses[houseIndex].rooms[roomIndex].id) { action = { [roomIndex]: { to_delete: { $set: true } } }; } else { // if not, we remove it action = { $splice: [[roomIndex, 1]] }; } const newState = update(state, { houses: { [houseIndex]: { rooms: action } } }); store.setState(newState); }
props.houses.map(house => ( <optgroup label={house.name}> {house.rooms.map(room => ( <option selected={room.id === props.device.room_id} value={room.id}> {room.name}
props.houses.map(house => ( <optgroup label={house.name}> {house.rooms.map(room => ( <option selected={room.id === props.device.room_id} value={room.id}> {room.name}
props.houses.map(house => ( <optgroup label={house.name}> {house.rooms.map(room => ( <option selected={room.id === props.device.room_id} value={room.id}> {room.name}