added control sidebar #10 (#87)

- added configurable sidebar #10
- added language switch in sidebar preferences tab #10
- added sidebar tab with kimai beta-info message #10
- use trait for repositories
- improved README
This commit is contained in:
Kevin Papst
2018-01-14 01:36:07 +01:00
committed by GitHub
parent d5e689e307
commit 023fef6a70
15 changed files with 277 additions and 59 deletions

View File

@@ -5,7 +5,6 @@
# KIMAI DEFAULT ENV VARS
DATABASE_PREFIX=kimai2_
DATABASE_ENGINE=sqlite
DATABASE_URL=sqlite:///%kernel.project_dir%/var/data/kimai.sqlite
###> symfony/framework-bundle ###
APP_ENV=dev
@@ -18,7 +17,8 @@ APP_SECRET=c88c14fa70a424e7a12d459b9dd9df7f
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data/kimai.sqlite"
# Configure your db driver and server_version in config/packages/doctrine.yaml
#DATABASE_URL=mysql://db_user:db_password@127.0.0.1:3306/db_name
# DATABASE_URL=mysql://db_user:db_password@127.0.0.1:3306/db_name
DATABASE_URL=sqlite:///%kernel.project_dir%/var/data/kimai.sqlite
###< doctrine/doctrine-bundle ###
###> symfony/swiftmailer-bundle ###

View File

@@ -44,16 +44,6 @@ The next command will create the database, the schema and install all web assets
$ bin/console kimai:install --relative
```
### Installation (live)
All thats left to do is to create your first user:
```bash
$ bin/console kimai:create-user username admin@example.com password en ROLE_SUPER_ADMIN
```
For available roles, please refer to [the user documentation](var/docs/users.md).
### Installation (development / demo)
Lets boostrap your environment by executing this commands (which is only available in dev environment):
@@ -82,8 +72,37 @@ $ bin/console doctrine:schema:drop --force
$ bin/console doctrine:schema:create
```
The `kimai:reset-dev` command can always be executed later on to reset your dev database and cache. I use it very frequently.
The `kimai:reset-dev` command can always be executed later on to reset your dev database and cache.
### Installation (live)
The default installation uses a SQLite database, which is not recommended for production usage.
You can configure your database through your environment (e.g. Webserver, Cloud-Provider) or in your `.env file:
```bash
$ cp .env.dist .env
```
You have to adjust the following ENV values to your needs:
```
DATABASE_PREFIX=kimai2_
DATABASE_ENGINE=sqlite
DATABASE_URL=sqlite:///%kernel.project_dir%/var/data/kimai.sqlite
APP_ENV=dev
APP_SECRET=some_random_secret_string_for_your_installation
```
Now create the database schemas:
```bash
$ bin/console doctrine:schema:create
```
And finally create your first user:
```bash
$ bin/console kimai:create-user username admin@example.com password en ROLE_SUPER_ADMIN
```
For available roles, please refer to [the user documentation](var/docs/users.md).
## Usage

View File

@@ -9,6 +9,6 @@ avanzu_admin_theme:
boxed_layout: false
collapsed_sidebar: true
mini_sidebar: true
control_sidebar: false
control_sidebar: true
knp_menu:
enable: false

View File

@@ -7,3 +7,10 @@ twig:
date_1: "d.m.Y" # used for display in timesheets
box_color: "green" # a color for ???
active_warning: 3 # display a warning color if the user has at least X active recordings
control_sidebar:
settings:
icon: gears
controller: 'App\Controller\SidebarController::settingsAction'
home:
icon: question-circle-o
template: sidebar/home.html.twig

View File

@@ -2,10 +2,3 @@ twig:
#paths: ['%kernel.project_dir%/templates']
debug: '%kernel.debug%'
strict_variables: '%kernel.debug%'
# TODO move me to kimai config
globals:
kimai_context:
date_1: "d.m.Y" # used for display in timesheets
box_color: "green" # a color for ???
active_warning: 3 # display a warning color if the user has at least X active recordings

View File

@@ -39,6 +39,11 @@ li.open .ticktac i.running{
/* ================================ TOOLBAR ================================ */
.control-sidebar select {
color: #000;
}
/* ================================ TOOLBAR ================================ */
.data_table .box-header>.box-tools {
top: 3px;
}

View File

@@ -0,0 +1,34 @@
<?php
/*
* This file is part of the Kimai package.
*
* (c) Kevin Papst <kevin@kevinpapst.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
/**
* Sidebar controller
*
* @Security("has_role('ROLE_USER')")
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class SidebarController extends AbstractController
{
public function homeAction()
{
return $this->render('sidebar/home.html.twig', []);
}
public function settingsAction()
{
return $this->render('sidebar/settings.html.twig', []);
}
}

View File

@@ -25,32 +25,5 @@ use Pagerfanta\Pagerfanta;
*/
abstract class AbstractRepository extends EntityRepository
{
/**
* @param QueryBuilder $qb
* @param BaseQuery $query
* @return QueryBuilder|Pagerfanta
*/
protected function getBaseQueryResult(QueryBuilder $qb, BaseQuery $query)
{
if ($query->getResultType() == BaseQuery::RESULT_TYPE_PAGER) {
return $this->getPager($qb->getQuery(), $query->getPage(), $query->getPageSize());
}
return $qb;
}
/**
* @param Query $query
* @param int $page
* @param int $maxPerPage
* @return Pagerfanta
*/
protected function getPager(Query $query, $page = 1, $maxPerPage = 25)
{
$paginator = new Pagerfanta(new DoctrineORMAdapter($query, false));
$paginator->setMaxPerPage($maxPerPage);
$paginator->setCurrentPage($page);
return $paginator;
}
use RepositoryTrait;
}

View File

@@ -0,0 +1,55 @@
<?php
/*
* This file is part of the Kimai package.
*
* (c) Kevin Papst <kevin@kevinpapst.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Repository;
use App\Repository\Query\BaseQuery;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use Pagerfanta\Adapter\DoctrineORMAdapter;
use Pagerfanta\Pagerfanta;
/**
* Trait RepositoryTrait
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
trait RepositoryTrait
{
/**
* @param QueryBuilder $qb
* @param BaseQuery $query
* @return QueryBuilder|Pagerfanta
*/
protected function getBaseQueryResult(QueryBuilder $qb, BaseQuery $query)
{
if ($query->getResultType() == BaseQuery::RESULT_TYPE_PAGER) {
return $this->getPager($qb->getQuery(), $query->getPage(), $query->getPageSize());
}
return $qb;
}
/**
* @param Query $query
* @param int $page
* @param int $maxPerPage
* @return Pagerfanta
*/
protected function getPager(Query $query, $page = 1, $maxPerPage = 25)
{
$paginator = new Pagerfanta(new DoctrineORMAdapter($query, false));
$paginator->setMaxPerPage($maxPerPage);
$paginator->setCurrentPage($page);
return $paginator;
}
}

View File

@@ -57,16 +57,6 @@
{% if app.user is not null and is_granted('IS_AUTHENTICATED_FULLY') %}
{{ render(controller('App\\Controller\\ActivityController::recentActivitiesAction')) }}
{% endif %}
{#
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-globe"></i> <span class="caret"></span></a>
<ul class="dropdown-menu locales" role="menu">
{% for locale in locales() %}
<li {% if app.request.locale == locale.code %}class="active"{% endif %}><a href="{{ path(app.request.get('_route', 'homepage'), app.request.get('_route_params', [])|merge({ _locale: locale.code })) }}">{{ locale.name|capitalize }}</a></li>
{% endfor %}
</ul>
</li>
#}
{% endblock %}
{% block avanzu_navbar_toggle %}{{ parent() }}{% endblock %}

View File

@@ -0,0 +1,23 @@
<aside class="control-sidebar control-sidebar-dark">
<ul class="nav nav-tabs nav-justified control-sidebar-tabs">
{% if kimai_context.control_sidebar is defined %}
{% for name, tab in kimai_context.control_sidebar %}
<li{% if loop.first %} class="active"{% endif %}><a href="#control-sidebar-{{ name }}-tab" data-toggle="tab"><i class="fa fa-{{ tab.icon }}"></i></a></li>
{% endfor %}
{% endif %}
</ul>
<div class="tab-content">
{% if kimai_context.control_sidebar is defined %}
{% for name, tab in kimai_context.control_sidebar %}
<div class="tab-pane {% if loop.first %}active{% endif %}" id="control-sidebar-{{ name }}-tab">
{% if tab.controller is defined %}
{{ render(controller(tab.controller)) }}
{% elseif tab.template is defined %}
{% include tab.template %}
{% endif %}
</div>
{% endfor %}
{% endif %}
</div>
</aside>
<div class="control-sidebar-bg"></div>

View File

@@ -0,0 +1,40 @@
<h3 class="control-sidebar-heading">{{ 'home.title'|trans({}, 'sidebar') }}</h3>
<div class="form-group">
{{ 'home.betainfo'|trans({}, 'sidebar')|raw|nl2br }}
<ul class="control-sidebar-menu">
<li>
<a href="https://github.com/kevinpapst/kimai2/" target="_blank">{{ 'home.link.issues'|trans({}, 'sidebar') }}</a>
</li>
</ul>
</div>
{#
<ul class="control-sidebar-menu">
<li>
<a href="javascript:;">
<i class="menu-icon fa fa-birthday-cake bg-red"></i>
<div class="menu-info">
<h4 class="control-sidebar-subheading">{{ 'Kevin\'s Birthday'|trans({}, 'AvanzuAdminTheme') }}</h4>
<p>{{ 'Will be 23 on April 24th'|trans({}, 'AvanzuAdminTheme') }}</p>
</div>
</a>
</li>
</ul>
<h3 class="control-sidebar-heading">{{ 'Tasks Progress'|trans({}, 'AvanzuAdminTheme') }}</h3>
<ul class="control-sidebar-menu">
<li>
<a href="javascript::;">
<h4 class="control-sidebar-subheading">
{{ 'Custom Template Design'|trans({}, 'AvanzuAdminTheme') }}
<span class="label label-danger pull-right">70%</span>
</h4>
<div class="progress progress-xxs">
<div class="progress-bar progress-bar-danger" style="width: 70%"></div>
</div>
</a>
</li>
</ul>
#}

View File

@@ -0,0 +1,11 @@
<h3 class="control-sidebar-heading">{{ 'preferences.title'|trans({}, 'sidebar') }}</h3>
<div class="form-group">
<label class="control-sidebar-subheading">
{{ 'preferences.label.language'|trans({}, 'sidebar') }}
<select class="pull-right" onchange="window.location.href = this.options[this.selectedIndex].value;">
{% for locale in locales() %}
<option value="{{ path(app.request.get('_route', 'homepage'), app.request.get('_route_params', [])|merge({ _locale: locale.code })) }}" {% if app.request.locale == locale.code %}selected="selected"{% endif %}>{{ locale.name|capitalize }}</option>
{% endfor %}
</select>
</label>
</div>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file date="2017-01-12T20:00:00Z" source-language="en" target-language="de" datatype="plaintext" original="sidebar.en.xliff">
<body>
<trans-unit id="home.title">
<source>home.title</source>
<target>Kimai v2 - Vorab Version</target>
</trans-unit>
<trans-unit id="home.betainfo">
<source>home.betainfo</source>
<target><![CDATA[Danke für die Nutzung der Open-Source Zeiterfassung <strong>Kimai</strong>.
Diese neue Version 2 ist aktuell noch in einer frühen Phase der Entwicklung und wurde vorab veröffentlicht, um frühzeitig Rückmeldungen ihrer Benutzer zu sammeln und deren Ideen in die weitere Planung zu integrieren.
Um bei der Verbesserung von <strong>Kimai</strong> zu helfen, schicken Sie mir bitte eine Nachricht auf der verlinkten Webseite. Egal ob Fragen, Fehlermeldungen oder Ideen für Erweiterungen, Ihr Feedback ist wertvoll!
Weitere Informationen auf der:
]]></target>
</trans-unit>
<trans-unit id="home.link.issues">
<source>home.link.issues</source>
<target>GitHub Projekt-Webseite</target>
</trans-unit>
<trans-unit id="preferences.title">
<source>preferences.title</source>
<target>Deine Einstellungen</target>
</trans-unit>
<trans-unit id="preferences.label.language">
<source>preferences.label.language</source>
<target>Sprache</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file date="2017-01-12T20:00:00Z" source-language="en" target-language="en" datatype="plaintext" original="none">
<body>
<trans-unit id="home.title">
<source>home.title</source>
<target>Kimai v2 - Pre-Version</target>
</trans-unit>
<trans-unit id="home.betainfo">
<source>home.betainfo</source>
<target><![CDATA[Thank you for using the open source time-tracker <strong>Kimai</strong>.
This new version 2 is currently in an early stage of development and has been published in advance to collect feedback from its users and integrate their ideas into further planning.
To help me improve <strong>Kimai</strong>, please send your message on the linked website. Whether you have questions, error messages or ideas for enhancements, your feedback is valuable!
Further information on the:
]]></target>
</trans-unit>
<trans-unit id="home.link.issues">
<source>home.link.issues</source>
<target>GitHub Project-Website</target>
</trans-unit>
<trans-unit id="preferences.title">
<source>preferences.title</source>
<target>Your preferences</target>
</trans-unit>
<trans-unit id="preferences.label.language">
<source>preferences.label.language</source>
<target>Language</target>
</trans-unit>
</body>
</file>
</xliff>