Split alert messages into title and msg, title should be unique
This commit is contained in:
parent
df9b41a843
commit
9fa687081a
3 changed files with 22 additions and 8 deletions
|
|
@ -5,7 +5,8 @@
|
|||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<span class="glyphicon glyphicon-minus-sign" aria-hidden="true"></span>
|
||||
<strong>{{.getMessage()}}</strong>
|
||||
<strong>{{.getTitle()}}</strong>
|
||||
{{#.getMessage()}}{{.getMessage()}}{{/.getMessage()}}
|
||||
</div>
|
||||
{{/.isError()}}
|
||||
{{#.isWarning()}}
|
||||
|
|
@ -14,7 +15,8 @@
|
|||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<span class="glyphicon glyphicon-warning-sign" aria-hidden="true"></span>
|
||||
<strong>{{.getMessage()}}</strong>
|
||||
<strong>{{.getTitle()}}</strong>
|
||||
{{#.getMessage()}}{{.getMessage()}}{{/.getMessage()}}
|
||||
</div>
|
||||
{{/.isWarning()}}
|
||||
{{#.isSuccess()}}
|
||||
|
|
@ -23,7 +25,8 @@
|
|||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<span class="glyphicon glyphicon-ok-circle" aria-hidden="true"></span>
|
||||
<strong>{{.getMessage()}}</strong>
|
||||
<strong>{{.getTitle()}}</strong>
|
||||
{{#.getMessage()}}{{.getMessage()}}{{/.getMessage()}}
|
||||
</div>
|
||||
{{/.isSuccess()}}
|
||||
{{#.isInfo()}}
|
||||
|
|
@ -32,7 +35,8 @@
|
|||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
|
||||
<strong>{{.getMessage()}}</strong>
|
||||
<strong>{{.getTitle()}}</strong>
|
||||
{{#.getMessage()}}{{.getMessage()}}{{/.getMessage()}}
|
||||
</div>
|
||||
{{/.isInfo()}}
|
||||
{{/alerts}}
|
||||
|
|
|
|||
|
|
@ -108,8 +108,9 @@ public class SensorDataAggregatorDaemon implements HalDaemon {
|
|||
maxRawTimestampInDB + (dataInterval * 3) < System.currentTimeMillis()) {
|
||||
logger.fine("Sensor \"" + sensorId + "\" has stopped sending data");
|
||||
HalAlertManager.getInstance().addAlert(new HalAlert(AlertLevel.WARNING,
|
||||
"Sensor \"" + sensor.getName() + "\" has stopped responding " +
|
||||
"since <span class=\"timestamp\">"+maxRawTimestampInDB+"</span>", AlertTTL.DISMISSED));
|
||||
"Sensor \"" + sensor.getName() + "\" has stopped responding",
|
||||
"since <span class=\"timestamp\">"+maxRawTimestampInDB+"</span>",
|
||||
AlertTTL.DISMISSED));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -110,12 +110,18 @@ public class HalAlertManager implements HttpPage {
|
|||
|
||||
private int id;
|
||||
private AlertLevel level;
|
||||
private String title;
|
||||
private String msg;
|
||||
private int ttl;
|
||||
|
||||
public HalAlert(AlertLevel level, String msg, AlertTTL ttl) {
|
||||
|
||||
public HalAlert(AlertLevel level, String title, AlertTTL ttl) {
|
||||
this(level, title, null, ttl);
|
||||
}
|
||||
public HalAlert(AlertLevel level, String title, String msg, AlertTTL ttl) {
|
||||
this.id = nextId++;
|
||||
this.level = level;
|
||||
this.title = title;
|
||||
this.msg = msg;
|
||||
setTTL(ttl);
|
||||
}
|
||||
|
|
@ -131,6 +137,9 @@ public class HalAlertManager implements HttpPage {
|
|||
public boolean isWarning(){ return level == AlertLevel.WARNING; }
|
||||
public boolean isSuccess(){ return level == AlertLevel.SUCCESS; }
|
||||
public boolean isInfo(){ return level == AlertLevel.INFO; }
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
public String getMessage() {
|
||||
return msg;
|
||||
}
|
||||
|
|
@ -149,7 +158,7 @@ public class HalAlertManager implements HttpPage {
|
|||
public boolean equals(Object obj){
|
||||
if (obj instanceof HalAlert)
|
||||
return level == ((HalAlert) obj).level &&
|
||||
msg.equals(((HalAlert) obj).msg);
|
||||
title.equals(((HalAlert) obj).title);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue