From aaf517cbb6ab722669fcd90e0626de4bd09a9997 Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Oct 18 2018 14:03:13 +0000 Subject: Ticket 49978 - Add CLI logging function for UI Description: Add a web browser console logging function to enforce a consistent format and hide password values for CLI commands. https://pagure.io/389-ds-base/issue/49978 Reviewed by: ? --- diff --git a/src/cockpit/389-console/js/ds.js b/src/cockpit/389-console/js/ds.js index 2bff8fc..eb6ade5 100644 --- a/src/cockpit/389-console/js/ds.js +++ b/src/cockpit/389-console/js/ds.js @@ -37,6 +37,43 @@ var DSCREATE = '/home/mareynol/source/ds389/389-ds-base/src/lib389/cli/dscreate' var ENV = "PYTHONPATH=/home/mareynol/source/ds389/389-ds-base/src/lib389"; */ +/* + * Console logging function for CLI commands + * + * @param {text} js_func The javascript/jquery function that is making this call. + * @param {text} desc The description of the CLI command. + * @param {array} cmd_array An array of all the CLI arguments. + */ +function log_cmd(js_func, desc, cmd_array) { + if (window.console) { + var pw_args = ['--passwd', '--bind-pw']; + var cmd_list = []; + var converted_pw = false; + + for (var idx in cmd_array) { + var cmd = cmd_array[idx]; + converted_pw = false; + for (var arg_idx in pw_args) { + if ( cmd.startsWith(pw_args[arg_idx]) ) { + // We are setting a password, if it has a value we need to hide it + var arg_len = cmd.indexOf('='); + var arg = cmd.substring(0, arg_len); + if (cmd.length != arg_len + 1) { + // We are setting a password value... + cmd_list.push(arg + "=**********"); + converted_pw = true; + } + break; + } + } + if (!converted_pw) { + cmd_list.push(cmd); + } + } + window.console.log("CMD: " + js_func + ": " + desc + " ==> " + cmd_list.join(' ')); + } +} + // TODO validation functions function valid_dn (dn){ diff --git a/src/cockpit/389-console/js/replication.js b/src/cockpit/389-console/js/replication.js index d90702a..7581138 100644 --- a/src/cockpit/389-console/js/replication.js +++ b/src/cockpit/389-console/js/replication.js @@ -154,7 +154,7 @@ function add_repl_mgr(dn){ function do_agmt_init(suffix, agmt_cn, idx) { var status_cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','repl-agmt', 'init-status', '--suffix=' + suffix, '"' + agmt_cn + '"' ]; - console.log("CMD: Get initialization status for agmt: " + status_cmd.join(' ')); + log_cmd('do_agmt_init', 'Get initialization status for agmt', status_cmd); cockpit.spawn(status_cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { var init_stat = JSON.parse(data); if (init_stat == 'Agreement successfully initialized.' || @@ -169,7 +169,7 @@ function do_agmt_init(suffix, agmt_cn, idx) { function do_winsync_agmt_init(suffix, agmt_cn, idx) { var status_cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','repl-winsync-agmt', 'init-status', '--suffix=' + suffix, '"' + agmt_cn + '"' ]; - console.log("CMD: Get initialization status for agmt: " + status_cmd.join(' ')) + log_cmd('do_winsync_agmt_init', 'Get initialization status for agmt', status_cmd); cockpit.spawn(status_cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { var init_stat = JSON.parse(data); if (init_stat == 'Agreement successfully initialized.' || @@ -192,7 +192,7 @@ function get_and_set_repl_winsync_agmts() { if (suffix) { console.log("Loading winsync replication agreements..."); var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','repl-winsync-agmt', 'list', '--suffix=' + suffix ]; - console.log("CMD: Get winsync agmts: " + cmd.join(' ')) + log_cmd('get_and_set_repl_winsync_agmts', 'Get the winsync agmts', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { var obj = JSON.parse(data); for (var idx in obj['items']) { @@ -220,7 +220,7 @@ function get_and_set_repl_winsync_agmts() { var ws_interval_agmt_name = agmt_name; var ws_init_status_interval = setInterval(function() { var status_cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','repl-winsync-agmt', 'init-status', '--suffix=' + suffix, '"' + ws_interval_agmt_name + '"' ]; - console.log("CMD: Get initialization status for winsync agmt: " + status_cmd.join(' ')) + log_cmd('get_and_set_repl_winsync_agmts', 'Get initialization status for winsync agmt', status_cmd); cockpit.spawn(status_cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { var init_stat = JSON.parse(data); if (init_stat == 'Agreement successfully initialized.' || @@ -265,7 +265,7 @@ function get_and_set_repl_agmts () { if (suffix) { console.log("Loading replication agreements..."); var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','repl-agmt', 'list', '--suffix=' + suffix ]; - console.log("CMD: Get agmts: " + cmd.join(' ')) + log_cmd('get_and_set_repl_agmts', 'Get replication agreements', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { var obj = JSON.parse(data); for (var idx in obj['items']) { @@ -325,7 +325,7 @@ function get_and_set_repl_agmts () { function get_and_set_cleanallruv() { console.log("Loading replication tasks..."); var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','repl-tasks', 'list-cleanallruv']; - console.log("CMD: Get repl tasks: " + cmd.join(' ')); + log_cmd('get_and_set_cleanallruv', 'Get the cleanAllRUV tasks', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { var tasks = JSON.parse(data); repl_clean_table.clear(); @@ -361,7 +361,7 @@ function get_and_set_repl_config () { console.log("Loading replication configuration..."); var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','replication', 'get', '--suffix=' + suffix ]; - console.log("CMD: Get repl config: " + cmd.join(' ')); + log_cmd('get_and_set_repl_config', 'Get replication configuration', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { var repl = JSON.parse(data); var repl_type; @@ -445,7 +445,7 @@ function get_and_set_repl_config () { $("#cl-create-div").show(); $("#cl-del-div").hide(); var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','replication', 'get-changelog']; - console.log("CMD: Get changelog: " + cmd.join(' ')); + log_cmd('get_and_set_repl_config', 'Get replication changelog', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { $(".ds-cl").val(""); // Clear form var cl = JSON.parse(data); @@ -527,7 +527,7 @@ function save_repl_config(suffix, ignore_rid) { var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','replication', 'set', '--suffix=' + suffix ]; cmd = cmd.concat(arg_list); - console.log("CMD: set replication: " + cmd.join(' ')); + log_cmd('save_repl_config', 'Set replication configuration', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { popup_success('Saved replication configuration'); for (var key in set_repl_values) { @@ -541,7 +541,7 @@ function save_repl_config(suffix, ignore_rid) { if (arg_cl_list.length > 0){ var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','replication' ,'set-changelog']; cmd = cmd.concat(arg_cl_list); - console.log("CMD: Set changelog: " + cmd.join(' ')); + log_cmd('save_repl_config', 'Set changelog configuration', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { popup_success('Saved changelog configuration'); for (var key in set_cl_values) { @@ -565,7 +565,7 @@ function save_repl_config(suffix, ignore_rid) { */ var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','replication' ,'set-changelog']; cmd = cmd.concat(arg_cl_list); - console.log("CMD: Set changelog: " + cmd.join(' ')); + log_cmd('save_repl_config', 'Set changelog configuration', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { popup_success('Saved changelog configuration'); for (var key in set_cl_values) { @@ -752,7 +752,7 @@ $(document).ready( function() { } cmd.push("--replica-id=" + rid); } - console.log("CMD: Enable replication: " + cmd.join(' ')); + log_cmd('#repl-config-save (click)', 'Enable replication', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { popup_success('Successfully enabled replication'); get_and_set_repl_config(); @@ -769,7 +769,7 @@ $(document).ready( function() { popup_confirm("Are you sure you want to disable replication? This will remove all your replication agreements and can not be undone!", "Confirmation", function (yes) { if (yes) { var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','replication', 'disable', '--suffix=' + suffix ]; - console.log("CMD: Disable replication: " + cmd.join(' ')); + log_cmd('#repl-config-save (click)', 'Disable replication', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { current_role = "Disabled"; $("#repl-config-content").hide(); @@ -806,7 +806,7 @@ $(document).ready( function() { } var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','replication', 'promote', '--suffix=' + suffix, "--newrole=" + new_role, "--replica-id=" + rid]; - console.log("CMD: Promote replica: " + cmd.join(' ')); + log_cmd('#repl-config-save (click)', 'Promote replica to Master', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { current_role = "Master";; popup_success('Successfully promoted replica to a Master'); @@ -822,7 +822,7 @@ $(document).ready( function() { */ var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','replication', 'demote', '--suffix=' + suffix, "--newrole=" + new_role]; - console.log("CMD: Demote replica: " + cmd.join(' ')); + log_cmd('#repl-config-save (click)', 'Demote replica to Hub', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { current_role = "Hub"; popup_success('Successfully demoted replica to a Hub'); @@ -837,7 +837,7 @@ $(document).ready( function() { */ var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','replication', 'promote', '--suffix=' + suffix, "--newrole=" + new_role]; - console.log("CMD: Promote replica: " + cmd.join(' ')); + log_cmd('#repl-config-save (click)', 'Promote replica to Hub ', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { current_role = "Hub";; popup_success('Successfully promoted replica to a Hub'); @@ -852,7 +852,7 @@ $(document).ready( function() { */ var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','replication', 'demote', '--suffix=' + suffix, "--newrole=" + new_role]; - console.log("CMD: Demote replica: " + cmd.join(' ')); + log_cmd('#repl-config-save (click)', 'Demote replication to Consumer', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { current_role = "Consumer"; popup_success('Successfully demoted replica to a Consumer'); @@ -881,7 +881,7 @@ $(document).ready( function() { // Create changelog $("#create-cl-btn").on('click', function () { var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','replication' ,'create-changelog']; - console.log("CMD: Create changelog: " + cmd.join(' ')); + log_cmd('#create-cl-btn (click)', 'Create replication changelog', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { get_and_set_repl_config(); popup_success('Successfully created replication changelog'); @@ -896,7 +896,7 @@ $(document).ready( function() { popup_confirm("Are you sure you want to delete the replication changelog as it will break all the existing agreements?", "Confirmation", function (yes) { if (yes) { var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','replication' ,'delete-changelog']; - console.log("CMD: Delete changelog: " + cmd.join(' ')); + log_cmd('#delete-cl-btn (click)', 'Delete replication changelog', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { get_and_set_repl_config(); popup_success('Successfully removed replication changelog'); @@ -1121,7 +1121,7 @@ $(document).ready( function() { cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','repl-agmt', 'create', '--suffix=' + suffix]; } cmd = cmd.concat(cmd_args); - console.log("CMD: Set/Create repl agmt: " + cmd.join(' ')); + log_cmd('#agmt-save (click)', 'Create/Set replication agreement', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { if (editing){ popup_success('Successfully edited replication agreement'); @@ -1131,7 +1131,7 @@ $(document).ready( function() { if (init_replica) { // Launch popup stating initialization has begun var init_cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','repl-agmt', 'init', '--suffix=' + suffix, agmt_name ]; - console.log("CMD: Init agmt: " + init_cmd.join(' ')); + log_cmd('#agmt-save (click)', 'Initialize agreement', init_cmd); cockpit.spawn(init_cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function() { popup_msg("Agreement Initialization", "The agreement initialization has begun..."); }).fail(function(data) { @@ -1164,9 +1164,9 @@ $(document).ready( function() { var row_idx = $(this).closest('tr').index(); repl_agmt_table.cell({row: row_idx, column: 5}).data(progress_html).draw(); - var status_cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','repl-agmt', 'init', '--suffix=' + suffix, '"' + agmt_name + '"' ]; - console.log("CMD: init agmt: " + status_cmd.join(' ')); - cockpit.spawn(status_cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { + var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','repl-agmt', 'init', '--suffix=' + suffix, '"' + agmt_name + '"' ]; + log_cmd('.agmt-init-btn (click)', 'Initialize replication agreement', cmd); + cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { var init_idx = agmt_init_counter; agmt_init_counter += 1; agmt_init_intervals[init_idx] = setInterval( do_agmt_init, 2000, suffix, agmt_name, init_idx); @@ -1184,9 +1184,9 @@ $(document).ready( function() { var row_idx = $(this).closest('tr').index(); repl_winsync_agmt_table.cell({row: row_idx, column: 5}).data(progress_html).draw(); - var status_cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','repl-winsync-agmt', 'init', '--suffix=' + suffix, '"' + agmt_name + '"' ]; - console.log("CMD: Init winsync agmt: " + status_cmd.join(' ')); - cockpit.spawn(status_cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { + var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','repl-winsync-agmt', 'init', '--suffix=' + suffix, '"' + agmt_name + '"' ]; + log_cmd('.winsync-agmt-init-btn (click)', 'Initialize replication winsync agreement', cmd); + cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { var init_idx = agmt_init_counter; agmt_init_counter += 1; agmt_init_intervals[init_idx] = setInterval( do_winsync_agmt_init, 2000, suffix, agmt_name, init_idx); @@ -1210,14 +1210,14 @@ $(document).ready( function() { var suffix = $("#select-repl-cfg-suffix").val(); var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','replication' ,'set', '--repl-del-bind-dn=' + mgr_dn.text(), '--suffix=' + suffix]; - console.log("CMD: Set replication config: " + cmd.join(' ')); + log_cmd('#remove-mgr-btn (click)', 'Remove replication manager from the configuration', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { /* Success, now check if they want the entry deleted */ if ($("#delete-mgr-checkbox").is(":checked")) { /* Remove the manager entry */ var del_cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','replication', 'delete-manager', "--name=" + mgr_dn.text()]; - console.log("CMD: Delete replication manager: " + del_cmd.join(' ')); + log_cmd('#remove-mgr-btn (click)', 'Delete replication manager entry', del_cmd); cockpit.spawn(del_cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { popup_success('Successfully removed replication manager'); }); @@ -1245,7 +1245,7 @@ $(document).ready( function() { if (yes) { var suffix = $("#select-repl-agmt-suffix").val(); var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','repl-agmt', 'delete', '--suffix=' + suffix, '"' + del_agmt_name + '"']; - console.log("CMD: Delete agmt: " + cmd.join(' ')); + log_cmd('.agmt-del-btn (click)', 'Delete replication agreement', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { popup_success('Successfully removed replication agreement'); // Update table @@ -1267,7 +1267,7 @@ $(document).ready( function() { if (yes) { var suffix = $("#select-repl-agmt-suffix").val(); var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','repl-winsync-agmt', 'delete', '--suffix=' + suffix, '"' + del_agmt_name + '"']; - console.log("CMD: Delete winsync agmt: " + cmd.join(' ')); + log_cmd('.winsync-agmt-del-btn (click)', 'Delete replication winsync agreement', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { popup_success('Successfully removed replication winsync agreement'); // Update table @@ -1297,7 +1297,7 @@ $(document).ready( function() { // Get agreement from DS and populate form var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','repl-agmt', 'get', '--suffix=' + suffix, '"' + edit_agmt_name + '"']; - console.log("CMD: Get agmt: " + cmd.join(' ')); + log_cmd('.agmt-edit-btn (click)', 'Edit replication agreement', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { var agmt_obj = JSON.parse(data); var frac_attrs = ""; @@ -1430,7 +1430,7 @@ $(document).ready( function() { // Get agreement from DS and populate form var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','repl-winsync-agmt', 'get', '--suffix=' + suffix, '"' + edit_agmt_name + '"']; - console.log("CMD: Get winsync agmt: " + cmd.join(' ')); + log_cmd('.winsync-agmt-edit-btn (click)', 'Get replication winsync agreement', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { var agmt_obj = JSON.parse(data); @@ -1769,7 +1769,7 @@ $(document).ready( function() { cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','repl-winsync-agmt', 'create', '"' + agmt_name + '"', '--suffix=' + suffix]; } cmd = cmd.concat(cmd_args); - console.log("CMD: Set/Create winsync agmt: " + cmd.join(' ')); + log_cmd('#winsync-agmt-save (click)', 'Create/Set replication winsync agreement', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { if (editing){ popup_success('Successfully edited replication winsync agreement'); @@ -1779,7 +1779,7 @@ $(document).ready( function() { if (init_replica) { // Launch popup stating initialization has begun var init_cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','repl-winsync-agmt', 'init', '--suffix=' + suffix, '"' + agmt_name + '"' ]; - console.log("CMD: Init winsync agmt: " + init_cmd.join(' ')); + log_cmd('#winsync-agmt-save (click)', 'Initialize winsync agreement', init_cmd); cockpit.spawn(init_cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function() { popup_msg("Agreement Initialization", "The agreement initialization has begun..."); }).fail(function(data) { @@ -1826,10 +1826,10 @@ $(document).ready( function() { if (force) { cmd.push('--force-cleaning'); } - console.log("CMD: Creating cleanAllRUV Task: " + cmd.join(' ')); + log_cmd('#cleanallruv-save (click)', 'Create CleanAllRUV Task', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function() { var list_cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','repl-tasks', 'list-cleanallruv']; - console.log("CMD: Listing cleanAllRUV tasks: " + list_cmd.join(' ')); + log_cmd('#cleanallruv-save (click)', 'List all the CleanAllRUV tasks', list_cmd); cockpit.spawn(list_cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { repl_clean_table.clear(); var obj = JSON.parse(data); @@ -1865,7 +1865,7 @@ $(document).ready( function() { popup_confirm("Are you sure you want to abort the cleaning task on: " + suffix + " for Replica ID " + task_rid + "", "Confirmation", function (yes) { if (yes) { var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','repl-tasks', 'abort-cleanallruv', '--replica-id=' + task_rid, '--suffix=' + suffix]; - console.log("CMD: Abort cleanAllRUV task: " + cmd.join(' ')); + log_cmd('.abort_cleanallruv_btn (click)', 'Abort CleanAllRUV task', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { popup_success("Creating task to abort the CleanAllRUV Task"); }).fail(function(data) { @@ -1898,17 +1898,15 @@ $(document).ready( function() { popup_confirm("Are you sure you want to delete replication manager: " + repl_mgr_dn.val() + "", "Confirmation", function (yes) { if (yes) { // Update replica config entry, do not delete the real repl mgr entry - var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','replication', 'set', '--suffix="' + suffix + '"', "--repl-remove-bind-dn=" + repl_mgr_dn.val() ]; - console.log("CMD: Setting replication configuration: " + cmd.join(' ')); - cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function() { - // Update HTML - repl_mgr_dn.remove(); - // Just refresh the entire config - get_and_set_repl_config(); - popup_success("Successfully updated replication configuration"); - }).fail( function(err) { - popup_err("Failed to remove the replication manager from the replication configuration", data.message); - }); + var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','replication', 'set', '--suffix="' + suffix + '"', "--repl-remove-bind-dn=" + repl_mgr_dn.val() ]; + log_cmd('#delete-repl-manager (click)', 'Remove replication manager from the configuration', cmd); + cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function() { + repl_mgr_dn.remove(); + get_and_set_repl_config(); + popup_success("Successfully updated replication configuration"); + }).fail( function(err) { + popup_err("Failed to remove the replication manager from the replication configuration", data.message); + }); } }); } @@ -1949,13 +1947,13 @@ $(document).ready( function() { // If we are creating the entry do it now if (repl_pw != ""){ var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','replication', 'create-manager', '--name=' + repl_dn, '--passwd=' + repl_pw ]; - console.log("CMD: Creating replication manager: " + cmd.join(' ')); + log_cmd('#add-repl-mgr-save (click)', 'Create replication manager entry', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function() { /* * Success, now update the repl config */ var update_cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','replication', 'set', '--repl-add-bind-dn=' + repl_dn, '--suffix=' + suffix]; - console.log("CMD: Adding replication manager to configuration: " + update_cmd.join(' ')); + log_cmd('#add-repl-mgr-save (click)', 'Add replication manager to configuration', update_cmd); cockpit.spawn(update_cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function() { // Update html get_and_set_repl_config(); @@ -1972,7 +1970,7 @@ $(document).ready( function() { } else { // Just update repl config var update_cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','replication', 'set', '--repl-add-bind-dn=' + repl_dn, '--suffix=' + suffix]; - console.log("CMD: Adding replication manager to configuration: " + update_cmd.join(' ')); + log_cmd('#add-repl-mgr-save (click)', 'Add replication manager to configuration', update_cmd); cockpit.spawn(update_cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function() { // Update html get_and_set_repl_config(); @@ -1985,11 +1983,6 @@ $(document).ready( function() { } }); - - $(document).on('click', '.abort-cleanallruv-btn', function(e) { - // TODO - abort the cleantask - update table (remove or update existing clean task?) - }); - /* Send update now */ $(document).on('click', '.agmt-send-updates-btn', function(e) { var suffix = $("#select-repl-agmt-suffix").val(); @@ -1997,7 +1990,7 @@ $(document).ready( function() { var update_agmt_name = data[0]; var update_cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','repl-agmt', 'poke', update_agmt_name, '--suffix=' + suffix]; - console.log("CMD: Trigger send updates now: " + update_cmd.join(' ')); + log_cmd('.agmt-send-updates-btn (click)', 'Trigger send updates now (replication)', update_cmd); cockpit.spawn(update_cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function() { popup_success("Triggered replication updates"); }).fail( function(err) { @@ -2012,7 +2005,7 @@ $(document).ready( function() { var update_agmt_name = data[0]; var update_cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','repl-winsync-agmt', 'poke', update_agmt_name, '--suffix=' + suffix]; - console.log("CMD: Trigger send updates now: " + update_cmd.join(' ')); + log_cmd('.winsync-agmt-send-updates-btn (click)', 'Trigger send updates now (winsync)', update_cmd); cockpit.spawn(update_cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function() { popup_success("Kick started replication"); }).fail( function(err) { @@ -2020,7 +2013,6 @@ $(document).ready( function() { }); }); - /* * Enable/Disable repl agmt */ @@ -2034,7 +2026,7 @@ $(document).ready( function() { popup_confirm("Are you sure you want to disable replication agreement: " + enable_agmt_name + "", "Confirmation", function (yes) { if (yes) { var disable_cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','repl-agmt', 'disable', enable_agmt_name, '--suffix=' + suffix]; - console.log("CMD: Disable replication agmt: " + disable_cmd.join(' ')); + log_cmd('.agmt-enable-btn (click)', 'Disable replication agreement', disable_cmd); cockpit.spawn(disable_cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function() { get_and_set_repl_agmts(); popup_success("The replication agreement has been disabled."); @@ -2048,7 +2040,7 @@ $(document).ready( function() { popup_confirm("Are you sure you want to enable replication agreement: " + enable_agmt_name + "", "Confirmation", function (yes) { if (yes) { var enable_cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','repl-agmt', 'enable', enable_agmt_name, '--suffix=' + suffix]; - console.log("CMD: Enable replication agmt: " + enable_cmd.join(' ')); + log_cmd('.agmt-enable-btn (click)', 'Enable replication agreement', enable_cmd); cockpit.spawn(enable_cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function() { get_and_set_repl_agmts(); popup_success("The replication agreement has been enabled."); @@ -2073,7 +2065,7 @@ $(document).ready( function() { popup_confirm("Are you sure you want to disable replication agreement: " + enable_agmt_name + "", "Confirmation", function (yes) { if (yes) { var disable_cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','repl-winsync-agmt', 'disable', enable_agmt_name, '--suffix=' + suffix]; - console.log("CMD: Disable winsync agmt: " + disable_cmd.join(' ')); + log_cmd('.winsync-agmt-enable-btn (click)', 'Disable winsync agreement', disable_cmd); cockpit.spawn(disable_cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function() { get_and_set_repl_winsync_agmts(); popup_success("The replication agreement has been disabled."); @@ -2087,7 +2079,7 @@ $(document).ready( function() { popup_confirm("Are you sure you want to enable replication agreement: " + enable_agmt_name + "", "Confirmation", function (yes) { if (yes) { var enable_cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','repl-winsync-agmt', 'enable', enable_agmt_name, '--suffix=' + suffix]; - console.log("CMD: Enable winsync agmt: " + enable_cmd.join(' ')); + log_cmd('.winsync-agmt-enable-btn (click)', 'Enable winsync agreement', disable_cmd); cockpit.spawn(enable_cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function() { get_and_set_repl_winsync_agmts(); popup_success("The replication agreement has been enabled."); diff --git a/src/cockpit/389-console/js/schema.js b/src/cockpit/389-console/js/schema.js index a490fac..ebe47a6 100644 --- a/src/cockpit/389-console/js/schema.js +++ b/src/cockpit/389-console/js/schema.js @@ -107,7 +107,7 @@ function clear_attr_form() { function load_schema_objects_to_select(object, select_id) { var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket', 'schema', object, 'list']; - console.log("CMD: Get schema: " + cmd.join(' ')); + log_cmd('load_schema_objects_to_select', 'Get schema', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(select_data) { var obj = JSON.parse(select_data); var data = []; @@ -153,7 +153,7 @@ function get_and_set_schema_tables() { // Setup the tables: standard, custom, and Matching Rules var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket', 'schema', 'objectclasses', 'list']; - console.log("CMD: Get objectclasses: " + cmd.join(' ')); + log_cmd('get_and_set_schema_tables', 'Get objectclasses', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(oc_data) { var obj = JSON.parse(oc_data); var data = []; @@ -201,7 +201,8 @@ function get_and_set_schema_tables() { }); // Get syntaxes and use the data to populate the attribute's table - console.log("CMD: Get syntaxes: " + cmd.join(' ')); + log_cmd('get_and_set_schema_tables', 'Get syntaxes', cmd); + get_and_set_schema_tables cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket', 'schema', "attributetypes", 'get_syntaxes']; cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(syntax_data) { var obj = JSON.parse(syntax_data); @@ -227,7 +228,7 @@ function get_and_set_schema_tables() { }); var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket', 'schema', 'attributetypes', 'list']; - console.log("CMD: Get attributes: " + cmd.join(' ')); + log_cmd('get_and_set_schema_tables', 'Get attributes', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(at_data) { var obj = JSON.parse(at_data); var data = []; @@ -296,7 +297,7 @@ function get_and_set_schema_tables() { }); cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket', 'schema', 'matchingrules', 'list']; - console.log("CMD: Get matching rules: " + cmd.join(' ')); + log_cmd('get_and_set_schema_tables', 'Get matching rules', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(mr_data) { var obj = JSON.parse(mr_data); var data = []; @@ -412,7 +413,7 @@ $(document).ready( function() { } $("#save-oc-spinner").show(); - console.log("CMD: Save objectclass: " + cmd.join(' ')); + log_cmd('#save-oc-button (click)', 'Save objectclasses', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}). done(function(data) { $("#oc-name").attr('disabled', false); @@ -423,7 +424,7 @@ $(document).ready( function() { schema_oc_table.row(selector).remove().draw(false); } var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket', 'schema', 'objectclasses', 'query', oc_name]; - console.log("CMD: Query objectclass: " + cmd.join(' ')); + log_cmd('#save-oc-button (click)', 'Search objectclasses', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}). done(function(oc_data) { var obj = JSON.parse(oc_data); @@ -600,7 +601,7 @@ $(document).ready( function() { cmd.push.apply(cmd, [""]); } $("#save-attr-spinner").show(); - console.log("CMD: Save attribute: " + cmd.join(' ')); + log_cmd('#save-attr-button (click)', 'Save attribute', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}). done(function(data) { var attr_syntax_name = '
' + @@ -612,7 +613,7 @@ $(document).ready( function() { schema_at_table.row(selector).remove().draw(false); } var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket', 'schema', 'attributetypes', 'query', attr_name]; - console.log("CMD: Query attribute: " + cmd.join(' ')); + log_cmd('#save-oc-button (click)', 'Get attribute', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}). done(function(at_data) { var obj = JSON.parse(at_data); @@ -730,7 +731,7 @@ $(document).ready( function() { popup_confirm("Are you sure you want to delete attribute: " + del_attr_name + "", "Confirmation", function (yes) { if (yes) { var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket', 'schema', 'attributetypes', 'remove', del_attr_name]; - console.log("CMD: Remove attribute: " + cmd.join(' ')); + log_cmd('.attr-del-btn (click)', 'Remove attribute', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { popup_success("Attribute was successfully removed!"); schema_at_table.row( at_row.parents('tr') ).remove().draw( false ); @@ -809,7 +810,7 @@ $(document).ready( function() { popup_confirm("Are you sure you want to delete objectclass: " + del_oc_name + "", "Confirmation", function (yes) { if (yes) { var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket', 'schema', 'objectclasses', 'remove', del_oc_name]; - console.log("CMD: Remove objectclass: " + cmd.join(' ')); + log_cmd('.oc-del-btn (click)', 'Remove objectclass', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { popup_success("ObjectClass was successfully removed!"); schema_oc_table.row( oc_row.parents('tr') ).remove().draw( false ); diff --git a/src/cockpit/389-console/js/servers.js b/src/cockpit/389-console/js/servers.js index cb0e58e..6557223 100644 --- a/src/cockpit/389-console/js/servers.js +++ b/src/cockpit/389-console/js/servers.js @@ -158,7 +158,7 @@ function add_validate_arg (arg_list, valtype, val, def_val, edit, attr, arg, msg function get_and_set_config () { var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','config', 'get']; console.log("Loading server configuration."); - console.log("CMD: get config: " + cmd.join(' ')); + log_cmd('get_and_set_config', 'Get server configuration', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { var obj = JSON.parse(data); // Reset tables before populating them @@ -214,7 +214,7 @@ function update_suffix_dropdowns () { 'monitor-repl-backend-list']; var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','backend', 'list', '--suffix']; - console.log("CMD: Get backends: " + cmd.join(' ')); + log_cmd('update_suffix_dropdowns', 'Get suffix list', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { // Clear all the dropdowns first for (var idx in dropdowns) { @@ -243,7 +243,7 @@ function get_and_set_localpwp (quiet) { return; } var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','localpwp', 'list', suffix ]; - console.log("CMD: Get local password policies: " + cmd.join(' ')); + log_cmd('get_and_set_localpwp', 'Get local password policies', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { var obj = JSON.parse(data); // Empty table @@ -269,13 +269,13 @@ function get_and_set_sasl () { console.log("Loading SASL configuration..."); var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','sasl', 'list']; - console.log("CMD: get SASL mappings: " + cmd.join(' ')); + log_cmd('get_and_set_sasl', 'Get SASL mappings', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { var obj = JSON.parse(data); sasl_table.clear().draw(); for (var idx in obj['items']) { var map_cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','sasl', 'get', obj['items'][idx] ]; - console.log("CMD: get SASL mapping: " + map_cmd.join(' ')); + log_cmd('get_and_set_sasl', 'Get sASL mapping', map_cmd); cockpit.spawn(map_cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { var map_obj = JSON.parse(data); @@ -658,7 +658,7 @@ $(document).ready( function() { popup_confirm("Are you sure you want to delete sasl mapping: " + del_sasl_name + "", "Confirmation", function (yes) { if (yes) { var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','sasl', 'delete', del_sasl_name]; - console.log("CMD: delete SASL mapping: " + cmd.join(' ')); + log_cmd('.sasl-del-btn (click)', 'Delete SASL mapping', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { sasl_table.row( sasl_row.parents('tr') ).remove().draw( false ); popup_success("Removed SASL mapping " + del_sasl_name + ""); @@ -1034,7 +1034,7 @@ $(document).ready( function() { if ( edit ) { var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','localpwp', 'set', policy_name]; cmd = cmd.concat(arg_list); - console.log("CMD: Set local password policy: " + cmd.join(' ')); + log_cmd('local-pwp-save', 'Set local password policy', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { popup_success('Successfully edited local password policy'); $("#local-pwp-form").modal('toggle') @@ -1049,7 +1049,7 @@ $(document).ready( function() { } var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','localpwp', action, policy_name]; cmd = cmd.concat(arg_list); - console.log("CMD: Add local password policy: " + cmd.join(' ')); + log_cmd('local-pwp-save', 'Add local password policy', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { pwp_table.row.add( [ policy_name, @@ -1075,7 +1075,7 @@ $(document).ready( function() { if (yes) { // Delete pwp from DS var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','localpwp', 'remove', del_pwp_name]; - console.log("CMD: Remove local password policy: " + cmd.join(' ')); + log_cmd('.delete-local-pwp (click)', 'Remove local password policy', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { // Update html table pwp_table.row( pwp_row.parents('tr') ).remove().draw( false ); @@ -1136,7 +1136,7 @@ $(document).ready( function() { // Create new mapping and update table var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','sasl', 'create', sasl_name_cmd, sasl_regex_cmd, sasl_base_cmd, sasl_filter_cmd, sasl_priority_cmd]; - console.log("CMD: Create SASL mapping: " + cmd.join(' ')); + log_cmd('#sasl-map-save (click)', 'Add SASL mapping', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function() { // Update html table sasl_table.row.add( [ @@ -1156,7 +1156,7 @@ $(document).ready( function() { } else { // Editing mapping. First delete the old mapping var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','sasl', 'delete', sasl_map_name]; - console.log("CMD: Delete SASL mapping: " + cmd.join(' ')); + log_cmd('#sasl-map-save (click)', 'Delete SASL mapping', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function() { // Remove row from old sasl_table.rows( function ( idx, data, node ) { @@ -1166,7 +1166,7 @@ $(document).ready( function() { // Then add new mapping and update table var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','sasl', 'create', sasl_name_cmd, sasl_regex_cmd, sasl_base_cmd, sasl_filter_cmd, sasl_priority_cmd]; - console.log("CMD: create SASL mapping: " + cmd.join(' ')); + log_cmd('#sasl-map-save (click)', 'Add SASL mapping', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function() { // Update html table sasl_table.row.add( [ @@ -1199,7 +1199,7 @@ $(document).ready( function() { $("#ds-start-inst").html(" Starting instance " + server_id + "..."); $("#start-instance-form").modal('toggle'); var cmd = [DSCTL, server_inst, 'start']; - console.log("CMD: Start instance: " + cmd.join(' ')); + log_cmd('#start-server-btn (click)', 'Start server instance', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { $("#start-instance-form").modal('toggle'); load_config(); @@ -1214,7 +1214,7 @@ $(document).ready( function() { $("#ds-stop-inst").html(" Stopping instance " + server_id + "..."); $("#stop-instance-form").modal('toggle'); var cmd = [DSCTL, server_inst, 'stop']; - console.log("CMD: Stop instance: " + cmd.join(' ')); + log_cmd('#stop-server-btn (click)', 'Stop server instance', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { $("#stop-instance-form").modal('toggle'); popup_success("Stopped instance \"" + server_id + "\""); @@ -1230,7 +1230,7 @@ $(document).ready( function() { $("#ds-restart-inst").html(" Retarting instance " + server_id + "..."); $("#restart-instance-form").modal('toggle'); var cmd = [DSCTL, server_inst, 'restart']; - console.log("CMD: Restart instance: " + cmd.join(' ')); + log_cmd('#restart-server-btn (click)', 'Restart server instance', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { $("#restart-instance-form").modal('toggle'); load_config(); @@ -1262,7 +1262,7 @@ $(document).ready( function() { cockpit.spawn(cmd, { superuser: true}). done(function() { var cmd = [DSCONF, server_inst, 'backup', 'create', backup_name]; - console.log("CMD: Backup database: " + cmd.join(' ')); + log_cmd('#ds-backup-btn (click)', 'Backup server instance', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}). done(function(data) { $("#backup-spinner").hide(); @@ -1276,7 +1276,7 @@ $(document).ready( function() { }). fail(function() { var cmd = [DSCTL, server_inst, 'db2bak', backup_name]; - console.log("CMD: Backup database(offline): " + cmd.join(' ')); + log_cmd('#ds-backup-btn (click)', 'Backup server instance (offline)', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}). done(function(data) { $("#backup-spinner").hide(); @@ -1297,7 +1297,7 @@ $(document).ready( function() { /* Restore. load restore table with current backups */ $("#restore-server-btn").on('click', function () { var cmd = [DSCTL, server_id, '-j', 'backups']; - console.log("CMD: Resotre database(offline): " + cmd.join(' ')); + log_cmd('#restore-server-btn (click)', 'Restore server instance', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { var backup_btn = ""; var del_btn = ""; @@ -1326,7 +1326,7 @@ $(document).ready( function() { cockpit.spawn(cmd, { superuser: true}). done(function() { var cmd = [DSCONF, server_inst, 'backup', 'restore', restore_name]; - console.log("CMD: Restore database(online): " + cmd.join(' ')); + log_cmd('.restore-btn (click)', 'Restore server instance(online)', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}). done(function(data) { $("#restore-spinner").hide(); @@ -1340,7 +1340,7 @@ $(document).ready( function() { }). fail(function() { var cmd = [DSCTL, server_inst, 'bak2db', restore_name]; - console.log("CMD: Restore database (offline): " + cmd.join(' ')); + log_cmd('.restore-btn (click)', 'Restore server instance(offline)', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}). done(function(data) { $("#restore-spinner").hide(); @@ -1366,7 +1366,7 @@ $(document).ready( function() { if (yes) { var cmd = [DSCTL, server_inst, 'backups', '--delete', restore_name]; $("#restore-spinner").show(); - console.log("CMD: Delete backup: " + cmd.join(' ')); + log_cmd('.ds-del-backup-btn (click)', 'Delete backup', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { $("#restore-spinner").hide(); backup_table.row( backup_row.parents('tr') ).remove().draw( false ); @@ -1388,7 +1388,7 @@ $(document).ready( function() { var cmd = [DSCONF, server_id, 'schema', 'reload', '--wait']; } $("#reload-spinner").show(); - console.log("CMD: Reload schema files: " + cmd.join(' ')); + log_cmd('#schema-reload-btn (click)', 'Reload schema files', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { popup_success("Successfully reloaded schema"); // TODO use timed interval success msg (waiting for another PR top be merged before we can add it) $("#schema-reload-form").modal('toggle'); @@ -1407,7 +1407,7 @@ $(document).ready( function() { var cmd = [DSCTL, server_id, "remove", "--doit"]; $("#ds-remove-inst").html(" Removing instance " + server_id + "..."); $("#remove-instance-form").modal('toggle'); - console.log("CMD: Delete instance: " + cmd.join(' ')); + log_cmd('#remove-server-btn (click)', 'Remove instance', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { $("#remove-instance-form").modal('toggle'); popup_success("Instance has been deleted"); @@ -1655,7 +1655,7 @@ $(document).ready( function() { // lookup the entry, and get the current settings var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','localpwp', 'get', policy_name]; - console.log("CMD: Get local password policy: " + cmd.join(' ')); + log_cmd('.edit-local-pwp (click)', 'Get local password policy', cmd); cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { localpwp_values = {}; // Clear it out var obj = JSON.parse(data);