FELIX-1607 - Improve status info line, correct timeline display.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@818849 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/EventCollector.java b/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/EventCollector.java
index 2ff7402..14ae432 100644
--- a/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/EventCollector.java
+++ b/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/EventCollector.java
@@ -50,6 +50,10 @@
{
eventInfos.remove( 0 );
}
+ if ( this.eventInfos.size() == 1 )
+ {
+ this.startTime = info.received;
+ }
}
}
}
diff --git a/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/OptionalFeaturesHandler.java b/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/OptionalFeaturesHandler.java
index 0de3a6c..bc73c8a 100644
--- a/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/OptionalFeaturesHandler.java
+++ b/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/OptionalFeaturesHandler.java
@@ -166,6 +166,7 @@
{
this.unbindConfigAdmin(this.configAdminReference);
}
+ this.plugin.setConfigAdminAvailable(true);
this.configAdminReference = ref;
this.configListenerRegistration = ConfigurationListener.create(this.bundleContext, this.plugin);
}
@@ -175,6 +176,7 @@
if ( this.configAdminReference == ref )
{
this.configAdminReference = null;
+ this.plugin.setConfigAdminAvailable(false);
if ( this.configListenerRegistration != null )
{
this.configListenerRegistration.unregister();
diff --git a/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/PluginServlet.java b/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/PluginServlet.java
index 4779559..a3b672f 100644
--- a/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/PluginServlet.java
+++ b/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/PluginServlet.java
@@ -76,14 +76,6 @@
List events = this.collector.getEvents();
StringBuffer statusLine = new StringBuffer();
- if ( this.eventAdminAvailable )
- {
- statusLine.append("Event Admin service is available. ");
- }
- else
- {
- statusLine.append("Event Admin service is not available. ");
- }
statusLine.append( events.size() );
statusLine.append( " Event");
if ( events.size() != 1 )
@@ -98,16 +90,22 @@
d.setTime( ( ( EventInfo ) events.get( 0 ) ).received );
statusLine.append( d );
}
- statusLine.append( "." );
+ statusLine.append( ". (Event admin: " );
+ if ( !this.eventAdminAvailable )
+ {
+ statusLine.append("un");
+ }
+ statusLine.append("available; Config admin: ");
+ if ( !this.configAdminAvailable )
+ {
+ statusLine.append("un");
+ }
+ statusLine.append("available)");
// Compute scale: startTime is 0, lastTimestamp is 100%
final long startTime = this.collector.getStartTime();
- long endTime = (events.size() == 0 ? startTime : ((EventInfo)events.get(events.size() - 1)).received);
- if ( endTime == startTime )
- {
- endTime = startTime + 10;
- }
- final float scale = 100.0f / (endTime - startTime);
+ final long endTime = (events.size() == 0 ? startTime : ((EventInfo)events.get(events.size() - 1)).received);
+ final float scale = (endTime == startTime ? 100.0f : 100.0f / (endTime - startTime));
JSONWriter jw = new JSONWriter( pw );
try
@@ -193,11 +191,13 @@
final long msec = info.received - start;
// Compute color bar size and make sure the bar is visible
- final int percent = Math.max((int)((msec) * scale), 2);
+ final int percent = Math.max((int)(msec * scale), 2);
jw.object();
jw.key( "id" );
jw.value( String.valueOf( index ) );
+ jw.key( "offset" );
+ jw.value( msec );
jw.key( "width" );
jw.value( percent );
jw.key( "category" );
@@ -261,4 +261,9 @@
{
this.eventAdminAvailable = flag;
}
+
+ public void setConfigAdminAvailable(final boolean flag)
+ {
+ this.configAdminAvailable = flag;
+ }
}
diff --git a/webconsole-plugins/event/src/main/resources/res/ui/events.js b/webconsole-plugins/event/src/main/resources/res/ui/events.js
index 771451f..acb3951 100644
--- a/webconsole-plugins/event/src/main/resources/res/ui/events.js
+++ b/webconsole-plugins/event/src/main/resources/res/ui/events.js
@@ -47,7 +47,7 @@
$("#plugin_table").trigger("update");
if ( view == 1 ) {
$("#timeline").remove();
- $("div.table").append( "<div id='timeline'></div>" );
+ $("div.table").append( "<div id='timeline' width='100%'></div>" );
for ( var idx in eventData.data ) {
entryTimeline( eventData.data[idx] );
}
@@ -61,13 +61,13 @@
}
function entryTimeline( /* Object */ dataEntry ) {
- var txt = "<div class='event" + dataEntry.category + "' style='width:" + dataEntry.width + "%;'>";
- txt = txt + "<b>" + dataEntry.topic + "</b> ";
+ var txt = "<div class='event" + dataEntry.category + "' style='overflow:visible;white-space:nowrap;width:" + dataEntry.width + "%;'>";
+ txt = txt + "<b>" + dataEntry.offset + "</b> <b>" + dataEntry.topic + "</b>";
if ( dataEntry.info ) {
- txt = txt + dataEntry.info;
+ txt = txt + " : " + dataEntry.info;
}
txt = txt + "</div>";
- $("#timeline").append(txt);
+ $("#timeline").prepend(txt);
}
function entryInternal( /* Element */ parent, /* Object */ dataEntry ) {