An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix: charts
Andras Bacsai36f251e7102b
diff --git a/app/Livewire/Charts/ServerCpu.php b/app/Livewire/Charts/ServerCpu.phpindex 454f591938..50a7e115e5 100644--- a/app/Livewire/Charts/ServerCpu.php+++ b/app/Livewire/Charts/ServerCpu.php@@ -15,7 +15,9 @@ class ServerCpu extends Componentpublic $categories;- public $interval = 5;+ public int $interval = 5;++ public bool $poll = true;public function render(){@@ -27,6 +29,16 @@ class ServerCpu extends Component$this->loadData();}+ public function pollData()+ {+ if ($this->poll || $this->interval <= 10) {+ $this->loadData();+ if ($this->interval > 10) {+ $this->poll = false;+ }+ }+ }+public function loadData(){try {@@ -44,6 +56,9 @@ class ServerCpu extends Componentpublic function setInterval(){+ if ($this->interval <= 10) {+ $this->poll = true;+ }$this->loadData();}}diff --git a/app/Livewire/Charts/ServerMemory.php b/app/Livewire/Charts/ServerMemory.phpindex f3f992e979..15a2345f52 100644--- a/app/Livewire/Charts/ServerMemory.php+++ b/app/Livewire/Charts/ServerMemory.php@@ -15,13 +15,25 @@ class ServerMemory extends Componentpublic $categories;- public $interval = 5;+ public int $interval = 5;++ public bool $poll = true;public function render(){return view('livewire.charts.server-memory');}+ public function pollData()+ {+ if ($this->poll || $this->interval <= 10) {+ $this->loadData();+ if ($this->interval > 10) {+ $this->poll = false;+ }+ }+ }+public function mount(){$this->loadData();@@ -44,6 +56,9 @@ class ServerMemory extends Componentpublic function setInterval(){+ if ($this->interval <= 10) {+ $this->poll = true;+ }$this->loadData();}}diff --git a/app/Models/Server.php b/app/Models/Server.phpindex 1dedf80458..3d40042bb8 100644--- a/app/Models/Server.php+++ b/app/Models/Server.php@@ -498,28 +498,11 @@ $schema://$host {$parsedCollection = collect($cpu)->flatMap(function ($item) {return collect(explode("\n", trim($item)))->map(function ($line) {[$time, $value] = explode(',', trim($line));+ $value = number_format($value, 0);return [(int) $time, (float) $value];});});- if ($mins === 30 || $mins === 60) {- $parsedCollection = $parsedCollection->filter(function ($item, $key) {- return $key % 5 === 0;- });- $parsedCollection = $parsedCollection->values();- }- if ($mins === 720) {- $parsedCollection = $parsedCollection->filter(function ($item, $key) {- return $key % 10 === 0;- });- $parsedCollection = $parsedCollection->values();- }- if ($mins === 10080) {- $parsedCollection = $parsedCollection->filter(function ($item, $key) {- return $key % 20 === 0;- });- $parsedCollection = $parsedCollection->values();- }return $parsedCollection->toArray();}@@ -542,28 +525,11 @@ $schema://$host {$parsedCollection = collect($memory)->flatMap(function ($item) {return collect(explode("\n", trim($item)))->map(function ($line) {[$time, $used, $free, $usedPercent] = explode(',', trim($line));+ $usedPercent = number_format($usedPercent, 0);return [(int) $time, (float) $usedPercent];});});- if ($mins === 30 || $mins === 60) {- $parsedCollection = $parsedCollection->filter(function ($item, $key) {- return $key % 5 === 0;- });- $parsedCollection = $parsedCollection->values();- }- if ($mins === 720) {- $parsedCollection = $parsedCollection->filter(function ($item, $key) {- return $key % 10 === 0;- });- $parsedCollection = $parsedCollection->values();- }- if ($mins === 10080) {- $parsedCollection = $parsedCollection->filter(function ($item, $key) {- return $key % 20 === 0;- });- $parsedCollection = $parsedCollection->values();- }return $parsedCollection->toArray();}diff --git a/resources/views/livewire/charts/server-cpu.blade.php b/resources/views/livewire/charts/server-cpu.blade.phpindex ff85f94f1d..a6eefdf155 100644--- a/resources/views/livewire/charts/server-cpu.blade.php+++ b/resources/views/livewire/charts/server-cpu.blade.php@@ -1,8 +1,8 @@-<div wire:poll.5000ms='loadData'>+<div @if ($poll) wire:poll.5000ms='pollData' @endif><h3>CPU</h3><x-forms.select label="Interval" wire:change="setInterval" id="interval">- <option value="5">5 minutes</option>- <option value="10">10 minutes</option>+ <option value="5">5 minutes (live)</option>+ <option value="10">10 minutes (live)</option><option value="30">30 minutes</option><option value="60">1 hour</option><option value="720">12 hours</option>diff --git a/resources/views/livewire/charts/server-memory.blade.php b/resources/views/livewire/charts/server-memory.blade.phpindex 1b29e20b66..8003a6eabf 100644--- a/resources/views/livewire/charts/server-memory.blade.php+++ b/resources/views/livewire/charts/server-memory.blade.php@@ -1,8 +1,8 @@-<div wire:poll.5000ms='loadData'>+<div @if ($poll) wire:poll.5000ms='pollData' @endif><h3>Memory</h3><x-forms.select label="Interval" wire:change="setInterval" id="interval">- <option value="5">5 minutes</option>- <option value="10">10 minutes</option>+ <option value="5">5 minutes (live)</option>+ <option value="10">10 minutes (live)</option><option value="30">30 minutes</option><option value="60">1 hour</option><option value="720">12 hours</option>