You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sirona.apache.org by rm...@apache.org on 2013/11/04 17:38:43 UTC
svn commit: r1538668 - in /incubator/sirona/trunk/reporting/src/main:
java/org/apache/sirona/reporting/web/plugin/status/
resources/templates/status/
Author: rmannibucau
Date: Mon Nov 4 16:38:42 2013
New Revision: 1538668
URL: http://svn.apache.org/r1538668
Log:
using color for node status
Added:
incubator/sirona/trunk/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/status/StatusHelper.java
Modified:
incubator/sirona/trunk/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/status/StatusEndpoints.java
incubator/sirona/trunk/reporting/src/main/resources/templates/status/detail.vm
incubator/sirona/trunk/reporting/src/main/resources/templates/status/home.vm
Modified: incubator/sirona/trunk/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/status/StatusEndpoints.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/status/StatusEndpoints.java?rev=1538668&r1=1538667&r2=1538668&view=diff
==============================================================================
--- incubator/sirona/trunk/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/status/StatusEndpoints.java (original)
+++ incubator/sirona/trunk/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/status/StatusEndpoints.java Mon Nov 4 16:38:42 2013
@@ -23,12 +23,13 @@ import org.apache.sirona.repositories.Re
public class StatusEndpoints {
@Regex
public Template home() {
- return new Template("status/home.vm").set("nodes", Repository.INSTANCE.statuses());
+ return new Template("status/home.vm").set("helper", StatusHelper.class).set("nodes", Repository.INSTANCE.statuses());
}
@Regex("/([^/]*)")
public Template detail(final String node) {
return new Template("status/detail.vm")
+ .set("helper", StatusHelper.class)
.set("node", Repository.INSTANCE.statuses().get(node))
.set("name", node);
}
Added: incubator/sirona/trunk/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/status/StatusHelper.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/status/StatusHelper.java?rev=1538668&view=auto
==============================================================================
--- incubator/sirona/trunk/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/status/StatusHelper.java (added)
+++ incubator/sirona/trunk/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/status/StatusHelper.java Mon Nov 4 16:38:42 2013
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sirona.reporting.web.plugin.status;
+
+import org.apache.sirona.status.Status;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public final class StatusHelper {
+ private static final Map<Status, String> mapping = new HashMap<Status, String>();
+ static {
+ mapping.put(Status.OK, "success");
+ mapping.put(Status.DEGRADED, "warning");
+ mapping.put(Status.KO, "danger");
+ }
+
+ private StatusHelper() {
+ // no-op
+ }
+
+ public static String map(final Status status) {
+ return mapping.get(status);
+ }
+}
Modified: incubator/sirona/trunk/reporting/src/main/resources/templates/status/detail.vm
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/reporting/src/main/resources/templates/status/detail.vm?rev=1538668&r1=1538667&r2=1538668&view=diff
==============================================================================
--- incubator/sirona/trunk/reporting/src/main/resources/templates/status/detail.vm (original)
+++ incubator/sirona/trunk/reporting/src/main/resources/templates/status/detail.vm Mon Nov 4 16:38:42 2013
@@ -17,25 +17,23 @@
<h1>Node $name</h1>
<div>
- Global status: $node.status
- <ul>
- <table class="table table-bordered table-striped table-hover">
- <thead>
- <tr>
- <th>Name</th>
- <th>Description</th>
- <th>Status</th>
+ <div class="alert alert-$helper.map($node.status)">Global status: $node.status</div>
+ <table class="table table-bordered table-striped">
+ <thead>
+ <tr>
+ <th>Name</th>
+ <th>Description</th>
+ <th>Status</th>
+ </tr>
+ </thead>
+ <tbody>
+ #foreach ($result in $node.results)
+ <tr class="$helper.map($result.status)">
+ <td>$result.name</td>
+ <td>$result.message</td>
+ <td>$result.status</td>
</tr>
- </thead>
- <tbody>
- #foreach ($result in $node.results)
- <tr>
- <td>$result.name</td>
- <td>$result.message</td>
- <td>$result.status.name()</td>
- </tr>
- #end
- </tbody>
- </table>
- </ul>
+ #end
+ </tbody>
+ </table>
</div>
Modified: incubator/sirona/trunk/reporting/src/main/resources/templates/status/home.vm
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/reporting/src/main/resources/templates/status/home.vm?rev=1538668&r1=1538667&r2=1538668&view=diff
==============================================================================
--- incubator/sirona/trunk/reporting/src/main/resources/templates/status/home.vm (original)
+++ incubator/sirona/trunk/reporting/src/main/resources/templates/status/home.vm Mon Nov 4 16:38:42 2013
@@ -20,7 +20,13 @@
Here is the list of available nodes with their status:
<ul>
#foreach ($node in $nodes.entrySet())
- <li><a href="$mapping/status/$node.key">$node.key<a/>: $node.value.status</li>
+ #set($status = $node.value.status)
+ #set($statusClass = $helper.map($status))
+ <li>
+ <div class="alert alert-$statusClass">
+ <a class="alert-$statusClass" href="$mapping/status/$node.key">$node.key</a>: $status
+ </div>
+ </li>
#end
</ul>
</div>