2010-02-24 Miguel de Dios <miguel.dedios@artica.es>

* include/functions_gis.php: fix the refresh time in function
	"activateAjaxRefresh", in functions "activateAjaxRefresh" and "addPoint"
	 add status agent.
	 
	* include/javascript/openlayers.pandora.js: add function "changeShowStatus"
	for change show icons by status, in function "changeRefreshTime" add reset
	timer, in function "js_addPoint" and "js_addPointExtent" add the state and
	hide if it's necesary.
	
	* operation/gis_maps/render_view.php: change the style of page, and add
	controls for hide agent icons by state.

	* operation/gis_maps/ajax.php: add the option "get_map_connection_data" in
	switch for get map connection data.

	* godmode/gis_maps/configure_gis_map.php: start to develop the preview map
	in editor.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2412 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2010-02-24 11:49:03 +00:00
parent 5503851276
commit 845b9d9cfa
6 changed files with 220 additions and 15 deletions

View File

@ -1,6 +1,26 @@
2010-02-24 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_gis.php: fix the refresh time in function
"activateAjaxRefresh", in functions "activateAjaxRefresh" and "addPoint"
add status agent.
* include/javascript/openlayers.pandora.js: add function "changeShowStatus"
for change show icons by status, in function "changeRefreshTime" add reset
timer, in function "js_addPoint" and "js_addPointExtent" add the state and
hide if it's necesary.
* operation/gis_maps/render_view.php: change the style of page, and add
controls for hide agent icons by state.
* operation/gis_maps/ajax.php: add the option "get_map_connection_data" in
switch for get map connection data.
* godmode/gis_maps/configure_gis_map.php: start to develop the preview map
in editor.
2010-02-24 Pablo de la Concepción <pablo.concepcion@artica.es>
* pandora_console/operation/gis_maps/render_view.php: Changed PanZoom
* operation/gis_maps/render_view.php: Changed PanZoom
to PanZoomBar in the map.
2010-02-23 Miguel de Dios <miguel.dedios@artica.es>

View File

