Graphing cleanup (#14492)

* WIP

* Fixes and cleanups

* Move parseAtTime to Time util class

* lint fixes, explicitly define variables

* Style fixes
This commit is contained in:
Tony Murray
2022-10-28 08:06:29 -05:00
committed by GitHub
parent d5fcf53e01
commit 4b65dc41d2
16 changed files with 420 additions and 308 deletions

View File

@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use LibreNMS\Config;
use LibreNMS\Enum\ImageFormat;
use LibreNMS\Exceptions\RrdGraphException;
use LibreNMS\Util\Debug;
use LibreNMS\Util\Graph;
@@ -33,20 +34,20 @@ class GraphController extends Controller
}
$headers = [
'Content-type' => $graph->imageType(),
'Content-type' => $graph->contentType(),
];
if ($output == 'base64') {
return response($graph, 200, $headers);
}
return response($graph->data(), 200, $headers);
return response($graph->data, 200, $headers);
} catch (RrdGraphException $e) {
if (Debug::isEnabled()) {
throw $e;
}
return response($e->generateErrorImage(), 500, ['Content-type' => Graph::imageType()]);
return response($e->generateErrorImage(), 500, ['Content-type' => ImageFormat::forGraph()->contentType()]);
}
}
}