2009-03-09 Evi Vanoost <vanooste@rcbi.rochester.edu>
* include/javascript/pandora.js: Moved agent_changed here from map_builder because it's quite a useful function. * include/functions_visual_map.php: In case you want no labels (a lot of icons on a graph) just set the color to anything not starting with # * godmode/reporting/map_builder_wizard.php: Added the possibility to add modules as well using the wizard. Very useful if you have a switch. * godmode/reporting/map_builder.php: Fixed some issues with the ajax thing and fixed issue #2527894. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1521 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
838b82448e
commit
7feab70ec5
|
@ -1,3 +1,17 @@
|
||||||
|
2009-03-09 Evi Vanoost <vanooste@rcbi.rochester.edu>
|
||||||
|
|
||||||
|
* include/javascript/pandora.js: Moved agent_changed here from map_builder
|
||||||
|
because it's quite a useful function.
|
||||||
|
|
||||||
|
* include/functions_visual_map.php: In case you want no labels (a lot of
|
||||||
|
icons on a graph) just set the color to anything not starting with #
|
||||||
|
|
||||||
|
* godmode/reporting/map_builder_wizard.php: Added the possibility to add
|
||||||
|
modules as well using the wizard. Very useful if you have a switch.
|
||||||
|
|
||||||
|
* godmode/reporting/map_builder.php: Fixed some issues with the ajax thing
|
||||||
|
and fixed issue #2527894.
|
||||||
|
|
||||||
2009-03-05 Evi Vanoost <vanooste@rcbi.rochester.edu>
|
2009-03-05 Evi Vanoost <vanooste@rcbi.rochester.edu>
|
||||||
|
|
||||||
* godmode/reporting/map_builder_wizard.php: Fixed small error when no
|
* godmode/reporting/map_builder_wizard.php: Fixed small error when no
|
||||||
|
|
|
@ -88,9 +88,9 @@ if ($delete_layout) {
|
||||||
|
|
||||||
if ($update_layout) {
|
if ($update_layout) {
|
||||||
$name = (string) get_parameter ('name');
|
$name = (string) get_parameter ('name');
|
||||||
$id_group = (int) get_parameter ('id_group');
|
$id_group = (int) get_parameter ('id_group', 1);
|
||||||
$width = (int) get_parameter ('width');
|
$width = (int) get_parameter ('width', 0);
|
||||||
$height = (int) get_parameter ('height');
|
$height = (int) get_parameter ('height', 0);
|
||||||
$background = (string) get_parameter ('background');
|
$background = (string) get_parameter ('background');
|
||||||
$bg_info = array (0, 0);
|
$bg_info = array (0, 0);
|
||||||
if (file_exists ('images/console/background/'.$background))
|
if (file_exists ('images/console/background/'.$background))
|
||||||
|
@ -101,15 +101,10 @@ if ($update_layout) {
|
||||||
if (! $height)
|
if (! $height)
|
||||||
$height = $bg_info[1];
|
$height = $bg_info[1];
|
||||||
|
|
||||||
$result = process_sql_update ('tlayout',
|
$result = process_sql_update ('tlayout', array ('name' => $name, 'background' => $background, 'height' => $height, 'width' => $width, 'id_group' => $id_group), array ('id' => $id_layout));
|
||||||
array ('name' => $name, 'background' => $background,
|
|
||||||
'height' => $height, 'width' => $width),
|
print_error_message ($result, __('Update layout successful'), __('Update layout failed'));
|
||||||
array ('id' => $id_layout));
|
|
||||||
if ($result) {
|
|
||||||
echo '<h3 class="suc">'.__('Update layout successful').'</h3>';
|
|
||||||
} else {
|
|
||||||
echo '<h3 class="err">'.__('Update layout failed').'</h3>';
|
|
||||||
}
|
|
||||||
if (is_ajax ()) {
|
if (is_ajax ()) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
@ -377,18 +372,18 @@ if (! $edit_layout && ! $id_layout) {
|
||||||
|
|
||||||
/* Layout_data editor form */
|
/* Layout_data editor form */
|
||||||
$intervals = array ();
|
$intervals = array ();
|
||||||
$intervals[1] = __('Hour');
|
$intervals[3600] = __('Hour');
|
||||||
$intervals[2] = "2 ".__('Hours');
|
$intervals[7200] = "2 ".__('Hours');
|
||||||
$intervals[3] = "3 ".__('Hours');
|
$intervals[10800] = "3 ".__('Hours');
|
||||||
$intervals[6] = "6 ".__('Hours');
|
$intervals[21600] = "6 ".__('Hours');
|
||||||
$intervals[12] = "12 ".__('Hours');
|
$intervals[43200] = "12 ".__('Hours');
|
||||||
$intervals[24] = __('Last day');
|
$intervals[86400] = __('Last day');
|
||||||
$intervals[48] = "2 ". __('days');
|
$intervals[172800] = "2 ". __('days');
|
||||||
$intervals[168] = __('Last week');
|
$intervals[1209600] = __('Last week');
|
||||||
$intervals[360] = __('15 days');
|
$intervals[2419200] = __('15 days');
|
||||||
$intervals[720] = __('Last Month');
|
$intervals[4838400] = __('Last Month');
|
||||||
$intervals[1440] = __('Two Months');
|
$intervals[9676800] = __('Two Months');
|
||||||
$intervals[4320] = __('Six Months');
|
$intervals[29030400] = __('Six Months');
|
||||||
|
|
||||||
$agents = get_group_agents ($id_group);
|
$agents = get_group_agents ($id_group);
|
||||||
|
|
||||||
|
@ -451,33 +446,6 @@ require_javascript_file ('wz_jsgraphics');
|
||||||
require_javascript_file ('pandora_visual_console');
|
require_javascript_file ('pandora_visual_console');
|
||||||
?>
|
?>
|
||||||
<script language="javascript" type="text/javascript">
|
<script language="javascript" type="text/javascript">
|
||||||
function agent_changed (event, id_agent, selected) {
|
|
||||||
if (id_agent == undefined)
|
|
||||||
id_agent = this.value;
|
|
||||||
$('#form_layout_data_editor #module').attr ('disabled', 1);
|
|
||||||
$('#form_layout_data_editor #module').empty ();
|
|
||||||
$('#form_layout_data_editor #module').append ($('<option></option>').html ("<?php echo __('Loading'); ?>...").attr ("value", 0));
|
|
||||||
jQuery.post ('ajax.php',
|
|
||||||
{"page": "operation/agentes/ver_agente",
|
|
||||||
"get_agent_modules_json": 1,
|
|
||||||
"id_agent": id_agent
|
|
||||||
},
|
|
||||||
function (data) {
|
|
||||||
$('#form_layout_data_editor #module').empty ();
|
|
||||||
$('#form_layout_data_editor #module').append ($('<option></option>').html ("<?php echo __('Any')?>").attr ("value", 0));
|
|
||||||
jQuery.each (data, function (i, val) {
|
|
||||||
s = html_entity_decode (val['nombre']);
|
|
||||||
$('#form_layout_data_editor #module').append ($('<option></option>').html (s).attr ("value", val['id_agente_modulo']));
|
|
||||||
$('#form_layout_data_editor #module').fadeIn ('normal');
|
|
||||||
});
|
|
||||||
if (selected != undefined)
|
|
||||||
$('#form_layout_data_editor #module').attr ('value', selected);
|
|
||||||
$('#form_layout_data_editor #module').attr ('disabled', 0);
|
|
||||||
},
|
|
||||||
"json"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$(document).ready (function () {
|
$(document).ready (function () {
|
||||||
<?php if ($id_layout): ?>
|
<?php if ($id_layout): ?>
|
||||||
if (lines)
|
if (lines)
|
||||||
|
@ -554,7 +522,7 @@ $(document).ready (function () {
|
||||||
$("#form_layout_data_editor #text-height").attr ('value', data['height']);
|
$("#form_layout_data_editor #text-height").attr ('value', data['height']);
|
||||||
$("#form_layout_data_editor #image").change ();
|
$("#form_layout_data_editor #image").change ();
|
||||||
$("#form_layout_data_editor #id_layout_data").attr ('value', data['id']);
|
$("#form_layout_data_editor #id_layout_data").attr ('value', data['id']);
|
||||||
$("#form_layout_data_editor #period").attr ('value', data['period'] / 3600);
|
$("#form_layout_data_editor #period").attr ('value', data['period']);
|
||||||
$("#form_layout_data_editor #agent").attr ('value', data['id_agent']);
|
$("#form_layout_data_editor #agent").attr ('value', data['id_agent']);
|
||||||
$("#form_layout_data_editor #parent_item").attr ('value', data['parent_item']);
|
$("#form_layout_data_editor #parent_item").attr ('value', data['parent_item']);
|
||||||
$("#form_layout_data_editor #map_linked").attr ('value', data['id_layout_linked']);
|
$("#form_layout_data_editor #map_linked").attr ('value', data['id_layout_linked']);
|
||||||
|
|
|
@ -42,9 +42,9 @@ if (! give_acl ($config['id_user'], $layout_group, "AW")) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
function process_wizard_add ($id_agents, $image, $id_layout, $range) {
|
function process_wizard_add ($id_agents, $image, $id_layout, $range, $width = 0, $height = 0) {
|
||||||
if (empty ($id_agents)) {
|
if (empty ($id_agents)) {
|
||||||
echo '<h3 class="error">'.__('No agents selected').'</h3>';
|
print_error_message (false, '', __('No agents selected'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,31 +60,78 @@ function process_wizard_add ($id_agents, $image, $id_layout, $range) {
|
||||||
}
|
}
|
||||||
|
|
||||||
process_sql_insert ('tlayout_data',
|
process_sql_insert ('tlayout_data',
|
||||||
array ('id_layout' => $id_layout,
|
array ('id_layout' => $id_layout,
|
||||||
'pos_x' => $pos_x,
|
'pos_x' => $pos_x,
|
||||||
'pos_y' => $pos_y,
|
'pos_y' => $pos_y,
|
||||||
'label' => get_agent_name ($id_agent),
|
'label' => get_agent_name ($id_agent),
|
||||||
'image' => $image,
|
'image' => $image,
|
||||||
'id_agent' => $id_agent,
|
'id_agent' => $id_agent,
|
||||||
'label_color' => '#000000'));
|
'width' => $width,
|
||||||
|
'height' => $height,
|
||||||
|
'label_color' => '#000000')
|
||||||
|
);
|
||||||
|
|
||||||
$pos_x = $pos_x + $range;
|
$pos_x = $pos_x + $range;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '<h3 class="suc">'.__('Successfully added').'</h3>';
|
print_error_message (true, __('Agent successfully added to layout'), '');
|
||||||
echo '<h3><a href="index.php?sec=greporting&sec2=godmode/reporting/map_builder&id_layout='.$id_layout.'">'.__('Map builder').'</a></h3>';
|
echo '<h3><a href="index.php?sec=greporting&sec2=godmode/reporting/map_builder&id_layout='.$id_layout.'">'.__('Map builder').'</a></h3>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function process_wizard_add_modules ($id_modules, $image, $id_layout, $range, $width = 0, $height = 0) {
|
||||||
|
if (empty ($id_modules)) {
|
||||||
|
print_error_message (false, '', __('No modules selected'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$id_modules = (array) $id_modules;
|
||||||
|
|
||||||
|
$error = false;
|
||||||
|
$pos_y = 10;
|
||||||
|
$pos_x = 10;
|
||||||
|
|
||||||
|
foreach ($id_modules as $id_module) {
|
||||||
|
if ($pos_x > 600) {
|
||||||
|
$pos_x = 10;
|
||||||
|
$pos_y = $pos_y + $range;
|
||||||
|
}
|
||||||
|
|
||||||
|
$id_agent = get_agentmodule_agent ($id_module);
|
||||||
|
|
||||||
|
process_sql_insert ('tlayout_data',
|
||||||
|
array ('id_layout' => $id_layout,
|
||||||
|
'pos_x' => $pos_x,
|
||||||
|
'pos_y' => $pos_y,
|
||||||
|
'label' => get_agentmodule_name ($id_module),
|
||||||
|
'image' => $image,
|
||||||
|
'id_agent' => $id_agent,
|
||||||
|
'id_agente_modulo' => $id_module,
|
||||||
|
'width' => $width,
|
||||||
|
'height' => $height,
|
||||||
|
'label_color' => '#000000')
|
||||||
|
);
|
||||||
|
|
||||||
|
$pos_x = $pos_x + $range;
|
||||||
|
}
|
||||||
|
|
||||||
|
print_error_message (true, __('Modules successfully added to layout'), '');
|
||||||
|
}
|
||||||
|
|
||||||
echo '<h2>'.__('Visual map wizard').' - '.$layout["name"].'</h2>';
|
echo '<h2>'.__('Visual map wizard').' - '.$layout["name"].'</h2>';
|
||||||
|
|
||||||
$id_agents = get_parameter ('id_agents');
|
$id_agents = get_parameter ('id_agents', array ());
|
||||||
|
$id_modules = get_parameter ('module', array ());
|
||||||
$image = get_parameter ('image');
|
$image = get_parameter ('image');
|
||||||
$add = (bool) get_parameter ('add', false);
|
$add = (bool) get_parameter ('add', false);
|
||||||
$range = get_parameter ("range", 50);
|
$range = (int) get_parameter ("range", 50);
|
||||||
|
$width = (int) get_parameter ("width", 0);
|
||||||
|
$height = (int) get_parameter ("height", 0);
|
||||||
|
|
||||||
if ($add) {
|
if ($add) {
|
||||||
process_wizard_add ($id_agents, $image, $layout["id"], $range);
|
process_wizard_add ($id_agents, $image, $layout["id"], $range, $width, $height);
|
||||||
|
if (!empty ($id_modules)) {
|
||||||
|
process_wizard_add_modules ($id_modules, $image, $layout["id"], $range, $width, $height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$table->id = 'wizard_table';
|
$table->id = 'wizard_table';
|
||||||
|
@ -115,10 +162,17 @@ $table->data[0][1] = print_select ($images_list, 'image', '', '', '', '', true);
|
||||||
$table->data[1][0] = __('Image range (px)');
|
$table->data[1][0] = __('Image range (px)');
|
||||||
$table->data[1][1] = print_input_text ('range', $range, '', 5, 5, true);
|
$table->data[1][1] = print_input_text ('range', $range, '', 5, 5, true);
|
||||||
|
|
||||||
$table->data[2][0] = __('Agents');
|
$table->data[2][0] = __('Image size (px)');
|
||||||
$table->data[2][1] = print_select (get_group_agents ($layout_group, false, "none"),
|
$table->data[2][1] = __('Width').': '.print_input_text ('width', 0, '', 5, 5, true);
|
||||||
|
$table->data[2][1] .= '<br />'.__('Height').': '.print_input_text ('height', 0, '', 5, 5, true);
|
||||||
|
|
||||||
|
$table->data[3][0] = __('Agents');
|
||||||
|
$table->data[3][1] = print_select (get_group_agents ($layout_group, false, "none"),
|
||||||
'id_agents[]', 0, false, '', '', true, true);
|
'id_agents[]', 0, false, '', '', true, true);
|
||||||
|
|
||||||
|
$table->data[4][0] = __('Modules');
|
||||||
|
$table->data[4][1] = print_select (array (), 'module[]', 0, false, '', '', true, true);
|
||||||
|
|
||||||
echo '<form method="post" onsubmit="if (! confirm(\''.__('Are you sure').'\')) return false;">';
|
echo '<form method="post" onsubmit="if (! confirm(\''.__('Are you sure').'\')) return false;">';
|
||||||
print_table ($table);
|
print_table ($table);
|
||||||
|
|
||||||
|
@ -128,7 +182,9 @@ print_input_hidden ('id_layout', $layout["id"]);
|
||||||
print_submit_button (__('Add'), 'go', false, 'class="sub wizard"');
|
print_submit_button (__('Add'), 'go', false, 'class="sub wizard"');
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
echo '</form>';
|
echo '</form>';
|
||||||
|
|
||||||
echo '<h3 class="error invisible" id="message"> </h3>';
|
|
||||||
?>
|
?>
|
||||||
|
<script language="javascript" type="text/javascript">
|
||||||
|
$(document).ready (function () {
|
||||||
|
$("#id_agents").change (agent_changed);
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -89,7 +89,7 @@ function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines =
|
||||||
$z_index = 1; // Print BAD over good
|
$z_index = 1; // Print BAD over good
|
||||||
|
|
||||||
// Draw image
|
// Draw image
|
||||||
echo '<div style="z-index: '.$z_index.'; color: '.$layout_data['label_color'].'; position: absolute; margin-left: '.$layout_data['pos_x'].'px; margin-top:'.$layout_data['pos_y'].'px;" id="layout-data-'.$layout_data['id'].'" class="layout-data">';
|
echo '<div style="z-index: '.$z_index.'; '.($layout_data['label_color'][0] == '#' ? 'color: '.$layout_data['label_color'].';' : '').' position: absolute; margin-left: '.$layout_data['pos_x'].'px; margin-top:'.$layout_data['pos_y'].'px;" id="layout-data-'.$layout_data['id'].'" class="layout-data">';
|
||||||
|
|
||||||
if (!isset($id_agent))
|
if (!isset($id_agent))
|
||||||
$id_agent = 0;
|
$id_agent = 0;
|
||||||
|
@ -144,9 +144,11 @@ function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines =
|
||||||
|
|
||||||
echo "</a>";
|
echo "</a>";
|
||||||
|
|
||||||
// Print label
|
// Print label if valid label_color (only testing for starting with #) otherwise print nothing
|
||||||
echo "<br />";
|
if ($layout_data['label_color'][0] == '#') {
|
||||||
echo $layout_data['label'];
|
echo "<br />";
|
||||||
|
echo $layout_data['label'];
|
||||||
|
}
|
||||||
echo "</div>";
|
echo "</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,3 +50,37 @@ Array.prototype.in_array = function () {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill up select box with id "module" with modules after agent has been selected
|
||||||
|
*
|
||||||
|
* @param event that has been triggered
|
||||||
|
* @param id_agent Agent ID that has been selected
|
||||||
|
* @param selected Which module(s) have to be selected
|
||||||
|
*/
|
||||||
|
function agent_changed (event, id_agent, selected) {
|
||||||
|
if (id_agent == undefined)
|
||||||
|
id_agent = this.value;
|
||||||
|
$('#module').attr ('disabled', 1);
|
||||||
|
$('#module').empty ();
|
||||||
|
$('#module').append ($('<option></option>').html ("<?php echo __('Loading'); ?>...").attr ("value", 0));
|
||||||
|
jQuery.post ('ajax.php',
|
||||||
|
{"page": "operation/agentes/ver_agente",
|
||||||
|
"get_agent_modules_json": 1,
|
||||||
|
"id_agent": id_agent
|
||||||
|
},
|
||||||
|
function (data) {
|
||||||
|
$('#module').empty ();
|
||||||
|
$('#module').append ($('<option></option>').html ("<?php echo __('Any')?>").attr ("value", 0));
|
||||||
|
jQuery.each (data, function (i, val) {
|
||||||
|
s = html_entity_decode (val['nombre']);
|
||||||
|
$('#module').append ($('<option></option>').html (s).attr ("value", val['id_agente_modulo']));
|
||||||
|
$('#module').fadeIn ('normal');
|
||||||
|
});
|
||||||
|
if (selected != undefined)
|
||||||
|
$('#module').attr ('value', selected);
|
||||||
|
$('#module').attr ('disabled', 0);
|
||||||
|
},
|
||||||
|
"json"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue