Source
const vault_enabled = [DB_STORE_CREDS_VAULT_HASHICORP, DB_STORE_CREDS_VAULT_CYBERARK].includes(vault_selected);
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
const ZBX_DB_MYSQL = 'MYSQL';
const ZBX_DB_POSTGRESQL = 'POSTGRESQL';
const ZBX_DB_ORACLE = 'ORACLE';
const DB_STORE_CREDS_VAULT_HASHICORP = 1;
const DB_STORE_CREDS_VAULT_CYBERARK = 2;
const STEP_WELCOME = 1;
const STEP_DB_CONNECTION = 3;
const STEP_SETTINGS = 4;
const view = new class {
init({step, hashicorp_endpoint_default, cyberark_endpoint_default}) {
this._hashicorp_endpoint_default = hashicorp_endpoint_default;
this._cyberark_endpoint_default = cyberark_endpoint_default;
const form = document.getElementById('setup-form');
switch (step) {
case STEP_WELCOME:
document.getElementById('default-lang').addEventListener('change', () => form.submit());
break;
case STEP_DB_CONNECTION:
for (const id of ['type', 'server', 'tls_encryption', 'verify_certificate', 'creds_storage',
'vault_certificates_toggle', 'vault_url']) {
document.getElementById(id).addEventListener('change', () => this._update());
}
form.addEventListener('submit', () => {
const input_ids = ['server', 'database', 'schema', 'vault_url', 'vault_prefix_hashicorp',
'vault_prefix_cyberark', 'vault_db_path', 'vault_query_string', 'vault_token',
'vault_cert_file', 'vault_key_file', 'ca_file', 'key_file', 'cert_file'
];
for (const id of input_ids) {
const input = document.getElementById(id);
input.value = input.value.trim();
}
});
this._update();
break;
case STEP_SETTINGS:
document.getElementById('default-theme').addEventListener('change', () => form.submit())
break;