Fix validation page (#13929)

* Validation web page fixes

* Validation web page fixes

* update baseline
This commit is contained in:
Tony Murray 2022-04-17 08:38:16 -05:00 committed by GitHub
parent 6410775bd5
commit 9c126572a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 46 deletions

View File

@ -136,19 +136,6 @@ class Html
return $graph_data;
}
/**
* Find all links in some text and turn them into html links.
*
* @param string|null $text
* @return string
*/
public static function linkify(?string $text): string
{
$regex = "#(http|https|ftp|ftps)://[a-z0-9\-.]*[a-z0-9\-]+(/\S*)?#i";
return preg_replace($regex, '<a href="$0">$0</a>', $text);
}
public static function percentageBar($width, $height, $percent, $left_text = '', $right_text = '', $warn = null, $shadow = null, $colors = null)
{
$percent = min($percent, 100);

View File

@ -25,7 +25,7 @@
namespace LibreNMS;
use LibreNMS\Util\Html;
use Illuminate\Support\Arr;
class ValidationResult
{
@ -223,9 +223,9 @@ class ValidationResult
return [
'status' => $resultStatus,
'statusText' => $this->getStatusText($resultStatus),
'statusText' => substr($this->getStatusText($resultStatus), 2, -2), // remove console colors
'message' => $this->getMessage(),
'fix' => is_array($resultFix) ? $resultFix : ($resultList ? [Html::linkify($resultFix)] : []),
'fix' => Arr::wrap($resultFix),
'listDescription' => $this->getListDescription(),
'list' => is_array($resultList) ? array_values($resultList) : [],
];

View File

@ -11235,11 +11235,6 @@ parameters:
count: 1
path: tests/FunctionsTest.php
-
message: "#^Method LibreNMS\\\\Tests\\\\FunctionsTest\\:\\:testLinkify\\(\\) has no return type specified\\.$#"
count: 1
path: tests/FunctionsTest.php
-
message: "#^Method LibreNMS\\\\Tests\\\\FunctionsTest\\:\\:testMacCleanToReadable\\(\\) has no return type specified\\.$#"
count: 1

View File

@ -32,18 +32,14 @@
<div x-bind:id="'body-' + group.group" class="panel-collapse collapse" x-bind:class="{'in': group.status !== 2}">
<div class="panel-body">
<template x-for="result in group.results">
<div class="panel" x-bind:class="{'panel-success': group.status === 2, 'panel-warning': group.status === 1, 'panel-danger': group.status === 0}">
<div class="panel" x-bind:class="{'panel-success': result.status === 2, 'panel-warning': result.status === 1, 'panel-danger': result.status === 0}">
<div class="panel-heading"
x-bind:class="{'bg-success': result.status === 2, 'bg-warning': result.status === 1, 'bg-danger': result.status === 0}"
x-text="result.statusText + ': ' + result.message"
></div>
<div class="panel-body" x-show="result.fix.length || result.list.length">
<div x-show="result.fix.length">
{{ __('validation.results.fix') }}: <code>
<template x-for="fixText in result.fix">
<span x-text="fixText"></span>
</template>
</code>
{{ __('validation.results.fix') }}: <pre x-text='result.fix.join("\r\n")'>
</pre>
</div>
<div x-show="result.list.length" class="tw-mt-5">
<ul class='list-group' style='margin-bottom: -1px'>

View File

@ -26,7 +26,6 @@
namespace LibreNMS\Tests;
use LibreNMS\Device\YamlDiscovery;
use LibreNMS\Util\Html;
use LibreNMS\Util\Rewrite;
class FunctionsTest extends TestCase
@ -55,23 +54,6 @@ class FunctionsTest extends TestCase
$this->assertFalse(isHexString('a5fe53'));
}
public function testLinkify()
{
$input = 'foo@demo.net bar.ba@test.co.uk
www.demo.com http://foo.co.uk/
sdfsd ftp://192.168.1.1/help/me/now.php
http://regexr.com/foo.html?q=bar
https://mediatemple.net.';
$expected = 'foo@demo.net bar.ba@test.co.uk
www.demo.com <a href="http://foo.co.uk/">http://foo.co.uk/</a>
sdfsd <a href="ftp://192.168.1.1/help/me/now.php">ftp://192.168.1.1/help/me/now.php</a>
<a href="http://regexr.com/foo.html?q=bar">http://regexr.com/foo.html?q=bar</a>
<a href="https://mediatemple.net">https://mediatemple.net</a>.';
$this->assertSame($expected, Html::linkify($input));
}
public function testDynamicDiscoveryGetValue()
{
$pre_cache = [