You could've just asked...

This commit is contained in:
James Cole 2024-05-21 17:48:54 +02:00
parent dfe055732d
commit 477524a8ae
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
4 changed files with 1711 additions and 1702 deletions

View File

@ -61,11 +61,11 @@ class HomeController extends Controller
*/ */
public function dateRange(Request $request): JsonResponse public function dateRange(Request $request): JsonResponse
{ {
$stringStart = ''; $stringStart = '';
$stringEnd = ''; $stringEnd = '';
try { try {
$stringStart = e((string)$request->get('start')); $stringStart = e((string) $request->get('start'));
$start = Carbon::createFromFormat('Y-m-d', $stringStart); $start = Carbon::createFromFormat('Y-m-d', $stringStart);
} catch (InvalidFormatException $e) { } catch (InvalidFormatException $e) {
app('log')->error(sprintf('Start: could not parse date string "%s" so ignore it.', $stringStart)); app('log')->error(sprintf('Start: could not parse date string "%s" so ignore it.', $stringStart));
@ -73,7 +73,7 @@ class HomeController extends Controller
} }
try { try {
$stringEnd = e((string)$request->get('end')); $stringEnd = e((string) $request->get('end'));
$end = Carbon::createFromFormat('Y-m-d', $stringEnd); $end = Carbon::createFromFormat('Y-m-d', $stringEnd);
} catch (InvalidFormatException $e) { } catch (InvalidFormatException $e) {
app('log')->error(sprintf('End could not parse date string "%s" so ignore it.', $stringEnd)); app('log')->error(sprintf('End could not parse date string "%s" so ignore it.', $stringEnd));
@ -92,15 +92,15 @@ class HomeController extends Controller
app('log')->debug('dateRange: Received dateRange', ['start' => $stringStart, 'end' => $stringEnd, 'label' => $request->get('label')]); app('log')->debug('dateRange: Received dateRange', ['start' => $stringStart, 'end' => $stringEnd, 'label' => $request->get('label')]);
// check if the label is "everything" or "Custom range" which will betray // check if the label is "everything" or "Custom range" which will betray
// a possible problem with the budgets. // a possible problem with the budgets.
if ($label === (string)trans('firefly.everything') || $label === (string)trans('firefly.customRange')) { if ($label === (string) trans('firefly.everything') || $label === (string) trans('firefly.customRange')) {
$isCustomRange = true; $isCustomRange = true;
app('log')->debug('Range is now marked as "custom".'); app('log')->debug('Range is now marked as "custom".');
} }
$diff = $start->diffInDays($end, true) + 1; $diff = $start->diffInDays($end, true) + 1;
if ($diff > 366) { if ($diff > 366) {
$request->session()->flash('warning', (string)trans('firefly.warning_much_data', ['days' => (int)$diff])); $request->session()->flash('warning', (string) trans('firefly.warning_much_data', ['days' => (int) $diff]));
} }
$request->session()->put('is_custom_range', $isCustomRange); $request->session()->put('is_custom_range', $isCustomRange);
@ -128,10 +128,10 @@ class HomeController extends Controller
return redirect(route('new-user.index')); return redirect(route('new-user.index'));
} }
if ('v1' === (string)config('view.layout')) { if ('v1' === (string) config('view.layout')) {
return $this->indexV1($repository); return $this->indexV1($repository);
} }
if ('v2' === (string)config('view.layout')) { if ('v2' === (string) config('view.layout')) {
return $this->indexV2(); return $this->indexV2();
} }
@ -141,8 +141,9 @@ class HomeController extends Controller
private function indexV1(AccountRepositoryInterface $repository): mixed private function indexV1(AccountRepositoryInterface $repository): mixed
{ {
$types = config('firefly.accountTypesByIdentifier.asset'); $types = config('firefly.accountTypesByIdentifier.asset');
$pageTitle = (string) trans('firefly.main_dashboard_page_title');
$count = $repository->count($types); $count = $repository->count($types);
$subTitle = (string)trans('firefly.welcome_back'); $subTitle = (string) trans('firefly.welcome_back');
$transactions = []; $transactions = [];
$frontpage = app('preferences')->getFresh('frontpageAccounts', $repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray()); $frontpage = app('preferences')->getFresh('frontpageAccounts', $repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray());
$frontpageArray = $frontpage->data; $frontpageArray = $frontpage->data;
@ -151,13 +152,13 @@ class HomeController extends Controller
} }
/** @var Carbon $start */ /** @var Carbon $start */
$start = session('start', today(config('app.timezone'))->startOfMonth()); $start = session('start', today(config('app.timezone'))->startOfMonth());
/** @var Carbon $end */ /** @var Carbon $end */
$end = session('end', today(config('app.timezone'))->endOfMonth()); $end = session('end', today(config('app.timezone'))->endOfMonth());
$accounts = $repository->getAccountsById($frontpageArray); $accounts = $repository->getAccountsById($frontpageArray);
$today = today(config('app.timezone')); $today = today(config('app.timezone'));
$accounts = $accounts->sortBy('order'); // sort frontpage accounts by order $accounts = $accounts->sortBy('order'); // sort frontpage accounts by order
app('log')->debug('Frontpage accounts are ', $frontpageArray); app('log')->debug('Frontpage accounts are ', $frontpageArray);
@ -167,30 +168,31 @@ class HomeController extends Controller
// collect groups for each transaction. // collect groups for each transaction.
foreach ($accounts as $account) { foreach ($accounts as $account) {
/** @var GroupCollectorInterface $collector */ /** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setAccounts(new Collection([$account]))->withAccountInformation()->setRange($start, $end)->setLimit(10)->setPage(1); $collector->setAccounts(new Collection([$account]))->withAccountInformation()->setRange($start, $end)->setLimit(10)->setPage(1);
$set = $collector->getExtractedJournals(); $set = $collector->getExtractedJournals();
$transactions[] = ['transactions' => $set, 'account' => $account]; $transactions[] = ['transactions' => $set, 'account' => $account];
} }
/** @var User $user */ /** @var User $user */
$user = auth()->user(); $user = auth()->user();
event(new RequestedVersionCheckStatus($user)); event(new RequestedVersionCheckStatus($user));
return view('index', compact('count', 'subTitle', 'transactions', 'billCount', 'start', 'end', 'today')); return view('index', compact('count', 'subTitle', 'transactions', 'billCount', 'start', 'end', 'today', 'pageTitle'));
} }
private function indexV2(): mixed private function indexV2(): mixed
{ {
$subTitle = (string)trans('firefly.welcome_back'); $subTitle = (string) trans('firefly.welcome_back');
$pageTitle = (string) trans('firefly.main_dashboard_page_title');
$start = session('start', today(config('app.timezone'))->startOfMonth()); $start = session('start', today(config('app.timezone'))->startOfMonth());
$end = session('end', today(config('app.timezone'))->endOfMonth()); $end = session('end', today(config('app.timezone'))->endOfMonth());
/** @var User $user */ /** @var User $user */
$user = auth()->user(); $user = auth()->user();
event(new RequestedVersionCheckStatus($user)); event(new RequestedVersionCheckStatus($user));
return view('index', compact('subTitle', 'start', 'end')); return view('index', compact('subTitle', 'start', 'end', 'pageTitle'));
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,10 @@
<meta name="color-scheme" content="light dark"> <meta name="color-scheme" content="light dark">
<title> <title>
{% if subTitle %} {% if pageTitle %}
{{ pageTitle }} »
{% endif %}
{% if subTitle and not pageTitle %}
{{ subTitle }} » {{ subTitle }} »
{% endif %} {% endif %}
{% if title != "Firefly III" %} {% if title != "Firefly III" %}

View File

@ -56,9 +56,12 @@
</script> </script>
<title> <title>
@if($subTitle) @if($subTitle && null === ($pageTitle ?? null))
{{ $subTitle }} » {{ $subTitle }} »
@endif @endif
@if(null !== ($pageTitle ?? null))
{{ $pageTitle }} »
@endif
@if($title !== 'Firefly III') @if($title !== 'Firefly III')
{{ $title }} » {{ $title }} »