From 395a4a26bd2043effe00b93930961ba210da5c5c Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Mar 25 2019 15:23:59 +0000 Subject: Ticket 50289 - Fix various database UI issues Description: Fixed these issues: - https://bugzilla.redhat.com/show_bug.cgi?id=1664621 - backup freezes when no suffix present - https://bugzilla.redhat.com/show_bug.cgi?id=1685395 - Perform Backup fails when Backend Name is not configured - https://bugzilla.redhat.com/show_bug.cgi?id=1688587 - typo when restarting instance - https://bugzilla.redhat.com/show_bug.cgi?id=1688775 - db tree breaks when suffix contains spaces. - https://bugzilla.redhat.com/show_bug.cgi?id=1688919 - backups fail with empty name Also fixed issue where if you start an instance in UI the configuration is correctly loaded. https://pagure.io/389-ds-base/issue/50289 Reviewed by: spichugi(Thanks!) --- diff --git a/ldap/servers/slapd/task.c b/ldap/servers/slapd/task.c index 8741570..b42e872 100644 --- a/ldap/servers/slapd/task.c +++ b/ldap/servers/slapd/task.c @@ -1486,7 +1486,7 @@ task_backup_add(Slapi_PBlock *pb __attribute__((unused)), Slapi_Entry *e, Slapi_Entry *eAfter __attribute__((unused)), int *returncode, - char *returntext __attribute__((unused)), + char *returntext, void *arg __attribute__((unused))) { Slapi_Backend *be = NULL; @@ -1529,18 +1529,19 @@ task_backup_add(Slapi_PBlock *pb __attribute__((unused)), } slapi_ch_free_string(&cookie); if (NULL == be || NULL == be->be_database->plg_db2archive) { - slapi_log_err(SLAPI_LOG_ERR, - "task_backup_add", "no db2archive function defined.\n"); + PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, + "no db2archive function defined. There is no backend/suffix present"); + slapi_log_err(SLAPI_LOG_ERR, "task_backup_add", "Error: %s\n", returntext); *returncode = LDAP_UNWILLING_TO_PERFORM; rv = SLAPI_DSE_CALLBACK_ERROR; goto out; } if (!SLAPI_PLUGIN_IS_V3(be->be_database)) { - slapi_log_err(SLAPI_LOG_ERR, - "task_backup_add", "Can't perform an backup with pre-V3 " - "backend plugin %s\n", - be->be_database->plg_name); + PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, + "Can't perform an backup with pre-V3 backend plugin %s\n", + be->be_database->plg_name); + slapi_log_err(SLAPI_LOG_ERR, "task_backup_add", "Error: %s\n", returntext); *returncode = LDAP_UNWILLING_TO_PERFORM; rv = SLAPI_DSE_CALLBACK_ERROR; goto out; diff --git a/src/cockpit/389-console/src/database.jsx b/src/cockpit/389-console/src/database.jsx index ccc2c19..cbcb126 100644 --- a/src/cockpit/389-console/src/database.jsx +++ b/src/cockpit/389-console/src/database.jsx @@ -97,11 +97,13 @@ export class Database extends React.Component { } componentWillMount () { - this.loadGlobalConfig(); - this.loadChainingConfig(); - this.loadLDIFs(); - this.loadBackups(); - this.loadSuffixList(); + if (!this.state.loaded) { + this.loadGlobalConfig(); + this.loadChainingConfig(); + this.loadLDIFs(); + this.loadBackups(); + this.loadSuffixList(); + } } componentDidMount() { @@ -183,7 +185,7 @@ export class Database extends React.Component { }), this.setState({configUpdated: 0})); }) .fail(err => { - this.props.addNotification( + this.addNotification( "error", `Error loading database configuration - ${err}` ); @@ -269,7 +271,7 @@ export class Database extends React.Component { ), this.loadAvailableControls()); }) .fail(err => { - this.props.addNotification( + this.addNotification( "error", `Error loading default chaining configuration - ${err}` ); @@ -313,11 +315,14 @@ export class Database extends React.Component { "dsconf", "-j", "ldapi://%2fvar%2frun%2fslapd-" + this.props.serverId + ".socket", "backend", "get-tree", ]; - log_cmd("getTree", "Start building the suffix tree", cmd); + log_cmd("loadSuffixTree", "Start building the suffix tree", cmd); cockpit .spawn(cmd, { superuser: true, err: "message" }) .done(content => { - let treeData = JSON.parse(content); + let treeData = []; + if (content != "") { + treeData = JSON.parse(content); + } let basicData = [ { text: "Global Database Configuration", @@ -356,7 +361,6 @@ export class Database extends React.Component { this.setState(() => ({ nodes: basicData, node_name: current_node, - }), this.update_tree_nodes); }); } @@ -770,7 +774,7 @@ export class Database extends React.Component { }); }) .fail(err => { - this.props.addNotification( + this.addNotification( "error", `Error loading indexes for ${suffix} - ${err}` ); @@ -924,7 +928,7 @@ export class Database extends React.Component { }); }) .fail(err => { - this.props.addNotification( + this.addNotification( "error", `Error loading indexes for ${suffix} - ${err}` ); @@ -960,7 +964,7 @@ export class Database extends React.Component { const cmd = [ "dsctl", "-j", this.props.serverId, "backups" ]; - log_cmd("loadLDIFs", "Load Backups", cmd); + log_cmd("loadBackups", "Load Backups", cmd); cockpit .spawn(cmd, { superuser: true, err: "message" }) .done(content => { @@ -995,7 +999,7 @@ export class Database extends React.Component { }); }) .fail(err => { - this.props.addNotification( + this.addNotification( "error", `Failed to get attributes - ${err}` ); diff --git a/src/cockpit/389-console/src/ds.js b/src/cockpit/389-console/src/ds.js index 953a450..581d690 100644 --- a/src/cockpit/389-console/src/ds.js +++ b/src/cockpit/389-console/src/ds.js @@ -309,13 +309,6 @@ function popup_success(msg) { // all the save functions for all the pages here. This is not used for modal forms function save_all () { save_config(); // Server Config Page - // - // TODO: - // save_chaining(); - // save_chaining_suffix(); - // save_global_backend(); - // save_suffix(); - // save_security(); } function load_repl_suffix_dropdowns() { @@ -351,7 +344,7 @@ function load_repl_suffix_dropdowns() { var loading_cfg = 0; -function load_config (){ +function load_config (refresh){ // If we are currently loading config don't do it twice if (loading_cfg == 1){ return; @@ -418,6 +411,13 @@ function load_config (){ $("#server-config").show(); clearInterval(loading_config); loading_cfg = 0; + + if (refresh) { + // Reload reactJS pages by clicking dummy element + let reload_el = document.getElementById('reload-page'); + reload_el.click(); + } + console.log("Completed configuration initialization."); } }, 300); diff --git a/src/cockpit/389-console/src/index.es6 b/src/cockpit/389-console/src/index.es6 index 7dfd433..404cbb0 100644 --- a/src/cockpit/389-console/src/index.es6 +++ b/src/cockpit/389-console/src/index.es6 @@ -14,16 +14,18 @@ function renderReactDOM(clear) { .getElementById("select-server") .value.replace("slapd-", ""); } + let d = new Date(); + let n = d.getTime(); // might not be needed MARK // Plugins Tab ReactDOM.render( - , + , document.getElementById("plugins") ); // Database tab ReactDOM.render( - , + , document.getElementById("database") ); } @@ -45,10 +47,7 @@ document.addEventListener("DOMContentLoaded", function() { .getElementById("select-server") .addEventListener("change", renderReactWrapper); document - .getElementById("start-server-btn") - .addEventListener("click", renderReactWrapper); - document - .getElementById("restart-server-btn") + .getElementById("reload-page") .addEventListener("click", renderReactWrapper); document .getElementById("remove-server-btn") diff --git a/src/cockpit/389-console/src/index.html b/src/cockpit/389-console/src/index.html index 5015717..96586d1 100644 --- a/src/cockpit/389-console/src/index.html +++ b/src/cockpit/389-console/src/index.html @@ -35,6 +35,7 @@ +