* Fixed a bug in tools/anvil-update-states that was causing deleted interfaces to update the network_interfaces every pass, growing the DB excessively.

* Cleaned up the file manager;
** Got the jquery file uploader JS to be sane and altered it to be more useful.
** Got the list of existing files to be displayed (links clickable but not working yet).

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 4 years ago
parent 7d3c4371c7
commit ea84ba68eb
  1. 2
      Anvil/Tools/Database.pm
  2. 35
      cgi-bin/striker
  3. 228
      html/skins/alteeve/files.css
  4. 105
      html/skins/alteeve/files.html
  5. 406
      html/skins/alteeve/files.js
  6. BIN
      html/skins/alteeve/images/manage_file.png
  7. BIN
      html/skins/alteeve/images/manage_file_32.png
  8. 4
      html/skins/alteeve/images/sources.txt
  9. 12
      html/skins/alteeve/main.css
  10. 6
      share/words.xml
  11. 9
      tools/anvil-sync-shared
  12. 10
      tools/anvil-update-states

@ -8354,7 +8354,7 @@ INSERT INTO
$anvil->Database->write({uuid => $uuid, query => $query, source => $file ? $file." -> ".$THIS_FILE : $THIS_FILE, line => $line ? $line." -> ".__LINE__ : __LINE__}); $anvil->Database->write({uuid => $uuid, query => $query, source => $file ? $file." -> ".$THIS_FILE : $THIS_FILE, line => $line ? $line." -> ".__LINE__ : __LINE__});
} }
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0126", variables => { method => "Database->insert_or_update_network_interfaces()" }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { manifest_uuid => $manifest_uuid }});
return($manifest_uuid); return($manifest_uuid);
} }

@ -1446,15 +1446,48 @@ sub process_file_menu
$anvil->data->{cgi}{task}{value} = "" if not defined $anvil->data->{cgi}{task}{value}; $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}; $anvil->data->{cgi}{action}{value} = "" if not defined $anvil->data->{cgi}{action}{value};
if ($anvil->data->{cgi}{task}{value} eq "upload") if ($anvil->data->{cgi}{file_uuid}{value})
{ {
#process_upload_page($anvil); #process_upload_page($anvil);
} }
else else
{ {
### TODO: Left off here. Show the available files and make them clickable. On click, make it
### possible to select which Anvil! systems should have the files, and offer an option
### to "purge" the file from all systems.
# Build the list of existing files.
$anvil->Database->get_files({debug => 2});
my $file_list = $anvil->Template->get({file => "files.html", name => "open-file-list"});
foreach my $file_name (sort {$a cmp $b} keys %{$anvil->data->{files}{file_name}})
{
my $file_uuid = $anvil->data->{files}{file_name}{$file_name}{file_uuid};
my $file_size = $anvil->data->{files}{file_name}{$file_name}{file_size};
my $say_file_size = $anvil->Convert->bytes_to_human_readable({'bytes' => $file_size});
my $file_md5sum = $anvil->data->{files}{file_name}{$file_name}{file_md5sum};
my $file_type = $anvil->data->{files}{file_name}{$file_name}{file_type};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
file_name => $file_name,
file_uuid => $file_uuid,
file_size => $file_size." (".$say_file_size.")",
file_md5sum => $file_md5sum,
file_type => $file_type,
}});
$file_list .= $anvil->Template->get({file => "files.html", name => "file-list-entry", variables => {
file_uuid => $file_uuid,
file_name => $file_name,
file_type => $file_type,
file_size => $say_file_size,
md5sum => $file_md5sum,
}});
}
$file_list .= $anvil->Template->get({file => "files.html", name => "close-file-list"});
# The 'back' goes home # The 'back' goes home
$anvil->data->{form}{back_link} = "?"; $anvil->data->{form}{back_link} = "?";
$anvil->data->{form}{body} = $anvil->Template->get({file => "files.html", name => "main-menu", variables => { $anvil->data->{form}{body} = $anvil->Template->get({file => "files.html", name => "main-menu", variables => {
file_list => $file_list,
}}); }});
} }

@ -1,147 +1,149 @@
/* From: http://hayageek.github.io/jQuery-Upload-File/4.0.11/uploadfile.css */ /* From: http://hayageek.github.io/jQuery-Upload-File/4.0.11/uploadfile.css */
.ajax-file-upload-statusbar { .ajax-file-upload-statusbar {
border: 1px solid #0ba1b5; border: 1px solid #0ba1b5;
margin-top: 10px; margin-top: 10px;
width: 420px; width: 420px;
margin-right: 10px; margin-right: 10px;
margin: 5px; margin: 5px;
-moz-border-radius: 4px; -moz-border-radius: 4px;
-webkit-border-radius: 4px; -webkit-border-radius: 4px;
border-radius: 4px; border-radius: 4px;
padding: 5px 5px 5px 15px padding: 5px 5px 5px 15px
} }
.ajax-file-upload-filename { .ajax-file-upload-filename {
width: 300px; width: 300px;
height: auto; height: auto;
margin: 0 5px 5px 0px; margin: 0 5px 5px 0px;
} }
.ajax-file-upload-filesize { .ajax-file-upload-filesize {
width: 50px; width: 50px;
height: auto; height: auto;
margin: 0 5px 5px 0px; margin: 0 5px 5px 0px;
display: inline-block; display: inline-block;
vertical-align:middle; vertical-align: middle;
} }
.ajax-file-upload-progress { .ajax-file-upload-progress {
margin: 5px 10px 5px 0px; margin: 5px 10px 5px 0px;
position: relative; position: relative;
width: 250px; width: 250px;
border: 1px solid #ddd; border: 1px solid #ddd;
padding: 1px; padding: 1px;
border-radius: 3px; border-radius: 3px;
display: inline-block; display: inline-block;
color:#FFFFFF; color: #FFFFFF;
} }
.ajax-file-upload-bar {
background-color: #0ba1b5;
width: 0;
height: 20px;
border-radius: 3px;
color:#FFFFFF;
.ajax-file-upload-bar {
background-color: #0ba1b5;
width: 0;
height: 20px;
border-radius: 3px;
color: #FFFFFF;
} }
.ajax-file-upload-percent { .ajax-file-upload-percent {
position: absolute; position: absolute;
display: inline-block; display: inline-block;
top: 3px; top: 3px;
left: 48% left: 48%
} }
.ajax-file-upload-red { .ajax-file-upload-red {
-moz-box-shadow: inset 0 39px 0 -24px #e67a73; -moz-box-shadow: inset 0 39px 0 -24px #e67a73;
-webkit-box-shadow: inset 0 39px 0 -24px #e67a73; -webkit-box-shadow: inset 0 39px 0 -24px #e67a73;
box-shadow: inset 0 39px 0 -24px #e67a73; box-shadow: inset 0 39px 0 -24px #e67a73;
background-color: #e4685d; background-color: #e4685d;
-moz-border-radius: 4px; -moz-border-radius: 4px;
-webkit-border-radius: 4px; -webkit-border-radius: 4px;
border-radius: 4px; border-radius: 4px;
display: inline-block; display: inline-block;
color: #fff; color: #fff;
font-family: arial; font-family: arial;
font-size: 13px; font-size: 13px;
font-weight: normal; font-weight: normal;
padding: 4px 15px; padding: 4px 15px;
text-decoration: none; text-decoration: none;
text-shadow: 0 1px 0 #b23e35; text-shadow: 0 1px 0 #b23e35;
cursor: pointer; cursor: pointer;
vertical-align: top; vertical-align: top;
margin: 5px 10px 5px 0px; margin: 5px 10px 5px 0px;
} }
.ajax-file-upload-green { .ajax-file-upload-green {
background-color: #77b55a; background-color: #77b55a;
-moz-border-radius: 4px; -moz-border-radius: 4px;
-webkit-border-radius: 4px; -webkit-border-radius: 4px;
border-radius: 4px; border-radius: 4px;
margin: 0; margin: 0;
padding: 0; padding: 0;
display: inline-block; display: inline-block;
color: #fff; color: #fff;
font-family: arial; font-family: arial;
font-size: 13px; font-size: 13px;
font-weight: normal; font-weight: normal;
padding: 4px 15px; padding: 4px 15px;
text-decoration: none; text-decoration: none;
cursor: pointer; cursor: pointer;
text-shadow: 0 1px 0 #5b8a3c; text-shadow: 0 1px 0 #5b8a3c;
vertical-align: top; vertical-align: top;
margin: 5px 10px 5px 0px; margin: 5px 10px 5px 0px;
} }
.ajax-file-upload { .ajax-file-upload {
font-family: Arial, Helvetica, sans-serif; font-family: Arial, Helvetica, sans-serif;
font-size: 16px; font-size: 16px;
font-weight: bold; font-weight: bold;
padding: 15px 20px; padding: 15px 20px;
cursor:pointer; cursor: pointer;
line-height:20px; line-height: 20px;
height:25px; height: 25px;
margin:0 10px 10px 0; margin: 0 10px 10px 0;
display: inline-block; display: inline-block;
background: #fff; background: #fff;
border: 1px solid #e8e8e8; border: 1px solid #e8e8e8;
color: #888; color: #888;
text-decoration: none; text-decoration: none;
border-radius: 3px; border-radius: 3px;
-webkit-border-radius: 3px; -webkit-border-radius: 3px;
-moz-border-radius: 3px; -moz-border-radius: 3px;
-moz-box-shadow: 0 2px 0 0 #e8e8e8; -moz-box-shadow: 0 2px 0 0 #e8e8e8;
-webkit-box-shadow: 0 2px 0 0 #e8e8e8; -webkit-box-shadow: 0 2px 0 0 #e8e8e8;
box-shadow: 0 2px 0 0 #e8e8e8; box-shadow: 0 2px 0 0 #e8e8e8;
padding: 6px 10px 4px 10px; padding: 6px 10px 4px 10px;
color: #fff; color: #fff;
background: #2f8ab9; background: #2f8ab9;
border: none; border: none;
-moz-box-shadow: 0 2px 0 0 #13648d; -moz-box-shadow: 0 2px 0 0 #13648d;
-webkit-box-shadow: 0 2px 0 0 #13648d; -webkit-box-shadow: 0 2px 0 0 #13648d;
box-shadow: 0 2px 0 0 #13648d; box-shadow: 0 2px 0 0 #13648d;
vertical-align: middle; vertical-align: middle;
} }
.ajax-file-upload:hover { .ajax-file-upload:hover {
background: #3396c9; background: #3396c9;
-moz-box-shadow: 0 2px 0 0 #15719f; -moz-box-shadow: 0 2px 0 0 #15719f;
-webkit-box-shadow: 0 2px 0 0 #15719f; -webkit-box-shadow: 0 2px 0 0 #15719f;
box-shadow: 0 2px 0 0 #15719f; box-shadow: 0 2px 0 0 #15719f;
} }
.ajax-upload-dragdrop .ajax-upload-dragdrop
{ {
border: 1px dotted #7f7f7f;
border:2px dotted #A5A5C7; width: 50%;
width:420px; color: #f2f2f2;
color: #DADCE3; text-align: center;
text-align:left; vertical-align: middle;
vertical-align:middle; padding: 10px 10px 10px 10px;
padding:10px 10px 0px 10px;
} }
.state-hover .state-hover
{ {
border:2px solid #A5A5C7; border: 2px solid #A5A5C7;
} }
.ajax-file-upload-container .ajax-file-upload-container
{ {
margin:20px 0px 20px 0px; margin: 20px 0px 20px 0px;
} }

@ -1,33 +1,112 @@
<!-- start main-menu --> <!-- start main-menu -->
<table align="center" class="anvil_main_menu"> <table align="center" class="anvil_main_menu">
<script type="text/javascript" src="#!data!skin::url!#/files.js"></script> <script type="text/javascript" src="#!data!skin::url!#/files.js"></script>
<link rel="stylesheet" href="#!data!skin::url!#/files.css"> <link rel="stylesheet" href="#!data!skin::url!#/files.css">
<form method="post" enctype="multipart/form-data"> <form method="post" enctype="multipart/form-data">
<tr> <tr>
<td colspan="2"> <td colspan="3" class="menu_title" style="text-align: center;" >
&nbsp; #!string!striker_0119!#
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2" class="title"> <td style="width: 30%;">
#!string!striker_0119!# &nbsp;
</td>
<td style="width: 40%;" >
<div id="fileuploader">Upload</div>
</td>
<td style="width: 30%;">
&nbsp;
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="3" style="text-align: center; white-space: nowrap;">
&nbsp; #!variable!file_list!#
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td colspan="3">
Upload &nbsp;
<div id="fileuploader">Upload</div>
</td> </td>
</tr> </tr>
</form> </form>
</table> </table>
<!-- end main-menu --> <!-- end main-menu -->
<!-- start open-file-list -->
<table style="width: 100%; text-align: center;">
<tr>
<td class="column_header">
<!-- Manage -->
#!string!header_0042!#
</td>
<td>
&nbsp;
</td>
<td class="column_header">
<!-- File Name -->
#!string!header_0043!#
</td>
<td>
&nbsp;
</td>
<td class="column_header">
<!-- File Type -->
#!string!header_0044!#
</td>
<td>
&nbsp;
</td>
<td class="column_header">
<!-- File Size -->
#!string!header_0045!#
</td>
<td>
&nbsp; &nbsp; &nbsp;
</td>
<td class="column_header">
<!-- md5sum -->
#!string!header_0046!#
</td>
</tr>
<!-- end open-file-list -->
<!-- start close-file-list -->
</table>
<!-- end close-file-list -->
<!-- start file-list-entry -->
<tr>
<td class="fixed_width_no_wrap">
<a href="?files=true&file_uuid=#!variable!file_uuid!#"><img src="#!data!skin::url!#/images/manage_file_32.png" alt="#!string!message_0281!#" style="height: .8em;"></a>
</td>
<td>
&nbsp;
</td>
<td class="fixed_width_no_wrap_left">
<a href="?files=true&file_uuid=#!variable!file_uuid!#">#!variable!file_name!#</a>
</td>
<td>
&nbsp;
</td>
<td class="fixed_width_no_wrap">
#!variable!file_type!#
</td>
<td>
&nbsp;
</td>
<td class="fixed_width_no_wrap_right">
#!variable!file_size!#
</td>
<td>
&nbsp; &nbsp; &nbsp;
</td>
<td class="fixed_width_no_wrap_left">
#!variable!md5sum!#
</td>
</tr>
<!-- end file-list-entry -->
<!-- start upload_header --> <!-- start upload_header -->
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en_CA"> <html lang="en_CA">

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

@ -82,3 +82,7 @@ uninterruptible power supply by Denis Shumaylov from the Noun Project (https://t
operation by Adrien Coquet from the Noun Project (https://thenounproject.com/term/operation/2998606/) operation by Adrien Coquet from the Noun Project (https://thenounproject.com/term/operation/2998606/)
- run.png - run.png
service by Gem Designs from the Noun Project (https://thenounproject.com/term/service/2569069/)
- manage_file.png

@ -112,6 +112,18 @@ body {
text-align: center; text-align: center;
} }
.fixed_width_no_wrap_left {
font-family: 'Dejavu Sans Mono', Courier;
white-space: nowrap;
text-align: left;
}
.fixed_width_no_wrap_right {
font-family: 'Dejavu Sans Mono', Courier;
white-space: nowrap;
text-align: left;
}
.footer { .footer {
background: #171717; background: #171717;
font-size: 12px; font-size: 12px;

@ -293,6 +293,11 @@ The error was:
<key name="header_0039">New Hostname</key> <key name="header_0039">New Hostname</key>
<key name="header_0040">#!string!brand_0006!# Description</key> <key name="header_0040">#!string!brand_0006!# Description</key>
<key name="header_0041">Scan Agent</key> <key name="header_0041">Scan Agent</key>
<key name="header_0042">Manage</key>
<key name="header_0043">File Name</key>
<key name="header_0044">File Type</key>
<key name="header_0045">File Size</key>
<key name="header_0046">md5sum</key>
<!-- Strings used by jobs --> <!-- Strings used by jobs -->
<key name="job_0001">Configure Network</key> <key name="job_0001">Configure Network</key>
@ -1708,6 +1713,7 @@ If you are comfortable that the target has changed for a known reason, you can s
<key name="striker_0278">This is a condition record, used by programs like scan agents to track how long a condition has existed for.</key> <key name="striker_0278">This is a condition record, used by programs like scan agents to track how long a condition has existed for.</key>
<key name="striker_0279">This indicated why a machine was powered off. This is used by ScanCore to decide if or when to power up the target host.</key> <key name="striker_0279">This indicated why a machine was powered off. This is used by ScanCore to decide if or when to power up the target host.</key>
<key name="striker_0280">Storage Pool #!variable!number!#</key> <!-- This is used for auto-generated VG groups --> <key name="striker_0280">Storage Pool #!variable!number!#</key> <!-- This is used for auto-generated VG groups -->
<key name="message_0281">Manage this file.</key>
<!-- These are generally units and appended to numbers --> <!-- These are generally units and appended to numbers -->
<key name="suffix_0001">#!variable!number!#/sec</key> <key name="suffix_0001">#!variable!number!#/sec</key>

@ -32,13 +32,16 @@ $| = 1;
my $anvil = Anvil::Tools->new(); my $anvil = Anvil::Tools->new();
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0115", variables => { program => $THIS_FILE }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0115", variables => { program => $THIS_FILE }});
$anvil->Log->level({set => 2});
$anvil->Log->secure({set => 1});
# Read switches (target ([user@]host[:port]) and the file with the target's password. # Read switches (target ([user@]host[:port]) and the file with the target's password.
$anvil->data->{switches}{'job-uuid'} = ""; $anvil->data->{switches}{'job-uuid'} = "";
$anvil->Get->switches; $anvil->Get->switches;
# Connect to the database(s). # Connect to the database(s).
$anvil->Database->connect; $anvil->Database->connect;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0132"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0132"});
# If we don't have a job-uuid, look for one. # If we don't have a job-uuid, look for one.
if (not $anvil->data->{switches}{'job-uuid'}) if (not $anvil->data->{switches}{'job-uuid'})
@ -664,7 +667,7 @@ AND
message => "message_0199,!!strikers!".$striker_count."!!,!!node1_waiting!".$node1_waiting."!!,!!node2_waiting!".$node2_waiting."!!,!!wait_until!".$wait_until."!!", message => "message_0199,!!strikers!".$striker_count."!!,!!node1_waiting!".$node1_waiting."!!,!!node2_waiting!".$node2_waiting."!!,!!wait_until!".$wait_until."!!",
job_status => "failed", job_status => "failed",
}); });
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "message_0199", variables => { $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "message_0199", variables => {
strikers => $striker_count, strikers => $striker_count,
node1_waiting => $node1_waiting, node1_waiting => $node1_waiting,
node2_waiting => $node2_waiting, node2_waiting => $node2_waiting,
@ -717,7 +720,7 @@ AND
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "message_0201"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "message_0201"});
my $local_md5sum = $anvil->Get->md5sum({file => $file_path}); my $local_md5sum = $anvil->Get->md5sum({file => $file_path});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "message_0199", variables => { local_md5sum => $local_md5sum }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "message_0199", variables => { local_md5sum => $local_md5sum }});
if ($file_md5sum eq $local_md5sum) if ($file_md5sum eq $local_md5sum)
{ {

@ -880,9 +880,13 @@ ORDER BY
# Make sure I've seen this interface in this scan and, if not, update this entry to remove it. # Make sure I've seen this interface in this scan and, if not, update this entry to remove it.
if (not exists $anvil->data->{network}{$local_host}{interface}{$network_interface_name}) if (not exists $anvil->data->{network}{$local_host}{interface}{$network_interface_name})
{ {
# Mark it as deleted. if ($anvil->data->{network_interfaces}{$network_interface_uuid}{network_interface_operational} ne "DELETED")
my $query = "UPDATE network_interfaces SET network_interface_operational = 'DELETED' WHERE network_interface_uuid = ".$anvil->Database->quote($network_interface_uuid).";"; {
$anvil->Database->write({debug => 3, query => $query, source => $THIS_FILE, line => __LINE__}); # Mark it as deleted.
my $query = "UPDATE network_interfaces SET network_interface_operational = 'DELETED' WHERE network_interface_uuid = ".$anvil->Database->quote($network_interface_uuid).";";
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0124", variables => { query => $query }});
$anvil->Database->write({query => $query, source => $THIS_FILE, line => __LINE__});
}
# Remove it from the hash so we don't add it to the .json and .xml files. # Remove it from the hash so we don't add it to the .json and .xml files.
delete $anvil->data->{interface}{$network_interface_uuid}; delete $anvil->data->{interface}{$network_interface_uuid};

Loading…
Cancel
Save