Skip to content

Commit

Permalink
Merge pull request #1697 from swaterkamp/ReportDetailsPerformance8
Browse files Browse the repository at this point in the history
Load "small" before "full" report
  • Loading branch information
bjoernricks authored Oct 16, 2019
2 parents 733bc11 + 2219310 commit 4397958
Showing 10 changed files with 256 additions and 38 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
[#1507](https://github.com/greenbone/gsa/pull/1507)

### Changed
- Load "small" report before full report [#1697](https://github.com/greenbone/gsa/pull/1697)
- Removed Clone and Verify functionalities for report formats [#1650](https://github.com/greenbone/gsa/pull/1650)
- Use new [React context API](https://reactjs.org/docs/context.html#api) [#1637](https://github.com/greenbone/gsa/pull/1637)
- Update response data parsing in Model classes
3 changes: 2 additions & 1 deletion gsa/src/gmp/commands/reports.js
Original file line number Diff line number Diff line change
@@ -137,11 +137,12 @@ class ReportCommand extends EntityCommand {
).then(this.transformResponse);
}

get({id}, {filter, ...options} = {}) {
get({id}, {filter, details, ...options} = {}) {
return this.httpGet(
{
id,
filter,
details,
ignore_pagination: 1,
},
{...options, transform: FastXmlTransform},
22 changes: 11 additions & 11 deletions gsa/src/web/pages/reports/detailscontent.js
Original file line number Diff line number Diff line change
@@ -285,16 +285,16 @@ const PageContent = ({
const userTagsCount = userTags.length;

const {
applications,
closed_cves,
cves,
errors,
hosts,
operatingsystems,
ports,
results,
applications = {},
closed_cves = {},
cves = {},
errors = {},
hosts = {},
operatingsystems = {},
ports = {},
results = {},
result_count = {},
tls_certificates,
tls_certificates = {},
timestamp,
scan_run_status,
} = report;
@@ -457,7 +457,7 @@ const PageContent = ({
</Tab>
</TabList>
</TabLayout>
{isDefined(results) ? (
{isDefined(report) ? (
<Tabs active={activeTab}>
<TabPanels>
<TabPanel>
@@ -469,7 +469,7 @@ const PageContent = ({
</TabPanel>
<TabPanel>
<ResultsTab
counts={results.counts}
counts={isDefined(results.counts) ? results.counts : {}}
delta={delta}
filter={filter}
hasTarget={!isContainer}
26 changes: 16 additions & 10 deletions gsa/src/web/pages/reports/detailspage.js
Original file line number Diff line number Diff line change
@@ -54,7 +54,8 @@ import {
import {
loadDeltaReport,
deltaSelector,
loadEntity as loadReport,
loadEntity as loadReportEntityWithStore,
loadEntityIfNeeded as loadReportEntityWithStoreIfNeeded,
selector as reportSelector,
} from 'web/store/entities/reports';

@@ -111,7 +112,7 @@ class ReportDetails extends React.Component {
super(...args);

this.state = {
activeTab: 1,
activeTab: 0,
showFilterDialog: false,
showDownloadReportDialog: false,
sorting: {
@@ -268,9 +269,11 @@ class ReportDetails extends React.Component {
lastFilter: filter,
}));

this.props.loadReport(reportId, deltaReportId, filter).then(() => {
this.startTimer();
this.setState({isUpdating: false});
this.props.loadReportIfNeeded(reportId, deltaReportId, filter).then(() => {
this.props.loadReport(reportId, deltaReportId, filter).then(() => {
this.startTimer();
this.setState({isUpdating: false});
});
});
}

@@ -682,6 +685,7 @@ ReportDetails.propTypes = {
loadReport: PropTypes.func.isRequired,
loadReportComposerDefaults: PropTypes.func.isRequired,
loadReportFormats: PropTypes.func.isRequired,
loadReportIfNeeded: PropTypes.func.isRequired,
loadSettings: PropTypes.func.isRequired,
loadTarget: PropTypes.func.isRequired,
location: PropTypes.object.isRequired,
@@ -710,11 +714,13 @@ const mapDispatchToProps = (dispatch, {gmp}) => {
loadReportFormats: () =>
dispatch(loadReportFormats(gmp)(REPORT_FORMATS_FILTER)),
loadReport: (id, deltaId, filter) =>
dispatch(
isDefined(deltaId)
? loadDeltaReport(gmp)(id, deltaId, filter)
: loadReport(gmp)(id, filter),
),
isDefined(deltaId)
? dispatch(loadDeltaReport(gmp)(id, deltaId, filter))
: dispatch(loadReportEntityWithStore(gmp)(id, filter)),
loadReportIfNeeded: (id, deltaId, filter) =>
isDefined(deltaId)
? dispatch(loadDeltaReport(gmp)(id, deltaId, filter))
: dispatch(loadReportEntityWithStoreIfNeeded(gmp)(id, filter)),
loadReportComposerDefaults: () =>
dispatch(loadReportComposerDefaults(gmp)()),
saveReportComposerDefaults: reportComposerDefaults =>
8 changes: 5 additions & 3 deletions gsa/src/web/pages/reports/reportentitiescontainer.js
Original file line number Diff line number Diff line change
@@ -22,6 +22,8 @@ import {isDefined} from 'gmp/utils/identity';

import PropTypes from 'web/utils/proptypes';

import Loading from 'web/components/loading/loading';

import SortBy from 'web/components/sortby/sortby';

const sortEntities = ({
@@ -144,7 +146,7 @@ class ReportEntitiesContainer extends React.Component {
const {page} = this.state;

if (!isDefined(children) || !isDefined(entities)) {
return null;
return <Loading />;
}

const sortedEntities = sortEntities({
@@ -181,8 +183,8 @@ class ReportEntitiesContainer extends React.Component {

ReportEntitiesContainer.propTypes = {
children: PropTypes.func,
counts: PropTypes.counts.isRequired,
entities: PropTypes.array.isRequired,
counts: PropTypes.oneOfType([PropTypes.counts, PropTypes.object]).isRequired,
entities: PropTypes.array,
filter: PropTypes.filter,
sortField: PropTypes.string.isRequired,
sortFunctions: PropTypes.object,
14 changes: 7 additions & 7 deletions gsa/src/web/pages/reports/resultstab.js
Original file line number Diff line number Diff line change
@@ -19,13 +19,13 @@

import React from 'react';

import PropTypes from '../../utils/proptypes.js';
import PropTypes from 'web/utils/proptypes';

import ResultsTable from '../results/table.js';
import ResultsTable from 'web/pages/results/table';

import EmptyReport from './emptyreport.js';
import EmptyResultsReport from './emptyresultsreport.js';
import ReportEntitiesContainer from './reportentitiescontainer.js';
import EmptyReport from './emptyreport';
import EmptyResultsReport from './emptyresultsreport';
import ReportEntitiesContainer from './reportentitiescontainer';

import {resultsSortFunctions} from './sort.js';

@@ -116,13 +116,13 @@ const ResultsTab = ({
};

ResultsTab.propTypes = {
counts: PropTypes.counts.isRequired,
counts: PropTypes.oneOfType([PropTypes.counts, PropTypes.object]).isRequired,
delta: PropTypes.bool,
filter: PropTypes.filter.isRequired,
hasTarget: PropTypes.bool,
isUpdating: PropTypes.bool,
progress: PropTypes.number.isRequired,
results: PropTypes.array.isRequired,
results: PropTypes.array,
sortField: PropTypes.string.isRequired,
sortReverse: PropTypes.bool.isRequired,
status: PropTypes.string.isRequired,
6 changes: 4 additions & 2 deletions gsa/src/web/pages/reports/scaninfo.js
Original file line number Diff line number Diff line change
@@ -88,7 +88,7 @@ const ReportScanInfoTable = ({filterString, links = true, report}) => {
const hosts_count =
isDefined(hosts) && isDefined(hosts.counts) ? hosts.counts.all : 0;

if (!isDefined(filterString)) {
if (isDefined(filter) && !isDefined(filterString)) {
filterString = filter.simple().toFilterString();
}

@@ -97,7 +97,9 @@ const ReportScanInfoTable = ({filterString, links = true, report}) => {
? _('Container')
: scan_run_status;

const delta = report.isDeltaReport();
const delta = isDefined(report.isDeltaReport)
? report.isDeltaReport()
: false;

const is_ended = isDefined(scan_end) && scan_end.isValid();
return (
Loading

0 comments on commit 4397958

Please sign in to comment.