#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['default_event_filter'] = (int) get_parameter('default_event_filter');
$values['default_custom_view'] = (int) get_parameter('default_custom_view');
$values['show_tips_startup'] = (int) get_parameter_switch('show_tips_startup');
// API Token information.
$apiTokenRenewed = (bool) get_parameter('renewAPIToken');
$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.'),
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.
$userManagementTable->rowclass['captions_userSessionTime'] = 'field_half_width';

View File

@ -113,13 +113,13 @@ class TipsWindow
public function run()
{
global $config;
$_SESSION['showed_tips_window'] = true;
$userInfo = users_get_user_by_id($config['id_user']);
if ((bool) $userInfo['show_tips_startup'] === false) {
return;
}
$_SESSION['showed_tips_window'] = true;
ui_require_css_file('tips_window');
ui_require_css_file('jquery.bxslider');
ui_require_javascript_file('tipsWindow');
@ -479,7 +479,10 @@ class TipsWindow
__('Create tip'),
'create',
false,
'class="sub next"'
[
'class' => 'sub',
'icon' => 'create_file',
]
);
echo '</a>';
echo '</div>';
@ -583,22 +586,23 @@ class TipsWindow
$data[$key]['url'] = io_safe_output($row['url']);
$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'] .= html_print_input_image(
'button_edit_tip',
'images/edit.png',
'',
'',
true
$data[$key]['actions'] .= html_print_image(
'images/edit.svg',
true,
['class' => 'main_menu_icon']
);
$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'] .= html_print_input_image(
'button_delete_tip',
'images/delete.png',
'images/delete.svg',
'',
'',
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'] .= '</form>';
@ -706,7 +710,7 @@ class TipsWindow
$table->data[3][0] = __('Title');
$table->data[3][1] = html_print_input_text('title', '', '', 35, 100, true);
$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][1] = html_print_input_text('url', '', '', 35, 100, true);
$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">';
html_print_table($table);
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(
__('Preview'),
'preview_button',
@ -722,9 +735,9 @@ class TipsWindow
[
'class' => 'sub preview',
'id' => 'prev_button',
'icon' => 'preview',
]
);
html_print_submit_button(__('Send'), 'submit_button', false, ['class' => 'sub next']);
echo '</div>';
echo '</form>';
html_print_div(['id' => 'tips_window_modal_preview']);
@ -770,11 +783,14 @@ class TipsWindow
$imageTip = html_print_image($namePath, true);
$imageTip .= html_print_input_image(
'delete_image_tip',
'images/delete.png',
'images/delete.svg',
'',
'',
true,
['onclick' => 'deleteImage(this, \''.$value['id'].'\', \''.$namePath.'\')']
[
'onclick' => 'deleteImage(this, \''.$value['id'].'\', \''.$namePath.'\')',
'class' => 'remove-image',
]
);
$outputImagesTip .= html_print_div(
[
@ -828,7 +844,7 @@ class TipsWindow
$table->data[3][0] = __('Title');
$table->data[3][1] = html_print_input_text('title', $tip['title'], '', 35, 100, true);
$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][1] = html_print_input_text('url', $tip['url'], '', 35, 100, true);
$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">';
html_print_table($table);
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(
__('Preview'),
'preview_button',
@ -844,9 +869,9 @@ class TipsWindow
[
'class' => 'sub preview',
'id' => 'prev_button',
'icon' => 'preview',
]
);
html_print_submit_button(__('Send'), 'submit_button', false, ['class' => 'sub next']);
echo '</div>';
echo '</form>';

View File

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

View File

@ -10491,6 +10491,11 @@ button div.create_directory {
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 {
animation: rotation 4s infinite linear;
}

View File

@ -24,6 +24,8 @@
height: fit-content;
background-color: white;
color: #161628;
border-top-left-radius: 25px !important;
border-top-right-radius: 25px !important;
}
.tips_header .title {
font-size: 15px;
@ -124,6 +126,7 @@
#tips_window_modal_preview .ui-dialog-buttonset button {
margin: 0px 20px !important;
margin-top: 10px !important;
min-width: fit-content;
}
.dialog_tips .ui-dialog-buttonset {
border-bottom-right-radius: 10px !important;
@ -201,7 +204,10 @@ span.disable {
#notices_images {
color: #e63c52;
}
.preview {
background-position: 92% 10px !important;
margin-right: 20px !important;
.remove-image {
max-width: 35px;
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['id_skin'] = get_parameter('skin', $user_info['id_skin']);
$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']);
@ -585,23 +584,6 @@ if ((bool) check_acl($config['id_user'], 0, 'ER') === true) {
).'</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 = [];
if (is_metaconsole() === false || is_centralized() === true) {
$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>
<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;

View File

@ -37,7 +37,7 @@ $output .= '<p>'.html_print_checkbox(
true,
true,
false,
'',
'show_tips_startup(this)',
false,
'',
($preview === true) ? '' : 'checkbox_tips_startup'
@ -81,15 +81,45 @@ $output .= '</div>';
$output .= '<div class="ui-dialog-buttonset">';
// 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 .= 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 .= '</div>';
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 {
$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>';