Commit 74043860 authored by Heinz N. Gies's avatar Heinz N. Gies

Add events section

parent aae86b8c
<!doctype html>
<html class='no-js' lang='en'>
<html class="no-js" lang="en">
<head>
<meta charset='utf-8' />
<meta name='viewport' content='width=device-width, initial-scale=1.0' />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>DalmatinerDB | Buckets</title>
<link rel='stylesheet' href='/css/foundation.css' />
<script src='/js/vendor/modernizr.js'></script>
<script src='/js/vendor/jquery.js'></script>
<script src='/js/vendor/jquery.cookie.js'></script>
<script src='/js/vendor/fastclick.js'></script>
<script src='/js/foundation.min.js'></script>
<script src='/js/msgpack.base.js'></script>
<script src='/js/msgpack.codec.js'></script>
<script src='/js/msgpack.js'></script>
<script src='/js/bucket.js'></script>
<link rel="stylesheet" href="/css/foundation.css" />
<script src="/js/vendor/modernizr.js"></script>
<script src="/js/vendor/jquery.js"></script>
<script src="/js/vendor/jquery.cookie.js"></script>
<script src="/js/vendor/fastclick.js"></script>
<script src="/js/foundation.min.js"></script>
<script src="/js/msgpack.base.js"></script>
<script src="/js/msgpack.codec.js"></script>
<script src="/js/msgpack.js"></script>
<script src="/js/bucket.js"></script>
</head>
<body>
<nav class='top-bar' data-topbar>
<ul class='title-area'>
<li class='name'>
<h1><a href='#'>Dalmatiner DB</a></h1>
<nav class="top-bar" data-topbar>
<ul class="title-area">
<li class="name">
<h1><a href="#">Dalmatiner DB</a></h1>
</li>
<!-- Remove the class 'menu-icon' to get rid of menu icon. Take out 'Menu' to just have icon alone -->
<li class='toggle-topbar menu-icon'><a href='#'><span>Menu</span></a></li>
<!-- Remove the class "menu-icon" to get rid of menu icon. Take out "Menu" to just have icon alone -->
<li class="toggle-topbar menu-icon"><a href="#"><span>Menu</span></a></li>
</ul>
<section class='top-bar-section'>
<section class="top-bar-section">
<!-- Left Nav Section -->
<ul class='left tabs' data-options='deep_linking:true' data-tab>
<li><a href='/'>Query</a></li>
<li><a href='/buckets' id='h'>Buckets</a></li>
<li><a href='/functions' id='h'>Functions</a></li>
<ul class="left tabs" data-options="deep_linking:true" data-tab>
<li><a href="/">Query</a></li>
<li><a href="/events">Events</a></li>
<li><a href="/buckets">Buckets</a></li>
<li><a href="/functions">Functions</a></li>
</ul>
</section>
</nav>
<div class='row'>
<div class='large-12 columns'>
<div class="row">
<div class="large-12 columns">
<table>
<thead>
<tr>
<th>Bucket</th>
</tr>
</thead>
<tbody id='buckets'>
<tbody id="buckets">
</tbody>
</table>
</div>
......
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>DalmatinerDB | Events</title>
<link rel="stylesheet" href="/css/foundation.css" />
<script src="/js/vendor/modernizr.js"></script>
<script src="/js/vendor/jquery.js"></script>
<script src="/js/vendor/jquery.cookie.js"></script>
<script src="/js/vendor/fastclick.js"></script>
<script src="/js/foundation.min.js"></script>
<script src="/js/msgpack.base.js"></script>
<script src="/js/msgpack.codec.js"></script>
<script src="/js/msgpack.js"></script>
<script src="/js/event.js"></script>
</head>
<body>
<nav class="top-bar" data-topbar>
<ul class="title-area">
<li class="name">
<h1><a href="#">Dalmatiner DB</a></h1>
</li>
<!-- Remove the class "menu-icon" to get rid of menu icon. Take out "Menu" to just have icon alone -->
<li class="toggle-topbar menu-icon"><a href="#"><span>Menu</span></a></li>
</ul>
<section class="top-bar-section">
<!-- Left Nav Section -->
<ul class="left tabs" data-options="deep_linking:true" data-tab>
<li><a href="/">Query</a></li>
<li><a href="/events">Events</a></li>
<li><a href="/buckets">Buckets</a></li>
<li><a href="/functions">Functions</a></li>
</ul>
</section>
</nav>
<div class="row">
<form id="queryfrom" action="/events" method="get">
<div class="large-2 columns">
<input type="text" id="bucket" name="bucket" value="" placeholder="Bucket"/>
</div>
<div class="large-4 columns">
<input type="text" id="start" name="start" value="" placeholder="Start date"/>
</div>
<div class="large-4 columns">
<input type="text" id="end" name="end" value="" placeholder="End date"/>
</div>
<div class="small-2 columns">
<button type="submit" class="button postfix">Lookup</button>
</div>
</form>
</div>
<div class="row">
<div class="large-12 columns">
<table>
<thead>
<tr>
<th>Date</th>
<th>Event</th>
</tr>
</thead>
<tbody id="events">
</tbody>
</table>
</div>
</div>
</body>
</html>
......@@ -29,6 +29,7 @@
<!-- Left Nav Section -->
<ul class="left tabs" data-options="deep_linking:true" data-tab>
<li><a href="/">Query</a></li>
<li><a href="/events">Events</a></li>
<li><a href="/buckets">Buckets</a></li>
<li><a href="/functions">Functions</a></li>
</ul>
......
......@@ -23,6 +23,7 @@
<!-- Left Nav Section -->
<ul class="left tabs" data-options="deep_linking:true" data-tab>
<li><a href="/">Query</a></li>
<li><a href="/events">Events</a></li>
<li><a href="/buckets">Buckets</a></li>
<li><a href="/functions">Functions</a></li>
</ul>
......@@ -33,7 +34,7 @@
<form id="queryfrom" action="/" method="get">
<div class="row collapse">
<div class="small-10 columns">
<input type="text"id="query" name="query" value="" placeholder="Type your query..."/>
<input type="text" id="query" name="query" value="" placeholder="Type your query..."/>
</div>
<div class="small-2 columns">
<button type="submit" class="button postfix">query</button>
......
$(function() {
msgpack.download(
"", {header: {accept:"application/x-msgpack"}},
function(d) {
console.log(d)
d.forEach(function(e) {
var date = new Date(e.timestamp/1000/1000);
$("#events").append("<tr><td>" + date +
"</td><td>" + JSON.stringify(e.event) + "</td></tr>")
})
})
})
......@@ -29,7 +29,8 @@
<!-- Left Nav Section -->
<ul class="left tabs" data-options="deep_linking:true" data-tab>
<li><a href="/">Query</a></li>
<li><a href="/buckets" id="h">Buckets</a></li>
<li><a href="/events">Events</a></li>
<li><a href="/buckets">Buckets</a></li>
<li><a href="/functions">Functions</a></li>
</ul>
</section>
......
-module(dalmatiner_event_h).
-behaviour(cowboy_http_handler).
-export([init/3, handle/2, terminate/3]).
-ignore_xref([init/3, handle/2, terminate/3]).
init(_Transport, Req, []) ->
{ok, Req, undefined}.
-dialyzer({no_opaque, handle/2}).
handle(Req, State) ->
{ContentType, Req1} = dalmatiner_idx_handler:content_type(Req),
{Bucket, Req2} = cowboy_req:qs_val(<<"bucket">>, Req1),
{StartS, Req3} = cowboy_req:qs_val(<<"start">>, Req2),
{EndS, Req4} = cowboy_req:qs_val(<<"end">>, Req3),
case {ContentType, Bucket, StartS, EndS} of
{html, _, _, _} ->
F = fun (Socket, Transport) ->
File = code:priv_dir(dalmatiner_frontend) ++
"/static/event.html",
Transport:sendfile(Socket, File)
end,
Req5 = cowboy_req:set_resp_body_fun(F, Req4),
{ok, Req6} = cowboy_req:reply(200, Req5),
{ok, Req6, State};
{_, Bucket, _, _}
when Bucket =:= undefined; Bucket =:= <<>> ->
{ok, Req5} = cowboy_req:reply(400, [], "Bad bucket", Req4),
{ok, Req5, State};
{_, _, StartS, _}
when StartS =:= undefined; StartS =:= <<>> ->
{ok, Req5} = cowboy_req:reply(400, [], "Bad start", Req4),
{ok, Req5, State};
{_, _, _, EndS}
when EndS =:= undefined; EndS =:= <<>> ->
{ok, Req5} = cowboy_req:reply(400, [], "Bad end", Req4),
{ok, Req5, State};
_ ->
StartSec = qdate:to_unixtime(StartS),
Start = erlang:convert_time_unit(StartSec, seconds, nano_seconds),
EndSec = qdate:to_unixtime(EndS),
End = erlang:convert_time_unit(EndSec, seconds, nano_seconds),
{ok, Es} = ddb_connection:read_events(Bucket, Start, End),
Es1 = [[{<<"timestamp">>, T}, {<<"event">>, E}] ||
{T, E} <- Es],
dalmatiner_idx_handler:send(ContentType, Es1, Req4, State)
end.
terminate(_Reason, _Req, _State) ->
ok.
......@@ -24,6 +24,8 @@ start(_StartType, _StartArgs) ->
{"/functions", dalmatiner_function_h, []},
{"/events", dalmatiner_event_h, []},
%% New style API
%% List all collections
{"/collections", dalmatiner_collection_h, []},
......
[{<<"cf">>,{pkg,<<"cf">>,<<"0.2.1">>},3},
{<<"cowboy">>,{pkg,<<"cowboy">>,<<"1.0.4">>},0},
{<<"cowlib">>,{pkg,<<"cowlib">>,<<"1.0.2">>},1},
{<<"ddb_client">>,{pkg,<<"ddb_client">>,<<"0.1.28">>},2},
{<<"ddb_connection">>,{pkg,<<"ddb_connection">>,<<"0.1.10">>},1},
{<<"ddb_client">>,{pkg,<<"ddb_client">>,<<"0.1.29">>},2},
{<<"ddb_connection">>,{pkg,<<"ddb_connection">>,<<"0.1.11">>},1},
{<<"dflow">>,{pkg,<<"dflow">>,<<"0.1.5">>},1},
{<<"dproto">>,{pkg,<<"dproto">>,<<"0.1.20">>},1},
{<<"dproto">>,{pkg,<<"dproto">>,<<"0.1.22">>},1},
{<<"dqe">>,
{git,"https://github.com/dalmatinerdb/dqe.git",
{ref,"3755cd8d1b5e741b54924c5cb2e110056f54ea3c"}},
{ref,"d5ce86abb79bd0e9b1833cf37e81700232331ef1"}},
0},
{<<"dqe_fun">>,{pkg,<<"dqe_fun">>,<<"0.1.11">>},1},
{<<"dqe_idx">>,{pkg,<<"dqe_idx">>,<<"0.1.18">>},1},
......@@ -27,7 +27,7 @@
{<<"pgapp">>,{pkg,<<"pgapp">>,<<"0.0.1">>},2},
{<<"poolboy">>,{pkg,<<"poolboy">>,<<"1.5.1">>},2},
{<<"qdate">>,{pkg,<<"qdate">>,<<"0.4.3">>},1},
{<<"quickrand">>,{pkg,<<"quickrand">>,<<"1.5.2-rc1">>},2},
{<<"quickrand">>,{pkg,<<"quickrand">>,<<"1.5.2">>},2},
{<<"ranch">>,{pkg,<<"ranch">>,<<"1.2.1">>},0},
{<<"recon">>,{pkg,<<"recon">>,<<"2.3.2">>},0},
{<<"snappy">>,{pkg,<<"snappy">>,<<"1.1.1">>},3},
......
├─ cowboy─1.0.4
│ └─ cowlib─1.0.2
├─ dalmatiner_frontend─0.2.0
├─ dqe─0.3.15
│ ├─ ddb_connection─0.1.10
│ │ ├─ ddb_client─0.1.28
├─ dqe─0.3.16
│ ├─ ddb_connection─0.1.11
│ │ ├─ ddb_client─0.1.29
│ │ │ └─ snappy─1.1.1
│ │ └─ poolboy─1.5.1
│ ├─ dflow─0.1.5
│ ├─ dproto─0.1.20
│ ├─ dproto─0.1.22
│ ├─ dqe_fun─0.1.11
│ ├─ dqe_idx─0.1.18
│ ├─ dqe_idx_ddb─0.1.14
......@@ -23,7 +23,7 @@
├─ eper─0.94.0
├─ fifo_utils─0.1.22
│ └─ uuid─1.5.1
│ └─ quickrand─1.5.2-rc1
│ └─ quickrand─1.5.2
├─ jsone─1.2.6
├─ lager─3.2.1
│ └─ goldrush─0.1.8
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment