Commit 498cae01 authored by ale's avatar ale

various changes to get the UI to work

parent aab97dfa
......@@ -198,7 +198,8 @@ class LogStore(object):
return search
def search(self, query_str, time_range, size=100, start=0):
log.info('search: "%s"', query_str)
log.info('search: "%s", range=%s, start=%d',
query_str, time_range, start)
search = self._make_search(query_str, time_range,
start=start, size=size)
results = self.conn.search(search,
......
#searchForm input {
font-size: 16px;
}
pre {
word-wrap: break-word;
}
.log:hover {
background-color: #eef;
}
.ts {
.timestamp {
color: #666;
}
.host {
font-weight: bold;
}
a.attr {
color: blue;
text-decoration: none;
}
a.attr:hover {
text-decoration: underline;
}
a.lf {
color: #009;
}
a.lf:hover {
text-decoration: underline;
}
#resultDiv {
#log_pagination_div {
font-size: 85%;
padding-bottom: 3px;
}
#resultInfo {
padding-left: 30px;
padding-right: 30px;
}
#resultDiv a {
color: blue;
#log_pagination_prev {
cursor: pointer;
}
#log_pagination_next {
cursor: pointer;
}
#logsDiv {
#log_viewer {
border-top: 1px solid #666;
padding-top: 3px;
font-family: 'Ubuntu Mono', monospace;
word-wrap: break-word;
}
#log_viewer a {
color: #09f;
text-decoration: none;
padding-left: 1px;
padding-right: 1px;
}
#log_viewer a:hover {
background-color: #009;
color: white;
-moz-border-radius: 7px;
-webkit-border-radius: 7px;
}
#header {
padding-right: 40px;
background: url(/static/rstar32.gif) no-repeat top right;
}
#serverError {
#error {
display: block;
color: red;
}
This diff is collapsed.
......@@ -5,6 +5,7 @@
<title>A/I Log Search</title>
<link href="/static/favicon.ico" type="image/x-icon" rel="shortcut icon">
<link rel="stylesheet" type="text/css" href="/static/lens2.css">
<link href="//fonts.googleapis.com/css?family=Ubuntu+Mono" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/static/strftime.min.js"></script>
<script type="text/javascript" src="/static/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="/static/jquery.tmpl.min.js"></script>
......@@ -16,10 +17,10 @@ var lens_instance;
$(document).ready(function() {
lens_instance = new lens.Lens();
$('#queryField').focus();
$('#query_field').focus();
$('#searchForm').submit(
function() {
lens_instance.search($('#queryField').val());
lens_instance.search($('#query_field').val());
return false;
});
......@@ -31,7 +32,7 @@ $(document).ready(function() {
<div id="header">
<div id="searchDiv">
<form id="searchForm" action="/search" method="post">
<input type="text" id="queryField" name="q" size="60" value="{{ query or '' | e }}">
<input type="text" id="query_field" name="q" size="90" value="{{ query or '' | e }}">
<input type="submit" value="Search">
<span id="loading" style="display:none;">
<img src="/static/spinner.gif" border="0">
......@@ -39,16 +40,16 @@ $(document).ready(function() {
<span id="error" style="display:none;"></span>
</form>
</div>
<div id="resultDiv">
<div id="log_pagination_div">
<!-- Note that the time-based navigation logic is reversed,
since we retrieve results in timestamp-descending order. -->
<span id="log_pagination_prev" style="display:none;">
<a id="log_pagination_prev" style="display:none;">
&lt;-- Previous
</span>
</a>
<span id="log_pagination_title"></span>
<span id="log_pagination_next" style="display:none;">
<a id="log_pagination_next" style="display:none;">
Next --&gt;
</span>
</a>
</div>
</div>
......@@ -57,14 +58,20 @@ $(document).ready(function() {
{% raw %}
<div id="log_template" style="display:none;">
<div id="log">
<div class="log">
<span class="timestamp">${lens.util.timestampToString(log.timestamp)}</span>
<span class="host">${log.host}</span>
<span class="facility">${log.facility}</span>.<span class="severity"
>${log.severity}</span>
<a class="host">${log.host}</a>
<a class="program">${log.program}</a>{{if log.pid}}[<a class="pid">${log.pid}</a>]{{/if}}
{{if log.facility}}<a class="facility">${log.facility}</a>.<span class="severity"
>${log.severity}</span>{{/if}}
<span class="msg">{{html lens.util.replaceAttrsInMsg(log)}}</span>
</div>
</div>
<div id="error_template" style="display:none;">
ERROR: ${error}<br>
<span class="error_detail">${errorThrown}</span>
</div>
{% endraw %}
</body>
......
......@@ -33,7 +33,10 @@ def parse_timespec(s):
spec = int(m.group(1))
if m.group(2):
spec *= sfx_to_sec[m.group(2)]
return _now() - timedelta(0, spec)
return _now() - timedelta(0, spec)
else:
spec /= 1000000.0
return datetime.utcfromtimestamp(spec)
def parse_datespec(s):
......
......@@ -19,9 +19,12 @@ def api_search():
log.exception('search not parsed')
abort(400)
results, total = current_app.logstore.search(
query, time_range, start=start, size=page_size)
return jsonify(results=results, total=total)
try:
results, total = current_app.logstore.search(
query, time_range, start=start, size=page_size)
return jsonify(results=results, total_results=total)
except Exception, e:
return jsonify(error=str(e))
@api_app.route('/status')
......
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