#9073 resolve conflics and bugs

This commit is contained in:
Daniel Cebrian 2023-03-07 17:57:09 +01:00
parent a4634717d8
commit 27005158ba
8 changed files with 130 additions and 79 deletions

View File

@ -653,6 +653,7 @@ if ($update_user) {
$values['timezone'] = (string) get_parameter('timezone'); $values['timezone'] = (string) get_parameter('timezone');
$values['default_event_filter'] = (int) get_parameter('default_event_filter'); $values['default_event_filter'] = (int) get_parameter('default_event_filter');
$values['default_custom_view'] = (int) get_parameter('default_custom_view'); $values['default_custom_view'] = (int) get_parameter('default_custom_view');
$values['show_tips_startup'] = (int) get_parameter_switch('show_tips_startup');
// API Token information. // API Token information.
$apiTokenRenewed = (bool) get_parameter('renewAPIToken'); $apiTokenRenewed = (bool) get_parameter('renewAPIToken');
$values['api_token'] = ($apiTokenRenewed === true) ? api_token_generate() : users_get_API_token($values['id_user']); $values['api_token'] = ($apiTokenRenewed === true) ? api_token_generate() : users_get_API_token($values['id_user']);

View File

@ -372,6 +372,8 @@ $userManagementTable->data['captions_loginErrorUser'][1] .= ui_print_input_place
__('The user with local authentication enabled will always use local authentication.'), __('The user with local authentication enabled will always use local authentication.'),
true true
); );
$userManagementTable->data['show_tips_startup'][0] = html_print_checkbox_switch('show_tips_startup', 1, ($user_info['show_tips_startup'] === null) ? true : $user_info['show_tips_startup'], true);
$userManagementTable->data['show_tips_startup'][1] = __('Show usage tips at startup');
// Session time input. // Session time input.
$userManagementTable->rowclass['captions_userSessionTime'] = 'field_half_width'; $userManagementTable->rowclass['captions_userSessionTime'] = 'field_half_width';

View File

