'graphs', DEMO_NETWORK_MAP => 'network_maps', DEMO_GIS_MAP => 'gis_maps', DEMO_SERVICE => 'services', DEMO_REPORT => 'reports', DEMO_DASHBOARD => 'dashboards', DEMO_VISUAL_CONSOLE => 'visual_consoles', ]; $enabled_items = [ 'graphs' => (int) get_parameter('enable_cg', $def_value), 'network_maps' => (int) get_parameter('enable_nm', $def_value), 'gis_maps' => (int) get_parameter('enable_gis', $def_value), 'services' => (int) get_parameter('enable_services', $def_value), 'reports' => (int) get_parameter('enable_rep', $def_value), 'dashboards' => (int) get_parameter('enable_dashboards', $def_value), 'visual_consoles' => (int) get_parameter('enable_vc', $def_value), 'enable_history' => (int) get_parameter('enable_history', 0), ]; $generate_hist = (int) get_parameter('enable_history', $def_value); $plugin_agent = get_parameter('plugin_agent', 'demo-global-agent-1'); $traps_target_ip = get_parameter('traps_target_ip', '127.0.0.1'); $traps_community = get_parameter('traps_community', 'public'); $tentacle_target_ip = get_parameter('tentacle_target_ip', '127.0.0.1'); $tentacle_port = get_parameter('tentacle_port', '41121'); $tentacle_extra_options = get_parameter('tentacle_extra_options', ''); $demo_items_count = (int) db_get_value('count(*)', 'tdemo_data'); $current_progress_val = db_get_value_filter( 'value', 'tconfig', ['token' => 'demo_data_load_progress'], 'AND', false, false ); $current_progress_val_delete = db_get_value_filter( 'value', 'tconfig', ['token' => 'demo_data_delete_progress'], 'AND', false, false ); $running_create = ($current_progress_val > 0 && $current_progress_val < 100); $running_delete = ($current_progress_val_delete > 0 && $current_progress_val_delete < 100); // Real time loading. if ($display_loading === true || $running_create === true || $running_delete) { $table_load = new stdClass(); $table_load->id = 'table-demo'; $table_load->class = 'filter-table-adv'; $table_load->width = '100%'; $table_load->data = []; $table_load->size = []; $table_load->size[0] = '50%'; $table_load->size[1] = '50%'; $table_load->data['row0'][] = progress_bar( 0, 100, 20, '', 0, false, ((int) 0 !== -1) ? false : '#f3b200', [ 'class' => 'progress_bar', 'id' => 'progress_bar', ] ).html_print_input_hidden('js_timer_'.$operation['id'], 0, true); if ($create_data === true || $running_create === true) { // Map demo item ID to display name in page. $items_ids_text_map = [ DEMO_AGENT => 'agents', DEMO_SERVICE => 'services', DEMO_NETWORK_MAP => 'network maps', DEMO_GIS_MAP => 'GIS maps', DEMO_CUSTOM_GRAPH => 'custom graphs', DEMO_REPORT => 'custom reports', DEMO_VISUAL_CONSOLE => 'visual consoles', DEMO_DASHBOARD => 'dashboards', ]; if ((bool) $adv_options_is_enabled === true) { $enabled_keys = array_keys(array_filter($enabled_items)); $items_ids_text_map = array_filter( $items_ids_text_map, function ($k) use ($dir_item_id_map, $enabled_keys) { return in_array($dir_item_id_map[$k], $enabled_keys); }, ARRAY_FILTER_USE_KEY ); } if (enterprise_installed() === false) { unset($items_ids_text_map[DEMO_SERVICE]); } $items_ids_text_map[DEMO_PLUGIN] = 'plugin'; $items_ids_text_map = ([DEMO_AGENT => 'agents'] + $items_ids_text_map); $list_mkup = ''; } echo '
'; echo '
'; echo ''.__('Progress').''; html_print_table($table_load); echo $list_mkup; echo '
'; if ($create_data === true || $running_create === true) { $btn_span = __('View summary'); $icon = 'next'; } else { $btn_span = __('Back'); $icon = 'back'; } $action_btns = html_print_action_buttons( html_print_submit_button( $btn_span, 'redirect_button', false, ['icon' => $icon], true ), [], true ); // Only rendered when data creation has been completed. html_print_div( [ 'id' => 'action-btns-loading-done', 'class' => 'invisible', 'content' => $action_btns, ] ); echo '
'; } else { // Configuration. if ($demo_items_count === 0) { $table_aux = new stdClass(); $table_aux->id = 'table-demo'; $table_aux->class = 'filter-table-adv'; $table_aux->width = '100%'; $table_aux->data = []; $table_aux->size = []; $table_aux->size[0] = '50%'; $table_aux->size[1] = '50%'; $agent_sel_values = [ 30 => '30', 50 => '50', 500 => '500', 1000 => '1000', 2000 => '2000', ]; $agent_num = (int) get_parameter('agents_num'); $otherData = []; $table_aux->data['row1'][] = html_print_label_input_block( __('Agents').ui_print_help_tip(__('You may need to increase the value of the plugin_timeout parameter in your server configuration to get all your agents data updated'), true), html_print_div( [ 'class' => '', 'content' => html_print_select( $agent_sel_values, 'agents_num', $agents_num, '', '', 30, true, false, true, 'w80px' ), ], true ) ); $table_aux->data['row2'][] = html_print_label_input_block( __('Advanced options'), html_print_checkbox_switch( 'toggle_adv_opts', 1, false, true ) ); $table_adv = new stdClass(); $table_adv->id = 'table-adv'; $table_adv->class = 'filter-table-adv'; $table_adv->width = '100%'; $table_adv->data = []; $table_adv->size = []; $table_adv->size[0] = '50%'; $table_adv->size[1] = '50%'; $interval_select = html_print_extended_select_for_time( 'interval', $interval, '', '', '0', 10, true, false, true, 'w20p' ); $table_adv->data['row0'][] = html_print_label_input_block( __('Agents interval'), $interval_select ); $table_adv->data['row1'][] = html_print_label_input_block( __('Generate historical data for all agents'), html_print_checkbox_switch( 'enable_history', 1, (bool) $generate_hist, true ) ); $table_adv->data['row2'][] = html_print_label_input_block( __('Days of historical data to insert in the agent data'), html_print_input_text( 'days_hist_data', $days_hist_data, '', 10, 20, true, false, false, '', 'w80px' ) ); if (enterprise_installed() === true) { $table_adv->data['row3'][] = html_print_label_input_block( __('Create services'), html_print_checkbox_switch( 'enable_services', 1, $enabled_items['services'], true ) ); /* $table_adv->data['row4'][] = html_print_label_input_block( __('Services agent name').ui_print_help_tip(__('If not set, %s will be used as the default agent', 'demo-global-agent-1'), true), html_print_input_text( 'service_agent_name', $service_agent_name, '', 50, 255, true, false, false, '', 'w300px' ) ); */ } $table_adv->data['row5'][] = html_print_label_input_block( __('Create network maps'), html_print_checkbox_switch( 'enable_nm', 1, $enabled_items['network_maps'], true ) ); $table_adv->data['row6'][] = html_print_label_input_block( __('Create GIS maps'), html_print_checkbox_switch( 'enable_gis', 1, $enabled_items['gis_maps'], true ) ); $table_adv->data['row7'][] = html_print_label_input_block( __('Create custom graphs'), html_print_checkbox_switch( 'enable_cg', 1, $enabled_items['graphs'], true ) ); $table_adv->data['row8'][] = html_print_label_input_block( __('Create reports'), html_print_checkbox_switch( 'enable_rep', 1, $enabled_items['reports'], true ) ); $table_adv->data['row9'][] = html_print_label_input_block( __('Create visual consoles'), html_print_checkbox_switch( 'enable_vc', 1, $enabled_items['visual_consoles'], true ) ); $table_adv->data['row10'][] = html_print_label_input_block( __('Create dashboards'), html_print_checkbox_switch( 'enable_dashboards', 1, $enabled_items['dashboards'], true ) ); /* $table_adv->data['row11'][] = html_print_label_input_block( __('Demo data plugin agent'), html_print_input_text( 'plugin_agent', $plugin_agent, '', 50, 255, true, false, false, '', 'w300px' ) ); */ $table_adv->data['row12'][] = html_print_label_input_block( __('Traps target IP').ui_print_help_tip(__('All demo traps are generated using version 1'), true), html_print_input_text( 'traps_target_ip', $traps_target_ip, '', 50, 255, true, false, false, '', 'w300px' ) ); $table_adv->data['row13'][] = html_print_label_input_block( __('Traps community'), html_print_input_text( 'traps_community', $traps_community, '', 50, 255, true, false, false, '', 'w300px' ) ); $table_adv->data['row14'][] = html_print_label_input_block( __('Tentacle target IP'), html_print_input_text( 'tentacle_target_ip', $tentacle_target_ip, '', 50, 255, true, false, false, '', 'w300px' ) ); $table_adv->data['row15'][] = html_print_label_input_block( __('Tentacle port'), html_print_input_text( 'tentacle_port', $tentacle_port, '', 50, 255, true, false, false, '', 'w300px' ) ); $table_adv->data['row16'][] = html_print_label_input_block( __('Tentacle extra options'), html_print_input_text( 'tentacle_extra_options', $tentacle_extra_options, '', 50, 255, true, false, false, '', 'w300px' ) ); echo '
'; echo '
'; echo ''.__('Configure demo data').''; html_print_input_hidden('create_data', 1); html_print_input_hidden('display_loading', 1); html_print_table($table_aux); html_print_div( [ 'class' => 'invisible', 'content' => html_print_table($table_adv), ], true ); echo '
'; $actionButtons = []; $actionButtons[] = html_print_submit_button( __('Create demo data'), 'create_button', false, [ 'icon' => 'update', 'fixed_id' => 'btn-create-demo-data', ], true ); // echo ''; echo '
'; } else { // Summary data. $demo_agents_count = (int) db_get_value('count(*)', 'tdemo_data', 'table_name', 'tagente'); $demo_services_count = (int) db_get_value('count(*)', 'tdemo_data', 'table_name', 'tservice'); $demo_nm_count = (int) db_get_value('count(*)', 'tdemo_data', 'table_name', 'tmap'); $demo_gis_count = (int) db_get_value('count(*)', 'tdemo_data', 'table_name', 'tgis_map'); $demo_cg_count = (int) db_get_value('count(*)', 'tdemo_data', 'table_name', 'tgraph'); $demo_rep_count = (int) db_get_value('count(*)', 'tdemo_data', 'table_name', 'treport'); $demo_vc_count = (int) db_get_value('count(*)', 'tdemo_data', 'table_name', 'tlayout'); $demo_dashboards_count = (int) db_get_value('count(*)', 'tdemo_data', 'table_name', 'tdashboard'); $table_summary = new stdClass(); $table_summary->id = 'table-summary'; $table_summary->class = 'filter-table-adv'; $table_summary->width = '100%'; $table_summary->data = []; $table_summary->size = []; $table_summary->size[0] = '50%'; $table_summary->size[1] = '50%'; $i = 0; $table_summary->data[$i][0] = __('Agents'); $table_summary->data[$i][1] = ($demo_agents_count > 0) ? $demo_agents_count : '-'; $i++; if (enterprise_installed() === true) { $table_summary->data[$i][0] = __('Services'); $table_summary->data[$i][1] = ($demo_services_count > 0) ? $demo_services_count : '-'; $i++; } $i++; $table_summary->data[$i][0] = __('Network maps'); $table_summary->data[$i][1] = ($demo_nm_count > 0) ? $demo_nm_count : '-'; $i++; $table_summary->data[$i][0] = __('GIS maps'); $table_summary->data[$i][1] = ($demo_gis_count > 0) ? $demo_gis_count : '-'; $i++; $table_summary->data[$i][0] = __('Custom graphs'); $table_summary->data[$i][1] = ($demo_cg_count > 0) ? $demo_cg_count : '-'; $i++; $table_summary->data[$i][0] = __('Custom reports'); $table_summary->data[$i][1] = ($demo_rep_count > 0) ? $demo_rep_count : '-'; $i++; $table_summary->data[$i][0] = __('Visual consoles'); $table_summary->data[$i][1] = ($demo_vc_count > 0) ? $demo_vc_count : '-'; $i++; $table_summary->data[$i][0] = __('Dashboards'); $table_summary->data[$i][1] = ($demo_dashboards_count > 0) ? $demo_dashboards_count : '-'; echo '
'; echo '
'; echo ''.__('Active demo data summary').''; html_print_table($table_summary); echo '
'; html_print_input_hidden('delete_data', 1); html_print_input_hidden('display_loading', 1); html_print_action_buttons( html_print_submit_button( __('Delete all demo data'), 'delete_button', false, [ 'icon' => 'delete', 'mode' => 'secondary', 'fixed_id' => 'btn-delete-demo-data', ], true ) ); echo '
'; } } ?>