@@ -742,5 +677,48 @@ var vuln_chart_options = {
var chart = new ApexCharts(document.querySelector("#vuln_chart"), vuln_chart_options);
chart.render();
+var scan_chart_options = {
+ chart: {
+ id: 'sparkline1',
+ type: 'area',
+ height: 80,
+ sparkline: {
+ enabled: true
+ },
+ },
+ stroke: {
+ curve: 'smooth',
+ width: 2,
+ },
+ series: [{
+ name: 'Scans Initiated',
+ data: [{{scans_in_last_week.0}},{{scans_in_last_week.1}},{{scans_in_last_week.2}},{{scans_in_last_week.3}},{{scans_in_last_week.4}},{{scans_in_last_week.5}},{{scans_in_last_week.6}}]
+ }],
+ labels: ['1', '2', '3', '4', '5', '6', '7'],
+ yaxis: {
+ min: 0
+ },
+ colors: ['#8dbf42'],
+ tooltip: {
+ x: {
+ show: false,
+ }
+ },
+ fill: {
+ type:"gradient",
+ gradient: {
+ type: "vertical",
+ shadeIntensity: 1,
+ inverseColors: !1,
+ opacityFrom: .40,
+ opacityTo: .05,
+ stops: [45, 100]
+ }
+ },
+}
+
+var chart = new ApexCharts(document.querySelector("#scan_chart"), scan_chart_options);
+chart.render();
+
{% endblock page_level_script %}
diff --git a/dashboard/views.py b/dashboard/views.py
index 275033ef..c2c98b82 100644
--- a/dashboard/views.py
+++ b/dashboard/views.py
@@ -64,6 +64,10 @@ def index(request):
discovered_date__gte=last_week).annotate(
date=TruncDay('discovered_date')).values("date").annotate(
count=Count('id')).order_by("-date")
+ count_scans_by_date = ScanHistory.objects.filter(
+ last_scan_date__gte=last_week).annotate(
+ date=TruncDay('last_scan_date')).values("date").annotate(
+ count=Count('id')).order_by("-date")
last_7_dates = [(timezone.now() - timedelta(days=i)).date() for i in range(0, 7)]
@@ -94,6 +98,15 @@ def index(request):
vulns_in_last_week.append(0)
vulns_in_last_week.reverse()
+ scans_in_last_week = []
+ for date in last_7_dates:
+ _scan = count_scans_by_date.filter(date=date)
+ if _scan:
+ scans_in_last_week.append(_scan[0]['count'])
+ else:
+ scans_in_last_week.append(0)
+ scans_in_last_week.reverse()
+
context = {
'dashboard_data_active': 'true',
'domain_count': domain_count,
@@ -118,6 +131,7 @@ def index(request):
'targets_in_last_week': targets_in_last_week,
'subdomains_in_last_week': subdomains_in_last_week,
'vulns_in_last_week': vulns_in_last_week,
+ 'scans_in_last_week': scans_in_last_week,
}
return render(request, 'dashboard/index.html', context)