2.x - firewall/metrics/services/cronjobs

This commit is contained in:
Saeed Vaziry
2024-10-01 19:09:38 +02:00
parent 2e9620409b
commit 906ddc38de
58 changed files with 1625 additions and 631 deletions

View File

@ -2,6 +2,7 @@
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@ -16,9 +17,15 @@
* @property float $disk_total
* @property float $disk_used
* @property float $disk_free
* @property-read float|int $memory_total_in_bytes
* @property-read float|int $memory_used_in_bytes
* @property-read float|int $memory_free_in_bytes
* @property-read float|int $disk_total_in_bytes
* @property-read float|int $disk_used_in_bytes
* @property-read float|int $disk_free_in_bytes
* @property Server $server
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property Carbon $created_at
* @property Carbon $updated_at
*/
class Metric extends Model
{
@ -50,4 +57,34 @@ public function server(): BelongsTo
{
return $this->belongsTo(Server::class);
}
public function getMemoryTotalInBytesAttribute(): float|int
{
return $this->memory_total * 1024;
}
public function getMemoryUsedInBytesAttribute(): float|int
{
return $this->memory_used * 1024;
}
public function getMemoryFreeInBytesAttribute(): float|int
{
return $this->memory_free * 1024;
}
public function getDiskTotalInBytesAttribute(): float|int
{
return $this->disk_total * (1024 * 1024);
}
public function getDiskUsedInBytesAttribute(): float|int
{
return $this->disk_used * (1024 * 1024);
}
public function getDiskFreeInBytesAttribute(): float|int
{
return $this->disk_free * (1024 * 1024);
}
}

View File

@ -21,6 +21,7 @@
* @property string $status
* @property bool $is_default
* @property Server $server
* @property string $image_url
*/
class Service extends AbstractModel
{
@ -116,4 +117,9 @@ public function disable(): void
{
$this->unit && app(Manage::class)->disable($this);
}
public function getImageUrlAttribute(): string
{
return url('/static/images/'.$this->name.'.svg');
}
}

View File

@ -5,11 +5,8 @@
use App\Enums\UserRole;
use App\Traits\HasTimezoneTimestamps;
use Carbon\Carbon;
use Filament\Models\Contracts\HasTenants;
use Filament\Panel;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
@ -42,7 +39,7 @@
* @property Carbon $created_at
* @property Carbon $updated_at
*/
class User extends Authenticatable implements HasTenants
class User extends Authenticatable
{
use HasFactory;
use HasTimezoneTimestamps;
@ -119,16 +116,6 @@ public function projects(): BelongsToMany
return $this->belongsToMany(Project::class, 'user_project')->withTimestamps();
}
public function getTenants(Panel $panel): Collection
{
return $this->projects;
}
public function canAccessTenant(Model $tenant): bool
{
return $this->projects()->whereKey($tenant)->exists();
}
public function currentProject(): HasOne
{
return $this->HasOne(Project::class, 'id', 'current_project_id');