Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.0] Reload on inactive tabs #1761

Merged
merged 7 commits into from
Nov 7, 2019
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
- Consider visibility status of page for calculating the reload interval [#1761](https://github.com/greenbone/gsa/pull/1761)
- Do not simplify filterString in content composer for report download [#1733](https://github.com/greenbone/gsa/pull/1733)
- Use single component for reloading data [#1722](https://github.com/greenbone/gsa/pull/1722)
- Use last chars of a label string in BarChart [#1713](https://github.com/greenbone/gsa/pull/1713)
Expand Down
24 changes: 24 additions & 0 deletions gsa/src/gmp/__tests__/gmpsettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import GmpSettings, {
DEFAULT_RELOAD_INTERVAL,
DEFAULT_PROTOCOLDOC_URL,
DEFAULT_LOG_LEVEL,
DEFAULT_RELOAD_INTERVAL_ACTIVE,
DEFAULT_RELOAD_INTERVAL_INACTIVE,
} from 'gmp/gmpsettings';

const createStorage = state => {
Expand Down Expand Up @@ -48,6 +50,12 @@ describe('GmpSettings tests', () => {
expect(settings.protocol).toEqual('http:');
expect(settings.protocoldocurl).toEqual(DEFAULT_PROTOCOLDOC_URL);
expect(settings.reloadInterval).toEqual(DEFAULT_RELOAD_INTERVAL);
expect(settings.reloadIntervalActive).toEqual(
DEFAULT_RELOAD_INTERVAL_ACTIVE,
);
expect(settings.reloadIntervalInactive).toEqual(
DEFAULT_RELOAD_INTERVAL_INACTIVE,
);
expect(settings.server).toEqual('localhost');
expect(settings.token).toBeUndefined();
expect(settings.timeout).toBeUndefined();
Expand Down Expand Up @@ -76,6 +84,8 @@ describe('GmpSettings tests', () => {
protocol: 'http',
protocoldocurl: 'http://protocol',
reloadInterval: 10,
reloadIntervalActive: 5,
reloadIntervalInactive: 60,
server: 'localhost',
token: 'atoken',
timeout: 30000,
Expand All @@ -96,6 +106,8 @@ describe('GmpSettings tests', () => {
expect(settings.protocol).toEqual('http');
expect(settings.protocoldocurl).toEqual('http://protocol');
expect(settings.reloadInterval).toEqual(10);
expect(settings.reloadIntervalActive).toEqual(5);
expect(settings.reloadIntervalInactive).toEqual(60);
expect(settings.server).toEqual('localhost');
expect(settings.token).toBeUndefined();
expect(settings.timeout).toEqual(30000);
Expand Down Expand Up @@ -138,6 +150,12 @@ describe('GmpSettings tests', () => {
expect(settings.protocol).toEqual('http');
expect(settings.protocoldocurl).toEqual(DEFAULT_PROTOCOLDOC_URL);
expect(settings.reloadInterval).toEqual(DEFAULT_RELOAD_INTERVAL);
expect(settings.reloadIntervalActive).toEqual(
DEFAULT_RELOAD_INTERVAL_ACTIVE,
);
expect(settings.reloadIntervalInactive).toEqual(
DEFAULT_RELOAD_INTERVAL_INACTIVE,
);
expect(settings.server).toEqual('foo');
expect(settings.token).toEqual('atoken');
expect(settings.timeout).toBeUndefined();
Expand All @@ -158,6 +176,8 @@ describe('GmpSettings tests', () => {
protocol: 'https',
protocoldocurl: 'http://lorem',
reloadInterval: 20,
reloadIntervalActive: 20,
reloadIntervalInactive: 20,
server: 'foo.bar',
token: 'btoken',
timeout: 10000,
Expand All @@ -176,6 +196,8 @@ describe('GmpSettings tests', () => {
protocol: 'http',
protocoldocurl: 'http://protocol',
reloadInterval: 10,
reloadIntervalActive: 5,
reloadIntervalInactive: 60,
server: 'localhost',
token: 'atoken',
timeout: 30000,
Expand All @@ -193,6 +215,8 @@ describe('GmpSettings tests', () => {
expect(settings.protocol).toEqual('http');
expect(settings.protocoldocurl).toEqual('http://protocol');
expect(settings.reloadInterval).toEqual(10);
expect(settings.reloadIntervalActive).toEqual(5);
expect(settings.reloadIntervalInactive).toEqual(60);
expect(settings.server).toEqual('localhost');
expect(settings.token).toEqual('btoken');
expect(settings.timeout).toEqual(30000);
Expand Down
6 changes: 6 additions & 0 deletions gsa/src/gmp/gmpsettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import {isDefined} from './utils/identity';

export const DEFAULT_RELOAD_INTERVAL = 15 * 1000; // fifteen seconds
export const DEFAULT_RELOAD_INTERVAL_ACTIVE = 3 * 1000; // three seconds
export const DEFAULT_RELOAD_INTERVAL_INACTIVE = 60 * 1000; // one minute
export const DEFAULT_MANUAL_URL = 'http://docs.greenbone.net/GSM-Manual/gos-5/';
export const DEFAULT_PROTOCOLDOC_URL =
'https://docs.greenbone.net/API/GMP/gmp-8.0.html';
Expand Down Expand Up @@ -52,6 +54,8 @@ class GmpSettings {
protocol = global.location.protocol,
protocoldocurl = DEFAULT_PROTOCOLDOC_URL,
reloadInterval = DEFAULT_RELOAD_INTERVAL,
reloadIntervalActive = DEFAULT_RELOAD_INTERVAL_ACTIVE,
reloadIntervalInactive = DEFAULT_RELOAD_INTERVAL_INACTIVE,
server = global.location.host,
timeout,
vendorVersion,
Expand All @@ -65,6 +69,8 @@ class GmpSettings {

this.loglevel = isDefined(loglevel) ? loglevel : DEFAULT_LOG_LEVEL;
this.reloadInterval = reloadInterval;
this.reloadIntervalActive = reloadIntervalActive;
this.reloadIntervalInactive = reloadIntervalInactive;
this.timeout = timeout;

setAndFreeze(this, 'disableLoginForm', disableLoginForm);
Expand Down
Loading