Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_TIMEZONE=Asia/Hong_Kong

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ yarn-error.log
/.fleet
/.idea
/.vscode
/dist
2 changes: 1 addition & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
|
*/

'timezone' => 'Asia/Hong_Kong',
'timezone' => env('APP_TIMEZONE', 'Asia/Hong_Kong'),

/*
|--------------------------------------------------------------------------
Expand Down
24 changes: 11 additions & 13 deletions resources/views/livewire/server/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@

state(['servers' => Monitor::all()]);

$editMonitor = function ($monitor) {
};

$deleteMonitor= function ($monitor) {
$deleteMonitor = function ($monitor) {
Monitor::destroy($monitor['id']);
};

$notificationTest = function () {
Notification::title('Hello from NativePHP')
->message('This is a detail message coming from your Laravel app.')
->show();
->message('This is a detail message coming from your Laravel app.')
->show();
}

// \Log::debug($monitor->toArray());
Expand All @@ -28,36 +26,36 @@
<div class="flex items-center justify-between mb-10">
<h1 class="text-xl font-bold">My Monitor {{ now()->format('H:i:s')}}</h1>
<a href="{{route('create')}}" type="button"
class="bg-pink-600 px-2 py-1 text-xs font-bold text-white shadow hover:bg-pink-500">Add Monitor</a>
class="bg-pink-600 px-2 py-1 text-xs font-bold text-white shadow hover:bg-pink-500">Add Monitor</a>
</div>
<div wire:poll>
@foreach($servers as $monitor)
<div wire:key="{{ $monitor->id }}" class="my-2 flex items-center justify-between">

<div>
{{-- align center vertical --}}
<p class="text-xs font-bold text-sky-500 flex items-center">

@if($monitor->certificate_status == 'valid' ?? false)
<x-heroicon-s-shield-check class="w-5 h-5 mr-2"/>
<x-heroicon-s-shield-check class="w-5 h-5 mr-2" />
@endif
{{$monitor->url}}
</p>

<p class="text-xs flex items-center">
Last Monitor: {{$monitor->uptime_last_check_date?->format('h:i:s A') ?? ''}}
<span>
@if($monitor->uptime_status == 'up' ?? false)
<x-heroicon-s-check class="w-5 h-5 ml-2"/>
<x-heroicon-s-check class="w-5 h-5 ml-2" />
@endif
</span>
</p>
</div>
<div class="flex items-center">
{{-- <button wire:click="editMonitor({{$monitor}})">
<a href="{{route('edit', ['server' => $monitor->id])}}" type="button">
<span class="sr-only">Edit</span>
<x-heroicon-m-pencil class="w-5 h-5 mr-3 hover:text-pink-500 transition-all duration-300" />
</button> --}}
</a>
<button wire:click="deleteMonitor({{$monitor}})">
<x-heroicon-m-trash class="w-5 h-5 mr-3 hover:text-red-600 transition-all duration-300" />
</button>
Expand Down
62 changes: 59 additions & 3 deletions resources/views/livewire/server/update.blade.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,67 @@
<?php

use function Livewire\Volt\{state};
use function Livewire\Volt\{rules};
use Spatie\UptimeMonitor\Models\Monitor;
use Spatie\Url\Url;
use Illuminate\Validation\Rule;

//
state([
// Estas closures se evalúan solo al montar el componente (primera carga)
'monitorId' => fn() => (int) request()->route('server'),
'url' => fn() => (string) Monitor::findOrFail((int) request()->route('server'))->getRawUrlAttribute(),
]);

rules(fn() => [
'url' => [
'required',
'starts_with:http,https',
Rule::unique('monitors', 'url')->ignore((int) $this->monitorId), //Prevent duplicate URLS, ignore the current monitor being edited
],
]);

$editMember = function () {

$this->url = rtrim((string) $this->url, '/');

$this->validate();

$urlObj = Url::fromString($this->url);

Monitor::whereKey($this->monitorId)->update([
'url' => $this->url,
'certificate_check_enabled' => $urlObj->getScheme() === 'https',
'uptime_check_interval_in_minutes' => config('uptime-monitor.uptime_check.run_interval_in_minutes'),
]);

redirect()->route('index');
};

?>

<div>
//
</div>
<div class="flex items-center justify-between mb-10">
<h1 class="text-xl font-bold">Edit Monitor Server</h1>
<a href="{{route('index')}}" type="button"
class=" bg-pink-600 px-2 py-1 text-xs font-bold text-white shadow hover:bg-pink-500 flex items-center">
Go Back
</a>
</div>
<form wire:submit="editMember">
<div>
<label for="name" class="block text-sm font-medium leading-6 text-gray-100">Current URL</label>
<div class="mt-2">
<input type="text" wire:model="url" id="url"
placeholder="https://laravel.com"
class="block p-2 w-full border-0 py-1.5 text-gray-400 shadow-sm bg-gray-800 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-pink-600 sm:text-sm sm:leading-6">
@error('url')
<div class="mt-1 text-red-500 text-sm">{{ $message }}</div>
@enderror
</div>
</div>

<button type="submit"
class="mt-6 bg-pink-600 px-2 py-1 font-bold text-white shadow hover:bg-pink-500 w-full">Edit Monitor URL
</button>
</form>
</div>