Console: Add support for notification bubbles
This commit is contained in:
@ -45,4 +45,32 @@ public interface ClientAppManager {
|
||||
* @return client app or null
|
||||
*/
|
||||
public ClientApp getRegisteredApp(String name);
|
||||
|
||||
/**
|
||||
* Bubble count
|
||||
* @since 0.9.66
|
||||
*/
|
||||
public int getBubbleCount(String svc);
|
||||
|
||||
/**
|
||||
* Bubble message, translated, not HTML escaped
|
||||
* @return null if none
|
||||
* @since 0.9.66
|
||||
*/
|
||||
public String getBubbleText(String svc);
|
||||
|
||||
/**
|
||||
* Update notifications for service
|
||||
* @param count 0 to clear
|
||||
* @param text translated, not HTML escaped, null if none
|
||||
* @since 0.9.66
|
||||
*/
|
||||
public void setBubble(String svc, int count, String text);
|
||||
|
||||
/**
|
||||
* Increment the count and set the text
|
||||
* @param text translated, not HTML escaped, null if none
|
||||
* @since 0.9.66
|
||||
*/
|
||||
public void addBubble(String svc, String text);
|
||||
}
|
||||
|
@ -64,4 +64,32 @@ public class ClientAppManagerImpl implements ClientAppManager {
|
||||
public ClientApp getRegisteredApp(String name) {
|
||||
return _registered.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 0 always, see RouterAppManager override
|
||||
* @since 0.9.66
|
||||
*/
|
||||
public int getBubbleCount(String svc) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null always, see RouterAppManager override
|
||||
* @since 0.9.66
|
||||
*/
|
||||
public String getBubbleText(String svc) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does nothing, see RouterAppManager override
|
||||
* @since 0.9.66
|
||||
*/
|
||||
public void setBubble(String svc, int count, String text) {}
|
||||
|
||||
/**
|
||||
* Does nothing, see RouterAppManager override
|
||||
* @since 0.9.66
|
||||
*/
|
||||
public synchronized void addBubble(String svc, String text) {}
|
||||
}
|
||||
|
@ -166,6 +166,9 @@ public class LogManager implements Flushable {
|
||||
if (context.isRouterContext()) {
|
||||
// FIXME don't start thread in constructor
|
||||
startLogWriter();
|
||||
// for bubbles, host/port may be wrong
|
||||
PortMapper pm = context.portMapper();
|
||||
pm.register(PortMapper.SVC_LOGS, "127.0.0.1", 7657);
|
||||
} else {
|
||||
// Only in App Context.
|
||||
// In Router Context, the router has its own shutdown hook,
|
||||
|
@ -228,6 +228,10 @@ abstract class LogWriter implements Runnable {
|
||||
String tname = Translate.getString(name, _manager.getContext(), ROUTER_BUNDLE_NAME);
|
||||
ns.notify(name, null, priority, tname, msg, null);
|
||||
}
|
||||
if (priority >= Log.CRIT) {
|
||||
// Console sidebar
|
||||
cmgr.addBubble(PortMapper.SVC_LOGS, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -91,6 +91,11 @@ public class PortMapper {
|
||||
* @since 0.9.39
|
||||
*/
|
||||
public static final String SVC_JSONRPC = "jsonrpc";
|
||||
/**
|
||||
* For bubbles
|
||||
* @since 0.9.66
|
||||
*/
|
||||
public static final String SVC_LOGS = "logs";
|
||||
|
||||
/** @since 0.9.34 */
|
||||
public static final int DEFAULT_CONSOLE_PORT = 7657;
|
||||
|
Reference in New Issue
Block a user