mirror of
https://github.com/ad-aures/castopod.git
synced 2026-04-04 15:26:43 +02:00
feat(admin): add instance wide dashboard with storage and bandwidth usage
* add DashboardCard component * add instance wide podcasts and episodes numbers * add app.storageLimit environment variable * divide bytes by 1000 instead of 1024 in stats sql queries closes #216
This commit is contained in:
parent
3d363f2efe
commit
b1a6c02e56
57 changed files with 394 additions and 139 deletions
|
|
@ -10,6 +10,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Analytics\Controllers;
|
||||
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
use CodeIgniter\Controller;
|
||||
use CodeIgniter\Exceptions\PageNotFoundException;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
|
|
@ -17,6 +18,8 @@ use CodeIgniter\Model;
|
|||
|
||||
class AnalyticsController extends Controller
|
||||
{
|
||||
use ResponseTrait;
|
||||
|
||||
protected Model $analyticsModel;
|
||||
|
||||
protected string $methodName = '';
|
||||
|
|
@ -27,6 +30,12 @@ class AnalyticsController extends Controller
|
|||
throw PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
if (! is_numeric($params[0])) {
|
||||
$this->analyticsModel = model('Analytics' . $params[0] . 'Model');
|
||||
$this->methodName = 'getData' . $params[1];
|
||||
return $this->{$method}();
|
||||
}
|
||||
|
||||
$this->analyticsModel = model('Analytics' . $params[1] . 'Model');
|
||||
$this->methodName = 'getData' . (count($params) >= 3 ? $params[2] : '');
|
||||
|
||||
|
|
@ -36,14 +45,18 @@ class AnalyticsController extends Controller
|
|||
);
|
||||
}
|
||||
|
||||
public function getData(int $podcastId, ?int $episodeId = null): ResponseInterface
|
||||
public function getData(?int $podcastId = null, ?int $episodeId = null): ResponseInterface
|
||||
{
|
||||
$methodName = $this->methodName;
|
||||
|
||||
if ($episodeId === null) {
|
||||
return $this->response->setJSON($this->analyticsModel->{$methodName}($podcastId));
|
||||
if ($podcastId === null) {
|
||||
return $this->respond($this->analyticsModel->{$methodName}());
|
||||
}
|
||||
|
||||
return $this->response->setJSON($this->analyticsModel->{$methodName}($podcastId, $episodeId));
|
||||
if ($episodeId === null) {
|
||||
return $this->respond($this->analyticsModel->{$methodName}($podcastId));
|
||||
}
|
||||
|
||||
return $this->respond($this->analyticsModel->{$methodName}($podcastId, $episodeId));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue