[freeside-commits] branch master updated. ae14e320388fa5e7f400bff1c251ef885b7952e6

Jonathan Prykop jonathan at 420.am
Fri Sep 23 19:47:43 PDT 2016


The branch, master has been updated
       via  ae14e320388fa5e7f400bff1c251ef885b7952e6 (commit)
      from  e1acfb2921b35fe097015208e8072a2675d01d69 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ae14e320388fa5e7f400bff1c251ef885b7952e6
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Fri Sep 23 21:46:14 2016 -0500

    71873: GlobalVision - directions [better error handling]

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 57761bb..6bfbf98 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -2071,7 +2071,7 @@ and customer address. Include units.',
   {
     'key'         => 'google_maps_api_key',
     'section'     => 'addresses',
-    'description' => 'API key for google maps.  This must be set for map and directions links to appear on customer pages.  See <a href="https://developers.google.com/maps/documentation/javascript/get-api-key">Getting a Google Maps API Key</a>',
+    'description' => 'API key for google maps.  This must be set for map and directions links to work.  See <a href="https://developers.google.com/maps/documentation/javascript/get-api-key" target="_top">Getting a Google Maps API Key</a>',
     'type'        => 'text',
   },
 
diff --git a/httemplate/elements/coord-links.html b/httemplate/elements/coord-links.html
index a755791..f27ffd3 100644
--- a/httemplate/elements/coord-links.html
+++ b/httemplate/elements/coord-links.html
@@ -1,7 +1,5 @@
 <& /elements/init_overlib.html &>
 
-% if ( $apikey ) {
-
 <& /elements/popup_link.html,
      'action'      => $p. 'view/map.html?'. $query,
      'label'       => mt('map'),
@@ -21,8 +19,6 @@
   &>
 % }
 
-% } # end if $apikey
-
 <A HREF="<%$p%>view/kml.cgi?<% $query %>"><% mt('earth') |h %></A>
 
 <%init>
diff --git a/httemplate/elements/google_maps_api_key.html b/httemplate/elements/google_maps_api_key.html
new file mode 100644
index 0000000..0a4b764
--- /dev/null
+++ b/httemplate/elements/google_maps_api_key.html
@@ -0,0 +1,15 @@
+% if ($opt{'autherror'}) {
+<P STYLE="color: red;">
+There was an authentication error when loading google maps.
+Please check validity of existing key.
+</P>
+% }
+
+<P>In order to display google maps, your site administrator will need to set the
+<B>google_maps_api_key</B> setting under Configuration -> Settings.  Please see the Google Maps
+<a href="https://developers.google.com/maps/documentation/javascript/get-api-key" target="_top">Get
+a Key/Authentication</a> documentation for information on acquiring a key.</P>
+
+<%init>
+my %opt = @_;
+</%init>
diff --git a/httemplate/view/directions.html b/httemplate/view/directions.html
index a07df40..f23b7eb 100644
--- a/httemplate/view/directions.html
+++ b/httemplate/view/directions.html
@@ -1,3 +1,5 @@
+% if ( $apikey ) {
+
 %# the actual page
 <& /elements/header-popup.html, {
      title => '',#$name,
@@ -10,6 +12,11 @@
 <div id="directions_panel"></div>
 <div id="map_canvas"></div>
 
+% } else {
+<& /elements/header-popup.html &>
+<& /elements/google_maps_api_key.html &>
+% }
+
 <%def .head>
 % my $lat = $cgi->param('lat');
 % my $lon = $cgi->param('lon');
@@ -38,8 +45,6 @@ body { height: 100%; margin: 0px; padding: 0px }
 }
 </style>
 
-% my $conf = new FS::Conf;
-% my $apikey = $conf->config('google_maps_api_key');
 <script type="text/javascript" src="https://maps.google.com/maps/api/js?v=3&key=<% $apikey %>">
 </script>
 
@@ -69,6 +74,12 @@ function show_route() {
   });
 }
 
+// function name specified by google maps api, special hook for auth errors
+function gm_authFailure () {
+  document.body.innerHTML = 
+<% include('/elements/google_maps_api_key.html', autherror => 1) |js_string%>;
+}
+
 function initialize() {
   var myOptions = {
     zoom: 14,
@@ -88,6 +99,8 @@ function initialize() {
 </%def>
 <%shared>
 my ($lat, $lon, $name, $origin);
+my $conf = new FS::Conf;
+my $apikey = $conf->config('google_maps_api_key');
 </%shared>
 <%init>
 
diff --git a/httemplate/view/map.html b/httemplate/view/map.html
index d996a33..b3459dc 100644
--- a/httemplate/view/map.html
+++ b/httemplate/view/map.html
@@ -1,3 +1,5 @@
+% if ( $apikey ) {
+
 %# the actual page
 <& /elements/header-popup.html, {
      title => '',#$name,
@@ -9,6 +11,11 @@
 
 <div id="map_canvas"></div>
 
+% } else {
+<& /elements/header-popup.html &>
+<& /elements/google_maps_api_key.html &>
+% }
+
 <%def .head>
 <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
 
@@ -22,8 +29,6 @@ body { height: 100%; margin: 0px; padding: 0px }
 @media print { #map_canvas { height: 500px; margin: 0; } }
 </style>
 
-% my $conf = new FS::Conf;
-% my $apikey = $conf->config('google_maps_api_key');
 <script type="text/javascript" src="https://maps.google.com/maps/api/js?v=3&key=<% $apikey %>">
 </script>
 
@@ -31,6 +36,13 @@ body { height: 100%; margin: 0px; padding: 0px }
 var lengthLine=0;
 var map;
 
+// function name specified by google maps api, special hook for auth errors
+function gm_authFailure () {
+  document.body.innerHTML = 
+<% include('/elements/google_maps_api_key.html', autherror => 1) |js_string%>;
+}
+
+
 function initialize() {
   var latlng = new google.maps.LatLng(<%$lat%>, <%$lon%>);
   var myOptions = {
@@ -57,6 +69,8 @@ function initialize() {
 </%def>
 <%shared>
 my ($lat, $lon, $name);
+my $conf = new FS::Conf;
+my $apikey = $conf->config('google_maps_api_key');
 </%shared>
 <%init>
 

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Conf.pm                                |    2 +-
 httemplate/elements/coord-links.html         |    4 ----
 httemplate/elements/google_maps_api_key.html |   15 +++++++++++++++
 httemplate/view/directions.html              |   17 +++++++++++++++--
 httemplate/view/map.html                     |   18 ++++++++++++++++--
 5 files changed, 47 insertions(+), 9 deletions(-)
 create mode 100644 httemplate/elements/google_maps_api_key.html




More information about the freeside-commits mailing list