diff --git a/web/api/views.py b/web/api/views.py index 47b1eff1..abe5dbc5 100644 --- a/web/api/views.py +++ b/web/api/views.py @@ -1115,6 +1115,9 @@ class ListScanHistory(APIView): def get(self, request, format=None): req = self.request scan_history = ScanHistory.objects.all().order_by('-start_scan_date') + project = req.query_params.get('project') + if project: + scan_history = scan_history.filter(domain__project__slug=project) scan_history = ScanHistorySerializer(scan_history, many=True) return Response(scan_history.data) diff --git a/web/recon_note/static/note/js/todo.js b/web/recon_note/static/note/js/todo.js index c3ccbad3..86c05f1b 100644 --- a/web/recon_note/static/note/js/todo.js +++ b/web/recon_note/static/note/js/todo.js @@ -1,5 +1,5 @@ -function populateTodofunction(){ +function populateTodofunction(project=null){ $('.input-search').on('keyup', function() { var rex = new RegExp($(this).val(), 'i'); $('.todo-box .todo-item').hide(); @@ -41,7 +41,7 @@ function populateTodofunction(){ suppressScrollX : true }); - populateScanHistory(); + populateScanHistory(project=project); }); const ps = new PerfectScrollbar('.todo-box-scroll', { @@ -371,11 +371,11 @@ function todoItem() { }); } -function populateScanHistory() { +function populateScanHistory(project) { scan_history_select = document.getElementById('scanHistoryIDropdown'); - $.getJSON(`/api/listScanHistory?format=json`, function(data) { - for (var history in data['scan_histories']){ - history_object = data['scan_histories'][history]; + $.getJSON(`/api/listScanHistory/?format=json&project=${project}`, function(data) { + for (var history in data){ + history_object = data[history]; var option = document.createElement('option'); option.value = history_object['id']; option.innerHTML = history_object['domain']['name'] + ' - Scanned ' + moment.utc(history_object['start_scan_date']).fromNow(); diff --git a/web/recon_note/templates/note/index.html b/web/recon_note/templates/note/index.html index 74c5d83b..9194c0cb 100644 --- a/web/recon_note/templates/note/index.html +++ b/web/recon_note/templates/note/index.html @@ -123,7 +123,7 @@ $('#subdomainDropdown').select2({ $('#scanHistoryIDropdown').on('change', function() { $('#subdomainDropdown').find('option:not(:first)').remove(); subdomain_dropdown = document.getElementById('subdomainDropdown'); - $.getJSON(`/api/querySubdomains?scan_id=${this.value}&no_lookup_interesting&format=json`, function(data) { + $.getJSON(`/api/querySubdomains?project={{request.resolver_match.kwargs.slug}}&scan_id=${this.value}&no_lookup_interesting&format=json`, function(data) { document.querySelector("#selectedSubdomainCount").innerHTML = data['subdomains'].length + ' Subdomains in selected history for domain ' + $("#scanHistoryIDropdown option:selected").text().split('-')[0]; for (var subdomain in data['subdomains']){ subdomain_obj = data['subdomains'][subdomain]; @@ -193,7 +193,7 @@ $.getJSON(`/api/listTodoNotes?format=json&project={{request.resolver_match.kwarg todo_item.classList.add("todo-task-important"); } }; - populateTodofunction(); + populateTodofunction(project='{{request.resolver_match.kwargs.slug}}'); $('.bs-tooltip').tooltip(); }); diff --git a/web/static/custom/right_sidebar.js b/web/static/custom/right_sidebar.js index 582c89a7..fbf1de6d 100644 --- a/web/static/custom/right_sidebar.js +++ b/web/static/custom/right_sidebar.js @@ -1,5 +1,5 @@ function getScanStatusSidebar(reload) { - $.getJSON('/api/scan_status', function(data) { + $.getJSON('/api/scan_status/', function(data) { // main scans $('#currently_scanning').empty(); $('#completed').empty();