@ -295,7 +295,7 @@ $table->data[0][2] = "<table class='databox' border='0' id='map_connection'>
<td colspan='3'><div id='map' style='width: 300px; height: 300px; border: 1px solid black;'></div></td>
</tr>
<tr>
<td colspan='3'><a href=''>" . __("Refresh map preview") . "</a></td>
<td colspan='3'>" . print_button(__("Load preview map"),'button_refresh', false, 'refreshMapView();', 'class="sub"', true) . "</td>
</tr>
<tr>
<td>" . __("Add Map connection") . print_help_tip (__('At least one map connection must be deffined, it will be possible to change betwwen the connections in the map'), true). ": " . $iconError . "</td>
@ -465,6 +465,48 @@ require_jquery_file ('autocomplete');
require_jquery_file ('json');
?>
<script type="text/javascript">
function refreshMapView() {
map = null;
$("#map").html('');
id_connection_default = $("input[name=map_connection_default]:checked").val();
jQuery.ajax ({
data: "page=operation/gis_maps/ajax&opt=get_map_connection_data&id_connection=" + id_connection_default,
type: "GET",
dataType: 'json',
url: "ajax.php",
timeout: 10000,
success: function (data) {
if (data.correct) {
mapConnection = data.content;
arrayControls = null;
arrayControls = Array('Navigation', 'PanZoom', 'MousePosition');
//TODO read too from field forms user.
inital_zoom = mapConnection['default_zoom_level'];
num_levels_zoom = mapConnection['num_zoom_levels'];
center_latitude = mapConnection['initial_latitude'];
center_longitude = mapConnection['initial_longitude'];
center_altitude = mapConnection['initial_altitude'];
baseLayer = jQuery.evalJSON(mapConnection['conection_data']);
var objBaseLayers = Array();
objBaseLayers[0] = Array();
objBaseLayers[0]['type'] = baseLayer['type'];
objBaseLayers[0]['name'] = mapConnection['conection_name'];
objBaseLayers[0]['url'] = baseLayer['url'];
js_printMap('map', inital_zoom, num_levels_zoom, center_latitude, center_longitude, objBaseLayers, arrayControls);
}
}
});
}
$("#text_id_agent").autocomplete(
"ajax.php",
{

View File

@ -212,9 +212,9 @@ function activateAjaxRefresh($layers = null, $lastTimeOfData = null) {
?>
<script type="text/javascript">
var last_time_of_data = <?php echo $lastTimeOfData; ?>; //This time use in the ajax query to next recent points.
var refreshAjaxIntervalSeconds = 6000;
var refreshAjaxIntervalSeconds = 60000;
var idIntervalAjax = null;
var oldRefreshAjaxIntervalSeconds = 6000;
var oldRefreshAjaxIntervalSeconds = 60000;
<?php
if ($layers === null) {
@ -260,10 +260,11 @@ function activateAjaxRefresh($layers = null, $lastTimeOfData = null) {
delete feature;
feature = null
status = parseInt(agentDataGIS['status']);
js_addPointExtent(layer.name, agentDataGIS['name'],
agentDataGIS['stored_longitude'], agentDataGIS['stored_latitude'],
agentDataGIS['icon_path'], 20, 20, idAgent, 'point_agent_info');
agentDataGIS['icon_path'], 20, 20, idAgent, 'point_agent_info', status);
}
}
}
@ -322,10 +323,10 @@ function addPoint($layerName, $pointName, $lat, $lon, $icon = null, $width = 20,
function () {
<?php
if ($icon != null) {
echo "js_addPointExtent('$layerName', '$pointName', $lon, $lat, '$icon', $width, $height, $point_id, '$type_string');";
echo "js_addPointExtent('$layerName', '$pointName', $lon, $lat, '$icon', $width, $height, $point_id, '$type_string', $status);";
}
else {
echo "js_addPoint('$layerName', '$pointName', $lon, $lat, $point_id, '$type_string');";
echo "js_addPoint('$layerName', '$pointName', $lon, $lat, $point_id, '$type_string', $status);";
}
?>
}

View File

@ -13,6 +13,7 @@
// GNU General Public License for more details.
var map; // Map global var object is use in multiple places.
var statusShow = 'all';
/**
* Inicialize the map in the browser and the object map.
@ -93,6 +94,111 @@ function js_printMap(id_div, initial_zoom, num_levels_zoom, center_latitude, cen
);
}
/**
* Change the style of state button, and call the function "hideAgentsStatus"
* whith new state for agents icons to show.
*
* @param string newShowStatus State to show.
* @return none
*/
function changeShowStatus(newShowStatus) {
$("#button_status_" + statusShow).attr('style', '');
statusShow = newShowStatus;
$("#button_status_" + statusShow).attr('style', 'border: 1px black solid;');
hideAgentsStatus();
}
/**
* Function that change the visibility of feature by status and state var
* statusShow
*
* @param object feature The feature to change the visibility
* @param int status The status code, it can be (1,4) for bad, (2) for warning, (0) for ok and the rest
* @return
*/
function hideFeatureByStatus(feature, status) {
feature.style.display = 'none';
switch (statusShow) {
case 'bad':
if ((status == 1) || (status == 4))
feature.style.display = '';
break;
case 'warning':
if (status == 2)
feature.style.display = '';
break;
case 'ok':
if (status == 0)
feature.style.display = '';
break;
case 'default':
if ((status != 1) && (status != 4) && (status != 2) && (status != 0))
feature.style.display = '';
break;
case 'all':
feature.style.display = '';
break;
}
}
/**
* Test if the feature is hidden.
*
* @param integer status The integer status.
* @return boolean The true or false.
*/
function isHideFeatureByStatus(status) {
returnVar = true;
switch (statusShow) {
case 'bad':
if ((status == 1) || (status == 4))
returnVar = false;
break;
case 'warning':
if (status == 2)
returnVar = false;
break;
case 'ok':
if (status == 0)
returnVar = false;
break;
case 'default':
if ((status != 1) && (status != 4) && (status != 2) && (status != 0))
returnVar = false;
break;
case 'all':
returnVar = false;
break;
}
return returnVar;
}
/**
* Hide the agents icons that not is of current state var statusShow.
*
* @return none
*/
function hideAgentsStatus() {
layers = map.getLayersByClass("OpenLayers.Layer.Vector");
jQuery.each(layers, function (i, layer) {
features = layer.features;
jQuery.each(features, function (j, feature) {
status = feature.data.status;
hideFeatureByStatus(feature, status);
});
layer.redraw();
});
}
/**
* Change the refresh time for the map.
*
@ -101,6 +207,10 @@ function js_printMap(id_div, initial_zoom, num_levels_zoom, center_latitude, cen
*/
function changeRefreshTime(time) {
refreshAjaxIntervalSeconds = time * 1000;
clearInterval(idIntervalAjax);
idIntervalAjax = setInterval("clock_ajax_refresh()", refreshAjaxIntervalSeconds);
oldRefreshAjaxIntervalSeconds = refreshAjaxIntervalSeconds;
}
/**
@ -257,17 +367,22 @@ function showHideLayer(name, action) {
* @param float lat The coord of longitude for point.
* @param string id The id of point.
* @param string type_string The type of point, it's use for ajax request.
* @param integer statusAgent The status of point.
*
* @return Object The point.
*/
function js_addPoint(layerName, pointName, lon, lat, id, type_string) {
function js_addPoint(layerName, pointName, lon, lat, id, type_string, statusAgent) {
var point = new OpenLayers.Geometry.Point(lon, lat)
.transform(map.displayProjection, map.getProjectionObject());
var layer = map.getLayersByName(layerName);
layer = layer[0];
feature = new OpenLayers.Feature.Vector(point,{nombre: pointName, id: id, type: type_string, long_lat: new OpenLayers.LonLat(lon, lat).transform(map.displayProjection, map.getProjectionObject()) });
feature = new OpenLayers.Feature.Vector(point,{status: statusAgent, nombre: pointName, id: id, type: type_string, long_lat: new OpenLayers.LonLat(lon, lat).transform(map.displayProjection, map.getProjectionObject()) });
if (isHideFeatureByStatus(statusAgent)) {
feature.style.display = 'none';
}
layer.addFeatures(feature);
@ -286,17 +401,27 @@ function js_addPoint(layerName, pointName, lon, lat, id, type_string) {
* @param integer height The height of icon.
* @param string id The id of point.
* @param string type_string The type of point, it's use for ajax request.
* @param integer statusAgent The status of point.
*
* @return Object The point.
*/
function js_addPointExtent(layerName, pointName, lon, lat, icon, width, height, id, type_string) {
function js_addPointExtent(layerName, pointName, lon, lat, icon, width, height, id, type_string, statusAgent) {
var point = new OpenLayers.Geometry.Point(lon, lat)
.transform(map.displayProjection, map.getProjectionObject());
var layer = map.getLayersByName(layerName);
layer = layer[0];
feature = new OpenLayers.Feature.Vector(point,{id: id, type: type_string, long_lat: new OpenLayers.LonLat(lon, lat).transform(map.displayProjection, map.getProjectionObject()) }, {fontWeight: "bolder", fontColor: "#00014F", labelYOffset: -height, graphicHeight: width, graphicWidth: height, externalGraphic: icon, label: pointName});
if (typeof(statusAgent) == 'string')
statusA = parseInt(statusAgent);
else
statusA = statusAgent;
feature = new OpenLayers.Feature.Vector(point,{status: statusA, id: id, type: type_string, long_lat: new OpenLayers.LonLat(lon, lat).transform(map.displayProjection, map.getProjectionObject()) }, {fontWeight: "bolder", fontColor: "#00014F", labelYOffset: -height, graphicHeight: width, graphicWidth: height, externalGraphic: icon, label: pointName});
if (isHideFeatureByStatus(statusAgent)) {
feature.style.display = 'none';
}
layer.addFeatures(feature);

View File

@ -172,6 +172,17 @@ switch ($opt) {
echo json_encode($returnJSON);
break;
case 'get_map_connection_data':
$idConnection = get_parameter('id_connection');
$returnJSON = array();
$returnJSON['correct'] = 1;
$returnJSON['content'] = get_db_row_sql('SELECT * FROM tgis_map_connection WHERE id_tmap_connection = ' . $idConnection);
echo json_encode($returnJSON);
break;
}
?>

View File

@ -77,7 +77,14 @@ $times = array(
7200 => 2 . ' ' . __('hours')
);
$buttons[] = __('Refresh: ') . print_select($times, 'refresh_time', 60, 'changeRefreshTime(this.value);', '', 0, true, false, false);
$buttons[] = '&nbsp;' . __('Refresh: ') . print_select($times, 'refresh_time', 60, 'changeRefreshTime(this.value);', '', 0, true, false, false) . "&nbsp;";
$buttons[] = '<a id="button_status_all" href="javascript: changeShowStatus(\'all\');" style="border: 1px black solid;">' . __('All') . '</a>';
$buttons[] = '<a id="button_status_bad" href="javascript: changeShowStatus(\'bad\');"><img src="images/status_sets/default/agent_critical_ball.png" /> ' . __('Critical') . '</a>';
$buttons[] = '<a id="button_status_warning" href="javascript: changeShowStatus(\'warning\');"><img src="images/status_sets/default/agent_warning_ball.png" /> ' . __('Warning') . '</a>';
$buttons[] = '<a id="button_status_ok" href="javascript: changeShowStatus(\'ok\');"><img src="images/status_sets/default/agent_ok_ball.png" /> ' . __('Ok') . '</a>';
$buttons[] = '<a id="button_status_default" href="javascript: changeShowStatus(\'default\');"><img src="images/status_sets/default/agent_no_monitors_ball.png" /> ' . __('Other') . '</a>';
$buttons[] = __('Show agents in state: ');
print_page_header(__('Visual console') . " &raquo; " . __('Map') . "&nbsp;" . $map['map_name'], "", false, "", false, $buttons);
@ -100,7 +107,7 @@ if ($layers != false) {
$coords['stored_longitude'] = $map['default_longitude'];
}
else {
if ($show_history == 'y') {
if ($show_history == 'y') {
addPath($layer['layer_name'], $idAgent);
}
}
@ -119,10 +126,9 @@ if ($layers != false) {
}
?>
<br /><br />
<?php
if ($config["pure"] == 0) {
echo "<div id='map' style='width: 99%; height: 400px; border: 1px solid black;' ></div>";
echo "<div id='map' style='width: 99%; height: 500px; border: 1px solid black;' ></div>";
}
else {
echo "<div id='map' style='position:absolute;top:40px; z-index:100; width: 98%; height:94%; border: 1px solid black;' ></div>";