Action messages in modals

This commit is contained in:
Jose Gonzalez 2023-03-07 12:50:09 +01:00
parent c3a297e096
commit 28a003706b
4 changed files with 36 additions and 107 deletions

View File

@ -103,42 +103,16 @@ class CredentialStore extends Wizard
*/ */
private function ajaxMsg($type, $msg, $delete=false) private function ajaxMsg($type, $msg, $delete=false)
{ {
$msg_err = 'Failed while saving: %s'; if ($type === 'error') {
$msg_ok = 'Successfully saved into keystore '; $msg_title = ($delete === true) ? 'Failed while removing' : 'Failed while saving';
if ($delete) {
$msg_err = 'Failed while removing: %s';
$msg_ok = 'Successfully deleted ';
}
if ($type == 'error') {
echo json_encode(
[
$type => ui_print_error_message(
__(
$msg_err,
$msg
),
'',
true
),
]
);
} else { } else {
echo json_encode( $msg_title = ($delete === true) ? 'Successfully deleted' : 'Successfully saved into keystore';
[
$type => ui_print_success_message(
__(
$msg_ok,
$msg
),
'',
true
),
]
);
} }
echo json_encode(
[ $type => __($msg_title).':<br>'.$msg ]
);
exit; exit;
} }

View File

@ -264,27 +264,11 @@ class ModuleTemplates extends HTML
*/ */
private function ajaxMsg($type, $msg) private function ajaxMsg($type, $msg)
{ {
if ($type == 'error') {
echo json_encode( echo json_encode(
[ [
$type => ui_print_error_message( $type => __($msg),
__($msg),
'',
true
),
] ]
); );
} else {
echo json_encode(
[
$type => ui_print_success_message(
__($msg),
'',
true
),
]
);
}
exit; exit;
} }

View File

@ -959,40 +959,27 @@ class SatelliteAgent extends HTML
*/ */
private function ajaxMsg($type, $msg, $delete=false, $disable=false) private function ajaxMsg($type, $msg, $delete=false, $disable=false)
{ {
$msg_err = 'Failed while saving: %s'; if ($type === 'error') {
$msg_ok = 'Successfully saved agent ';
if ($delete === true) { if ($delete === true) {
$msg_err = 'Failed while removing: %s'; $msg_title = 'Failed while removing';
$msg_ok = 'Successfully deleted '; } else if ($disable === true) {
} $msg_title = 'Failed while disabling';
if ($disable === true) {
$msg_err = 'Failed while disabling: %s';
$msg_ok = 'Successfully disabled';
}
if ($type == 'error') {
echo json_encode(
[
$type => ui_print_error_message(
__($msg),
'',
true
),
]
);
} else { } else {
echo json_encode( $msg_title = 'Failed while saving';
[
$type => ui_print_success_message(
__($msg),
'',
true
),
]
);
} }
} else {
if ($delete === true) {
$msg_title = 'Successfully deleted';
} else if ($disable === true) {
$msg_title = 'Successfully disabled';
} else {
$msg_title = 'Successfully saved agent';
}
}
echo json_encode(
[ $type => __($msg_title).':<br>'.$msg ]
);
exit; exit;
} }

View File

@ -475,27 +475,11 @@ class SatelliteCollection extends HTML
*/ */
private function ajaxMsg(string $type, string $msg) private function ajaxMsg(string $type, string $msg)
{ {
if ($type === 'error') {
echo json_encode( echo json_encode(
[ [
$type => ui_print_error_message( $type => __($msg),
__($msg),
'',
true
),
] ]
); );
} else {
echo json_encode(
[
$type => ui_print_success_message(
__($msg),
'',
true
),
]
);
}
exit; exit;
} }