Skip to content

Commit

Permalink
Add ability to configure <title>
Browse files Browse the repository at this point in the history
  • Loading branch information
jschwoerer authored and jschwoerer committed Mar 3, 2025
1 parent 358f44c commit 6ba76d6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
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

0 comments on commit 6ba76d6

Please sign in to comment.