From 578c23b0a36bcc848ecabcf575ee7f28a8e65a43 Mon Sep 17 00:00:00 2001 From: Digimer Date: Thu, 19 Jul 2018 16:40:03 -0400 Subject: [PATCH] * Finished the form for adding peers (but no logic to support it yet, it's just filled and formatted). Signed-off-by: Digimer --- cgi-bin/home | 21 +++++++- html/skins/alteeve/main.js | 8 +++ html/skins/alteeve/striker.html | 96 ++++++++++++++++++++++++--------- share/words.xml | 14 +++-- 4 files changed, 108 insertions(+), 31 deletions(-) diff --git a/cgi-bin/home b/cgi-bin/home index a91456e54..a14a502e1 100755 --- a/cgi-bin/home +++ b/cgi-bin/home @@ -283,12 +283,27 @@ sub process_sync_page next if not $anvil->Validate->is_subnet({subnet => $anvil->data->{sys}{network}{interface}{$interface}{subnet}}); my ($network_type, $network_number) = ($interface =~ /^(.*?)(\d+)_/); - my $database_user = $anvil->data->{database}{$host_uuid}{name}; + my $database_user = $anvil->data->{database}{$host_uuid}{user} ? $anvil->data->{database}{$host_uuid}{user} : $anvil->data->{sys}{database}{user}; my $database_port = $anvil->data->{database}{$host_uuid}{port}; my $network_key = $network_type eq "bcn" ? "striker_0018" : "striker_0022"; my $say_network = $anvil->Words->string({key => $network_key, variables => { number => $network_number }}); + + # The user 'admin' and the port 5432 are default, so only show them if they're non-standard. + my $access_string = $database_user."\@".$anvil->data->{sys}{network}{interface}{$interface}{ip}.":".$database_port; + if (($database_port eq "5432") && ($database_user eq "admin")) + { + $access_string = $anvil->data->{sys}{network}{interface}{$interface}{ip}; + } + elsif ($database_port eq "5432") + { + $access_string = $database_user."\@".$anvil->data->{sys}{network}{interface}{$interface}{ip}; + } + elsif ($database_user eq "admin") + { + $access_string = $anvil->data->{sys}{network}{interface}{$interface}{ip}.":".$database_port; + } $inbound_table .= $anvil->Template->get({file => "striker.html", name => "striker-sync-inbound", variables => { - access => $database_user."\@".$anvil->data->{sys}{network}{interface}{$interface}{ip}.":".$database_port, + access => $access_string, note => $say_network, }}); } @@ -347,8 +362,10 @@ sub process_sync_page password => $anvil->Log->secure ? $password : $anvil->Words->string({key => "log_0186"}), }}); + $anvil->data->{cgi}{new_peer_password}{value} = "" if not defined $anvil->data->{cgi}{new_peer_password}{value}; $peer_table .= $anvil->Template->get({file => "striker.html", name => "striker-sync-entry", variables => { access => $port eq 5432 ? $user."\@".$host : $user."\@".$host.":".$port, + password => $anvil->data->{cgi}{new_peer_password}{value}, ping_checked => $ping ? "checked" : "", }}); } diff --git a/html/skins/alteeve/main.js b/html/skins/alteeve/main.js index 37c4de102..67000d36d 100644 --- a/html/skins/alteeve/main.js +++ b/html/skins/alteeve/main.js @@ -6,4 +6,12 @@ $(function() { $( window ).on( "load", function() { + // This resizes the peer access field to the placeholder width to better handle translations. + $("#new_peer_access").each(function () { + //var npa_width = $(this).attr('placeholder').length; + //console.log('resize new_peer_access to: ['+npa_width+'].'); + $(this).attr('size', $(this).attr('placeholder').length); + }); + }) + diff --git a/html/skins/alteeve/striker.html b/html/skins/alteeve/striker.html index 0e16c9a3c..12a486b35 100644 --- a/html/skins/alteeve/striker.html +++ b/html/skins/alteeve/striker.html @@ -125,7 +125,8 @@ - +
+ - #!variable!inbound_table!# - + + + + - - #!variable!peer_table!# - + + - - - + + + +
#!string!header_0007!# @@ -134,62 +135,109 @@ #!string!header_0008!#
- #!string!header_0009!# +#!variable!inbound_table!# +
+  
- #!string!header_0010!# + #!string!header_0009!# +  
- +#!variable!peer_table!# +
+ - #!string!striker_0071!# + + - #!string!striker_0072!# + + #!string!striker_0071!#: - + + #!string!striker_0072!#:
+ +
+ + +   + + + + + + + + + + + + + + + + + +
+ #!string!striker_0075!#:   + + #!string!striker_0076!# +
+ #!string!striker_0071!#:   + + #!string!striker_0073!# +
+ #!string!striker_0072!#:   + + #!string!striker_0074!# +
+ + - + #!variable!access!# - - #!string!striker_0071!# + + #!variable!password!# - - + + #!string!striker_0071!# - - + + #!string!striker_0068!#" - + #!variable!access!# - + #!variable!note!# diff --git a/share/words.xml b/share/words.xml index 772f91f21..7b9292d2a 100644 --- a/share/words.xml +++ b/share/words.xml @@ -318,7 +318,7 @@ Here we will inject 't_0006', which injects 't_0001' which has a variable: [#!st Speed Up Order Inbound Connections - Network + Via network: Peer Connections Ping @@ -390,12 +390,16 @@ Here we will inject 't_0006', which injects 't_0001' which has a variable: [#!st Help and support Use 'anvil-change-password' from the console to reset it.]]> Access to this machine via: [#!variable!network!#]. - Update + Save Delete - db_user@hostname_or_ip[:tcp_port] + [db_user@]hostname_or_ip[:tcp_port] Add - Ping before connect: - Bi-directional: + Ping + Bi-directional + When checked, the Anvil! will ping the peer before trying to connect to the database. This speeds up skipping a database that is offline, but won't help if the databsae is behind a router. When unchecked, connections will be a touch faster when the database is available. + When checked, the peer will be configure to add the local database as a peer at the same time that we add it to this system. + Access + admin', and the default port is '5432'. If the peer uses these, then you only need to specify the IP address or hostname of the peer. If the user name is not 'admin', then you need to use the format 'user@host. If the TCP port is not '5432', then you need to use 'host:port. If both user and port are different, use the format 'user@host:port'.]]> Configure Network