fix: display bandwidth limit on dashboard when set in .env

This commit is contained in:
Yassine Doghri 2022-12-28 16:57:14 +00:00
parent fa6bb2f492
commit a2a87abf7c
5 changed files with 21 additions and 1 deletions

View File

@ -457,5 +457,10 @@ class App extends BaseConfig
*/
public ?int $storageLimit = null;
/**
* Bandwidth limit (per month) in Gigabytes
*/
public ?int $bandwidthLimit = null;
public ?string $legalNoticeURL = null;
}

View File

@ -10,15 +10,23 @@ class ChartsComponent extends Component
{
protected string $title = '';
protected string $subtitle = '';
protected string $dataUrl = '';
protected string $type = '';
public function render(): string
{
$subtitleBlock = '';
if ($this->subtitle !== '') {
$subtitleBlock = '<p class="px-6 -mt-4 text-sm text-skin-muted">' . $this->subtitle . '</p>';
}
return <<<HTML
<div class="bg-elevated border-3 rounded-xl border-subtle {$this->class}">
<h2 class="px-6 py-4 text-xl">{$this->title}</h2>
{$subtitleBlock}
<div class="w-full h-[500px]" data-chart-type="{$this->type}" data-chart-url="{$this->dataUrl}"></div>
</div>
HTML;

View File

@ -70,10 +70,14 @@ class DashboardController extends BaseController
->id;
}
$bandwidthLimit = config('App')
->bandwidthLimit;
$data = [
'podcastsData' => $podcastsData,
'episodesData' => $episodesData,
'storageData' => $storageData,
'bandwidthLimit' => $bandwidthLimit === null ? null : formatBytes($bandwidthLimit * 1000000000),
'onlyPodcastId' => $onlyPodcastId,
];

View File

@ -37,4 +37,5 @@ return [
'podcast_by_bandwidth' => 'Daily used bandwidth (in MB)',
'total_storage_by_month' => 'Monthly storage (in MB)',
'total_bandwidth_by_month' => 'Monthly used bandwidth (in MB)',
'total_bandwidth_by_month_limit' => 'Limited to {totalBandwidth} per month',
];

View File

@ -30,7 +30,9 @@
'Podcast',
'TotalStorageByMonth',
) ?>" />
<Charts.XY class="col-span-1" title="<?= lang('Charts.total_bandwidth_by_month') ?>" dataUrl="<?= route_to(
<Charts.XY class="col-span-1" title="<?= lang('Charts.total_bandwidth_by_month') ?>" subtitle="<?= $bandwidthLimit !== null ? lang('Charts.total_bandwidth_by_month_limit', [
'totalBandwidth' => $bandwidthLimit,
]) : '' ?>" dataUrl="<?= route_to(
'analytics-data-instance',
'Podcast',
'TotalBandwidthByMonth',