implement demo data load
This commit is contained in:
parent
1fcc263046
commit
d6bffbade1
|
@ -507,7 +507,7 @@ if ($access_console_node === true) {
|
|||
enterprise_hook('skins_submenu');
|
||||
|
||||
|
||||
$sub['godmode/setup/demo']['text'] = __('Demo');
|
||||
$sub['godmode/setup/demo']['text'] = __('Demo data');
|
||||
$sub['godmode/setup/demo']['id'] = 'demo';
|
||||
|
||||
$menu_godmode['gsetup']['sub'] = $sub;
|
||||
|
|
|
@ -38,6 +38,7 @@ config_update_value('demo_data_load_progress', 0);
|
|||
|
||||
html_print_input_hidden('demo_items_count', 0);
|
||||
|
||||
$agents_num = (int) get_parameter('agents_num', 30);
|
||||
$submit_value = (string) get_parameter('update_button', '');
|
||||
$demo_items_count = db_get_value('count(*)', 'tdemo_data');
|
||||
$demo_agents_count = db_get_value('count(*)', 'tdemo_data', 'table_name', 'tagente');
|
||||
|
@ -130,7 +131,7 @@ $table_aux->data['row1'][] = html_print_label_input_block(
|
|||
'content' => html_print_select(
|
||||
$arraySelectIcon,
|
||||
'agents_num',
|
||||
$config['gis_default_icon'],
|
||||
$agents_num,
|
||||
'',
|
||||
'30',
|
||||
30,
|
||||
|
@ -291,10 +292,14 @@ $actionButtons[] = html_print_submit_button(
|
|||
true
|
||||
);
|
||||
|
||||
echo '<div id="btn-set" style="display:none;">';
|
||||
|
||||
html_print_action_buttons(
|
||||
implode('', $actionButtons)
|
||||
);
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</form>';
|
||||
?>
|
||||
|
||||
|
@ -308,9 +313,11 @@ echo '</form>';
|
|||
var agents_str = '<?php echo __('agents'); ?>';
|
||||
var delete_demo_data_str = '<?php echo __('Delete demo data'); ?>';
|
||||
|
||||
|
||||
|
||||
$('#btn-set').show();
|
||||
if (demo_agents_count > 0) {
|
||||
$('#span-btn-delete-demo-data').text(delete_demo_data_str+' ('+demo_agents_count+')');
|
||||
$('#btn-create-demo-data').hide();
|
||||
$('#btn-delete-demo-data').show();
|
||||
}
|
||||
|
||||
|
@ -326,7 +333,7 @@ echo '</form>';
|
|||
var params = {};
|
||||
params["action"] = "create_demo_data";
|
||||
params["page"] = "include/ajax/demo_data.ajax";
|
||||
params["agents_num"] = $('#agents_num').val();
|
||||
params["agents_num"] = <?php echo $agents_num; ?>;
|
||||
|
||||
jQuery.ajax({
|
||||
data: params,
|
||||
|
@ -335,13 +342,16 @@ echo '</form>';
|
|||
dataType: 'json',
|
||||
success: function(data) {
|
||||
if (data.agents_count > 0) {
|
||||
$('#btn-create-demo-data').hide();
|
||||
$('#span-btn-delete-demo-data').text(delete_demo_data_str+' ('+data.agents_count+')');
|
||||
$('#agent-count-span').text('('+(data.agents_count ?? 0)+' '+agent_count_span_str+')');
|
||||
$('#btn-delete-demo-data').show();
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
console.log("ERROR");
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
// Handle error
|
||||
console.log('Error: ' + textStatus + ' - ' + errorThrown);
|
||||
console.log(jqXHR.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -362,6 +372,7 @@ echo '</form>';
|
|||
$('#span-btn-delete-demo-data').text(delete_demo_data_str);
|
||||
$('#agent-count-span').text('('+(data.agents_count ?? 0)+' '+agent_count_span_str+')');
|
||||
$('#btn-delete-demo-data').hide();
|
||||
$('#btn-create-demo-data').show();
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
console.log("ERROR");
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1158,7 +1158,7 @@ class WelcomeWindow extends Wizard
|
|||
|
||||
// Task to do actions.
|
||||
function loadDemoDataPage() {
|
||||
window.location = '<?php echo ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&show_deploy_agent=1'); ?>';
|
||||
window.location = '<?php echo ui_get_full_url('index.php?sec=gagente&sec2=godmode/setup/demo'); ?>';
|
||||
}
|
||||
|
||||
function openCreateModulesDialog() {
|
||||
|
|
|
@ -655,7 +655,7 @@ function mysql_encapsule_fields_with_same_name_to_instructions($field)
|
|||
*
|
||||
* @return mixed Value of first column of the first row. False if there were no row.
|
||||
*/
|
||||
function mysql_db_get_value_filter($field, $table, $filter, $where_join='AND', $search_history_db=false)
|
||||
function mysql_db_get_value_filter($field, $table, $filter, $where_join='AND', $search_history_db=false, $cache=true)
|
||||
{
|
||||
if (!is_array($filter) || empty($filter)) {
|
||||
return false;
|
||||
|
@ -672,7 +672,7 @@ function mysql_db_get_value_filter($field, $table, $filter, $where_join='AND', $
|
|||
db_format_array_where_clause_sql($filter, $where_join)
|
||||
);
|
||||
|
||||
$result = db_get_all_rows_sql($sql, $search_history_db);
|
||||
$result = db_get_all_rows_sql($sql, $search_history_db, $cache);
|
||||
|
||||
if ($result === false) {
|
||||
return false;
|
||||
|
@ -1022,7 +1022,11 @@ function mysql_db_get_row_filter($table, $filter, $fields=false, $where_join='AN
|
|||
}
|
||||
|
||||
$sql = sprintf('SELECT %s FROM %s %s', $fields, $table, $filter);
|
||||
|
||||
if ($table==='tagente_modulo') {
|
||||
hd("QUERYYYYYY", true);
|
||||
hd($sql, true);
|
||||
}
|
||||
|
||||
return db_get_row_sql($sql, $historydb, $cache);
|
||||
}
|
||||
|
||||
|
|
|
@ -574,7 +574,7 @@ function oracle_encapsule_fields_with_same_name_to_instructions($field)
|
|||
*
|
||||
* @return mixed Value of first column of the first row. False if there were no row.
|
||||
*/
|
||||
function oracle_db_get_value_filter($field, $table, $filter, $where_join='AND', $search_history_db=false)
|
||||
function oracle_db_get_value_filter($field, $table, $filter, $where_join='AND', $search_history_db=false, $cache=true)
|
||||
{
|
||||
if (! is_array($filter) || empty($filter)) {
|
||||
return false;
|
||||
|
@ -590,7 +590,7 @@ function oracle_db_get_value_filter($field, $table, $filter, $where_join='AND',
|
|||
$table,
|
||||
db_format_array_where_clause_sql($filter, $where_join)
|
||||
);
|
||||
$result = db_get_all_rows_sql($sql, $search_history_db);
|
||||
$result = db_get_all_rows_sql($sql, $search_history_db, $cache);
|
||||
|
||||
if ($result === false) {
|
||||
return false;
|
||||
|
|
|
@ -474,7 +474,7 @@ function postgresql_encapsule_fields_with_same_name_to_instructions($field)
|
|||
*
|
||||
* @return mixed Value of first column of the first row. False if there were no row.
|
||||
*/
|
||||
function postgresql_db_get_value_filter($field, $table, $filter, $where_join='AND', $search_history_db=false)
|
||||
function postgresql_db_get_value_filter($field, $table, $filter, $where_join='AND', $search_history_db=false, $cache=true)
|
||||
{
|
||||
if (! is_array($filter) || empty($filter)) {
|
||||
return false;
|
||||
|
@ -496,7 +496,7 @@ function postgresql_db_get_value_filter($field, $table, $filter, $where_join='AN
|
|||
db_format_array_where_clause_sql($filter, $where_join)
|
||||
);
|
||||
|
||||
$result = db_get_all_rows_sql($sql, $search_history_db);
|
||||
$result = db_get_all_rows_sql($sql, $search_history_db, $cache);
|
||||
|
||||
$row = array_shift($result);
|
||||
$value = array_shift($row);
|
||||
|
|
|
@ -380,21 +380,21 @@ function db_get_value(
|
|||
*
|
||||
* @return mixed Value of first column of the first row. False if there were no row.
|
||||
*/
|
||||
function db_get_value_filter($field, $table, $filter, $where_join='AND', $search_history_db=false)
|
||||
function db_get_value_filter($field, $table, $filter, $where_join='AND', $search_history_db=false, $cache=true)
|
||||
{
|
||||
global $config;
|
||||
|
||||
switch ($config['dbtype']) {
|
||||
case 'mysql':
|
||||
return mysql_db_get_value_filter($field, $table, $filter, $where_join, $search_history_db);
|
||||
return mysql_db_get_value_filter($field, $table, $filter, $where_join, $search_history_db, $cache);
|
||||
|
||||
break;
|
||||
case 'postgresql':
|
||||
return postgresql_db_get_value_filter($field, $table, $filter, $where_join, $search_history_db);
|
||||
return postgresql_db_get_value_filter($field, $table, $filter, $where_join, $search_history_db, $cache);
|
||||
|
||||
break;
|
||||
case 'oracle':
|
||||
return oracle_db_get_value_filter($field, $table, $filter, $where_join, $search_history_db);
|
||||
return oracle_db_get_value_filter($field, $table, $filter, $where_join, $search_history_db, $cache);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue