From 4997cb47d250be8d3e5efa0acb1efb6cba9e554b Mon Sep 17 00:00:00 2001 From: Eric Date: Sun, 26 Aug 2018 11:03:26 -0700 Subject: [PATCH] aredn: Node description enhancement (#156) * aredn: Node Description Enhancements Node Description entry on setup page is now multiline. Fixes #91 Node Description display on status page is now a table cell, allowing for background color addition and word-wrapping. Fixes #90 Description background color added to CSS files with colors appropriate to each theme. Other CSS additions for the description input field on the setup page. Updated onboard help file about the node description field (and fixed a typo) * move some of the character filtering "higher up the chain" in perl. javascript still will replace any new lines with a space in case the user hit's enter in the description entry box. tested with curl and I can't find any problems yet. * removed some commented lines that were not needed * actually fix the typo I saw in help.html file. --- files/www/aredn.css | 14 +++++++++++++- files/www/black_on_white.css | 12 ++++++++++++ files/www/cgi-bin/perlfunc.pm | 6 ++++++ files/www/cgi-bin/setup | 19 ++++++++++--------- files/www/cgi-bin/status | 2 +- files/www/cgi-bin/sysinfo.json | 5 ++++- files/www/help.html | 12 ++++++++++-- files/www/loading.css | 11 +++++++++++ files/www/red_on_black.css | 12 ++++++++++++ files/www/white_on_black.css | 12 ++++++++++++ files/www/yellow_on_black.css | 12 ++++++++++++ 11 files changed, 103 insertions(+), 14 deletions(-) diff --git a/files/www/aredn.css b/files/www/aredn.css index 40c3b1b6..5785cabb 100644 --- a/files/www/aredn.css +++ b/files/www/aredn.css @@ -44,4 +44,16 @@ body table { border: solid 1px black; border-radius: 10px; background-color: rgb(108,231,232); -} \ No newline at end of file +} +#node_description_entry { +vertical-align: middle; +resize: none; +} +#node_description_display { +text-align: center; +vertical-align: middle; +background-color: gainsboro; +font-size: 12pt; +width: 40%; +} + diff --git a/files/www/black_on_white.css b/files/www/black_on_white.css index b6b215e8..e5819c9b 100644 --- a/files/www/black_on_white.css +++ b/files/www/black_on_white.css @@ -32,3 +32,15 @@ body table { .LogoDiv { position:absolute left:0px; width:100%; height:95; } .AREDNLogo { background: white; position:absolute; left:10%; width:175; height:95; } .PartOfAREDN { font-family:Verdana; font-size:xx-small; text-align:center; } + +#node_description_entry { +vertical-align: middle; +resize: none; +} +#node_description_display { +text-align: center; +vertical-align: middle; +background-color: whitesmoke; +font-size: 12pt; +width: 40%; +} diff --git a/files/www/cgi-bin/perlfunc.pm b/files/www/cgi-bin/perlfunc.pm index 59dad66a..c969bf45 100644 --- a/files/www/cgi-bin/perlfunc.pm +++ b/files/www/cgi-bin/perlfunc.pm @@ -199,6 +199,12 @@ sub read_postdata $line = fgets(10); push(@parse_errors, "not blank: '$line'") unless $line eq "\r\n"; $line = fgets(1000); + if($parm =~ 'description_node') { + $line = substr($line, 0, 210); + $line =~ s/'/'/g; + $line =~ s//>/g; + } $line =~ s/[\r\n]+$//; $parms{$parm} = $line; $state = "boundary"; diff --git a/files/www/cgi-bin/setup b/files/www/cgi-bin/setup index aa0fd846..c0fb8c13 100755 --- a/files/www/cgi-bin/setup +++ b/files/www/cgi-bin/setup @@ -433,13 +433,6 @@ if($parms{button_save}) push (@errors, "OK") unless @errors; } - if($description_node) - { - if($description_node =~ /<.*>|<\/.*>/) { - push(@errors, "Node description cannot contain html like tags") - } - } - unless(@errors) { $parms{node} = $node; @@ -564,7 +557,7 @@ function toggleMap(toggleButton) { print ""; alert_banner(); -print "
\n" unless $debug == 2; +print "\n" unless $debug == 2; print "\n" if $debug == 2; print "\n"; @@ -642,7 +635,7 @@ print " -"; +"; push @hidden, ""; print " @@ -965,6 +958,14 @@ page_footer(); print < + +function doSubmit() { + var desc_text = document.mainForm.description_node.value; + var singleLine = desc_text.replace(new RegExp( "\\n", "g" ), " "); + document.mainForm.description_node.value = singleLine; + return true; +} + var map = L.map('map').setView([0.0, 0.0], 1); var dotIcon = L.icon({iconUrl: '/dot.png'}); EOF diff --git a/files/www/cgi-bin/status b/files/www/cgi-bin/status index 5bd63836..1de0babc 100755 --- a/files/www/cgi-bin/status +++ b/files/www/cgi-bin/status @@ -78,7 +78,7 @@ alert_banner(); print "

$node"; print " / $tactical" if $tactical; print "

"; -print "$node_desc" if $node_desc; +print "
Node Description (optional)Verify Password
$node_desc
" if $node_desc; print "
\n"; # nav buttons diff --git a/files/www/cgi-bin/sysinfo.json b/files/www/cgi-bin/sysinfo.json index 5e023b19..00a71465 100755 --- a/files/www/cgi-bin/sysinfo.json +++ b/files/www/cgi-bin/sysinfo.json @@ -55,7 +55,7 @@ end info={} -- API version -info['api_version']="1.3" +info['api_version']="1.4" -- NODE name css=getUciConfType("system", "system") @@ -65,6 +65,9 @@ info['node']=css[0]['hostname'] m=os.capture("/usr/local/bin/get_model") info['model']=m:chomp() +-- DESCRIPTION +info['description']=css[0]['description'] + -- BOARD ID info['board_id']=hardware_boardid() diff --git a/files/www/help.html b/files/www/help.html index fa29c971..d8cde986 100644 --- a/files/www/help.html +++ b/files/www/help.html @@ -272,8 +272,7 @@ manually configure the network. The buttons on this page work as follows: