Show revenue only for ROLE_ADMIN (#227)

This commit is contained in:
Kevin Papst
2018-07-22 15:31:59 +02:00
committed by GitHub
parent 75246e9db2
commit 194a1f204c
4 changed files with 36 additions and 28 deletions

View File

@@ -102,9 +102,7 @@ class DashboardController extends Controller
'header' => 'dashboard.all', 'header' => 'dashboard.all',
'widgets' => [ 'widgets' => [
"{{ widgets.info_box_counter('stats.durationThisMonth', timesheetGlobal.durationThisMonth|duration(true), 'far fa-hourglass', 'blue') }}", "{{ widgets.info_box_counter('stats.durationThisMonth', timesheetGlobal.durationThisMonth|duration(true), 'far fa-hourglass', 'blue') }}",
//"{{ widgets.info_box_counter('stats.amountThisMonth', timesheetGlobal.amountThisMonth|money, 'money', 'green') }}",
"{{ widgets.info_box_counter('stats.durationTotal', timesheetGlobal.durationTotal|duration(true), 'far fa-hourglass', 'yellow') }}", "{{ widgets.info_box_counter('stats.durationTotal', timesheetGlobal.durationTotal|duration(true), 'far fa-hourglass', 'yellow') }}",
//"{{ widgets.info_box_counter('stats.amountTotal', timesheetGlobal.amountTotal|money, 'money', 'red') }}",
"{{ widgets.info_box_counter('stats.activeRecordings', timesheetGlobal.activeCurrently, 'far fa-hourglass', 'red', path('admin_timesheet', {'state': " . TimesheetQuery::STATE_RUNNING . '})) }}', "{{ widgets.info_box_counter('stats.activeRecordings', timesheetGlobal.activeCurrently, 'far fa-hourglass', 'red', path('admin_timesheet', {'state': " . TimesheetQuery::STATE_RUNNING . '})) }}',
], ],
]; ];
@@ -123,6 +121,15 @@ class DashboardController extends Controller
return $widgets; return $widgets;
} }
$widgets[] = [
'id' => 'alluser.money_stats',
'header' => '',
'widgets' => [
"{{ widgets.info_box_counter('stats.amountThisMonth', timesheetGlobal.amountThisMonth|money, 'far fa-money-bill-alt', 'green') }}",
"{{ widgets.info_box_counter('stats.amountTotal', timesheetGlobal.amountTotal|money, 'far fa-money-bill-alt', 'red') }}",
],
];
$widgets[] = [ $widgets[] = [
'id' => 'admin.stats', 'id' => 'admin.stats',
'header' => 'dashboard.admin', 'header' => 'dashboard.admin',

View File

@@ -143,23 +143,25 @@
<b>{{ 'stats.durationThisMonth'|trans }}</b> <a class="pull-right">{{ stats.durationThisMonth|duration }}</a> <b>{{ 'stats.durationThisMonth'|trans }}</b> <a class="pull-right">{{ stats.durationThisMonth|duration }}</a>
</li> </li>
{% if is_granted('ROLE_ADMIN') %}
<li class="list-group-item"> <li class="list-group-item">
<b>{{ 'stats.amountThisMonth'|trans }}</b> <a class="pull-right">{{ stats.amountThisMonth|money }}</a> <b>{{ 'stats.amountThisMonth'|trans }}</b> <a class="pull-right">{{ stats.amountThisMonth|money }}</a>
</li> </li>
{% endif %}
<li class="list-group-item"> <li class="list-group-item">
<b>{{ 'stats.durationTotal'|trans }}</b> <a class="pull-right">{{ stats.durationTotal|duration }}</a> <b>{{ 'stats.durationTotal'|trans }}</b> <a class="pull-right">{{ stats.durationTotal|duration }}</a>
</li> </li>
{% if is_granted('ROLE_ADMIN') %}
<li class="list-group-item"> <li class="list-group-item">
<b>{{ 'stats.amountTotal'|trans }}</b> <a class="pull-right">{{ stats.amountTotal|money }}</a> <b>{{ 'stats.amountTotal'|trans }}</b> <a class="pull-right">{{ stats.amountTotal|money }}</a>
</li> </li>
{% endif %}
</ul> </ul>
{# <a href="#" class="btn btn-primary btn-block"><b>Follow</b></a> #}
</div> </div>
<!-- /.box-body -->
</div> </div>
{% endmacro %} {% endmacro %}

View File

@@ -33,10 +33,6 @@ yarn install
To rebuild all assets you have to execute: To rebuild all assets you have to execute:
```bash ```bash
yarn run dev
```
or
```bash
yarn run prod yarn run prod
``` ```
@@ -60,6 +56,11 @@ bin/console kimai:test-unit
bin/console kimai:test-integration bin/console kimai:test-integration
``` ```
Or you simply run all tests with:
```bash
bin/phpunit
```
## Check your code styles ## Check your code styles
You can run the code sniffer with a built-in command like that: You can run the code sniffer with a built-in command like that:
@@ -88,7 +89,6 @@ We try to keep the number of language files small, in order to make it easier to
The files in `translations/` as a quick overview: The files in `translations/` as a quick overview:
- `AvanzuAdminTheme` is only meant for translating strings from the original theme
- `exceptions` only holds translations of error pages and exception handlers - `exceptions` only holds translations of error pages and exception handlers
- `flashmessages` hold all success and error messages, that will be shown as results from action calls after page reload - `flashmessages` hold all success and error messages, that will be shown as results from action calls after page reload
- `messages` holds most of the visible application translations (like all the static UI elements and form translations) - `messages` holds most of the visible application translations (like all the static UI elements and form translations)
@@ -143,22 +143,21 @@ For more details check the [official menu subscriber](../../src/EventSubscriber/
We use twig globals to render the control sidebar tabs, so adding one is as easy as adding a new config entry: We use twig globals to render the control sidebar tabs, so adding one is as easy as adding a new config entry:
```yaml ```yaml
twig: admin_lte:
globals: options:
kimai_context: control_sidebar:
control_sidebar: # these are the "official" Kimai tabs
# these are the official tabs settings:
settings: icon: "fas fa-cogs"
icon: gears controller: 'App\Controller\SidebarController::settingsAction'
controller: 'App\Controller\SidebarController::settingsAction' home:
home: icon: "fas fa-question-circle"
icon: question-circle-o template: sidebar/home.html.twig
template: sidebar/home.html.twig
``` ```
You have to define the `icon` (font-awesome without the `fa-` prefix) to be used and one of `controller` action or `template`. You have to define the `icon` (FontAwesome 5) to be used and one of: `controller` action or twig `template`.
Both follow the default naming syntax and you can easily link your bundle here instead of the app controller or templates. Both follow the default naming syntax and you can link your bundle here instead of the app controller or templates.
You should NOT add them in `config/packages/kimai.yaml` but in your own bundle config, otherwise they might get lost in a Kimai update. You should NOT add them in `config/packages/kimai.yaml` but in your own bundle or the `local.yaml` [config](configurations.md),
otherwise they might get lost during an update.
## Adding invoice renderer ## Adding invoice renderer

View File

@@ -28,10 +28,10 @@ git clone https://github.com/kevinpapst/kimai2.git
cd kimai2/ cd kimai2/
``` ```
Create the `.env` file, using the `prod` environment and SQLite as database: Create the `.env` file (as copy from `.env.dist`), using the `prod` environment and SQLite as database:
``` ```
# you need all settings from .env.dist, but these two need to be adjusted!
APP_ENV=prod APP_ENV=prod
APP_SECRET=insert_a_random_secret_string_for_production
DATABASE_URL=sqlite:///%kernel.project_dir%/var/data/kimai.sqlite DATABASE_URL=sqlite:///%kernel.project_dir%/var/data/kimai.sqlite
``` ```
The file `var/data/kimai.sqlite` will hold all your data, so make sure to include it in your backups! The file `var/data/kimai.sqlite` will hold all your data, so make sure to include it in your backups!
@@ -45,6 +45,7 @@ composer install --no-dev
Create the database schemas: Create the database schemas:
```bash ```bash
bin/console doctrine:schema:create bin/console doctrine:schema:create
bin/console doctrine:migrations:version --add --all
``` ```
And create your first user with the following command. You will be asked to enter a password afterwards. And create your first user with the following command. You will be asked to enter a password afterwards.
@@ -67,12 +68,11 @@ composer install
The default installation uses a SQLite database, so there is no need to create a database for your first tests. The default installation uses a SQLite database, so there is no need to create a database for your first tests.
Our default settings will work out-of-the-box, but you might want to adjust the `.env` values to your needs. Our default settings will work out-of-the-box, but you might want to adjust the `.env` values to your needs.
You can configure your database through your environment (e.g. Webserver, Cloud-Provider) or in your `.env` file: You can configure your database in your `.env` file, e.g.:
``` ```
DATABASE_PREFIX=kimai2_ DATABASE_PREFIX=kimai2_
DATABASE_URL=sqlite:///%kernel.project_dir%/var/data/kimai.sqlite DATABASE_URL=sqlite:///%kernel.project_dir%/var/data/kimai.sqlite
APP_ENV=dev APP_ENV=dev
APP_SECRET=some_random_secret_string_for_your_installation
``` ```
The next commands will create the database and the schema: The next commands will create the database and the schema: