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

Add ability to configure <title> #4368

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ instantiated once for the [GSA application](./src/web/app.js#L53)
| [timeout](#timeout) | Integer | [300000; // 5 minutes](./src/gmp/gmpsettings.js#L28) | x | - |
| [vendorVersion](#vendorversion) | String | undefined | - | x |
| [vendorLabel](#vendorlabel) | String | undefined | - | x |

| [title](#title) | String | Greenbone Security Assistant | x | x |
#### vendorVersion

Allows to adjust the shown product version string at the Login and About pages.
Expand All @@ -259,6 +259,10 @@ Allows to adjust the product info image at the Login page. It must be a relative
path e.g. `foo.png`. The path will be mapped to `$INSTALL_PREFIX/share/gvm/gsad/web/img/`
on production (with [gsad]) and `gsa/public/img` for the [development server](#developing).

#### title

Allows to adjust the HTML title, i.e. the text shown in browser tabs which have GSA open.

#### guestUsername and guestPassword

Both settings allow to login with a single click. This user has to be set up
Expand Down
8 changes: 4 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
window.addEventListener('DOMContentLoaded', () => {
try {
const vendorLabel = config.vendorLabel;
const title = config.title

const match = vendorLabel.match(/gsm-(\w+)_label\.svg/);
const match = vendorLabel?.match(/gsm-(\w+)_label\.svg/);
if (match) {
let labelPart = match[1];
if (isNaN(labelPart)) {
labelPart = labelPart.toUpperCase();
}
const pageTitle = `Greenbone - ${labelPart}`;
document.title = pageTitle;
document.title = `${title} - ${labelPart}`;
} else {
document.title = 'Greenbone Security Assistant';
document.title = title;
}
} catch (error) {}
});
Expand Down
3 changes: 3 additions & 0 deletions src/gmp/gmpsettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const DEFAULT_PROTOCOLDOC_URL = `https://docs.greenbone.net/API/GMP/gmp-2
export const DEFAULT_REPORT_RESULTS_THRESHOLD = 25000;
export const DEFAULT_LOG_LEVEL = 'warn';
export const DEFAULT_TIMEOUT = 300000; // 5 minutes
export const DEFAULT_TITLE = 'Greenbone Security Assistant'

const set = (storage, name, value) => {
if (isDefined(value)) {
Expand Down Expand Up @@ -62,6 +63,7 @@ class GmpSettings {
timeout = DEFAULT_TIMEOUT,
vendorVersion,
vendorLabel,
title = DEFAULT_TITLE
} = options;
let {
apiProtocol = protocol,
Expand Down Expand Up @@ -105,6 +107,7 @@ class GmpSettings {
this.reloadIntervalInactive = reloadIntervalInactive;
this.reportResultsThreshold = reportResultsThreshold;
this.timeout = timeout;
this.title = title

setAndFreeze(this, 'apiProtocol', apiProtocol);
setAndFreeze(this, 'apiServer', apiServer);
Expand Down