Permalink
Browse files

Merge pull request #7 from mythmon/master

  • Loading branch information...
2 parents 6306fe2 + 7b69706 commit 6e9d7e31b92410ac59db32b5af60935875acb9a9 @marineam marineam committed Aug 11, 2011
@@ -28,7 +28,7 @@ def autocomplete(request, context):
"""
query = request.GET.get('term', '')
- limit = int(request.GET.get('limit', 10))
+ limit = int(request.GET.get('limit', 100))
stat, obj = views.parse()
@@ -76,5 +76,6 @@ def autocomplete(request, context):
results = itertools.product(*product_foder)
results = [','.join(result).strip() for result in itertools.islice(results, limit)]
result = [{"value": r} for r in results if r]
+ result.sort(lambda x,y: cmp(len(x['value']), len(y['value'])))
return HttpResponse(json.dumps(result))
@@ -363,6 +363,14 @@ def index(request):
stat, obj = parse()
services = stat['service']
+ hosts = stat['host']
+
+ host_status = {}
+ for h in hosts:
+ host_status[h['host_name']] = h['current_state']
+
+ for s in services:
+ s['host_state'] = host_status[s['host_name']]
context_data = {'services': services}
context_data = add_hostlist(stat, obj, context_data)
@@ -103,9 +103,9 @@
)
INSTALLED_APPS = (
-# 'django.contrib.auth',
'django.contrib.contenttypes',
-# 'django.contrib.sessions',
'django.contrib.sites',
'railroad.parserrd',
+ 'railroad.viewhosts',
+ 'railroad.permalink',
)
@@ -103,11 +103,9 @@
)
INSTALLED_APPS = (
-# 'django.contrib.auth',
'django.contrib.contenttypes',
-# 'django.contrib.sessions',
'django.contrib.sites',
- 'railroad.viewhosts',
'railroad.parserrd',
+ 'railroad.viewhosts',
'railroad.permalink',
)
@@ -463,10 +463,16 @@ fieldset {
}
#quicklook ul ul { list-style: circle; }
#quicklook ul ul ul { list-style: square; }
+#quicklook li {
+ margin: 2px 0;
+}
+
#quicklook .host { cursor: pointer; font-size: 1.1em; }
-#quicklook .status_text { cursor: pointer; font-size: 1.2em; font-weight: bold; }
+#quicklook .status_text {
+ cursor: pointer; font-size: 1.2em; font-weight: bold;
+}
.state_ok { background-color: #BFB !important; }
.state_warning { background-color: #FFB !important; }
.state_critical { background-color: #F64 !important; }
@@ -537,3 +543,9 @@ fieldset {
#pages {
display: none;
}
+
+.ui-autocomplete {
+ max-height: 150px;
+ overflow-y: auto;
+ padding-right: 20px;
+}
@@ -65,7 +65,8 @@ $(document).ready(function() {
// Autocomplete anything with class = "... autocomplete ..."
$('.autocomplete').each(function () {
$(this).autocomplete ( { source : "/railroad/ajax/autocomplete/" +
- $(this).attr('name'), minLength: 1, autoFocus: true})
+ $(this).attr('name'), minLength: 1, autoFocus: true,
+ delay: 30,})
});
//Make it so pressing enter triggers the add graphs button
@@ -105,6 +106,20 @@ $(document).ready(function() {
makeDatetimePicker($('#downtime-from').first());
makeDatetimePicker($('#downtime-to').last());
+
+ var makeDowntimeError = function(err) {
+ $('#downtime-submit')
+ .after('<span id="downtimeError" class="error">{0}</span>'
+ .format(err));
+
+ setTimeout(function() {
+ $('#downtimeError').fadeOut(function() {
+ $('#downtimeError').remove();
+ });
+ }, 5000);
+ console.log(err);
+ }
+
$('#configurator #downtime-submit').bind('click', function() {
$('#downtime-submit').parent().after(
'<img src="/railroad-static/images/loading.gif" ' +
@@ -147,25 +162,26 @@ $(document).ready(function() {
}
if (!expr) {
- console.log('no graphs')
+ makeDowntimeError("No graphs selected.");
+ $('#downtimeLoading').remove();
return;
}
var from = $('#downtime-from').datepicker('getDate');
var to = $('#downtime-to').datepicker('getDate');
- var now = new Date();
- if (!(from && to) || from < now || to < now) {
- $('#downtimeLoading').after('<span id="downtimeError"' +
- 'class="error">You must enter a future date.</span>');
+ var about_now = new Date().add({minutes: 5});
+ if (from < about_now) {
+ from = about_now;
+ }
+ if (!(from && to)) {
+ makeDowntimeError("Invalid dates!");
+ $('#downtimeLoading').remove();
+ return;
+ }
+ if (to < about_now) {
+ makeDowntimeError("Can't schedule downtimes in the past.");
$('#downtimeLoading').remove();
-
- setTimeout(function() {
- $('#downtimeError').fadeOut(function() {
- $('#downtimeError').remove();
- });
- }, 5000);
- console.log('invalid dates');
return;
}
@@ -204,9 +220,7 @@ $(document).ready(function() {
$('#downtimeLoading').remove();
},
error: function () {
- console.log('error');
- $('#downtimeLoading').after(
- '<span class="error">There was an error.</span>');
+ makeDowntimeError("There was an error.");
$('#downtimeLoading').remove();
}
});
@@ -38,7 +38,9 @@
{% for host in hosts_in_state %}
<li>
<span class="host">
- {{ host.grouper }} -
+ <span class="state_{{host.list.0.host_state|state_name|lower}}">
+ {{ host.grouper }}
+ </span> -
{{host.list|length}} service{{state.list|length|pluralize}}
</span>
<a href="/railroad/configurator/host/{{host.grouper}}">

0 comments on commit 6e9d7e3

Please sign in to comment.