Browse Source

Fix status updating

devel
bashmak 8 years ago
parent
commit
550c541215
  1. 2
      devapp/views.py
  2. 5
      mapapp/templates/maps/ya_index.html
  3. 31
      mapapp/views.py

2
devapp/views.py

@ -591,7 +591,7 @@ def nagios_objects_conf(request):
"}\n"
])
def norm_name(name: str, replreg=re.compile(r'\W+', re.IGNORECASE)):
def norm_name(name: str, replreg=re.compile(r'\W{1,255}', re.IGNORECASE)):
return replreg.sub('', name)
for dev in Device.objects.exclude(devtype='On', ip_address='127.0.0.1').select_related('parent_dev').only('ip_address', 'comment', 'parent_dev'):

5
mapapp/templates/maps/ya_index.html

@ -117,7 +117,7 @@
}
function get_placemark_states(){
$.getJSON("{% url 'mapapp:get_dots' %}", update_placemark_states);
$.getJSON("{% url 'mapapp:get_dots' %}?is_obtain_pk=on", update_placemark_states);
}
/*
@ -132,7 +132,8 @@
if(server_info === undefined)
continue;
var r = get_params_for_placemark(server_info);
placemark.events.remove('click');
placemark.events.remove('click', open_in_new_window);
placemark.events.remove('click', placemark_click);
placemark.events.add('click', r[1]);
placemark.options.set({'iconImageHref': '/static/img/gmarkers/' + r[0]});
}

31
mapapp/views.py

@ -109,14 +109,29 @@ def get_dots(request):
'comment': dev.comment
} if dev is not None else None
res = [{
'devcount': e.devcount,
'latitude': e.latitude,
'longitude': e.longitude,
'title': e.title,
'pk': e.pk,
'device': fill_dev(e.devices.first())
} for e in dots]
is_obtain_pk = request.GET.get('is_obtain_pk')
if is_obtain_pk == 'on':
res = dict()
for e in dots:
res[str(e.pk)] = {
'devcount': e.devcount,
'latitude': e.latitude,
'longitude': e.longitude,
'title': e.title,
'pk': e.pk,
'device': fill_dev(e.devices.first())
}
else:
res = [{
'devcount': e.devcount,
'latitude': e.latitude,
'longitude': e.longitude,
'title': e.title,
'pk': e.pk,
'device': fill_dev(e.devices.first())
} for e in dots]
return res

Loading…
Cancel
Save