Console: Add support for notification bubbles

This commit is contained in:
zzz
2025-02-22 11:07:43 +00:00
parent 538cb52ed3
commit 652d55a95c
17 changed files with 319 additions and 30 deletions

View File

@ -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);
}

View File

@ -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) {}
}

View File

@ -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,

View File

@ -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);
}
}
}
}

View File

@ -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;