#11117 Fix homscreen in metaconsole

This commit is contained in:
miguel angel rasteu 2023-05-19 10:49:16 +02:00
parent 1860baac0c
commit efc2990a5c
4 changed files with 89 additions and 44 deletions

View File

@ -0,0 +1,16 @@
START TRANSACTION;
UPDATE `tnetwork_component`
SET module_enabled=1
WHERE name='Cisco _nameOID_ power state';
ALTER TABLE `tlayout_data`
ADD COLUMN `recursive_group` TINYINT NOT NULL DEFAULT '0' AFTER `fill_color`;
ALTER TABLE `tusuario`
ADD COLUMN `metaconsole_section` VARCHAR(255) NOT NULL DEFAULT 'Default' AFTER `data_section`;
ALTER TABLE `tusuario`
ADD COLUMN `metaconsole_data_section` VARCHAR(255) NOT NULL DEFAULT '' AFTER `metaconsole_section`;
COMMIT;

View File

@ -73,6 +73,12 @@ if ($id !== $config['id_user']) {
// ID given as parameter.
$pure = get_parameter('pure', 0);
$user_info = get_user_info($id);
if (is_metaconsole() === true) {
$user_info['section'] = $user_info['metaconsole_section'];
$user_info['data_section'] = $user_info['metaconsole_data_section'];
}
$is_err = false;
if (is_ajax() === true) {

View File

@ -608,42 +608,51 @@ $userManagementTable->data['fields_blocksize_eventfilter'][1] = html_print_selec
false,
false
);
if (is_metaconsole() === false) {
// Home screen table.
$homeScreenTable = new stdClass();
$homeScreenTable->class = 'w100p full_section';
$homeScreenTable->id = 'home_screen_table';
$homeScreenTable->style = [];
$homeScreenTable->rowclass = [];
$homeScreenTable->data = [];
// Home screen.
$homeScreenTable->data['captions_homescreen'][0] = __('Home screen');
$homeScreenTable->colspan['captions_homescreen'][0] = 2;
$homeScreenTable->rowclass['captions_homescreen'] = 'field_half_width';
$homeScreenTable->rowclass['fields_homescreen'] = 'field_half_width flex';
$homeScreenTable->data['fields_homescreen'][0] = html_print_select(
$homeScreenValues,
'section',
io_safe_output($user_info['section']),
'show_data_section();',
'',
-1,
true,
false,
false
);
$homeScreenTable->data['fields_homescreen'][1] = html_print_div(
[
'class' => 'w100p',
'content' => $customHomeScreenDataField,
],
true
);
$userManagementTable->rowclass['homescreen_table'] = 'w100p';
$userManagementTable->data['homescreen_table'] = html_print_table($homeScreenTable, true);
// Home screen table.
$homeScreenTable = new stdClass();
$homeScreenTable->class = 'w100p full_section';
$homeScreenTable->id = 'home_screen_table';
$homeScreenTable->style = [];
$homeScreenTable->rowclass = [];
$homeScreenTable->data = [];
// Home screen.
$homeScreenTable->data['captions_homescreen'][0] = __('Home screen');
$homeScreenTable->colspan['captions_homescreen'][0] = 2;
$homeScreenTable->rowclass['captions_homescreen'] = 'field_half_width';
$homeScreenTable->rowclass['fields_homescreen'] = 'field_half_width flex';
$selected_homescreen = $user_info['section'];
foreach ($homeScreenValues as $key => $value) {
if ($value === $selected_homescreen) {
$selected_homescreen = $key;
break;
}
}
$homeScreenTable->data['fields_homescreen'][0] = html_print_select(
$homeScreenValues,
'section',
$selected_homescreen,
'show_data_section();',
'',
-1,
true,
false,
false
);
$homeScreenTable->data['fields_homescreen'][1] = html_print_div(
[
'class' => 'w100p',
'content' => $customHomeScreenDataField,
],
true
);
$userManagementTable->rowclass['homescreen_table'] = 'w100p';
$userManagementTable->data['homescreen_table'] = html_print_table($homeScreenTable, true);
if (is_metaconsole() === true && users_is_admin() === true) {
$userManagementTable->rowclass['search_custom1_looknfeel'] = 'field_half_width';
$userManagementTable->rowclass['search_custom2_looknfeel'] = 'field_half_width flex-column';

View File

@ -801,13 +801,31 @@ function update_user(string $id_user, array $values)
return false;
}
if (is_metaconsole() === true) {
unset($values['id_skin']);
unset($values['section']);
unset($values['default_event_filter']);
$update_user_metaconsole = true;
} else {
$update_user_metaconsole = false;
if (isset($values['section']) === true) {
$homeScreenValues = [
HOME_SCREEN_DEFAULT => __('Default'),
HOME_SCREEN_VISUAL_CONSOLE => __('Visual console'),
HOME_SCREEN_EVENT_LIST => __('Event list'),
HOME_SCREEN_GROUP_VIEW => __('Group view'),
HOME_SCREEN_TACTICAL_VIEW => __('Tactical view'),
HOME_SCREEN_ALERT_DETAIL => __('Alert detail'),
HOME_SCREEN_EXTERNAL_LINK => __('External link'),
HOME_SCREEN_OTHER => __('Other'),
HOME_SCREEN_DASHBOARD => __('Dashboard'),
];
if (array_key_exists($values['section'], $homeScreenValues) === true) {
$values['section'] = $homeScreenValues[$values['section']];
}
if (is_metaconsole() === true) {
$values['metaconsole_section'] = $values['section'];
$values['metaconsole_data_section'] = $values['data_section'];
unset($values['id_skin']);
unset($values['section']);
unset($values['data_section']);
unset($values['default_event_filter']);
}
}
$output = db_process_sql_update('tusuario', $values, ['id_user' => $id_user]);
@ -847,10 +865,6 @@ function update_user(string $id_user, array $values)
}
}
if ($update_user_metaconsole === true) {
$output = 1;
}
return $output;
}