* Started work on the Striker sync function. It shows (without formatting yet) the ways the local dashboard can be accessed.

* Added another check and better error handling to Template->get() to print a more useful message if a template is found but fails to parse.
* Moved some strings into the words file.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 7 years ago
parent 6e19d45845
commit ee649ff2dd
  1. 4
      Anvil/Tools/Database.pm
  2. 11
      Anvil/Tools/Template.pm
  3. 49
      cgi-bin/home
  4. 10
      html/skins/alteeve/main.css
  5. 2
      html/skins/alteeve/main.html
  6. 74
      html/skins/alteeve/striker.html
  7. 32
      share/words.xml

@ -679,6 +679,10 @@ sub connect
password => $anvil->Log->secure ? $password : "#!string!log_0186!#",
}});
# Some places will want to pull up the database user, so in case it isn't set (which is
# usual), set it as if we had read it from the config file using the default.
$anvil->data->{database}{$uuid}{name} = $anvil->data->{sys}{database}{name} if not $anvil->data->{database}{$uuid}{name};
# If not set, we will always ping before connecting.
if ((not exists $anvil->data->{database}{$uuid}{ping}) or (not defined $anvil->data->{database}{$uuid}{ping}))
{

@ -240,13 +240,22 @@ sub get
}});
if ((not $template_found) or ($template eq "#!not_found!#"))
{
# Error!
# Woops!
$template = $anvil->Words->string({key => "error_0029", variables => {
template => $name,
file => $source,
}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { template => $template }});
}
# If there was a problem processing the template, it will be '#!error!#'.
if ($template eq "#!error!#")
{
$template = $anvil->Words->string({key => "error_0030", variables => {
template => $name,
file => $source,
}});
}
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { template => $template }});

@ -218,10 +218,12 @@ sub process_task
# If we're here, the user is logged in!
if ($anvil->data->{cgi}{striker}{value})
{
$anvil->data->{form}{back_link} = "?striker=true";
$anvil->data->{form}{back_link} = "?striker=true";
$anvil->data->{cgi}{task}{value} = "" if not defined $anvil->data->{cgi}{task}{value};
$anvil->data->{cgi}{action}{value} = "" if not defined $anvil->data->{cgi}{action}{value};
if ($anvil->data->{cgi}{task}{value} eq "sync")
{
$anvil->data->{form}{body} = $anvil->Template->get({file => "striker.html", name => "striker-sync"});
process_sync_page($anvil);
}
else
{
@ -253,6 +255,49 @@ sub process_task
return(0);
}
# This handles tasks related to setting up peer Strikers.
sub process_sync_page
{
my ($anvil) = @_;
# Are we adding a new peer?
if ($anvil->data->{cgi}{action}{value} eq "add")
{
#add_sync_peer($anvil);
}
elsif ($anvil->data->{cgi}{action}{value} eq "remove")
{
#remove_sync_peer($anvil);
}
$anvil->System->get_ips();
# We'll want to show the user way to access the local machine. For that, we'll loop through our own IPs.
my $table = "";
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{sys}{network}{interface}})
{
next if (($interface !~ /^bcn/) && ($interface !~ /^ifn/));
next if not $anvil->Validate->is_ipv4({ip => $anvil->data->{sys}{network}{interface}{$interface}{ip}});
next if not $anvil->Validate->is_subnet({subnet => $anvil->data->{sys}{network}{interface}{$interface}{subnet}});
my ($network_type, $network_number) = ($interface =~ /^(.*?)(\d+)_/);
my $host_uuid = $anvil->Get->host_uuid;
my $database_user = $anvil->data->{database}{$host_uuid}{name};
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 }});
$table .= $anvil->Template->get({file => "striker.html", name => "striker-sync-inbound", variables => {
access => $database_user."\@".$anvil->data->{sys}{network}{interface}{$interface}{ip}.":".$database_port,
note => $anvil->Words->string({key => "striker_0066", variables => { network => $say_network }}),
}});
}
# Build the menu.
$anvil->data->{form}{body} = $anvil->Template->get({file => "striker.html", name => "striker-sync", variables => { table => $table }});
return(0);
}
# This shows the menus for configuring Striker.
sub configure_striker
{

@ -69,12 +69,18 @@ select {
}
body {
font-family: 'Dejavu Sans', Arial, Helvetica, Verdana, Sans-Serif;
background-image: url("/skins/alteeve/images/Texture.jpg");
font-family: 'Dejavu Sans', Arial, Helvetica, Verdana, Sans-Serif;
background-image: url("/skins/alteeve/images/Texture.jpg");
background-repeat: repeat;
color: #f2f2f2;
}
a {
font-family: 'Dejavu Sans', Arial, Helvetica, Verdana, Sans-Serif;
color: #f2f2f2;
text-decoration: none;
}
table.data_table_nowrap {
border: 1px solid #8f8f8f;
border-radius: 4px;

@ -219,5 +219,5 @@
<!-- end user_button_off -->
<!-- start user_button_on -->
<a href="?logout=true"><img src="#!data!skin::url!#/images/users_icon_on.png" alt="#!string!message_0033!#" class="top_icon"></a>
<a href="?logout=true"><img src="#!data!skin::url!#/images/users_icon_on.png" alt="#!string!striker_0063!#" class="top_icon"></a>
<!-- end user_button_on -->

@ -22,7 +22,7 @@
</tr>
<tr>
<td colspan="5" class="subtle_text" style="text-align: center;">
#!string!message_0032!#
#!string!striker_0065!#
</td>
</tr>
</div>
@ -40,7 +40,7 @@
<span name="#!variable!message_id!#" id="#!variable!message_id!#" class="config_header2">#!variable!description!#</span>
<br />
<hr>
<a href="/" class="button">Reload</a>
<a href="/" class="button">#!string!striker_0053!#</a>
</td>
</tr>
</div>
@ -56,7 +56,7 @@
</tr>
<tr>
<td colspan="2" class="title">
Striker Configuration and Management
#!string!striker_0052!#
</td>
</tr>
<tr>
@ -69,12 +69,12 @@
<a href="?striker=true&task=sync"><img src="#!data!skin::url!#/images/sync.png" class="top_icon" ></a>
</td>
<td class="menu_title">
Configure Striker Peers
<a href="?striker=true&task=sync">#!string!striker_0054!#</a>
</td>
</tr>
<tr>
<td class="menu_details">
When you sync with a peer, this machine's data will be copied to and recorded on the peer's database. Data gathered by ScanCore will also be kept in sync on both dashboards, and any general purpose data collected by other dashboards while this one is offline will be copied back when this machine comes online. Should this machine ever be rebuilt, data recorded from before the rebuild will be automatically restored as well.
#!string!striker_0055!#
</td>
</tr>
<tr>
@ -82,12 +82,12 @@
<a href="?striker=true&task=update"><img src="#!data!skin::url!#/images/update.png" class="top_icon" ></a>
</td>
<td class="menu_title">
Update this Striker
<a href="?striker=true&task=update">#!string!striker_0056!#</a>
</td>
</tr>
<tr>
<td class="menu_details">
This will update this system using any available software repositories. You can also use this to create or load update packs to allow for the update of offline or air-gapped Anvil! systems.
#!string!striker_0057!#
</td>
</tr>
<tr>
@ -95,20 +95,64 @@
<a href="?striker=true&task=update"><img src="#!data!skin::url!#/images/striker_configure.png" class="top_icon" ></a>
</td>
<td class="menu_title">
Configure this Striker
<a href="?striker=true&task=update">#!string!striker_0058!#</a>
</td>
</tr>
<tr>
<td class="menu_details">
Update the network configuration for this Striker.
#!string!striker_0059!#
</td>
</tr>
</table>
<!-- end striker-setup -->
<!-- start striker-sync -->
<table align="center">
<tr>
<td>
Add or remove Striker peers.
</td>
</tr>
<tr>
<td>
Peer dashboards are Striker machines whose databases this Striker will use to record data. If this machine ever needs to be replaced, or goes offline for a period of time, it will automatically pull the data back from any peers that it is missing.
</td>
</tr>
<tr>
<td>
<table>
#!variable!table!#
</table>
</td>
</tr>
</table>
<!-- end striker-sync -->
<!-- start striker-sync-entry -->
<tr>
<td>
#!variable!access!#
</td>
<td>
#!variable!ping!#
</td>
<td>
#!variable!button!#
</td>
</tr>
<!-- end striker-sync-entry -->
<!-- start striker-sync-inbound -->
<tr>
<td>
#!variable!access!#
</td>
<td colspan="2">
#!variable!note!#
</td>
</tr>
<!-- end striker-sync-inbound -->
<!-- start striker-welcome -->
<table align="center" class="striker_welcome">
<tr>
@ -118,7 +162,7 @@
</tr>
<tr>
<td colspan="2" class="title">
#!string!message_0035!#
#!string!striker_0060!#
</td>
</tr>
<tr>
@ -126,7 +170,7 @@
<a href="?anvil=true"><img src="#!data!skin::url!#/images/anvil_icon_on.png" class="top_icon"></a>
</td>
<td>
#!string!message_0036!#
#!string!striker_0061!#
</td>
</tr>
<tr>
@ -134,15 +178,15 @@
<a href="?striker=true"><img src="#!data!skin::url!#/images/striker_icon_on.png" class="top_icon"></a>
</td>
<td>
#!string!message_0037!#
#!string!striker_0062!#
</td>
</tr>
<tr>
<td>
<a href="?logout=true"><img src="#!data!skin::url!#/images/users_icon_on.png" alt="#!string!message_0033!#" class="top_icon"></a>
<a href="?logout=true"><img src="#!data!skin::url!#/images/users_icon_on.png" alt="#!string!striker_0063!#" class="top_icon"></a>
</td>
<td>
#!string!message_0033!#
#!string!striker_0063!#
</td>
</tr>
<tr>
@ -150,7 +194,7 @@
<a href="https://alteeve.com/w/Support" target="_new"><img src="#!data!skin::url!#/images/help_icon_on.png" id="help_icon" class="top_icon"></a>
</td>
<td>
#!string!message_0038!#
#!string!striker_0064!#
</td>
</tr>
</table>

@ -57,13 +57,13 @@ NOTE: You must update the password of any other system using this host's
</key>
<key name="message_0030">Failed to write the new password to the temporary file: [#!variable!file!#]. Please check the logs for details.</key>
<key name="message_0031">Beginning configuration of local system.</key>
<key name="message_0032"><![CDATA[Forgot your password?<br />Use '<span class="code">anvil-change-password</span>' from the console to reset it.]]></key>
<key name="message_0033">Log out</key>
<key name="message_0032"></key>
<key name="message_0033"></key>
<key name="message_0034"><![CDATA[Logged in as: [<span class="fixed_width">#!data!sys::users::user_name!#</span>]]]></key>
<key name="message_0035">Welcome!</key>
<key name="message_0036">Create or manage Anvil! systems</key>
<key name="message_0037">Manage this Striker system and sync with others</key>
<key name="message_0038">Help and support</key>
<key name="message_0035"></key>
<key name="message_0036"></key>
<key name="message_0037"></key>
<key name="message_0038"></key>
<!-- Log entries -->
<key name="log_0001">Starting: [#!variable!program!#].</key>
@ -370,6 +370,25 @@ Here we will inject 't_0006', which injects 't_0001' which has a variable: [#!st
<key name="striker_0049">Log in</key>
<key name="striker_0050">User name</key>
<key name="striker_0051">Password</key>
<key name="striker_0052">Striker Configuration and Management</key>
<key name="striker_0053">Reload</key>
<key name="striker_0054">Configure Striker Peers</key>
<key name="striker_0055">When you sync with a peer, this machine's data will be copied to and recorded on the peer's database. Data gathered by ScanCore will also be kept in sync on both dashboards, and any general purpose data collected by other dashboards while this one is offline will be copied back when this machine comes online. Should this machine ever be rebuilt, data recorded from before the rebuild will be automatically restored as well.</key>
<key name="striker_0056">Update this Striker</key>
<key name="striker_0057">This will update this system using any available software repositories. You can also use this to create or load update packs to allow for the update of offline or air-gapped Anvil! systems.</key>
<key name="striker_0058">Configure this Striker</key>
<key name="striker_0059">Update the network configuration for this Striker.</key>
<key name="striker_0060">Welcome!</key>
<key name="striker_0061">Create or manage Anvil! systems</key>
<key name="striker_0062">Manage this Striker system and sync with others</key>
<key name="striker_0063">Log out</key>
<key name="striker_0064">Help and support</key>
<key name="striker_0065"><![CDATA[Forgot your password?<br />Use '<span class="code">anvil-change-password</span>' from the console to reset it.]]></key>
<key name="striker_0066">Access to this machine via: [#!variable!network!#].</key>
<key name="striker_0067"></key>
<key name="striker_0068"></key>
<key name="striker_0069"></key>
<key name="striker_0070"></key>
<!-- Strings used by jobs -->
<key name="job_0001">Configure Network</key>
@ -408,6 +427,7 @@ Here we will inject 't_0006', which injects 't_0001' which has a variable: [#!st
<key name="error_0027">Login failed, please try again.</key>
<key name="error_0028"><![CDATA[There appears to be a problem with Striker. The login failed, please check: [<span class="code">#!data!sys::log_file!#</span>] for details.]]></key>
<key name="error_0029"><![CDATA[Failed to find the template: [<span class="code">#!variable!template!#</span>] in the template file: [<span class="code">#!variable!file!#</span>].]]></key>
<key name="error_0030"><![CDATA[Failed to process the template: [<span class="code">#!variable!template!#</span>] in the template file: [<span class="code">#!variable!file!#</span>]. Details of the problem should be in: [<span class="code">#!data!sys::log_file!#</span>].]]></key>
<!-- These are works and strings used by javascript/jqery -->
<key name="js_0001">Up</key>

Loading…
Cancel
Save