def item(request): """监控项视图""" application_id = request.GET.get('applicationid') if application_id: application_id = int(application_id) else: application_id = 0 application_obj_list = models.Application.objects.all() application_obj = models.Application.objects.filter( id=application_id).first() current_page = request.GET.get("p", 1) current_page = int(current_page) if application_obj: item_obj_list = application_obj.items.all() item_obj_count = item_obj_list.count() page_obj = Page(current_page, item_obj_count) item_obj_list = item_obj_list[page_obj.start:page_obj.end] page_str = page_obj.pager(base_url='item.html', application_id=application_id) else: item_obj_list = models.Item.objects.all() item_obj_count = item_obj_list.count() page_obj = Page(current_page, item_obj_count) item_obj_list = item_obj_list[page_obj.start:page_obj.end] page_str = page_obj.pager(base_url='item.html', application_id=application_id) return render( request, 'item.html', { 'item_obj_list': item_obj_list, 'page_str': page_str, 'application_obj_list': application_obj_list, 'application_id': application_id })
def application(request): """应用集视图""" template_id = request.GET.get('templateid') if template_id: template_id = int(template_id) else: template_id = 0 template_obj_list = models.Template.objects.all() template_obj = models.Template.objects.filter(id=template_id).first() current_page = request.GET.get("p", 1) current_page = int(current_page) if template_obj: application_obj_list = template_obj.applications.all() application_obj_count = application_obj_list.count() page_obj = Page(current_page, application_obj_count) application_obj_list = application_obj_list[page_obj.start:page_obj.end] page_str = page_obj.pager(base_url='application.html', template_id=template_id) else: application_obj_list = models.Application.objects.all() application_obj_count = application_obj_list.count() page_obj = Page(current_page, application_obj_count) application_obj_list = application_obj_list[page_obj.start:page_obj.end] page_str = page_obj.pager(base_url='application.html', template_id=template_id) return render(request, 'application.html', {'application_obj_list': application_obj_list, 'page_str': page_str, 'template_obj_list': template_obj_list, 'template_id': template_id})
def host(request): """主机视图""" host_group_id = request.GET.get('groupid') if host_group_id: host_group_id = int(host_group_id) else: host_group_id = 0 host_group_obj_list = models.HostGroup.objects.all() host_group_obj = models.HostGroup.objects.filter(id=host_group_id).first() current_page = request.GET.get("p", 1) current_page = int(current_page) if host_group_obj: host_obj_list = host_group_obj.host_set.all() host_obj_count = host_obj_list.count() page_obj = Page(current_page, host_obj_count) host_obj_list = host_obj_list[page_obj.start:page_obj.end] page_str = page_obj.pager(base_url='host.html', host_group_id=host_group_id) else: # 没找到相关主机组 host_obj_list = models.Host.objects.all() host_obj_count = host_obj_list.count() page_obj = Page(current_page, host_obj_count) host_obj_list = host_obj_list[page_obj.start:page_obj.end] page_str = page_obj.pager(base_url='host.html', host_group_id=host_group_id) return render( request, 'host.html', { 'host_obj_list': host_obj_list, 'page_str': page_str, 'host_group_obj_list': host_group_obj_list, 'host_group_id': host_group_id })
def template(request): """模板视图""" host_group_id = request.GET.get('groupid') if host_group_id: host_group_id = int(host_group_id) else: host_group_id = 0 host_group_obj_list = models.HostGroup.objects.all() host_group_obj = models.HostGroup.objects.filter(id=host_group_id).first() current_page = request.GET.get("p", 1) current_page = int(current_page) if host_group_obj: template_obj_list = host_group_obj.templates.all() template_obj_count = template_obj_list.count() page_obj = Page(current_page, template_obj_count) template_obj_list = template_obj_list[page_obj.start:page_obj.end] page_str = page_obj.pager(base_url='template.html', host_group_id=host_group_id) else: template_obj_list = models.Template.objects.all() template_obj_count = template_obj_list.count() page_obj = Page(current_page, template_obj_count) template_obj_list = template_obj_list[page_obj.start:page_obj.end] page_str = page_obj.pager(base_url='template.html', host_group_id=host_group_id) return render( request, 'template.html', { 'template_obj_list': template_obj_list, 'page_str': page_str, 'host_group_obj_list': host_group_obj_list, 'host_group_id': host_group_id })
def trigger(request): """触发器视图""" template_id = request.GET.get('templateid') if template_id: template_id = int(template_id) else: template_id = 0 template_obj_list = models.Template.objects.all() template_obj = models.Template.objects.filter(id=template_id).first() current_page = request.GET.get("p", 1) current_page = int(current_page) if template_obj: trigger_obj_list = template_obj.trigger_set.all() trigger_obj_count = trigger_obj_list.count() page_obj = Page(current_page, trigger_obj_count) trigger_obj_list = trigger_obj_list[page_obj.start:page_obj.end] page_str = page_obj.pager(base_url='trigger.html', template_id=template_id) else: trigger_obj_list = models.Trigger.objects.all() trigger_obj_count = trigger_obj_list.count() page_obj = Page(current_page, trigger_obj_count) trigger_obj_list = trigger_obj_list[page_obj.start:page_obj.end] page_str = page_obj.pager(base_url='trigger.html', template_id=template_id) return render( request, 'trigger.html', { 'trigger_obj_list': trigger_obj_list, 'page_str': page_str, 'template_obj_list': template_obj_list, 'template_id': template_id })
def chart(request): """图表视图""" current_page = request.GET.get("p", 1) current_page = int(current_page) chart_obj_list = models.Chart.objects.all() chart_obj_count = chart_obj_list.count() page_obj = Page(current_page, chart_obj_count) chart_obj_list = chart_obj_list[page_obj.start:page_obj.end] page_str = page_obj.pager('chart.html') return render(request, 'chart.html', {'chart_obj_list': chart_obj_list, 'page_str': page_str})
def host_group(request): """主机组视图""" current_page = request.GET.get("p", 1) current_page = int(current_page) host_group_obj_list = models.HostGroup.objects.all() host_group_obj_count = host_group_obj_list.count() page_obj = Page(current_page, host_group_obj_count) host_group_obj_list = host_group_obj_list[page_obj.start:page_obj.end] page_str = page_obj.pager('host_group.html') return render(request, 'host_group.html', { 'host_group_obj_list': host_group_obj_list, 'page_str': page_str })
def user(request): """用户视图""" current_page = request.GET.get("p", 1) current_page = int(current_page) user_obj_list = models.UserProfile.objects.all() user_obj_count = user_obj_list.count() page_obj = Page(current_page, user_obj_count) user_obj_list = user_obj_list[page_obj.start:page_obj.end] page_str = page_obj.pager('user.html') return render(request, 'user.html', { 'user_obj_list': user_obj_list, 'page_str': page_str })
def action(request): """报警策略视图""" current_page = request.GET.get("p", 1) current_page = int(current_page) action_obj_list = models.Action.objects.all() action_obj_count = action_obj_list.count() page_obj = Page(current_page, action_obj_count) action_obj_list = action_obj_list[page_obj.start:page_obj.end] page_str = page_obj.pager('action.html') return render(request, 'action.html', { 'action_obj_list': action_obj_list, 'page_str': page_str })