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)
{
$msg_err = 'Failed while saving: %s';
$msg_ok = 'Successfully saved into keystore ';
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
),
]
);
if ($type === 'error') {
$msg_title = ($delete === true) ? 'Failed while removing' : 'Failed while saving';
} else {
echo json_encode(
[
$type => ui_print_success_message(
__(
$msg_ok,
$msg
),
'',
true
),
]
);
$msg_title = ($delete === true) ? 'Successfully deleted' : 'Successfully saved into keystore';
}
echo json_encode(
[ $type => __($msg_title).':<br>'.$msg ]
);
exit;
}

View File

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

View File

@ -959,41 +959,28 @@ class SatelliteAgent extends HTML
*/
private function ajaxMsg($type, $msg, $delete=false, $disable=false)
{
$msg_err = 'Failed while saving: %s';
$msg_ok = 'Successfully saved agent ';
if ($delete === true) {
$msg_err = 'Failed while removing: %s';
$msg_ok = 'Successfully deleted ';
}
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
),
]
);
if ($type === 'error') {
if ($delete === true) {
$msg_title = 'Failed while removing';
} else if ($disable === true) {
$msg_title = 'Failed while disabling';
} else {
$msg_title = 'Failed while saving';
}
} else {
echo json_encode(
[
$type => ui_print_success_message(
__($msg),
'',
true
),
]
);
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;
}

View File

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