From 1e590728aa53c1338744a0e55c11a51dcdb1a222 Mon Sep 17 00:00:00 2001 From: "edu.corral" Date: Wed, 21 Sep 2022 17:41:09 +0200 Subject: [PATCH 1/2] ent 9098 gis cli --- pandora_server/util/pandora_manage.pl | 45 ++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 8df2893194..1539d1f5ee 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -251,6 +251,11 @@ sub help_screen{ print "\nEVENTS\n\n" unless $param ne ''; help_screen_line('--event_in_progress', ' ', 'Set event in progress'); + print "\nGIS\n\n" unless $param ne ''; + help_screen_line('--get_gis_agent', ' ', 'Gets agent GIS information'); + help_screen_line('--insert_gis_data', ' [] [] []', 'Sets new GIS data for specified agent'); + + print "\n"; exit; } @@ -275,10 +280,11 @@ sub api_call($$$;$$$$) { $params->{"other"} = $other; $params->{"return_type"} = $return_type; $params->{"other_mode"} = "url_encode_separator_|"; - + # Call the API. my $ua = new LWP::UserAgent; my $url = $pa_config->{"console_api_url"}; + my $response = $ua->post($url, $params); if ($response->is_success) { @@ -8043,6 +8049,14 @@ sub pandora_manage_main ($$$) { param_check($ltotal, 4, 5); cli_agent_update_custom_fields(); } + elsif ($param eq '--get_gis_agent') { + param_check($ltotal, 1, 0); + cli_get_gis_agent(); + } + elsif ($param eq '--insert_gis_data'){ + # param_check($ltotal, 4, 0); + cli_insert_gis_data(); + } else { print_log "[ERROR] Invalid option '$param'.\n\n"; $param = ''; @@ -8763,3 +8777,32 @@ sub pandora_validate_alert_id($$$$) { return 1; } + +############################################################################## +# Get GIS data from agent +############################################################################## + +sub cli_get_gis_agent(){ + + my $agent_id = @ARGV[2]; + + my $result = api_call(\%conf,'get', 'gis_agent', $agent_id); + print "$result \n\n "; + +} + +############################################################################## +# Set GIS data for specified agent +############################################################################## + +sub cli_insert_gis_data(){ + + my ($agent_id, $latitude, $longitude, $altitude) = @ARGV[2..5]; + my $agent_id = @ARGV[2]; + my @position = @ARGV[3..5]; + my $other = join('|', @position); + + my $result = api_call(\%conf,'set', 'gis_agent_only_position', $agent_id, undef, "$other"); + print "$result \n\n "; + +} \ No newline at end of file From 2262754eafb09ffb30f2b61aadd9f7bb3730dc88 Mon Sep 17 00:00:00 2001 From: "edu.corral" Date: Tue, 11 Oct 2022 11:46:02 +0200 Subject: [PATCH 2/2] ent 9098 insert_gis_data --- pandora_server/util/pandora_manage.pl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 1539d1f5ee..0778658e2f 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -266,7 +266,7 @@ sub help_screen{ sub api_call($$$;$$$$) { my ($pa_config, $op, $op2, $id, $id2, $other, $return_type) = @_; my $content = undef; - + eval { # Set the parameters for the POST request. my $params = {}; @@ -294,7 +294,7 @@ sub api_call($$$;$$$$) { $content = $response->decoded_content(); } }; - + return $content; } @@ -8054,7 +8054,7 @@ sub pandora_manage_main ($$$) { cli_get_gis_agent(); } elsif ($param eq '--insert_gis_data'){ - # param_check($ltotal, 4, 0); + param_check($ltotal, 4, 0); cli_insert_gis_data(); } else { @@ -8805,4 +8805,4 @@ sub cli_insert_gis_data(){ my $result = api_call(\%conf,'set', 'gis_agent_only_position', $agent_id, undef, "$other"); print "$result \n\n "; -} \ No newline at end of file +}