added avatars, show user teams in list, new team dashboard widgets (#1150)

This commit is contained in:
Kevin Papst
2019-10-03 13:44:16 +02:00
committed by GitHub
parent 718ad4b398
commit e8c25d8ac5
120 changed files with 2585 additions and 642 deletions

View File

@@ -0,0 +1,59 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Twig;
use App\Entity\User;
use App\Utils\AvatarService;
use Symfony\Component\Asset\Packages;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
class AvatarExtension extends AbstractExtension
{
/**
* @var AvatarService
*/
private $avatar;
/**
* @var Packages
*/
private $packages;
public function __construct(AvatarService $avatar, Packages $packages)
{
$this->avatar = $avatar;
$this->packages = $packages;
}
/**
* {@inheritdoc}
*/
public function getFunctions()
{
return [
new TwigFunction('avatar', [$this, 'getAvatarUrl']),
];
}
public function getAvatarUrl(?User $profile, string $default): string
{
if (null === $profile) {
return $this->packages->getUrl($default);
}
$url = $this->avatar->getAvatar($profile);
if (null === $url) {
return $this->packages->getUrl($default);
}
return $this->packages->getUrl($url);
}
}

View File

@@ -135,12 +135,11 @@ class Extensions extends AbstractExtension
}
if ($duration instanceof Timesheet) {
$seconds = $duration->getDuration();
if (null === $duration->getEnd()) {
$seconds = time() - $duration->getBegin()->getTimestamp();
$duration = time() - $duration->getBegin()->getTimestamp();
} else {
$duration = $duration->getDuration();
}
$duration = $seconds;
}
return (int) $duration;

View File

@@ -75,6 +75,8 @@ final class IconExtension extends AbstractExtension
'configuration' => 'fas fa-cogs',
'mail-sent' => 'fas fa-paper-plane',
'mail' => 'fas fa-envelope-open',
'doctor' => 'fas fa-medkit',
'success' => 'fas fa-check',
];
/**