mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 00:02:15 +00:00
- language updates
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Domain\Admin\Controllers\Dashboard;
|
||||
|
||||
use ByteUnits\Metric;
|
||||
@@ -14,6 +15,8 @@ class GetDashboardDataController extends Controller
|
||||
{
|
||||
public function __invoke(): Application|ResponseFactory|Response
|
||||
{
|
||||
list($originalTranslations, $activeTranslations) = $this->countTranslations();
|
||||
|
||||
// Get bandwidth data
|
||||
list($upload, $download, $uploadTotal, $downloadTotal, $storageUsage) = $this->getDiskData();
|
||||
|
||||
@@ -39,11 +42,12 @@ class GetDashboardDataController extends Controller
|
||||
'records' => $upload,
|
||||
],
|
||||
],
|
||||
'app' => [
|
||||
'isRunningCron' => isRunningCron(),
|
||||
'license' => get_settings('license'),
|
||||
'version' => config('vuefilemanager.version'),
|
||||
'earnings' => format_currency($totalEarnings, 'USD'), // todo: refactor currency to global setup or plan currency
|
||||
'app' => [
|
||||
'shouldUpgradeTranslations' => $activeTranslations !== $originalTranslations,
|
||||
'isRunningCron' => isRunningCron(),
|
||||
'license' => get_settings('license'),
|
||||
'version' => config('vuefilemanager.version'),
|
||||
'earnings' => format_currency($totalEarnings, 'USD'), // todo: refactor currency to global setup or plan currency
|
||||
],
|
||||
]);
|
||||
}
|
||||
@@ -64,18 +68,18 @@ class GetDashboardDataController extends Controller
|
||||
DB::raw('sum(download) as download'),
|
||||
DB::raw('sum(upload) as upload'),
|
||||
])
|
||||
->each(fn ($record) => $record->date = format_date($record->date, 'd. M. Y'))
|
||||
->each(fn($record) => $record->date = format_date($record->date, 'd. M. Y'))
|
||||
->keyBy('date');
|
||||
|
||||
$mappedTrafficRecords = mapTrafficRecords($trafficRecords);
|
||||
|
||||
$upload = $mappedTrafficRecords->map(fn ($record) => [
|
||||
$upload = $mappedTrafficRecords->map(fn($record) => [
|
||||
'created_at' => $record->date,
|
||||
'percentage' => intval($trafficRecords->max('upload')) !== 0 ? round(($record->upload / $trafficRecords->max('upload')) * 100, 2) : 0,
|
||||
'amount' => Metric::bytes($record->upload)->format(),
|
||||
]);
|
||||
|
||||
$download = $mappedTrafficRecords->map(fn ($record) => [
|
||||
$download = $mappedTrafficRecords->map(fn($record) => [
|
||||
'created_at' => $record->date,
|
||||
'percentage' => intval($trafficRecords->max('download')) !== 0 ? round(($record->download / $trafficRecords->max('download')) * 100, 2) : 0,
|
||||
'amount' => Metric::bytes($record->download)->format(),
|
||||
@@ -101,4 +105,29 @@ class GetDashboardDataController extends Controller
|
||||
|
||||
return [$upload, $download, $uploadTotal, $downloadTotal, $storageUsage];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function countTranslations(): array
|
||||
{
|
||||
$default_translations = [
|
||||
'extended' => collect([
|
||||
config('language-translations.extended'),
|
||||
config('language-translations.regular'),
|
||||
config('custom-language-translations'),
|
||||
])->collapse(),
|
||||
'regular' => collect([
|
||||
config('language-translations.regular'),
|
||||
config('custom-language-translations'),
|
||||
])->collapse(),
|
||||
];
|
||||
|
||||
$originalTranslationCount = count($default_translations[get_settings('license')]);
|
||||
|
||||
$activeTranslationsCount = DB::table('language_translations')
|
||||
->where('lang', 'en')
|
||||
->count();
|
||||
return array($originalTranslationCount, $activeTranslationsCount);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user