Skip to content

Firefly III: a personal finances manager

Expand index.

James Colec2ddabbad2c8
diff --git a/app/Http/Controllers/Transaction/IndexController.php b/app/Http/Controllers/Transaction/IndexController.php
index f51ef06aa4..bbc6f95e63 100644
--- a/app/Http/Controllers/Transaction/IndexController.php
+++ b/app/Http/Controllers/Transaction/IndexController.php
@@ -75,45 +75,52 @@ class IndexController extends Controller
$objectType = 'transfer';
}
- $subTitleIcon = config('firefly.transactionIconsByType.'.$objectType);
- $types = config('firefly.transactionTypesByType.'.$objectType);
- $page = (int)$request->get('page');
- $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
- if (null === $start) {
- $start = session('start');
- $end = session('end');
- }
- if (null === $end) {
- // get last transaction ever?
- $last = $this->repository->getLast();
- $end = null !== $last ? $last->date : session('end');
- }
+ // add a split for the (future) v2 release.
+ $periods = [];
+ $groups = [];
+ $subTitle = 'TODO page subtitle in v2';
- [$start, $end] = $end < $start ? [$end, $start] : [$start, $end];
- $path = route('transactions.index', [$objectType, $start->format('Y-m-d'), $end->format('Y-m-d')]);
- $startStr = $start->isoFormat($this->monthAndDayFormat);
- $endStr = $end->isoFormat($this->monthAndDayFormat);
- $subTitle = (string)trans(sprintf('firefly.title_%s_between', $objectType), ['start' => $startStr, 'end' => $endStr]);
+ $subTitleIcon = config('firefly.transactionIconsByType.' . $objectType);
+ $types = config('firefly.transactionTypesByType.' . $objectType);
+ $page = (int)$request->get('page');
+ $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
- $firstJournal = $this->repository->firstNull();
- $startPeriod = null === $firstJournal ? new Carbon() : $firstJournal->date;
- $endPeriod = clone $end;
- $periods = $this->getTransactionPeriodOverview($objectType, $startPeriod, $endPeriod);
+ if ('v2' !== (string)config('firefly.layout')) {
+ if (null === $start) {
+ $start = session('start');
+ $end = session('end');
+ }
+ if (null === $end) {
+ // get last transaction ever?
+ $last = $this->repository->getLast();
+ $end = null !== $last ? $last->date : session('end');
+ }
- /** @var GroupCollectorInterface $collector */
- $collector = app(GroupCollectorInterface::class);
+ [$start, $end] = $end < $start ? [$end, $start] : [$start, $end];
+ $startStr = $start->isoFormat($this->monthAndDayFormat);
+ $endStr = $end->isoFormat($this->monthAndDayFormat);
+ $subTitle = (string)trans(sprintf('firefly.title_%s_between', $objectType), ['start' => $startStr, 'end' => $endStr]);
+ $path = route('transactions.index', [$objectType, $start->format('Y-m-d'), $end->format('Y-m-d')]);
+ $firstJournal = $this->repository->firstNull();
+ $startPeriod = null === $firstJournal ? new Carbon() : $firstJournal->date;
+ $endPeriod = clone $end;
+ $periods = $this->getTransactionPeriodOverview($objectType, $startPeriod, $endPeriod);
+
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+
+ $collector->setRange($start, $end)
+ ->setTypes($types)
+ ->setLimit($pageSize)
+ ->setPage($page)
+ ->withBudgetInformation()
+ ->withCategoryInformation()
+ ->withAccountInformation()
+ ->withAttachmentInformation();
+ $groups = $collector->getPaginatedGroups();
+ $groups->setPath($path);
+ }
- $collector->setRange($start, $end)
- ->setTypes($types)
- ->setLimit($pageSize)
- ->setPage($page)
- ->withBudgetInformation()
- ->withCategoryInformation()
- ->withAccountInformation()
- ->withAttachmentInformation()
- ;
- $groups = $collector->getPaginatedGroups();
- $groups->setPath($path);
return view('transactions.index', compact('subTitle', 'objectType', 'subTitleIcon', 'groups', 'periods', 'start', 'end'));
}
@@ -125,8 +132,8 @@ class IndexController extends Controller
*/
public function indexAll(Request $request, string $objectType)
{
- $subTitleIcon = config('firefly.transactionIconsByType.'.$objectType);
- $types = config('firefly.transactionTypesByType.'.$objectType);
+ $subTitleIcon = config('firefly.transactionIconsByType.' . $objectType);
+ $types = config('firefly.transactionTypesByType.' . $objectType);
$page = (int)$request->get('page');
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$path = route('transactions.index.all', [$objectType]);
@@ -134,21 +141,20 @@ class IndexController extends Controller
$start = null === $first ? new Carbon() : $first->date;
$last = $this->repository->getLast();
$end = null !== $last ? $last->date : today(config('app.timezone'));
- $subTitle = (string)trans('firefly.all_'.$objectType);
+ $subTitle = (string)trans('firefly.all_' . $objectType);
/** @var GroupCollectorInterface $collector */
- $collector = app(GroupCollectorInterface::class);
+ $collector = app(GroupCollectorInterface::class);
$collector->setRange($start, $end)
- ->setTypes($types)
- ->setLimit($pageSize)
- ->setPage($page)
- ->withAccountInformation()
- ->withBudgetInformation()
- ->withCategoryInformation()
- ->withAttachmentInformation()
- ;
- $groups = $collector->getPaginatedGroups();
+ ->setTypes($types)
+ ->setLimit($pageSize)
+ ->setPage($page)
+ ->withAccountInformation()
+ ->withBudgetInformation()
+ ->withCategoryInformation()
+ ->withAttachmentInformation();
+ $groups = $collector->getPaginatedGroups();
$groups->setPath($path);
return view('transactions.index', compact('subTitle', 'objectType', 'subTitleIcon', 'groups', 'start', 'end'));
diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php
index 49c6271e8d..e7ebfab689 100644
--- a/app/Providers/AppServiceProvider.php
+++ b/app/Providers/AppServiceProvider.php
@@ -28,6 +28,7 @@ use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
use Laravel\Passport\Passport;
use Laravel\Sanctum\Sanctum;
+use Illuminate\Support\Facades\Blade;
/**
* Class AppServiceProvider
@@ -51,8 +52,25 @@ class AppServiceProvider extends ServiceProvider
return response()
->json($value)
- ->withHeaders($headers)
- ;
+ ->withHeaders($headers);
+ });
+
+ // blade extension
+ Blade::directive('activeXRoutePartial', function (string $route) {
+ $name = \Route::getCurrentRoute()->getName() ?? '';
+ if (str_contains($name, $route)) {
+ return 'menu-open';
+ }
+
+ return '';
+ });
+ Blade::if('partialroute', function (string $route) {
+ $name = \Route::getCurrentRoute()->getName() ?? '';
+ if (str_contains($name, $route)) {
+ return true;
+ }
+
+ return false;
});
}
diff --git a/composer.json b/composer.json
index cb56304420..0fce808942 100644
--- a/composer.json
+++ b/composer.json
@@ -110,12 +110,13 @@
"therobfonz/laravel-mandrill-driver": "^5.0"
},
"require-dev": {
+ "barryvdh/laravel-debugbar": "^3.9",
"barryvdh/laravel-ide-helper": "2.*",
"ergebnis/phpstan-rules": "^2.1",
"fakerphp/faker": "1.*",
"filp/whoops": "2.*",
- "mockery/mockery": "1.*",
"larastan/larastan": "^2",
+ "mockery/mockery": "1.*",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-deprecation-rules": "^1.1",
diff --git a/composer.lock b/composer.lock
index c8f5f75f3d..1efffe576b 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "84061ba3494e12bf5871a59c5a4744d4",
+ "content-hash": "a290b73e0cc243be7afa30409d4069a4",
"packages": [
{
"name": "bacon/bacon-qr-code",
@@ -9016,6 +9016,90 @@
}
],
"packages-dev": [
+ {
+ "name": "barryvdh/laravel-debugbar",
+ "version": "v3.9.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/barryvdh/laravel-debugbar.git",
+ "reference": "bfd0131c146973cab164e50f5cdd8a67cc60cab1"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/bfd0131c146973cab164e50f5cdd8a67cc60cab1",
+ "reference": "bfd0131c146973cab164e50f5cdd8a67cc60cab1",
+ "shasum": ""
+ },
+ "require": {
+ "illuminate/routing": "^9|^10",
+ "illuminate/session": "^9|^10",
+ "illuminate/support": "^9|^10",
+ "maximebf/debugbar": "^1.18.2",
+ "php": "^8.0",
+ "symfony/finder": "^6"
+ },
+ "require-dev": {
+ "mockery/mockery": "^1.3.3",
+ "orchestra/testbench-dusk": "^5|^6|^7|^8",
+ "phpunit/phpunit": "^8.5.30|^9.0",
+ "squizlabs/php_codesniffer": "^3.5"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.8-dev"
+ },
+ "laravel": {
+ "providers": [
+ "Barryvdh\\Debugbar\\ServiceProvider"
+ ],
+ "aliases": {
+ "Debugbar": "Barryvdh\\Debugbar\\Facades\\Debugbar"
+ }
+ }
+ },
+ "autoload": {
+ "files": [
+ "src/helpers.php"
+ ],
+ "psr-4": {
+ "Barryvdh\\Debugbar\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Barry vd. Heuvel",
+ "email": "[email protected]"
+ }
+ ],
+ "description": "PHP Debugbar integration for Laravel",
+ "keywords": [
+ "debug",
+ "debugbar",
+ "laravel",
+ "profiler",
+ "webprofiler"
+ ],
+ "support": {
+ "issues": "https://github.com/barryvdh/laravel-debugbar/issues",
+ "source": "https://github.com/barryvdh/laravel-debugbar/tree/v3.9.2"
+ },
+ "funding": [
+ {
+ "url": "https://fruitcake.nl",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/barryvdh",
+ "type": "github"
+ }
+ ],
+ "time": "2023-08-25T18:43:57+00:00"
+ },
{
"name": "barryvdh/laravel-ide-helper",
"version": "v2.13.0",
@@ -9593,6 +9677,72 @@
],
"time": "2024-01-02T22:09:07+00:00"
},
+ {
+ "name": "maximebf/debugbar",
+ "version": "v1.19.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/maximebf/php-debugbar.git",
+ "reference": "03dd40a1826f4d585ef93ef83afa2a9874a00523"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/03dd40a1826f4d585ef93ef83afa2a9874a00523",
+ "reference": "03dd40a1826f4d585ef93ef83afa2a9874a00523",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.1|^8",
+ "psr/log": "^1|^2|^3",
+ "symfony/var-dumper": "^4|^5|^6"
+ },
+ "require-dev": {
+ "phpunit/phpunit": ">=7.5.20 <10.0",
+ "twig/twig": "^1.38|^2.7|^3.0"
+ },
+ "suggest": {
+ "kriswallsmith/assetic": "The best way to manage assets",
+ "monolog/monolog": "Log using Monolog",
+ "predis/predis": "Redis storage"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.18-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "DebugBar\\": "src/DebugBar/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Maxime Bouroumeau-Fuseau",
+ "email": "[email protected]",
+ "homepage": "http://maximebf.com"
+ },
+ {
+ "name": "Barry vd. Heuvel",
+ "email": "[email protected]"
+ }
+ ],
+ "description": "Debug bar in the browser for php application",
+ "homepage": "https://github.com/maximebf/php-debugbar",
+ "keywords": [
+ "debug",
+ "debugbar"
+ ],
+ "support": {
+ "issues": "https://github.com/maximebf/php-debugbar/issues",
+ "source": "https://github.com/maximebf/php-debugbar/tree/v1.19.1"
+ },
+ "time": "2023-10-12T08:10:52+00:00"
+ },
{
"name": "mockery/mockery",
"version": "1.6.7",
diff --git a/config/debugbar.php b/config/debugbar.php
deleted file mode 100644
index 8260a9d88b..0000000000
--- a/config/debugbar.php
+++ /dev/null
@@ -1,223 +0,0 @@
-<?php
-/**
- * debugbar.php
- * Copyright (c) 2020 [email protected]
- *
- * This file is part of Firefly III (https://github.com/firefly-iii).
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-declare(strict_types=1);
-
-return [
- /*
- |--------------------------------------------------------------------------
- | Debugbar Settings
- |--------------------------------------------------------------------------
- |
- | Debugbar is enabled by default, when debug is set to true in app.php.
- | You can override the value by setting enable to true or false instead of null.
- |
- | You can provide an array of URI's that must be ignored (eg. 'api/*')
- |
- */
-
- 'enabled' => env('DEBUGBAR_ENABLED', null),
- 'except' => [
- 'telescope*',
- ],
-
- /*
- |--------------------------------------------------------------------------
- | Storage settings
- |--------------------------------------------------------------------------
- |
- | DebugBar stores data for session/ajax requests.
- | You can disable this, so the debugbar stores data in headers/session,
- | but this can cause problems with large data collectors.
- | By default, file storage (in the storage folder) is used. Redis and PDO
- | can also be used. For PDO, run the package migrations first.
- |
- */
- 'storage' => [
- 'enabled' => true,
- 'driver' => 'file', // redis, file, pdo, custom
- 'path' => storage_path('debugbar'), // For file driver
- 'connection' => null, // Leave null for default connection (Redis/PDO)
- 'provider' => '', // Instance of StorageInterface for custom driver
- ],
-
- /*
- |--------------------------------------------------------------------------
- | Vendors
- |--------------------------------------------------------------------------
- |
- | Vendor files are included by default, but can be set to false.
- | This can also be set to 'js' or 'css', to only include javascript or css vendor files.
- | Vendor files are for css: font-awesome (including fonts) and highlight.js (css files)
- | and for js: jquery and and highlight.js
- | So if you want syntax highlighting, set it to true.
- | jQuery is set to not conflict with existing jQuery scripts.
- |
- */
-
- 'include_vendors' => true,
-
- /*
- |--------------------------------------------------------------------------
- | Capture Ajax Requests
- |--------------------------------------------------------------------------
- |
- | The Debugbar can capture Ajax requests and display them. If you don't want this (ie. because of errors),
- | you can use this option to disable sending the data through the headers.
- |
- | Optionally, you can also send ServerTiming headers on ajax requests for the Chrome DevTools.
- */
-
- 'capture_ajax' => true,
- 'add_ajax_timing' => false,
-
- /*
- |--------------------------------------------------------------------------
- | Custom Error Handler for Deprecated warnings
- |--------------------------------------------------------------------------
- |
- | When enabled, the Debugbar shows deprecated warnings for Symfony components
- | in the Messages tab.
- |
- */
- 'error_handler' => true,
-
- /*
- |--------------------------------------------------------------------------
- | Clockwork integration
- |--------------------------------------------------------------------------
- |
- | The Debugbar can emulate the Clockwork headers, so you can use the Chrome
- | Extension, without the server-side code. It uses Debugbar collectors instead.
- |
- */
- 'clockwork' => false,
-
- /*
- |--------------------------------------------------------------------------
- | DataCollectors
- |--------------------------------------------------------------------------
- |
- | Enable/disable DataCollectors
- |
- */
-
- 'collectors' => [
- 'phpinfo' => true, // Php version
- 'messages' => true, // Messages
- 'time' => true, // Time Datalogger
- 'memory' => true, // Memory usage
- 'exceptions' => true, // Exception displayer
- 'log' => true, // Logs from Monolog (merged in messages if enabled)
- 'db' => true, // Show database (PDO) queries and bindings
- 'views' => true, // Views with their data
- 'route' => true, // Current route information
- 'auth' => true, // Display Laravel authentication status
- 'gate' => true, // Display Laravel Gate checks
- 'session' => true, // Display session data
- 'symfony_request' => true, // Only one can be enabled..
- 'mail' => true, // Catch mail messages
- 'laravel' => false, // Laravel version and environment
- 'events' => true, // All events fired
- 'default_request' => false, // Regular or special Symfony request logger
- 'logs' => false, // Add the latest log messages
- 'files' => false, // Show the included files
- 'config' => false, // Display config settings
- 'cache' => true, // Display cache events
- 'models' => false, // Display models
- ],
-
- /*
- |--------------------------------------------------------------------------
- | Extra options
- |--------------------------------------------------------------------------
- |
- | Configure some DataCollectors
- |
- */
-
- 'options' => [
- 'auth' => [
- 'show_name' => true, // Also show the users name/email in the debugbar
- ],
- 'db' => [
- 'with_params' => true, // Render SQL with the parameters substituted
- 'backtrace' => true, // Use a backtrace to find the origin of the query in your files.
- 'timeline' => false, // Add the queries to the timeline
- 'explain' => [ // Show EXPLAIN output on queries
- 'enabled' => false,
- 'types' => ['SELECT'],
- // // workaround ['SELECT'] only. https://github.com/barryvdh/laravel-debugbar/issues/888 ['SELECT', 'INSERT', 'UPDATE', 'DELETE']; for MySQL 5.6.3+
- ],
- 'hints' => true, // Show hints for common mistakes
- ],
- 'mail' => [
- 'full_log' => false,
- ],
- 'views' => [
- 'data' => true, // Note: Can slow down the application, because the data can be quite large..
- ],
- 'route' => [
- 'label' => true, // show complete route on bar
- ],
- 'logs' => [
- 'file' => null,
- ],
- 'cache' => [
- 'values' => true, // collect cache values
- ],
- ],
-
- /*
- |--------------------------------------------------------------------------
- | Inject Debugbar in Response
- |--------------------------------------------------------------------------
- |
- | Usually, the debugbar is added just before </body>, by listening to the
- | Response after the App is done. If you disable this, you have to add them
- | in your template yourself. See http://phpdebugbar.com/docs/rendering.html
- |
- */
-
- 'inject' => true,
-
- /*
- |--------------------------------------------------------------------------
- | DebugBar route prefix
- |--------------------------------------------------------------------------
- |
- | Sometimes you want to set route prefix to be used by DebugBar to load
- | its resources from. Usually the need comes from misconfigured web server or
- | from trying to overcome bugs like this: http://trac.nginx.org/nginx/ticket/97
- |
- */
- 'route_prefix' => '_debugbar',
-
- /*
- |--------------------------------------------------------------------------
- | DebugBar route domain
- |--------------------------------------------------------------------------
- |
- | By default DebugBar route served from the same domain that request served.
- | To override default domain, specify it as a non-empty value.
- */
- 'route_domain' => null,
-];
diff --git a/resources/assets/v2/pages/transactions/index.js b/resources/assets/v2/pages/transactions/index.js
index cd3d99f8ea..a18123b173 100644
--- a/resources/assets/v2/pages/transactions/index.js
+++ b/resources/assets/v2/pages/transactions/index.js
@@ -73,9 +73,11 @@ let index = function () {
this.getTransactions(this.page);
},
getTransactions(page) {
+ const urlParts = window.location.href.split('/');
+ const type = urlParts[urlParts.length - 1];
let getter = new Get();
- getter.list({page: page}).then(response => {
+ getter.list({page: page, type: type}).then(response => {
this.parseTransactions(response.data.data)
// set meta data
diff --git a/resources/views/v2/partials/layout/sidebar.blade.php b/resources/views/v2/partials/layout/sidebar.blade.php
index a6aeeb81dc..f434bfaca3 100644
--- a/resources/views/v2/partials/layout/sidebar.blade.php
+++ b/resources/views/v2/partials/layout/sidebar.blade.php
@@ -49,7 +49,7 @@
</a>
</li>
<li class="nav-header">{{ strtoupper(__('firefly.accounting')) }}</li>
- <li class="nav-item">
+ <li class="nav-item @partialroute('transactions') menu-open @endpartialroute">
<a href="#" class="nav-link">
<em class="nav-icon fa-solid fa-arrow-right-arrow-left"></em>
<p>