* 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. 20
      html/skins/alteeve/files.css
  4. 95
      html/skins/alteeve/files.html
  5. 396
      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. 6
      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,4 +1,5 @@
/* 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;
@ -15,7 +16,6 @@ padding: 5px 5px 5px 15px
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 {
@ -34,22 +34,23 @@ padding: 1px;
border-radius: 3px; border-radius: 3px;
display: inline-block; display: inline-block;
color: #FFFFFF; color: #FFFFFF;
} }
.ajax-file-upload-bar { .ajax-file-upload-bar {
background-color: #0ba1b5; background-color: #0ba1b5;
width: 0; width: 0;
height: 20px; height: 20px;
border-radius: 3px; border-radius: 3px;
color: #FFFFFF; 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;
@ -70,6 +71,7 @@ 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;
@ -89,6 +91,7 @@ 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;
@ -128,13 +131,12 @@ margin: 5px 10px 5px 0px;
.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 0px 10px; padding: 10px 10px 10px 10px;
} }
.state-hover .state-hover

@ -4,29 +4,108 @@
<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;" >
#!string!striker_0119!#
</td>
</tr>
<tr>
<td style="width: 30%;">
&nbsp;
</td>
<td style="width: 40%;" >
<div id="fileuploader">Upload</div>
</td>
<td style="width: 30%;">
&nbsp; &nbsp;
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2" class="title"> <td colspan="3" style="text-align: center; white-space: nowrap;">
#!string!striker_0119!# #!variable!file_list!#
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="3">
&nbsp; &nbsp;
</td> </td>
</tr> </tr>
</form>
</table>
<!-- end main-menu -->
<!-- start open-file-list -->
<table style="width: 100%; text-align: center;">
<tr> <tr>
<td class="column_header">
<!-- Manage -->
#!string!header_0042!#
</td>
<td> <td>
Upload &nbsp;
<div id="fileuploader">Upload</div> </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> </td>
</tr> </tr>
</form> <!-- end open-file-list -->
<!-- start close-file-list -->
</table> </table>
<!-- end main-menu --> <!-- 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>

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)
{ {

@ -879,10 +879,14 @@ 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})
{
if ($anvil->data->{network_interfaces}{$network_interface_uuid}{network_interface_operational} ne "DELETED")
{ {
# Mark it as deleted. # Mark it as deleted.
my $query = "UPDATE network_interfaces SET network_interface_operational = 'DELETED' WHERE network_interface_uuid = ".$anvil->Database->quote($network_interface_uuid).";"; 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__}); $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