@ -113,13 +113,13 @@ class TipsWindow
public function run() public function run()
{ {
global $config; global $config;
$_SESSION['showed_tips_window'] = true;
$userInfo = users_get_user_by_id($config['id_user']); $userInfo = users_get_user_by_id($config['id_user']);
if ((bool) $userInfo['show_tips_startup'] === false) { if ((bool) $userInfo['show_tips_startup'] === false) {
return; return;
} }
$_SESSION['showed_tips_window'] = true;
ui_require_css_file('tips_window'); ui_require_css_file('tips_window');
ui_require_css_file('jquery.bxslider'); ui_require_css_file('jquery.bxslider');
ui_require_javascript_file('tipsWindow'); ui_require_javascript_file('tipsWindow');
@ -479,7 +479,10 @@ class TipsWindow
__('Create tip'), __('Create tip'),
'create', 'create',
false, false,
'class="sub next"' [
'class' => 'sub',
'icon' => 'create_file',
]
); );
echo '</a>'; echo '</a>';
echo '</div>'; echo '</div>';
@ -583,22 +586,23 @@ class TipsWindow
$data[$key]['url'] = io_safe_output($row['url']); $data[$key]['url'] = io_safe_output($row['url']);
$data[$key]['actions'] = '<div class="buttons_actions">'; $data[$key]['actions'] = '<div class="buttons_actions">';
$data[$key]['actions'] .= '<a href="index.php?sec=gsetup&sec2=godmode/setup/setup&section=welcome_tips&view=edit&idTip='.$row['id'].'">'; $data[$key]['actions'] .= '<a href="index.php?sec=gsetup&sec2=godmode/setup/setup&section=welcome_tips&view=edit&idTip='.$row['id'].'">';
$data[$key]['actions'] .= html_print_input_image( $data[$key]['actions'] .= html_print_image(
'button_edit_tip', 'images/edit.svg',
'images/edit.png', true,
'', ['class' => 'main_menu_icon']
'',
true
); );
$data[$key]['actions'] .= '</a>'; $data[$key]['actions'] .= '</a>';
$data[$key]['actions'] .= '<form name="grupo" method="post" action="index.php?sec=gsetup&sec2=godmode/setup/setup&section=welcome_tips&action=delete">'; $data[$key]['actions'] .= '<form name="grupo" method="post" action="index.php?sec=gsetup&sec2=godmode/setup/setup&section=welcome_tips&action=delete">';
$data[$key]['actions'] .= html_print_input_image( $data[$key]['actions'] .= html_print_input_image(
'button_delete_tip', 'button_delete_tip',
'images/delete.png', 'images/delete.svg',
'', '',
'', '',
true, true,
['onclick' => 'if (!confirm(\''.__('Are you sure?').'\')) return false;'] [
'onclick' => 'if (!confirm(\''.__('Are you sure?').'\')) return false;',
'class' => 'main_menu_icon',
]
); );
$data[$key]['actions'] .= html_print_input_hidden('idTip', $row['id'], true); $data[$key]['actions'] .= html_print_input_hidden('idTip', $row['id'], true);
$data[$key]['actions'] .= '</form>'; $data[$key]['actions'] .= '</form>';
@ -706,7 +710,7 @@ class TipsWindow
$table->data[3][0] = __('Title'); $table->data[3][0] = __('Title');
$table->data[3][1] = html_print_input_text('title', '', '', 35, 100, true); $table->data[3][1] = html_print_input_text('title', '', '', 35, 100, true);
$table->data[4][0] = __('Text'); $table->data[4][0] = __('Text');
$table->data[4][1] = html_print_textarea('text', 5, 1, '', '', true); $table->data[4][1] = html_print_textarea('text', 5, 50, '', '', true);
$table->data[5][0] = __('Url'); $table->data[5][0] = __('Url');
$table->data[5][1] = html_print_input_text('url', '', '', 35, 100, true); $table->data[5][1] = html_print_input_text('url', '', '', 35, 100, true);
$table->data[6][0] = __('Enable'); $table->data[6][0] = __('Enable');
@ -715,6 +719,15 @@ class TipsWindow
echo '<form name="grupo" method="post" action="index.php?sec=gsetup&sec2=godmode/setup/setup&section=welcome_tips&view=create&action=create" enctype="multipart/form-data">'; echo '<form name="grupo" method="post" action="index.php?sec=gsetup&sec2=godmode/setup/setup&section=welcome_tips&view=create&action=create" enctype="multipart/form-data">';
html_print_table($table); html_print_table($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">'; echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_submit_button(
__('Send'),
'submit_button',
false,
[
'class' => 'sub',
'icon' => 'update',
]
);
html_print_submit_button( html_print_submit_button(
__('Preview'), __('Preview'),
'preview_button', 'preview_button',
@ -722,9 +735,9 @@ class TipsWindow
[ [
'class' => 'sub preview', 'class' => 'sub preview',
'id' => 'prev_button', 'id' => 'prev_button',
'icon' => 'preview',
] ]
); );
html_print_submit_button(__('Send'), 'submit_button', false, ['class' => 'sub next']);
echo '</div>'; echo '</div>';
echo '</form>'; echo '</form>';
html_print_div(['id' => 'tips_window_modal_preview']); html_print_div(['id' => 'tips_window_modal_preview']);
@ -770,11 +783,14 @@ class TipsWindow
$imageTip = html_print_image($namePath, true); $imageTip = html_print_image($namePath, true);
$imageTip .= html_print_input_image( $imageTip .= html_print_input_image(
'delete_image_tip', 'delete_image_tip',
'images/delete.png', 'images/delete.svg',
'', '',
'', '',
true, true,
['onclick' => 'deleteImage(this, \''.$value['id'].'\', \''.$namePath.'\')'] [
'onclick' => 'deleteImage(this, \''.$value['id'].'\', \''.$namePath.'\')',
'class' => 'remove-image',
]
); );
$outputImagesTip .= html_print_div( $outputImagesTip .= html_print_div(
[ [
@ -828,7 +844,7 @@ class TipsWindow
$table->data[3][0] = __('Title'); $table->data[3][0] = __('Title');
$table->data[3][1] = html_print_input_text('title', $tip['title'], '', 35, 100, true); $table->data[3][1] = html_print_input_text('title', $tip['title'], '', 35, 100, true);
$table->data[4][0] = __('Text'); $table->data[4][0] = __('Text');
$table->data[4][1] = html_print_textarea('text', 5, 1, $tip['text'], '', true); $table->data[4][1] = html_print_textarea('text', 5, 50, $tip['text'], '', true);
$table->data[5][0] = __('Url'); $table->data[5][0] = __('Url');
$table->data[5][1] = html_print_input_text('url', $tip['url'], '', 35, 100, true); $table->data[5][1] = html_print_input_text('url', $tip['url'], '', 35, 100, true);
$table->data[6][0] = __('Enable'); $table->data[6][0] = __('Enable');
@ -837,6 +853,15 @@ class TipsWindow
echo '<form name="grupo" method="post" action="index.php?sec=gsetup&sec2=godmode/setup/setup&section=welcome_tips&view=edit&action=edit&idTip='.$tip['id'].'" enctype="multipart/form-data">'; echo '<form name="grupo" method="post" action="index.php?sec=gsetup&sec2=godmode/setup/setup&section=welcome_tips&view=edit&action=edit&idTip='.$tip['id'].'" enctype="multipart/form-data">';
html_print_table($table); html_print_table($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">'; echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_submit_button(
__('Send'),
'submit_button',
false,
[
'class' => 'sub',
'icon' => 'update',
]
);
html_print_submit_button( html_print_submit_button(
__('Preview'), __('Preview'),
'preview_button', 'preview_button',
@ -844,9 +869,9 @@ class TipsWindow
[ [
'class' => 'sub preview', 'class' => 'sub preview',
'id' => 'prev_button', 'id' => 'prev_button',
'icon' => 'preview',
] ]
); );
html_print_submit_button(__('Send'), 'submit_button', false, ['class' => 'sub next']);
echo '</div>'; echo '</div>';
echo '</form>'; echo '</form>';

View File

@ -9,7 +9,7 @@ $(document).ready(function() {
1}" onchange="checkImage(this)"/>` 1}" onchange="checkImage(this)"/>`
); );
$(div_image).append( $(div_image).append(
`<input type="image" src="images/delete.png" onclick="removeInputImage('file_${numberImages + `<input type="image" src="images/delete.svg" onclick="removeInputImage('file_${numberImages +
1}');" class="remove-image" value="-"/>` 1}');" class="remove-image" value="-"/>`
); );
$("#inputs_images").append(div_image); $("#inputs_images").append(div_image);
@ -18,31 +18,29 @@ $(document).ready(function() {
$("#image-delete_image_tip1").on("click", function(e) { $("#image-delete_image_tip1").on("click", function(e) {
e.preventDefault(); e.preventDefault();
}); });
$("#submit-preview_button").on("click", function(e) { $("#button-preview_button").on("click", function(e) {
e.preventDefault(); e.preventDefault();
previewTip(); previewTip();
}); });
}); });
$("#checkbox_tips_startup").ready(function() { function show_tips_startup(e) {
$("#checkbox_tips_startup").on("click", function() { $.ajax({
$.ajax({ method: "POST",
method: "POST", url: url,
url: url, dataType: "json",
dataType: "json", data: {
data: { page: page,
page: page, method: "setShowTipsAtStartup",
method: "setShowTipsAtStartup", show_tips_startup: e.checked ? "1" : "0"
show_tips_startup: this.checked ? "1" : "0" },
}, success: function({ success }) {
success: function({ success }) { if (!success) {
if (!success) { $("#checkbox_tips_startup").prop("checked", true);
$("#checkbox_tips_startup").prop("checked", true);
}
} }
}); }
}); });
}); }
function checkImage(e) { function checkImage(e) {
var maxWidth = 464; var maxWidth = 464;
var maxHeight = 260; var maxHeight = 260;
@ -320,25 +318,27 @@ function previewTip() {
extradata["totalFiles64"] = totalInputsFiles; extradata["totalFiles64"] = totalInputsFiles;
$("input[type=file]").each(function(index) { $("input[type=file]").each(function(index) {
var reader = new FileReader(); var reader = new FileReader();
reader.readAsDataURL(this.files[0]); if (this.files.length > 0) {
reader.onload = function(e) { reader.readAsDataURL(this.files[0]);
var img = new Image(); reader.onload = function(e) {
img.src = e.target.result; var img = new Image();
img.onload = function() { img.src = e.target.result;
extradata[`file64_${index}`] = this.currentSrc; img.onload = function() {
if (totalInputsFiles - 1 === index) { extradata[`file64_${index}`] = this.currentSrc;
load_tips_modal({ if (totalInputsFiles - 1 === index) {
target: $("#tips_window_modal_preview"), load_tips_modal({
url: url, target: $("#tips_window_modal_preview"),
onshow: { url: url,
page: page, onshow: {
method: "renderPreview" page: page,
}, method: "renderPreview"
extradata //Receive json },
}); extradata //Receive json
} });
}
};
}; };
}; }
}); });
} else { } else {
load_tips_modal({ load_tips_modal({

View File

@ -10491,6 +10491,11 @@ button div.create_directory {
contain; contain;
} }
button div.preview {
mask: url(../../images/eye.png) no-repeat center / contain;
-webkit-mask: url(../../images/eye.png) no-repeat center / contain;
}
button div.cog.rotation { button div.cog.rotation {
animation: rotation 4s infinite linear; animation: rotation 4s infinite linear;
} }

View File

@ -24,6 +24,8 @@
height: fit-content; height: fit-content;
background-color: white; background-color: white;
color: #161628; color: #161628;
border-top-left-radius: 25px !important;
border-top-right-radius: 25px !important;
} }
.tips_header .title { .tips_header .title {
font-size: 15px; font-size: 15px;
@ -124,6 +126,7 @@
#tips_window_modal_preview .ui-dialog-buttonset button { #tips_window_modal_preview .ui-dialog-buttonset button {
margin: 0px 20px !important; margin: 0px 20px !important;
margin-top: 10px !important; margin-top: 10px !important;
min-width: fit-content;
} }
.dialog_tips .ui-dialog-buttonset { .dialog_tips .ui-dialog-buttonset {
border-bottom-right-radius: 10px !important; border-bottom-right-radius: 10px !important;
@ -201,7 +204,10 @@ span.disable {
#notices_images { #notices_images {
color: #e63c52; color: #e63c52;
} }
.preview { .remove-image {
background-position: 92% 10px !important; max-width: 35px;
margin-right: 20px !important; padding-top: 18px;
}
.buttons_actions input {
width: 32px;
} }

View File

@ -83,7 +83,6 @@ if (isset($_GET['modified']) && !$view_mode) {
$upd_info['timezone'] = get_parameter_post('timezone', ''); $upd_info['timezone'] = get_parameter_post('timezone', '');
$upd_info['id_skin'] = get_parameter('skin', $user_info['id_skin']); $upd_info['id_skin'] = get_parameter('skin', $user_info['id_skin']);
$upd_info['default_event_filter'] = get_parameter('event_filter', null); $upd_info['default_event_filter'] = get_parameter('event_filter', null);
$upd_info['show_tips_startup'] = get_parameter_switch('show_tips_startup');
$upd_info['block_size'] = get_parameter('block_size', $config['block_size']); $upd_info['block_size'] = get_parameter('block_size', $config['block_size']);
@ -585,23 +584,6 @@ if ((bool) check_acl($config['id_user'], 0, 'ER') === true) {
).'</div>'; ).'</div>';
} }
$show_tips = '<div class="label_select_simple"><p class="edit_user_labels">'.__('Show usage tips at startup').'</p>';
$show_tips .= html_print_checkbox_switch('show_tips_startup', 1, $user_info['show_tips_startup'], true).'</div>';
$autorefresh_list_out = []; $autorefresh_list_out = [];
if (is_metaconsole() === false || is_centralized() === true) { if (is_metaconsole() === false || is_centralized() === true) {
$autorefresh_list_out['operation/agentes/estado_agente'] = 'Agent detail'; $autorefresh_list_out['operation/agentes/estado_agente'] = 'Agent detail';
@ -825,7 +807,7 @@ if (is_metaconsole() === true) {
<div class="edit_user_autorefresh white_box">'.$autorefresh_show.$time_autorefresh.'</div> <div class="edit_user_autorefresh white_box">'.$autorefresh_show.$time_autorefresh.'</div>
</div> </div>
<div class="user_edit_second_row white_box"> <div class="user_edit_second_row white_box">
<div class="edit_user_options">'.$language.$size_pagination.$skin.$home_screen.$event_filter.$show_tips.$double_authentication.'</div> <div class="edit_user_options">'.$language.$size_pagination.$skin.$home_screen.$event_filter.$double_authentication.'</div>
<div class="edit_user_timezone">'.$timezone; <div class="edit_user_timezone">'.$timezone;

View File

@ -37,7 +37,7 @@ $output .= '<p>'.html_print_checkbox(
true, true,
true, true,
false, false,
'', 'show_tips_startup(this)',
false, false,
'', '',
($preview === true) ? '' : 'checkbox_tips_startup' ($preview === true) ? '' : 'checkbox_tips_startup'
@ -81,15 +81,45 @@ $output .= '</div>';
$output .= '<div class="ui-dialog-buttonset">'; $output .= '<div class="ui-dialog-buttonset">';
// TODO Delete this buttons and use html_print_button when merge new design // TODO Delete this buttons and use html_print_button when merge new design
$output .= '<button type="button" class="submit-cancel-tips ui-button ui-corner-all ui-widget" onclick="close_dialog()">Maybe later</button>'; $output .= html_print_button(
__('Maybe later'),
'',
false,
'',
[
'onclick' => 'close_dialog()',
'class' => 'secondary mini',
],
true
);
$output .= '<div class="counter-tips">'; $output .= '<div class="counter-tips">';
$output .= html_print_image('images/arrow-left-grey.png', true, ['class' => 'arrow_counter']); $output .= html_print_image('images/arrow-left-grey.png', true, ['class' => 'arrow_counter']);
$output .= html_print_image('images/arrow-right-grey.png', true, ['class' => 'arrow_counter']); $output .= html_print_image('images/arrow-right-grey.png', true, ['class' => 'arrow_counter']);
$output .= '</div>'; $output .= '</div>';
if ($preview === true) { if ($preview === true) {
$output .= '<button type="button" class="submit-next-tips ui-button ui-corner-all ui-widget" onclick="close_dialog()">Ok</button>'; $output .= html_print_button(
__('Ok'),
'next_tip',
false,
'',
[
'onclick' => 'close_dialog()',
'class' => 'mini',
],
true
);
} else { } else {
$output .= '<button type="button" class="submit-next-tips ui-button ui-corner-all ui-widget" onclick="next_tip()">Ok</button>'; $output .= html_print_button(
__('Ok'),
'next_tip',
false,
'',
[
'onclick' => 'next_tip()',
'class' => 'mini',
],
true
);
} }
$output .= '</div>'; $output .= '</div>';