Skip to content

Commit

Permalink
Merge pull request #239 from mwringe/HWKMETRICS-118
Browse files Browse the repository at this point in the history
HWKMETRICS-118
  • Loading branch information
tsegismont committed Jul 7, 2015
2 parents 42bf3de + 6fbaa2b commit 4b4cb0b
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,19 @@
package org.hawkular.metrics.api.jaxrs.handler;

import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static javax.ws.rs.core.MediaType.APPLICATION_XHTML_XML;
import static javax.ws.rs.core.MediaType.TEXT_HTML;

import com.wordnik.swagger.annotations.ApiOperation;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import org.jboss.resteasy.spi.ResteasyProviderFactory;

/**
* @author mwringe
Expand All @@ -51,6 +56,15 @@ public Response baseJSON(@Context ServletContext context) {
return Response.ok(hawkularMetrics).build();
}

@GET
@Produces({APPLICATION_XHTML_XML, TEXT_HTML})
public void baseHTML(@Context ServletContext context) throws Exception {

HttpServletRequest request = ResteasyProviderFactory.getContextData(HttpServletRequest.class);
HttpServletResponse response = ResteasyProviderFactory.getContextData(HttpServletResponse.class);
request.getRequestDispatcher("/static/index.html").forward(request,response);
}

private class HawkularMetricsBase {

String name = "Hawkular-Metrics";
Expand All @@ -68,4 +82,4 @@ public String getVersion() {
return version;
}
}
}
}
14 changes: 14 additions & 0 deletions api/metrics-api-jaxrs/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,18 @@
<param-name>resteasy.providers</param-name>
<param-value>org.hawkular.metrics.api.jaxrs.util.JacksonConfig</param-value>
</context-param>

<servlet>
<servlet-name>staticContent</servlet-name>
<servlet-class>io.undertow.servlet.handlers.DefaultServlet</servlet-class>
<init-param>
<param-name>resolve-against-context-root</param-name>
<param-value>true</param-value>
</init-param>
</servlet>

<servlet-mapping>
<servlet-name>staticContent</servlet-name>
<url-pattern>/static/*</url-pattern>
</servlet-mapping>
</web-app>
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions api/metrics-api-jaxrs/src/main/webapp/static/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!--
~ JBoss, Home of Professional Open Source.
~ Copyright (c) 2011, Red Hat, Inc., and individual contributors
~ as indicated by the @author tags. See the copyright.txt file in the
~ distribution for a full listing of individual contributors.
~
~ This is free software; you can redistribute it and/or modify it
~ under the terms of the GNU Lesser General Public License as
~ published by the Free Software Foundation; either version 2.1 of
~ the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
~ Lesser General Public License for more details.
~
~ You should have received a copy of the GNU Lesser General Public
~ License along with this software; if not, write to the Free
~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Hawkular Metrics</title>
<link rel="shortcut icon" href="/hawkular/metrics/static/favicon.ico" type="image/x-icon">
<link rel="StyleSheet" href="/hawkular/metrics/static/welcome.css" type="text/css">
<script src="/hawkular/metrics/static/status.js"></script>
</head>

<body>
<div class="content">
<div class="logo"/>
<img src="/hawkular/metrics/static/hawkular_logo.png" alt="Hawkular Logo"/>
</div>
<h1>Hawkular Metrics</h1>
<h3>A time series metrics engine based on Cassandra</h3>
<p>${project.version}</p>
<p id="status">Status: <i>Checking...</i></p>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ if (window.XMLHttpRequest) {
}

httpRequest.onreadystatechange = updateStatus;
httpRequest.open("GET", "/hawkular/metrics/ping");
httpRequest.setRequestHeader("Hawkular-Tenant", "status");
httpRequest.open("GET", "/hawkular/metrics/status");
httpRequest.send();

function updateStatus() {
if (httpRequest.readyState === 4) {
if (httpRequest.status === 200) {
document.getElementById("status").innerHTML = "Started";
statusJson = JSON.parse(httpRequest.responseText);
document.getElementById("status").innerHTML = "Metrics Service :" + statusJson.MetricsService;
} else if (httpRequest.status === 404 || httpRequest.status === 503) {
document.getElementById("status").innerHTML = "The server is not available";
} else {
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,13 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Hawkular Metrics</title>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="StyleSheet" href="welcome.css" type="text/css">
<script src="status.js"></script>
<meta http-equiv="refresh" content="0;hawkular/metrics">
<title>Hawkular Metrics</title>
</head>

<body>
<div class="content">
<div class="logo"/>
<img src="hawkular_logo.png" alt="Hawkular Logo"/>
</div>
<h1>Hawkular Metrics</h1>
<h3>A time series metrics engine based on Cassandra</h3>
<p>Status: <i id="status">Checking...</i></p>
</div>
<h1>Hawkular Metrics</h1>
<h3>A time series metrics engine based on Cassandra</h3>
<p>${project.version}</p>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<filtered>false</filtered>
<excludes>
<exclude>Dockerfile</exclude>
<exclude>welcome-content/index.html</exclude>
</excludes>
</fileSet>
</fileSets>
Expand All @@ -42,6 +43,11 @@
<outputDirectory></outputDirectory>
<filtered>true</filtered>
</file>
<file>
<source>./src/main/docker/welcome-content/index.html</source>
<outputDirectory>welcome-content</outputDirectory>
<filtered>true</filtered>
</file>
</files>
<dependencySets>
<dependencySet>
Expand Down

0 comments on commit 4b4cb0b

Please sign in to comment.