improvements

This commit is contained in:
Kevin Papst
2016-10-23 21:27:11 +02:00
parent c492d30be3
commit 8940b766b6
27 changed files with 728 additions and 138 deletions

View File

@@ -38,8 +38,8 @@ $ composer install
Lets prepare the environment
```bash
$ php bin/console assets:install --symlink
$ php bin/console avanzu:admin:fetch-vendor
$ php bin/console assets:install --symlink --relative
$ php bin/console avanzu:admin:initialize --symlink --relative
```

View File

@@ -0,0 +1,38 @@
<!-- User Account: style can be found in dropdown.less -->
{% import "AvanzuAdminThemeBundle:layout:macros.html.twig" as macro %}
<li class="dropdown user user-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
{{ macro.avatar(user.avatar, user.username, 'user-image') }}
<span class="hidden-xs">{{ user.name }}</span>
</a>
<ul class="dropdown-menu">
<!-- User image -->
<li class="user-header">
{{ macro.avatar(user.avatar, user.username) }}
<p>
{{user.name}} - {{user.title}}
<small>{{ 'Member since %date%'|trans({'%date%': user.memberSince|date('m.Y') }, 'AvanzuAdminTheme') }}</small>
</p>
</li>
{#
<!-- Menu Body -->
<li class="user-body">
<div class="col-xs-4 text-center">
</div>
<div class="col-xs-4 text-center">
</div>
<div class="col-xs-4 text-center">
</div>
</li>
#}
<!-- Menu Footer-->
<li class="user-footer">
<div class="pull-left">
<a href="{{ path('profile'|route_alias, {'ident' : user.identifier}) }}" class="btn btn-default btn-flat">{{'Profile'|trans({}, 'AvanzuAdminTheme')}}</a>
</div>
<div class="pull-right">
<a href="{{ logout_path() }}" class="btn btn-default btn-flat">{{ 'Sign out'|trans({}, 'AvanzuAdminTheme') }}</a>
</div>
</li>
</ul>
</li>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" target-language="de" datatype="plaintext" original="not.available">
<body>
<trans-unit id="Member since %date%">
<source>Member since %date%</source>
<target>Mitglied seit %date%</target>
</trans-unit>
<trans-unit id="Profile">
<source>Profile</source>
<target>Profil</target>
</trans-unit>
<trans-unit id="Sign out">
<source>Sign out</source>
<target>Abmelden</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@@ -2,6 +2,9 @@
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file date="2016-10-19T21:46:45Z" source-language="en" target-language="de" datatype="plaintext" original="not.available">
<body>
<!--
Global template keys
-->
<trans-unit id="browser.title">
<source>browser.title</source>
<target>Kimai - Time Tracking</target>
@@ -11,6 +14,57 @@
<target>Kimai</target>
</trans-unit>
<!--
Login / Security
-->
<trans-unit id="security.title.login">
<source>security.title.login</source>
<target>Anmelden</target>
</trans-unit>
<trans-unit id="security.label.username">
<source>security.label.username</source>
<target>Benutzername</target>
</trans-unit>
<trans-unit id="security.label.password">
<source>security.label.password</source>
<target>Passwort</target>
</trans-unit>
<trans-unit id="security.action.sign_in">
<source>security.action.sign_in</source>
<target>Los geht's</target>
</trans-unit>
<!--
Menu / Navbar items
-->
<trans-unit id="menu.homepage">
<source>menu.homepage</source>
<target>Dashboard</target>
</trans-unit>
<trans-unit id="menu.admin">
<source>menu.admin</source>
<target>Administration</target>
</trans-unit>
<trans-unit id="menu.logout">
<source>menu.logout</source>
<target>Abmelden</target>
</trans-unit>
<trans-unit id="menu.timesheet">
<source>menu.timesheet</source>
<target>Zeiterfassung</target>
</trans-unit>
<!--
Footer
-->
<trans-unit id="footer.license">
<source>footer.license</source>
<target>Alle Rechte vorbehalten.</target>
</trans-unit>
<!--
Error templates
-->
<trans-unit id="http_error.name">
<source>http_error.name</source>
<target>Error</target>
@@ -48,58 +102,34 @@
<target>Error</target>
</trans-unit>
<trans-unit id="action.browse_admin">
<source>action.browse_admin</source>
<target>Zum Backend</target>
<!--
General labels
-->
<trans-unit id="label.date">
<source>label.date</source>
<target>Datum</target>
</trans-unit>
<trans-unit id="help.browse_admin">
<source>help.browse_admin</source>
<target>Zum Backend</target>
<trans-unit id="label.starttime">
<source>label.starttime</source>
<target>Begin</target>
</trans-unit>
<trans-unit id="action.browse_app">
<source>action.browse_app</source>
<target>Zum Frontend</target>
<trans-unit id="label.endtime">
<source>label.endtime</source>
<target>Ende</target>
</trans-unit>
<trans-unit id="help.browse_app">
<source>help.browse_app</source>
<target>Zum Frontend</target>
</trans-unit>
<trans-unit id="title.login">
<source>title.login</source>
<target>Anmelden</target>
<trans-unit id="label.duration">
<source>label.duration</source>
<target>Dauer</target>
</trans-unit>
<trans-unit id="label.username">
<source>label.username</source>
<target>Benutzername</target>
<target>Benutzer</target>
</trans-unit>
<trans-unit id="label.password">
<source>label.password</source>
<target>Passwort</target>
</trans-unit>
<trans-unit id="action.sign_in">
<source>action.sign_in</source>
<target>Los geht's</target>
</trans-unit>
<trans-unit id="menu.logout">
<source>menu.logout</source>
<target>Abmelden</target>
</trans-unit>
<trans-unit id="menu.admin">
<source>menu.admin</source>
<target>Backend</target>
</trans-unit>
<trans-unit id="menu.timesheet">
<source>menu.timesheet</source>
<target>Zeiterfassung</target>
</trans-unit>
<trans-unit id="kimai.license">
<source>kimai.license</source>
<target>Copyright Kevin Papst. Alle Rechte vorbehalten.</target>
</trans-unit>
<trans-unit id="kimai.footer">
<source>kimai.footer</source>
<target>Kimai Time-Tracking</target>
<trans-unit id="label.description">
<source>label.description</source>
<target>Beschreibung</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@@ -1,18 +1,68 @@
{% extends 'AvanzuAdminThemeBundle:layout:base-layout.html.twig' %}
{% extends 'AvanzuAdminThemeBundle:layout:default-layout.html.twig' %}
{% block page_content %}
{% block main %}
{% endblock %}
{% block avanzu_page_content %}
{% block main %}{% endblock %}
{% endblock %}
{% block avanzu_document_title %}
{% block title %}{{ 'browser.title'|trans }}{% endblock %}
{% endblock %}
{% block avanzu_sidebar_search %}
<!-- right now we simply deactivate that box -->
{% endblock %}
{% block avanzu_page_title %}
{% block page_title %}{% endblock %}
{% endblock %}
{% block avanzu_page_subtitle %}
{% block page_subtitle %}{% endblock %}
{% endblock %}
{% block avanzu_logo_path %}
{{ path('dashboard') }}
{% endblock %}
{% block avanzu_logo_mini %}
<b>K</b>TT
{% endblock %}
{% block avanzu_logo_lg %}
<b>Kimai</b> - Time Tracking
{% endblock %}
{% block flash_messages %}
{{ include('default/_flash_messages.html.twig') }}
{% endblock %}
{% block avanzu_footer %}
{% block footer %}
<footer class="main-footer">
<div class="pull-right hidden-xs">
<b>Version</b> 2.0
</div>
<strong>Copyright &copy; {{ 'now'|date('Y') }} - <a href="http://www.kevinpapst.de">Kevin Papst</a></strong>.
{{ 'footer.license'|trans }}
</footer>
{% endblock %}
{% endblock %}
{#
<title>{% block title %}{{ 'browser.title'|trans }}{% endblock %}</title>
<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
avanzu_head
avanzu_navbar_toggle
avanzu_navbar_messages
avanzu_navbar_notifications
avanzu_navbar_tasks
avanzu_navbar_user
avanzu_navbar_control_sidebar_toggle
avanzu_sidebar_user
avanzu_sidebar_nav
avanzu_breadcrumb
avanzu_control_sidebar
avanzu_javascripts
avanzu_javascripts_inline
<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>
@@ -23,11 +73,6 @@
</ul>
</li>
<p>&copy; {{ 'now'|date('Y') }} - {{ 'kimai.footer'|trans }}</p>
<p>{{ 'kimai.license'|trans }}</p>
<!-- Page rendered on {{ 'now'|localizeddate('long', 'long', null, 'UTC') }} -->
#}

View File

@@ -1,7 +1,53 @@
{% extends 'base.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% block page_title %}Dashboard{% endblock %}
{% block page_subtitle %}Welcome!{% endblock %}
{% block main %}
<div class="row">
<div class="col-md-3 col-sm-6 col-xs-12">
{{ widgets.info_box_counter('Bla blub', 300, 'bar-chart', 'blue') }}
</div>
<div class="col-md-3 col-sm-6 col-xs-12">
{{ widgets.info_box_counter('Steigerungsrate', 80, 'line-chart', 'red') }}
</div>
<div class="col-md-3 col-sm-6 col-xs-12">
{{ widgets.info_box_counter('Anzahl Tage', 27, 'calendar', 'yellow') }}
</div>
<div class="col-md-3 col-sm-6 col-xs-12">
{{ widgets.info_box_counter('Stunden total / Monat', 460, 'clock-o', 'green') }}
</div>
</div>
<div class="row">
<div class="col-md-3 col-sm-6 col-xs-12">
{{ widgets.info_box_progress('Bewilligte Stunden', 'Stunden zur Abrechnung bewilligt', 120, 10, 'star-o') }}
</div>
<div class="col-md-3 col-sm-6 col-xs-12">
{{ widgets.info_box_progress('Umsatz / Monat', '70% Increase in 30 Days', 6830, 30, 'credit-card', 'black') }}
</div>
<div class="col-md-3 col-sm-6 col-xs-12">
{{ widgets.info_box_progress('Stunden persönlich', 'Das ist noch nicht genug', 135, 60, 'hourglass-o') }}
</div>
<div class="col-md-3 col-sm-6 col-xs-12">
{{ widgets.info_box_progress('Anzahl Benutzer', 'Mehr ist besser!', 5, 90, 'user') }}
</div>
</div>
<div class="row">
<div class="col-md-3 col-sm-6 col-xs-12">
{{ widgets.info_box_more('Bewilligte Stunden', 120, 'h', 'star-o', 'purple') }}
</div>
<div class="col-md-3 col-sm-6 col-xs-12">
{{ widgets.info_box_more('Umsatz / Monat', 6830, '$', '', 'yellow') }}
</div>
<div class="col-md-3 col-sm-6 col-xs-12">
{{ widgets.info_box_more('Stunden persönlich', 135, '€', 'hourglass-o', 'red') }}
</div>
<div class="col-md-3 col-sm-6 col-xs-12">
{{ widgets.info_box_more('Anzahl Benutzer', 5, '', 'user') }}
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,94 @@
{% macro profile_list(user, items, color) %}
{% import "AvanzuAdminThemeBundle:layout:macros.html.twig" as macro %}
<div class="box box-widget widget-user-2">
<!-- Add the bg color to the header using any of the bg-* classes -->
<div class="widget-user-header bg-{{ color|default(kimai_context.box_color) }}">
<div class="widget-user-image">
{{ macro.avatar(user.avatar, user.username) }}
</div>
<!-- /.widget-user-image -->
<h3 class="widget-user-username">{{ user.alias }} ({{ user.username }})</h3>
<h5 class="widget-user-desc">{{ user.title }}</h5>
</div>
<div class="box-footer no-padding">
<ul class="nav nav-stacked">
{% for entry in items %}
<li><a href="{{ entry.url }}">{{ entry.title|trans }} <span class="pull-right badge bg-{{ entry.color }}">{{ entry.amount }}</span></a></li>
{% endfor %}
</ul>
</div>
</div>
{% endmacro %}
{% macro profile_box(user, items) %}
{% import "AvanzuAdminThemeBundle:layout:macros.html.twig" as macro %}
<div class="box box-widget widget-user">
<!-- Add the bg color to the header using any of the bg-* classes -->
<div class="widget-user-header bg-{{ color|default(kimai_context.box_color) }}">
<h3 class="widget-user-username">{{ user.alias }} ({{ user.username }})</h3>
<h5 class="widget-user-desc">{{ user.title }}</h5>
</div>
<div class="widget-user-image">
{{ macro.avatar(user.avatar, user.username) }}
</div>
<div class="box-footer">
<div class="row">
{% for entry in items|slice(0, 3) %}
<div class="col-sm-4 border-right">
<div class="description-block">
<h5 class="description-header">{{ entry.amount }}</h5>
<span class="description-text">{{ entry.title|trans }}</span>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
{% endmacro %}
{% macro info_box_counter(title, amount, icon, color) %}
<div class="info-box">
<span class="info-box-icon bg-{{ color|default(kimai_context.box_color) }}"><i class="fa fa-{{ icon|default('flag-o') }}"></i></span>
<div class="info-box-content">
<span class="info-box-text">{{ title|trans }}</span>
<span class="info-box-number">{{ amount }}</span>
</div>
</div>
{% endmacro %}
{% macro info_box_progress(title, description, amount, percentage, icon, color) %}
<div class="info-box bg-{{ color|default(kimai_context.box_color) }}">
<span class="info-box-icon"><i class="fa fa-{{ icon|default('thumbs-o-up') }}"></i></span>
<div class="info-box-content">
<span class="info-box-text">{{ title|trans }}</span>
<span class="info-box-number">{{ amount }}</span>
<div class="progress">
<div class="progress-bar" style="width: {{ percentage }}%"></div>
</div>
<span class="progress-description">
{{ description }}
</span>
</div>
<!-- /.info-box-content -->
</div>
{% endmacro %}
{% macro info_box_more(title, amount, unit, icon, color) %}
<div class="small-box bg-{{ color|default(kimai_context.box_color) }}">
<div class="inner">
<h3>{{ amount }}<sup style="font-size: 20px">{{ unit|default('%') }}</sup></h3>
<p>{{ title|trans }}</p>
</div>
<div class="icon">
<i class="fa fa-{{ icon|default('bar-chart') }}"></i>
</div>
<a href="#" class="small-box-footer">
{{ 'more.info.link'|trans }} <i class="fa fa-arrow-circle-right"></i>
</a>
</div>
{% endmacro %}

View File

@@ -15,18 +15,18 @@
<div class="well">
<form action="{{ path('security_login') }}" method="post">
<fieldset>
<legend><i class="fa fa-lock"></i> {{ 'title.login'|trans }}</legend>
<legend><i class="fa fa-lock"></i> {{ 'security.title.login'|trans }}</legend>
<div class="form-group">
<label for="username">{{ 'label.username'|trans }}</label>
<label for="username">{{ 'security.label.username'|trans }}</label>
<input type="text" id="username" name="_username" value="{{ last_username }}" class="form-control"/>
</div>
<div class="form-group">
<label for="password">{{ 'label.password'|trans }}</label>
<label for="password">{{ 'security.label.password'|trans }}</label>
<input type="password" id="password" name="_password" class="form-control" />
</div>
<input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}"/>
<button type="submit" class="btn btn-primary">
<i class="fa fa-sign-in"></i> {{ 'action.sign_in'|trans }}
<i class="fa fa-sign-in"></i> {{ 'security.action.sign_in'|trans }}
</button>
</fieldset>
</form>

View File

@@ -0,0 +1,10 @@
{% extends 'base.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% block page_title %}Profile{% endblock %}
{% block page_subtitle %}manage your settings{% endblock %}
{% block main %}
{{ widgets.profile_list(user, items, 'aqua-active') }}
{{ widgets.profile_box(user, items, 'aqua-active') }}
{% endblock %}

View File

@@ -58,7 +58,9 @@ twig:
- "bootstrap_3_layout.html.twig"
- "form/fields.html.twig"
globals:
admin_skin: skin-blue
kimai_context:
date_1: "d.m.Y" # used for display in timesheets
box_color: "green"
# Assetic Configuration (used for managing web assets: CSS, JavaScript, Sass, etc.)
assetic:
@@ -89,5 +91,13 @@ swiftmailer:
password: "%mailer_password%"
spool: { type: memory }
#avanzu_admin_theme:
# use_assetic: false
avanzu_admin_theme:
use_twig : true
theme:
default_avatar : avatars/default.png
skin : skin-blue
fixed_layout : false
boxed_layout : false
collapsed_sidebar: true
mini_sidebar : true
control_sidebar : false

View File

@@ -7,9 +7,9 @@ framework:
strict_requirements: true
profiler: { only_exceptions: false }
web_profiler:
toolbar: '%kernel.debug%'
intercept_redirects: false
#web_profiler:
# toolbar: '%kernel.debug%'
# intercept_redirects: false
monolog:
handlers:
@@ -40,3 +40,6 @@ services:
class: Twig_Extensions_Extension_Text
tags:
- name: twig.extension
avanzu_admin_theme:
enable_demo: false

View File

@@ -34,6 +34,6 @@ homepage:
permanent: true
avanzu_admin_profile:
path: /profile/{userid}/
avanzu_admin_logout:
path: /logout
path: /{_locale}/profile/{ident}/
options:
avanzu_admin_route: profile

View File

@@ -1,17 +1,18 @@
# this imports the routes used to display the web debug toolbar at the bottom of each page
_wdt:
resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
prefix: /_wdt
#_wdt:
# resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
# prefix: /_wdt
# this imports the routes needed to display the Symfony Profiler information
_profiler:
resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
prefix: /_profiler
#_profiler:
# resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
# prefix: /_profiler
# this imports the route used to test error pages. Just browse the following URL:
# /{_locale}/_error/{status_code}.{format}
# (e.g. /en/_error/404, /en/_error/403.json, /fr/_error/500.xml)
# See http://symfony.com/doc/current/cookbook/controller/error_pages.html#testing-error-pages-during-development
_errors:
resource: "@TwigBundle/Resources/config/routing/errors.xml"
prefix: /{_locale}/_error
@@ -20,6 +21,76 @@ _errors:
defaults:
_locale: '%locale%'
# ======================================================================
# Template routes, that we need once we use those features
# ======================================================================
#avanzu_admin_login:
# path: /{_locale}/login
# options:
# avanzu_admin_route: login
#
#avanzu_admin_logout:
# path: /logout
# options:
# avanzu_admin_route: logout
#
#avanzu_admin_all_tasks:
# path: /tasks/
# options:
# avanzu_admin_route: all_tasks
#
#avanzu_admin_show_task:
# path: /tasks/{ident}/
# options:
# avanzu_admin_route: task
#
#avanzu_admin_all_notifications:
# path: /notifications/
# options:
# avanzu_admin_route: all_notifications
#
#avanzu_admin_show_notification:
# path: /notifications/{ident}/
# options:
# avanzu_admin_route: notification
#
#avanzu_admin_all_messages:
# path: /messages/
# options:
# avanzu_admin_route: all_messages
#
#avanzu_admin_show_message:
# path: /messages/{ident}/
# options:
# avanzu_admin_route: message
# ======================================================================
# Template demo screen
# Activate full demo mode by setting "enable_demo" in config_dev.xml
# ======================================================================
avanzu_admin_home:
path: /{_locale}/demo-admin/
defaults: {_controller: AvanzuAdminThemeBundle:Default:index}
options:
avanzu_admin_route: welcome
avanzu_admin_form_demo:
path: /{_locale}/demo-admin/form-demo/
defaults: {_controller: AvanzuAdminThemeBundle:Default:form}
avanzu_admin_login_demo:
path: /{_locale}/demo-admin/login/
defaults: {_controller: AvanzuAdminThemeBundle:Default:login}
avanzu_admin_dash_demo:
path: /{_locale}/demo-admin/dashboard/
defaults: {_controller: AvanzuAdminThemeBundle:Default:dashboard}
# ======================================================================
# this loads the main routing file, which usually defines the routes available
# in any environment (production, development, etc.)
_main:

View File

@@ -37,7 +37,7 @@ security:
# The route name the user can go to in order to logout
path: security_logout
# The name of the route to redirect to after logging out
target: timesheet
target: homepage
role_hierarchy:
ROLE_USER: ROLE_CUSTOMER

View File

@@ -61,3 +61,31 @@ services:
#
# // same code using repository services
# $posts = $this->get('app.post_repository')->findAll();
avanzu_admin_theme.navbar_user_listener:
class: AppBundle\EventListener\NavbarShowUserListener
arguments: ["@security.token_storage"]
tags:
- { name: kernel.event_listener, event: theme.navbar_user, method: onShowUser }
- { name: kernel.event_listener, event: theme.sidebar_user, method: onShowUser }
# avanzu_admin_theme.navbar_task_listener:
# class: "%avanzu_admin_theme.navbar_task_listener.class%"
# tags:
# - { name: kernel.event_listener, event: theme.tasks, method: onListTasks }
#
# avanzu_admin_theme.navbar_notify_listener:
# class: "%avanzu_admin_theme.navbar_notify_listener.class%"
# tags:
# - { name: kernel.event_listener, event: theme.notifications, method: onListNotifications }
#
# avanzu_admin_theme.navbar_msg_listener:
# class: "%avanzu_admin_theme.navbar_msg_listener.class%"
# tags:
# - { name: kernel.event_listener, event: theme.messages, method: onListMessages }
#
# avanzu_admin_theme.setup_menu_listener:
# class: "%avanzu_admin_theme.setup_menu_listener.class%"
# tags:
# - { name: kernel.event_listener, event: theme.sidebar_setup_menu, method: onSetupMenu }
# - { name: kernel.event_listener, event: theme.breadcrumb, method: onSetupMenu }

View File

@@ -31,7 +31,7 @@
"symfony/symfony": "^3.1",
"twig/extensions": "^1.3",
"white-october/pagerfanta-bundle": "^1.0",
"avanzu/admin-theme-bundle": "^1.3"
"avanzu/admin-theme-bundle": "dev-feature/2.0"
},
"require-dev": {
"sensio/generator-bundle": "~3.0",

View File

@@ -0,0 +1,71 @@
<?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 AppBundle\Controller;
use TimesheetBundle\Entity\Timesheet;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
/**
* User profile controller
*
* @Route("/profile")
* @Security("has_role('ROLE_USER')")
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class ProfileController extends Controller
{
/**
* @Route("/", defaults={"ident": null}, name="user_profile")
* @Route("/{ident}/", requirements={"ident": "[a-zA-Z0-9\-].*"}, name="user_profile_ident")
* @Method("GET")
*/
public function indexAction($ident)
{
// FIXME fetch values dynamically and add trans filter to macros
$items = [
[
'title' => 'Projects',
'url' => '#',
'color' => 'blue',
'amount' => 12
],
[
'title' => 'Tasks',
'url' => '#',
'color' => 'aqua',
'amount' => 5
],
[
'title' => 'Projects',
'url' => '#',
'color' => 'red',
'amount' => 27
],
[
'title' => 'Einträge',
'url' => '#',
'color' => 'green',
'amount' => 842
],
];
return $this->render(
'user/profile.html.twig',
['user' => $this->getUser(), 'items' => $items]
);
}
}

View File

@@ -31,6 +31,7 @@ class SecurityController extends Controller
{
$helper = $this->get('security.authentication_utils');
//return $this->render('AvanzuAdminThemeBundle:Security:login.html.twig', [
return $this->render('security/login.html.twig', [
// last username entered by the user (if any)
'last_username' => $helper->getLastUsername(),

View File

@@ -41,6 +41,8 @@ class LoadFixtures implements FixtureInterface, ContainerAwareInterface
$passwordEncoder = $this->container->get('security.password_encoder');
$claraCustomer = new User();
$claraCustomer->setAlias('Clara Haynes');
$claraCustomer->setTitle('CFO');
$claraCustomer->setUsername('clara_customer');
$claraCustomer->setEmail('clara_customer@example.com');
$claraCustomer->setRoles(['ROLE_CUSTOMER']);
@@ -49,6 +51,8 @@ class LoadFixtures implements FixtureInterface, ContainerAwareInterface
$manager->persist($claraCustomer);
$johnUser = new User();
$johnUser->setAlias('John Doe');
$johnUser->setTitle('Lead Developer');
$johnUser->setUsername('john_user');
$johnUser->setEmail('john_user@example.com');
$johnUser->setRoles(['ROLE_USER']);
@@ -57,6 +61,8 @@ class LoadFixtures implements FixtureInterface, ContainerAwareInterface
$manager->persist($johnUser);
$tonyTeamlead = new User();
$tonyTeamlead->setAlias('Tony Maier');
$tonyTeamlead->setTitle('Head of Development');
$tonyTeamlead->setUsername('tony_teamlead');
$tonyTeamlead->setEmail('tony_teamlead@example.com');
$tonyTeamlead->setRoles(['ROLE_TEAMLEAD']);
@@ -65,6 +71,8 @@ class LoadFixtures implements FixtureInterface, ContainerAwareInterface
$manager->persist($tonyTeamlead);
$annaAdmin = new User();
$annaAdmin->setAlias('Anna Smith');
$annaAdmin->setTitle('Administrator');
$annaAdmin->setUsername('anna_admin');
$annaAdmin->setEmail('anna_admin@example.com');
$annaAdmin->setRoles(['ROLE_ADMIN']);

View File

@@ -7,7 +7,7 @@ use Symfony\Component\Security\Core\User\UserInterface;
/**
* KimaiUsers
* User
*
* @ORM\Entity(repositoryClass="AppBundle\Repository\UserRepository")
* @ORM\Table(name="users", uniqueConstraints={@ORM\UniqueConstraint(name="name", columns={"name"}), @ORM\UniqueConstraint(name="apikey", columns={"apikey"})})
@@ -46,6 +46,8 @@ class User implements UserInterface
private $alias;
/**
* FIXME remove me
*
* @var boolean
*
* @ORM\Column(name="trash", type="boolean", nullable=false)
@@ -67,6 +69,8 @@ class User implements UserInterface
private $passwordresethash;
/**
* FIXME remove me
*
* @var integer
*
* @ORM\Column(name="ban", type="integer", nullable=false)
@@ -74,6 +78,7 @@ class User implements UserInterface
private $ban = '0';
/**
* FIXME remove me
* @var integer
*
* @ORM\Column(name="banTime", type="integer", nullable=false)
@@ -88,7 +93,7 @@ class User implements UserInterface
private $secure = '0';
/**
* FIXME
* FIXME manytoone relation
*
* @var integer
*
@@ -97,7 +102,7 @@ class User implements UserInterface
private $lastproject = '1';
/**
* FIXME
* FIXME manytoone
*
* @var integer
*
@@ -133,17 +138,32 @@ class User implements UserInterface
*/
private $apikey;
// ======= new columns for kimai 2 =======
/**
* @ORM\Column(type="json_array")
*/
private $roles = [];
/**
* @var string
*
* @ORM\Column(name="title", type="string", length=50, nullable=true)
*/
private $title;
/**
* @var string
*
* @ORM\Column(name="avatar", type="string", length=50, nullable=true)
*/
private $avatar;
/**
* Set alias
*
* @param string $alias
*
* @return KimaiUsers
* @return User
*/
public function setAlias($alias)
{
@@ -167,7 +187,7 @@ class User implements UserInterface
*
* @param boolean $trash
*
* @return KimaiUsers
* @return User
*/
public function setTrash($trash)
{
@@ -191,7 +211,7 @@ class User implements UserInterface
*
* @param boolean $active
*
* @return KimaiUsers
* @return User
*/
public function setActive($active)
{
@@ -215,7 +235,7 @@ class User implements UserInterface
*
* @param string $password
*
* @return KimaiUsers
* @return User
*/
public function setPassword($password)
{
@@ -239,7 +259,7 @@ class User implements UserInterface
*
* @param string $passwordresethash
*
* @return KimaiUsers
* @return User
*/
public function setPasswordresethash($passwordresethash)
{
@@ -263,7 +283,7 @@ class User implements UserInterface
*
* @param integer $ban
*
* @return KimaiUsers
* @return User
*/
public function setBan($ban)
{
@@ -287,7 +307,7 @@ class User implements UserInterface
*
* @param integer $bantime
*
* @return KimaiUsers
* @return User
*/
public function setBantime($bantime)
{
@@ -311,7 +331,7 @@ class User implements UserInterface
*
* @param string $secure
*
* @return KimaiUsers
* @return User
*/
public function setSecure($secure)
{
@@ -335,7 +355,7 @@ class User implements UserInterface
*
* @param integer $lastproject
*
* @return KimaiUsers
* @return User
*/
public function setLastproject($lastproject)
{
@@ -359,7 +379,7 @@ class User implements UserInterface
*
* @param integer $lastactivity
*
* @return KimaiUsers
* @return User
*/
public function setLastactivity($lastactivity)
{
@@ -383,7 +403,7 @@ class User implements UserInterface
*
* @param integer $lastrecord
*
* @return KimaiUsers
* @return User
*/
public function setLastrecord($lastrecord)
{
@@ -407,7 +427,7 @@ class User implements UserInterface
*
* @param string $timeframebegin
*
* @return KimaiUsers
* @return User
*/
public function setTimeframebegin($timeframebegin)
{
@@ -431,7 +451,7 @@ class User implements UserInterface
*
* @param string $timeframeend
*
* @return KimaiUsers
* @return User
*/
public function setTimeframeend($timeframeend)
{
@@ -455,7 +475,7 @@ class User implements UserInterface
*
* @param string $apikey
*
* @return KimaiUsers
* @return User
*/
public function setApikey($apikey)
{
@@ -474,30 +494,6 @@ class User implements UserInterface
return $this->apikey;
}
/**
* Set globalroleid
*
* @param integer $globalroleid
*
* @return KimaiUsers
*/
public function setGlobalroleid($globalroleid)
{
$this->globalroleid = $globalroleid;
return $this;
}
/**
* Get globalroleid
*
* @return integer
*/
public function getGlobalroleid()
{
return $this->globalroleid;
}
public function getId()
{
return $this->id;
@@ -565,8 +561,40 @@ class User implements UserInterface
// $this->plainPassword = null;
}
/**
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* @param string $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* @return string
*/
public function getAvatar()
{
return $this->avatar;
}
/**
* @param string $avatar
*/
public function setAvatar($avatar)
{
$this->avatar = $avatar;
}
public function __toString()
{
return $this->getUsername();
return $this->getAlias() ?: $this->getUsername();
}
}

View File

@@ -75,7 +75,7 @@ class MenuBuilder
if ($isAdmin) {
$event->addItem(
new MenuItemModel('admin', 'menu.admin_dashboard', '', [], 'fa fa-dashboard')
new MenuItemModel('admin', 'menu.admin', '', [], 'fa fa-dashboard')
);
$this->eventDispatcher->dispatch(

View File

@@ -0,0 +1,59 @@
<?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 AppBundle\EventListener;
use AppBundle\Entity\User;
use Avanzu\AdminThemeBundle\Event\ShowUserEvent;
use Avanzu\AdminThemeBundle\Model\UserModel;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* Class NavbarShowUserListener
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class NavbarShowUserListener
{
/**
* @var TokenStorageInterface
*/
protected $storage;
public function __construct(TokenStorageInterface $tokenStorage)
{
$this->storage = $tokenStorage;
}
public function onShowUser(ShowUserEvent $event)
{
/* @var $myUser User */
$myUser = $this->storage->getToken()->getUser();
$titles = [];
$roles = $this->storage->getToken()->getRoles();
foreach ($roles as $role) {
$titles[] = ucfirst(strtolower(str_replace('ROLE_', '', $role->getRole())));
}
$user = new UserModel();
$user->setName($myUser->getAlias() ?: $myUser->getUsername())
->setUsername($myUser->getUsername())
->setIsOnline(true)
->setTitle($myUser->getTitle())
->setAvatar($myUser->getAvatar())
->setMemberSince(new \DateTime()) // FIXME add column to entity
;
$event->setUser($user);
}
}

View File

@@ -36,7 +36,7 @@ class TimesheetController extends Controller
*/
public function indexAction($page)
{
$entries = $this->getDoctrine()->getRepository(Timesheet::class)->findLatest($page);
$entries = $this->getDoctrine()->getRepository(Timesheet::class)->findAll($page);
return $this->render('TimesheetBundle:timesheet:index.html.twig', ['entries' => $entries]);
}

View File

@@ -30,13 +30,14 @@ class TimesheetController extends Controller
{
/**
* @Route("/", defaults={"page": 1}, name="timesheet")
* @Route("/timesheet/{page}", requirements={"page": "[1-9]\d*"}, name="timesheet_paginated")
* @Route("/page/{page}", requirements={"page": "[1-9]\d*"}, name="timesheet_paginated")
* @Method("GET")
* @Cache(smaxage="10")
*/
public function indexAction($page)
{
$entries = $this->getDoctrine()->getRepository(Timesheet::class)->findLatest($page);
$user = $this->getUser();
$entries = $this->getDoctrine()->getRepository(Timesheet::class)->findLatest($user, $page);
return $this->render('TimesheetBundle:timesheet:index.html.twig', ['entries' => $entries]);
}

View File

@@ -11,6 +11,7 @@
namespace TimesheetBundle\Repository;
use AppBundle\Entity\User;
use TimesheetBundle\Entity\Timesheet;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;
@@ -26,16 +27,33 @@ class TimesheetRepository extends EntityRepository
{
/**
* @param User $user
* @return Query
*/
public function queryLatest()
public function queryLatest(User $user = null)
{
return $this->getEntityManager()
->createQuery('
SELECT p
FROM TimesheetBundle:Timesheet p
ORDER BY p.start DESC
');
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('p')
->from('TimesheetBundle:Timesheet', 'p')
->orderBy('p.start', 'DESC');
if (null !== $user) {
$qb->where('p.user = :user')
->setParameter('user', $user);
}
return $qb->getQuery();
}
/**
* @param User $user
* @param int $page
* @return Pagerfanta
*/
public function findLatest(User $user, $page = 1)
{
return $this->getPager($this->queryLatest($user), $page);
}
/**
@@ -43,9 +61,19 @@ class TimesheetRepository extends EntityRepository
*
* @return Pagerfanta
*/
public function findLatest($page = 1)
public function findAll($page = 1)
{
$paginator = new Pagerfanta(new DoctrineORMAdapter($this->queryLatest(), false));
return $this->getPager($this->queryLatest(), $page);
}
/**
* @param Query $query
* @param int $page
* @return Pagerfanta
*/
protected function getPager(Query $query, $page = 1)
{
$paginator = new Pagerfanta(new DoctrineORMAdapter($query, false));
$paginator->setMaxPerPage(25);
$paginator->setCurrentPage($page);

View File

@@ -9,17 +9,17 @@
<thead>
<tr>
<th><i class="fa fa-calendar"></i> {{ 'label.date'|trans }}</th>
<th><i class="fa fa-circle-o"></i> {{ 'label.start'|trans }}</th>
<th><i class="fa fa-circle"></i> {{ 'label.end'|trans }}</th>
<th><i class="fa fa-hourglass-start"></i> {{ 'label.starttime'|trans }}</th>
<th><i class="fa fa-hourglass-end"></i> {{ 'label.endtime'|trans }}</th>
<th><i class="fa fa-clock-o"></i> {{ 'label.duration'|trans }}</th>
<th><i class="fa fa-user"></i> {{ 'label.user'|trans }}</th>
<th>{{ 'label.description'|trans }}</th>
<th><i class="fa fa-user"></i> {{ 'label.username'|trans }}</th>
<th><i class="fa fa-pencil-square-o"></i> {{ 'label.description'|trans }}</th>
</tr>
</thead>
<tbody>
{% for entry in entries %}
<tr>
<td>{{ entry.start|date("m/d/Y") }}</td>
<td>{{ entry.start|date(kimai_context.date_1) }}</td>
<td>{{ entry.start|date("H:i") }}</td>
<td>{{ entry.end|date("H:i") }}</td>
<td>{{ entry.duration|gmdate }}</td>

BIN
web/avatars/default.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB