Commit a2a87abf authored by Yassine Doghri's avatar Yassine Doghri
Browse files

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

parent fa6bb2f4
Loading
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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;
}
+8 −0
Original line number Diff line number Diff line
@@ -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;
+4 −0
Original line number Diff line number Diff line
@@ -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,
        ];

+1 −0
Original line number Diff line number Diff line
@@ -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',
];
+3 −1
Original line number Diff line number Diff line
@@ -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',