* Started work on the Striker menus, adding mechanisms for "back" and "refresh".

* Fixed a bug where the old style '#!replace!...!#' replacement variables were not being escaped when processing variable insertions into strings.
* Made the body variable be stored in 'form::body' instead of passing around the '$body' variable.
* Created a set of new icons.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 7 years ago
parent f120866fa5
commit 19672f8b7c
  1. 13
      Anvil/Tools.pm
  2. 3
      Anvil/Tools/Words.pm
  3. 87
      cgi-bin/home
  4. BIN
      html/skins/alteeve/images/anvil_icon_off.png
  5. BIN
      html/skins/alteeve/images/back_off.png
  6. BIN
      html/skins/alteeve/images/back_on.png
  7. BIN
      html/skins/alteeve/images/refresh_off.png
  8. BIN
      html/skins/alteeve/images/refresh_on.png
  9. 12
      html/skins/alteeve/images/sources.txt
  10. BIN
      html/skins/alteeve/images/striker_icon_off.png
  11. BIN
      html/skins/alteeve/images/sync.png
  12. BIN
      html/skins/alteeve/images/update.png
  13. BIN
      html/skins/alteeve/images/users_icon_off.png
  14. 34
      html/skins/alteeve/main.css
  15. 144
      html/skins/alteeve/main.html
  16. 5
      share/words.xml

@ -739,6 +739,19 @@ sub _set_defaults
language => "en_CA",
skin => "alteeve",
},
# This is data filled from the active user's database table.
users => {
user_name => "",
user_password_hash => "",
user_session_salt => "",
user_salt => "",
user_algorithm => "",
user_hash_count => "",
user_language => "",
user_is_admin => "",
user_is_experienced => "",
user_is_trusted => "",
},
};
$anvil->data->{defaults} = {
## Network stuff... The second octet auto-increments to handle N-number of netowrks. As such,

@ -452,8 +452,7 @@ sub string
# restore them once we're out of this loop.
foreach my $check ($string =~ /#!([^\s]+?)!#/)
{
if (($check !~ /^replace/) &&
($check !~ /^data/) &&
if (($check !~ /^data/) &&
($check !~ /^string/) &&
($check !~ /^variable/))
{

@ -60,13 +60,15 @@ $| = 1;
### Setup some variables.
$anvil->data->{form}{error_massage} = "&nbsp;";
$anvil->data->{form}{back_link} = "";
$anvil->data->{form}{refresh_link} = "";
# Read in any CGI variables, if needed.
$anvil->Get->cgi();
$anvil->data->{skin}{url} = $anvil->data->{path}{urls}{skins}."/".$anvil->Template->skin;
$anvil->data->{skin}{url} = $anvil->data->{path}{urls}{skins}."/".$anvil->Template->skin;
$anvil->data->{form}{body} = "";
my $header = $anvil->Template->get({file => "main.html", name => "header", variables => { language => $anvil->Words->language }});
my $body = "";
# If any jobs are pending/running, show the "unavailable" option.
my $available = check_availability($anvil);
@ -74,7 +76,7 @@ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list
if (not $available)
{
# Set the body to 'say::maintenance'.
$body = $anvil->data->{say}{maintenance};
$anvil->data->{form}{body} = $anvil->data->{say}{maintenance};
}
# If there is no user account yet, then the system is new and needs to be reconfigured.
@ -82,20 +84,51 @@ my $configured = check_if_configured($anvil);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { configured => $configured }});
if (not $configured)
{
$body = configure_striker($anvil);
configure_striker($anvil);
}
else
{
# Normal operation
$body = process_task($anvil);
process_task($anvil);
}
# Preparing the back (and eventually 'reload' button) takes a bit more work.
my $refresh_button = "";
if ($anvil->data->{form}{refresh_link})
{
$refresh_button = $anvil->Template->get({file => "main.html", name => "refresh_button_on", variables => { url => $anvil->data->{form}{refresh_link} }});
}
else
{
$refresh_button = $anvil->Template->get({file => "main.html", name => "refresh_button_off"});
}
my $back_button = "";
if ($anvil->data->{form}{back_link})
{
my $url = $THIS_FILE;
if ($anvil->data->{form}{back_link} ne "?")
{
# Turn on the back button,
$url = $anvil->data->{form}{back_link};
}
$back_button = $anvil->Template->get({file => "main.html", name => "back_button_on", variables => { url => $url }});
}
else
{
# Back is disabled.
$back_button = $anvil->Template->get({file => "main.html", name => "back_button_off"});
}
my $buttons = $anvil->Template->get({file => "main.html", name => "button_bar", variables => {
back_button => $back_button,
refresh_button => $refresh_button,
anvil_button => 0 ? $anvil->Template->get({file => "main.html", name => "anvil_button_on"}) : $anvil->Template->get({file => "main.html", name => "anvil_button_off"}),
striker_button => 0 ? $anvil->Template->get({file => "main.html", name => "striker_button_on"}) : $anvil->Template->get({file => "main.html", name => "striker_button_off"}),
user_button => $anvil->data->{sys}{users}{user_name} ? $anvil->Template->get({file => "main.html", name => "user_button_on"}) : $anvil->Template->get({file => "main.html", name => "user_button_off"}),
}});
my $footer = $anvil->Template->get({file => "main.html", name => "footer"});
my $footer = $anvil->Template->get({file => "main.html", name => "footer", variables => {
user => $anvil->data->{sys}{users}{user_name} ? "#!string!message_0034!#" : "&nbsp;",
}});
# Display the page.
my $template = $anvil->Template->get({file => "main.html", name => "master", variables => {
@ -104,7 +137,7 @@ my $template = $anvil->Template->get({file => "main.html", name => "master", var
left_top_bar => "&nbsp;",
center_top_bar => $anvil->data->{form}{error_massage},
right_top_bar => $buttons,
center_body => $body,
center_body => $anvil->data->{form}{body},
left_bottom_bar => "&nbsp;",
center_bottom_bar => "&nbsp;",
right_bottom_bar => "&nbsp;",
@ -127,7 +160,6 @@ sub process_task
my ($anvil) = @_;
# Is the user trying to log in?
my $body = "hi";
my $logged_in = 0;
if ((defined $anvil->data->{cgi}{login}) && ($anvil->data->{cgi}{login}{value}))
{
@ -169,16 +201,28 @@ sub process_task
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { logged_in => $logged_in }});
if (not $logged_in)
{
$body = $anvil->Template->get({file => "main.html", name => "striker-login", variables => {
$anvil->data->{form}{body} = $anvil->Template->get({file => "main.html", name => "striker-login", variables => {
user => $anvil->data->{cgi}{username}{value},
password => "",
}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { body => $body }});
return($body);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "form::body" => $anvil->data->{form}{body} }});
return(0);
}
# If we're here, the user is logged in!
$body = "logged in as: [".$anvil->data->{sys}{users}{user_name}."]\n";
if ($anvil->data->{cgi}{striker}{value})
{
$anvil->data->{form}{back_link} = "?";
$anvil->data->{form}{body} = $anvil->Template->get({file => "main.html", name => "striker-setup"});
}
elsif (0)
{
}
else
{
# Load the main page.
$anvil->data->{form}{body} = $anvil->Template->get({file => "main.html", name => "striker-welcome"});
}
# $anvil->data->{sys}{users}{user_name} = $user_name;
# $anvil->data->{sys}{users}{user_uuid} = $user_uuid;
@ -191,7 +235,7 @@ sub process_task
# $anvil->data->{sys}{users}{user_is_experienced} = $user_is_experienced,
# $anvil->data->{sys}{users}{user_is_trusted} = $user_is_trusted,
return($body);
return(0);
}
# This shows the menus for configuring Striker.
@ -200,10 +244,9 @@ sub configure_striker
my ($anvil) = @_;
# This will be true when the dashboard is unconfigured.
my $body = "";
if (not $anvil->data->{cgi}{step}{value})
{
$body = config_step1($anvil);
$anvil->data->{form}{body} = config_step1($anvil);
}
elsif ($anvil->data->{cgi}{step}{value} eq "step1")
{
@ -213,12 +256,12 @@ sub configure_striker
if ($sane)
{
# Step 1 was sane, show step 2.
$body = config_step2($anvil);
$anvil->data->{form}{body} = config_step2($anvil);
}
else
{
# No good
$body = config_step1($anvil);
$anvil->data->{form}{body} = config_step1($anvil);
}
}
elsif ($anvil->data->{cgi}{step}{value} eq "step2")
@ -229,25 +272,25 @@ sub configure_striker
if ($sane)
{
# Step 2 was sane, show step 3.
$body = config_step3($anvil);
$anvil->data->{form}{body} = config_step3($anvil);
}
else
{
# No good
$body = config_step2($anvil);
$anvil->data->{form}{body} = config_step2($anvil);
}
}
elsif ($anvil->data->{cgi}{step}{value} eq "step3")
{
# User has confirmed, update the system!
$body = save_job($anvil);
$anvil->data->{form}{body} = save_job($anvil);
}
else
{
$body = get_network_details_form($anvil);
$anvil->data->{form}{body} = get_network_details_form($anvil);
}
return($body);
return(0);
}
# This checks to see if the local machine has been configured after initial install. If not, it will present

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

@ -16,3 +16,15 @@ User by Wilson Joseph from the Noun Project (https://thenounproject.com/term/use
Question by Travis Avery from the Noun Project (https://thenounproject.com/term/question/587291/)
- help_icon.png
Sync by Edward Boatman from the Noun Project (https://thenounproject.com/term/sync/290/)
- sync.png
update by sofi from the Noun Project (https://thenounproject.com/term/update/1723034/)
- update.png
back by K from the Noun Project (https://thenounproject.com/term/back/453801/)
- back.png
Refresh by Denis Klyuchnikov from the Noun Project (https://thenounproject.com/term/refresh/1147205/)
- refresh.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

@ -210,7 +210,6 @@ td {
}
.footer {
text-align: center;
background: #171717;
font-size: 12px;
color: #515151;
@ -231,3 +230,36 @@ td {
text-decoration: none;
color: #616161;
}
.fixed_width {
font-family: 'Dejavu Sans Mono', Courier;
}
#center_body {
height: 100%;
}
.striker_welcome {
}
.title {
font-size: 1.2em;
text-align: center;
}
.icon_button {
padding-top: 30px;
vertical-align: top;
}
.menu_title {
font-size: 1.1em;
padding-top: 30px;
padding-left: 20px;
padding-bottom: 10px;
}
.menu_details {
padding-left: 10px;
padding-right: 10px;
}

@ -1,6 +1,105 @@
<!-- start striker-setup -->
<table align="center" class="striker_welcome">
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td colspan="2" class="title">
Striker Configuration and Management
</td>
</tr>
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td rowspan="2" class="icon_button">
<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
</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.
</td>
</tr>
<tr>
<td rowspan="2" class="icon_button">
<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
</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.
</td>
</tr>
</table>
<!-- end striker-setup -->
<!-- start striker-welcome -->
<table align="center" class="striker_welcome">
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td colspan="2" class="title">
#!string!message_0035!#
</td>
</tr>
<tr>
<td>
<a href="?anvil=true"><img src="#!data!skin::url!#/images/anvil_icon_on.png" class="top_icon"></a>
</td>
<td>
#!string!message_0036!#
</td>
</tr>
<tr>
<td>
<a href="?striker=true"><img src="#!data!skin::url!#/images/striker_icon_on.png" class="top_icon"></a>
</td>
<td>
#!string!message_0037!#
</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>
</td>
<td>
#!string!message_0033!#
</td>
</tr>
<tr>
<td>
<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!#
</td>
</tr>
</table>
<!-- end striker-welcome -->
<!-- start button_bar -->
<table id="button_bar">
<tr>
<td>
#!variable!back_button!#
</td>
<td>
#!variable!refresh_button!#
</td>
<td>
#!variable!striker_button!#
</td>
@ -17,12 +116,28 @@
</table>
<!-- end button_bar -->
<!-- start back_button_off -->
<img src="#!data!skin::url!#/images/back_off.png" class="top_icon">
<!-- end back_button_off -->
<!-- start back_button_on -->
<a href="#!variable!url!#"><img src="#!data!skin::url!#/images/back_on.png" class="top_icon"></a>
<!-- end back_button_on -->
<!-- start refresh_button_off -->
<img src="#!data!skin::url!#/images/refresh_off.png" class="top_icon">
<!-- end refresh_button_off -->
<!-- start refresh_button_on -->
<a href="#!variable!url!#"><img src="#!data!skin::url!#/images/refresh_on.png" class="top_icon"></a>
<!-- end refresh_button_on -->
<!-- start anvil_button_off -->
<img src="#!data!skin::url!#/images/anvil_icon_off.png" class="top_icon">
<!-- end anvil_button_off -->
<!-- start anvil_button_on -->
<a href="?anvil=true"><img src="#!data!skin::url!#/images/anvil_icon_on.png" class="top_icon">
<a href="?anvil=true"><img src="#!data!skin::url!#/images/anvil_icon_on.png" class="top_icon"></a>
<!-- end anvil_button_on -->
<!-- start striker_button_off -->
@ -30,7 +145,7 @@
<!-- end striker_button_off -->
<!-- start striker_button_on -->
<a href="?striker=true"><img src="#!data!skin::url!#/images/striker_icon_on.png" class="top_icon">
<a href="?striker=true"><img src="#!data!skin::url!#/images/striker_icon_on.png" class="top_icon"></a>
<!-- end striker_button_on -->
<!-- start user_button_off -->
@ -38,7 +153,7 @@
<!-- 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 href="?logout=true"><img src="#!data!skin::url!#/images/users_icon_on.png" alt="#!string!message_0033!#" class="top_icon"></a>
<!-- end user_button_on -->
<!-- start config_step1 -->
@ -721,7 +836,22 @@
<!-- start footer -->
<div class="footer">
#!string!brand_0005!#
<table width="100%">
<tr>
<td width="2%">
&nbsp;
</td>
<td width="48%"">
#!variable!user!#
</td>
<td width="48%" style="text-align: right;">
#!string!brand_0005!#
</td>
<td width="2%">
&nbsp;
</td>
</tr>
</table>
</div>
<!-- end footer -->
@ -748,7 +878,7 @@
#!variable!header!#
<body>
<table class="body_table">
<table class="body_table" height="100%">
<tr>
<td class="header" width="5%">
<a href="/"><img src="#!data!skin::url!#/images/logo.png" class="logo"></a>
@ -761,8 +891,10 @@
</td>
</tr>
<tr>
<td colspan="3">
<td colspan="3" height="100%">
<div id="center_body">
#!variable!center_body!#
</div>
</td>
</tr>
<tr>

@ -59,6 +59,11 @@ NOTE: You must update the password of any other system using this host's
<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_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>
<!-- Log entries -->
<key name="log_0001">Starting: [#!variable!program!#].</key>

Loading…
Cancel
Save