From 6bfe74fcd07bdbc7dc9dad80516ab0d4d63bbb24 Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: May 28 2018 16:10:23 +0000 Subject: Ticket 49704 - Error log from the installer is concatenating all lines into one Description: Created new bootpopup wrapper functions that use the "content" option to add html messages. Then we use "pre" html tags for messages that come from the CLI, and regular "p" tags for generic messages. Also durign instance creation we now strip "slapd-" from instance name because the installer automatically adds "slapd-" to the name anyway. https://pagure.io/389-ds-base/issue/49704 Reviewed by: firstyear(Thanks!) --- diff --git a/src/cockpit/389-console/js/backend.js b/src/cockpit/389-console/js/backend.js index 66255a0..54f6ddf 100644 --- a/src/cockpit/389-console/js/backend.js +++ b/src/cockpit/389-console/js/backend.js @@ -116,7 +116,7 @@ function get_encoded_ref () { } if (ref_suffix == "" && (ref_attrs != "" || ref_filter != "" || ref_scope != "")) { - bootpopup.alert("Missing suffix - you can not set the attributes, scope, or filter without a suffix.", "Attention!"); + popup_msg("Attention!", "Missing suffix - you can not set the attributes, scope, or filter without a suffix."); return; } if (ref_suffix != "" || ref_attrs != "" || ref_filter != "" || ref_scope != "") { diff --git a/src/cockpit/389-console/js/ds.js b/src/cockpit/389-console/js/ds.js index 8988216..fb5ecf4 100644 --- a/src/cockpit/389-console/js/ds.js +++ b/src/cockpit/389-console/js/ds.js @@ -138,6 +138,26 @@ function report_err( input, msg) { $(".ds-modal-error").show(); } + +function popup_err(title, msg) { + // Display errors from the cli (we have to use pre tags) + bootpopup({ + title: title, + content: [ + '
' + msg + '
' + ] + }); +} + +function popup_msg(title, msg) { + bootpopup({ + title: title, + content: [ + '

' + msg + '

' + ] + }); +} + $(function() { $('#select-server').change(function() { server_id = $(this).val(); @@ -155,7 +175,4 @@ $(window.document).ready(function() { }); } - - - }); diff --git a/src/cockpit/389-console/js/replication.js b/src/cockpit/389-console/js/replication.js index 0e2b1dd..6853b32 100644 --- a/src/cockpit/389-console/js/replication.js +++ b/src/cockpit/389-console/js/replication.js @@ -184,11 +184,11 @@ $(document).ready( function() { if (role == "master") { if ($("#nsds5replicaid").val() == "" || $("#nsds5replicaid").val() === undefined ){ - bootpopup.alert("Replica ID is required for a Master role", "Attention!"); + popup_msg("Attention!", "Replica ID is required for a Master role"); return; } if ( !valid_num($("#nsds5replicaid").val()) ) { - bootpopup.alert("Replica ID must be a number", "Attention!"); + popup_msg("Attention!", "Replica ID must be a number"); return; } @@ -308,7 +308,7 @@ $(document).ready( function() { // Confirm passwords match if (agmt_bindpw != agmt_bindpw_confirm) { - bootpopup.alert("Passwords do not match", "Attention!"); + popup_msg("Attention!", "Passwords do not match"); return; } @@ -620,7 +620,7 @@ $(document).ready( function() { var passwd_confirm = $("#winsync-nsds5replicacredentials-confirm").val(); if (agmt_passwd != passwd_confirm) { - bootpopup.alert("Passwords do not match!", "Attention!"); + popup_msg("Attention!", "Passwords do not match!"); return; } // Get form values @@ -721,7 +721,7 @@ $(document).ready( function() { $("#add-repl-mgr-save").on("click", function() { var repl_dn = $("#add-repl-mgr-dn").val(); if (repl_dn == ""){ - bootpopup.alert("Replication Manager DN is required", "Attention!"); + popup_msg("Attention!", "Replication Manager DN is required"); return; } if ( $("#add-repl-mgr-checkbox").is(":checked") ){ @@ -729,7 +729,7 @@ $(document).ready( function() { var agmt_bindpw = $("#add-repl-pw").val(); var agmt_bindpw_confirm = $("#add-repl-pw-confirm").val(); if (agmt_bindpw != agmt_bindpw_confirm) { - bootpopup.alert("Passwords do not match", "Attention!"); + popup_msg("Attention!", "Passwords do not match"); $("#add-repl-pw").val(""); $("#add-repl-pw-confirm").val(""); return; @@ -738,7 +738,7 @@ $(document).ready( function() { console.log("Validate dn..."); if (!valid_dn(repl_dn)){ - bootpopup.alert("Invalid DN for Replication Manager", "Attention!"); + popup_msg("Attention!", "Invalid DN for Replication Manager"); return; } diff --git a/src/cockpit/389-console/js/servers.js b/src/cockpit/389-console/js/servers.js index dd2c745..dd2c654 100644 --- a/src/cockpit/389-console/js/servers.js +++ b/src/cockpit/389-console/js/servers.js @@ -780,6 +780,7 @@ $(document).ready( function() { report_err($("#create-inst-serverid"), 'You must provide an Instance name'); return; } else { + new_server_id = new_server_id.replace(/^slapd-/i, ""); // strip "slapd-" setup_inf = setup_inf.replace('INST_NAME', new_server_id); } @@ -858,7 +859,8 @@ $(document).ready( function() { cockpit.spawn(["hostname", "--fqdn"], { superuser: true, "err": "message" }).fail(function(ex) { // Failed to get FQDN - bootpopup.alert("Failed to get hostname: " + ex.message, "Failure!"); + popup_err("Failed to get hostname!", ex.message); + }).done(function (data){ // Set the hostname in inf file setup_inf = setup_inf.replace('FQDN', data); @@ -866,20 +868,20 @@ $(document).ready( function() { // Create setup inf file var cmd = ["/bin/sh", "-c", '/usr/bin/echo -e "' + setup_inf + '" > /tmp/389setup.inf']; cockpit.spawn(cmd, { superuser: true, "err": "message" }).fail(function(ex) { - bootpopup.alert("Failed to create installation file '/tmp/389setup.inf': " + ex.message, "Failure!"); + popup_err("Failed to create installation file!", ex.message); }).done(function (){ // Next, create the instance cmd = ['dscreate', 'fromfile', '/tmp/389setup.inf']; cockpit.spawn(cmd, { superuser: true, "err": "message" }).fail(function(ex) { $("#create-inst-spinner").hide(); - bootpopup.alert("Failed to create DS instance: " + ex.message, "Failure!"); + popup_err("Failed to create instance!", ex.message); }).done(function (){ // Cleanup $("#create-inst-spinner").hide(); $("#server-list-menu").attr('disabled', false); $("#no-instances").hide(); get_insts(); // Refresh server list - bootpopup.alert("Successfully created instance: slapd-" + new_server_id, "Success"); + popup_msg("Success!", "Successfully created instance: slapd-" + new_server_id + "", ); $("#create-inst-form").modal('toggle'); }); $("#create-inst-spinner").show();