Introduction of room alerts
This commit is contained in:
parent
ed04554a4a
commit
7747a10959
6 changed files with 158 additions and 6 deletions
34
hal-core/resources/web/css/hal.css
vendored
34
hal-core/resources/web/css/hal.css
vendored
|
|
@ -146,3 +146,37 @@ body {
|
||||||
transform: rotate(359deg);
|
transform: rotate(359deg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Animations
|
||||||
|
*/
|
||||||
|
|
||||||
|
.pulse-border {
|
||||||
|
animation: pulse 2s infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes pulse {
|
||||||
|
0% {
|
||||||
|
stroke-width: 3;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
10% {
|
||||||
|
stroke-width: 5;
|
||||||
|
opacity: 0.2;
|
||||||
|
}
|
||||||
|
15% {
|
||||||
|
stroke-width: 5;
|
||||||
|
opacity: 0.2;
|
||||||
|
}
|
||||||
|
|
||||||
|
50% {
|
||||||
|
stroke-width: 3;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
stroke-width: 3;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
39
hal-core/resources/web/js/hal_map.js
vendored
39
hal-core/resources/web/js/hal_map.js
vendored
|
|
@ -155,11 +155,7 @@ function drawMap() {
|
||||||
|
|
||||||
group.text(room.name).move(5, 5).fill('#999');
|
group.text(room.name).move(5, 5).fill('#999');
|
||||||
var rect = group.rect(room.map.width, room.map.height);
|
var rect = group.rect(room.map.width, room.map.height);
|
||||||
rect.fill('none').stroke({
|
setAlertStyle(rect, (room.alert == null ? null : room.alert.level));
|
||||||
color: '#000',
|
|
||||||
opacity: 0.6,
|
|
||||||
width: 3
|
|
||||||
});
|
|
||||||
rect.addClass("resizable");
|
rect.addClass("resizable");
|
||||||
|
|
||||||
group.addClass("room")
|
group.addClass("room")
|
||||||
|
|
@ -275,3 +271,36 @@ function saveDevice(element, type, id) {
|
||||||
data: data
|
data: data
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------
|
||||||
|
// Colors
|
||||||
|
// ----------------------------------------------
|
||||||
|
|
||||||
|
function setAlertStyle(target, level=null) {
|
||||||
|
target.addClass("pulse-border");
|
||||||
|
target.fill('none');
|
||||||
|
|
||||||
|
switch(level) {
|
||||||
|
case "ERROR":
|
||||||
|
target.stroke({opacity: 1, color: '#f00'});
|
||||||
|
break;
|
||||||
|
case "WARNING":
|
||||||
|
target.stroke({opacity: 1, color: '#ffa500'});
|
||||||
|
break;
|
||||||
|
case "SUCCESS":
|
||||||
|
target.stroke({opacity: 1, color: '#90EE90'});
|
||||||
|
break;
|
||||||
|
case "INFO":
|
||||||
|
target.stroke({opacity: 1, color: '#87CEFA'});
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
target.removeClass("pulse-border");
|
||||||
|
target.stroke({
|
||||||
|
color: '#000',
|
||||||
|
opacity: 0.6,
|
||||||
|
width: 3
|
||||||
|
});;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -33,6 +33,6 @@ public class AlertAction implements HalAction {
|
||||||
|
|
||||||
|
|
||||||
public String toString(){
|
public String toString(){
|
||||||
return "Send Alert: " + severity + ": " + title;
|
return "Generate Alert: " + severity + ": " + title;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
42
hal-core/src/se/hal/action/DismissRoomAlertAction.java
Normal file
42
hal-core/src/se/hal/action/DismissRoomAlertAction.java
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
package se.hal.action;
|
||||||
|
|
||||||
|
import se.hal.HalContext;
|
||||||
|
import se.hal.intf.HalAction;
|
||||||
|
import se.hal.struct.Room;
|
||||||
|
import se.hal.util.RoomValueProvider;
|
||||||
|
import zutil.log.LogUtil;
|
||||||
|
import zutil.ui.UserMessageManager.MessageTTL;
|
||||||
|
import zutil.ui.conf.Configurator;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import static zutil.ui.UserMessageManager.MessageLevel;
|
||||||
|
import static zutil.ui.UserMessageManager.UserMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action that will alert users with a message
|
||||||
|
*/
|
||||||
|
public class DismissRoomAlertAction implements HalAction {
|
||||||
|
private static final Logger logger = LogUtil.getLogger();
|
||||||
|
|
||||||
|
@Configurator.Configurable(value = "Target Room", valueProvider = RoomValueProvider.class)
|
||||||
|
private Room room;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
if (room != null) {
|
||||||
|
room.clearRoomAlert();
|
||||||
|
} else {
|
||||||
|
HalContext.getUserMessageManager().add(new UserMessage(MessageLevel.WARNING, "Room not defined for dismissing alert.", MessageTTL.ONE_VIEW));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
if (room != null) {
|
||||||
|
return "Dismiss alert for room: " + room.getName();
|
||||||
|
}
|
||||||
|
return "No room defined.";
|
||||||
|
}
|
||||||
|
}
|
||||||
45
hal-core/src/se/hal/action/RoomAlertAction.java
Normal file
45
hal-core/src/se/hal/action/RoomAlertAction.java
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
package se.hal.action;
|
||||||
|
|
||||||
|
import se.hal.HalContext;
|
||||||
|
import se.hal.intf.HalAction;
|
||||||
|
import se.hal.struct.Room;
|
||||||
|
import se.hal.util.ConfigSensorValueProvider;
|
||||||
|
import se.hal.util.RoomValueProvider;
|
||||||
|
import zutil.db.DBConnection;
|
||||||
|
import zutil.log.LogUtil;
|
||||||
|
import zutil.ui.UserMessageManager.MessageTTL;
|
||||||
|
import zutil.ui.conf.Configurator;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import static zutil.ui.UserMessageManager.MessageLevel;
|
||||||
|
import static zutil.ui.UserMessageManager.UserMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action that will alert users with a message
|
||||||
|
*/
|
||||||
|
public class RoomAlertAction implements HalAction {
|
||||||
|
private static final Logger logger = LogUtil.getLogger();
|
||||||
|
|
||||||
|
@Configurator.Configurable(value = "Target Room", valueProvider = RoomValueProvider.class)
|
||||||
|
private Room room;
|
||||||
|
@Configurator.Configurable("Alert Severity")
|
||||||
|
private MessageLevel severity = MessageLevel.INFO;
|
||||||
|
@Configurator.Configurable("Alert Title")
|
||||||
|
private String title = "";
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
if (room != null) {
|
||||||
|
room.setRoomAlert(new UserMessage(severity, title, MessageTTL.DISMISSED));
|
||||||
|
} else {
|
||||||
|
HalContext.getUserMessageManager().add(new UserMessage(MessageLevel.WARNING, "Room not defined for room alert.", MessageTTL.ONE_VIEW));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return "Generate Room Alert: " + severity + ": " + title;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -36,6 +36,8 @@
|
||||||
{"se.hal.intf.HalTrigger": "se.hal.trigger.TimerTrigger"},
|
{"se.hal.intf.HalTrigger": "se.hal.trigger.TimerTrigger"},
|
||||||
|
|
||||||
{"se.hal.intf.HalAction": "se.hal.action.AlertAction"},
|
{"se.hal.intf.HalAction": "se.hal.action.AlertAction"},
|
||||||
|
{"se.hal.intf.HalAction": "se.hal.action.DismissRoomAlertAction"},
|
||||||
|
{"se.hal.intf.HalAction": "se.hal.action.RoomAlertAction"},
|
||||||
{"se.hal.intf.HalAction": "se.hal.action.SendEventAction"}
|
{"se.hal.intf.HalAction": "se.hal.action.SendEventAction"}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue