#591 - monitoring

This commit is contained in:
Saeed Vaziry
2025-05-31 00:18:04 +02:00
parent 857319025f
commit c09c7a63fa
32 changed files with 1692 additions and 117 deletions

View File

@ -7,6 +7,7 @@
use Illuminate\Contracts\Database\Query\Expression;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;
class GetMetrics
@ -17,8 +18,13 @@ class GetMetrics
*/
public function filter(Server $server, array $input): Collection
{
if (isset($input['from']) && isset($input['to']) && $input['from'] === $input['to']) {
Validator::make($input, self::rules($input))->validate();
if (isset($input['from'])) {
$input['from'] = Carbon::parse($input['from'])->format('Y-m-d').' 00:00:00';
}
if (isset($input['to'])) {
$input['to'] = Carbon::parse($input['to'])->format('Y-m-d').' 23:59:59';
}
@ -145,8 +151,8 @@ public static function rules(array $input): array
];
if (isset($input['period']) && $input['period'] === 'custom') {
$rules['from'] = ['required', 'date', 'before:to'];
$rules['to'] = ['required', 'date', 'after:from'];
$rules['from'] = ['required', 'date', 'before_or_equal:to'];
$rules['to'] = ['required', 'date', 'after_or_equal:from'];
}
return $rules;

View File

@ -5,6 +5,7 @@
use App\Models\Server;
use App\Models\Service;
use App\SSH\Services\ServiceInterface;
use Illuminate\Support\Facades\Validator;
class UpdateMetricSettings
{
@ -13,6 +14,8 @@ class UpdateMetricSettings
*/
public function update(Server $server, array $input): void
{
Validator::make($input, self::rules())->validate();
/** @var Service $service */
$service = $server->monitoring();
/** @var ServiceInterface $handler */