from api import view_api_get_results
from alert_rule_enginelib import ae_manager
from django.shortcuts import render
from django.shortcuts import redirect
from django.http import HttpResponseRedirect, HttpResponse
import json
from alert_rule_enginelib import ae_manager
from django.contrib.auth.decorators import login_required
# from django.urls import reverse

def view_filtter_result(request):
	results = ae_manager.get_results(task=True)
	context = {
		'tasks': results
	}

	return render(request, 'filtered_result.html', context)

@login_required
def view_get_rules(request):
	context = {}
	try:
		rules = ae_manager.get_rules()
	except Exception as err:
		context['error'] = err
	context['rules'] = rules
	#return HttpResponse(context['rules'])
	return render(request, 'rules.html', context)
