-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from H2-invent/feature/admin_dashboard
Feature/admin dashboard
- Loading branch information
Showing
8 changed files
with
242 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace App\Controller; | ||
|
||
use App\Entity\Rooms; | ||
use App\Entity\Server; | ||
use App\Service\AdminService; | ||
use Doctrine\DBAL\Types\DateType; | ||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; | ||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
use Symfony\Component\Serializer\SerializerInterface; | ||
use Symfony\Contracts\HttpClient\HttpClientInterface; | ||
use Symfony\Contracts\Translation\TranslatorInterface; | ||
|
||
class AdminController extends AbstractController | ||
{ | ||
|
||
/** | ||
* @Route("/admin/server/{server}", name="admin_server") | ||
* @ParamConverter("server", class="App\Entity\Server",options={"mapping": {"server": "id"}}) | ||
*/ | ||
public function server(Server $server, AdminService $adminService, HttpClientInterface $httpClient, TranslatorInterface $translator) | ||
{ | ||
$countPart = 0; | ||
foreach ($server->getRooms() as $room) { | ||
$countPart = $countPart + count($room->getUser()); | ||
} | ||
|
||
if ($this->getUser() !== $server->getAdministrator()) { | ||
return $this->redirectToRoute('dashboard',['snack'=>$translator->trans('Fehler, Der Server wurde nicht gefunden'),'color'=>'danger']); | ||
} | ||
|
||
$req = $httpClient->request('GET', 'https://api.github.com/repos/H2-invent/jitsi-admin/tags'); | ||
$tags = json_decode($req->getContent(), true); | ||
$chart = $adminService->createChart($server); | ||
|
||
return $this->render('admin/modalChart.html.twig', [ | ||
'server' => $server, | ||
'countPart' => $countPart, | ||
'chart' => $chart, | ||
'tags' => $tags | ||
]); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: Emanuel | ||
* Date: 03.10.2019 | ||
* Time: 19:01 | ||
*/ | ||
|
||
namespace App\Service; | ||
|
||
use App\Entity\Rooms; | ||
use App\Entity\Server; | ||
use App\Entity\User; | ||
use Doctrine\ORM\EntityManagerInterface; | ||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | ||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | ||
use Symfony\Contracts\Translation\TranslatorInterface; | ||
use Twig\Environment; | ||
|
||
|
||
class AdminService | ||
{ | ||
private $em; | ||
|
||
public function __construct(EntityManagerInterface $entityManager) | ||
{ | ||
$this->em = $entityManager; | ||
} | ||
|
||
public function createChart(Server $server) | ||
{ | ||
$rooms = $this->em->getRepository(Rooms::class)->findBy(['server'=>$server]); | ||
|
||
$chart = array(); | ||
$firstDate = new \DateTime(); | ||
$firstDate = date_modify($firstDate,'-30 days'); | ||
for ($x = 0; $x <= 60; $x++) { | ||
$d = clone $firstDate; | ||
$date = date_modify($d,'+'.$x.'days'); | ||
|
||
$chart[$date->format('Ymd')]['date'] = $date; | ||
$chart[$date->format('Ymd')]['participants'] = 0; | ||
$chart[$date->format('Ymd')]['rooms'] = 0; | ||
foreach ($rooms as $data) { | ||
if ($data->getStart()->format('Ymd') === $date->format('Ymd')) { | ||
$chart[$date->format('Ymd')]['rooms'] = $chart[$date->format('Ymd')]['rooms'] + 1; | ||
$chart[$date->format('Ymd')]['participants'] = $chart[$date->format('Ymd')]['participants'] + count($data->getUser()); | ||
} | ||
} | ||
} | ||
return $chart; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<div class="modal-dialog modal-xl modal-dialog-centered"> | ||
<div class="modal-content"> | ||
|
||
<div class="modal-header light-blue darken-3 white-text"> | ||
<h5 class="modal-title">{{ server.url }}</h5> | ||
|
||
</div> | ||
<div class="modal-body "> | ||
<div class="row"> | ||
<div class="col-md-6 col-sm-6 col-lg-3 mb-2"> | ||
<div class="card border-info text-center"> | ||
<div class="card-body"> | ||
{{ 'Konferenzen'|trans }} | ||
<hr> | ||
{{ server.rooms | length }} | ||
</div> | ||
</div> | ||
</div> | ||
<div class="col-md-6 col-sm-6 col-lg-3 mb-2"> | ||
<div class="card border-info text-center"> | ||
<div class="card-body"> | ||
{{ 'Teilnehmer'|trans }} | ||
<hr> | ||
{{ countPart }} | ||
</div> | ||
</div> | ||
</div> | ||
<div class="col-md-6 col-sm-6 col-lg-3 mb-2"> | ||
<div class="card border-info text-center"> | ||
<div class="card-body"> | ||
{{ 'Organisatoren'|trans }} | ||
<hr> | ||
{{ server.user | length }} | ||
</div> | ||
</div> | ||
</div> | ||
<div class="col-md-6 col-sm-6 col-lg-3 mb-2"> | ||
<a href="https://github.com/H2-invent/jitsi-admin/releases/tag/{{ tags[0].name }}" referrerpolicy="no-referrer " target="_blank" rel="noreferrer noopener"> | ||
<div class="card {% if laf_version != tags[0].name %}border-danger{% else %}border-info{% endif %} text-center"> | ||
<div class="card-body"> | ||
{% if laf_version != tags[0].name %}{{ 'Neue Version von Jitsi Admin verfügbar'|trans }}{% else %}{{ 'Aktuellste Jitsi Admin Version installiert'|trans }}{% endif %} | ||
</div> | ||
</div> | ||
</a> | ||
</div> | ||
</div> | ||
<hr> | ||
<h3 class="h3-responsive"> | ||
{{ 'Konferenzen'|trans }} | ||
</h3> | ||
<canvas id="lineChart"></canvas> | ||
</div> | ||
</div> | ||
</div> | ||
<script> | ||
data = { | ||
labels: [{% for date in chart %}"{{ date['date']|date('d.m.Y') }}",{% endfor %}], | ||
datasets: [{ | ||
label: "{{ 'Anzahl Konferenzen'|trans }}", | ||
data: [{% for date in chart %}"{{ date['rooms'] }}",{% endfor %}], | ||
backgroundColor: [ | ||
'rgba(105, 0, 132, .2)', | ||
], | ||
borderColor: [ | ||
'rgba(200, 99, 132, .7)', | ||
], | ||
borderWidth: 2 | ||
}, | ||
{ | ||
label: "{{ 'Anzahl Teilnehmer'|trans }}", | ||
data: [{% for date in chart %}"{{ date['participants'] }}",{% endfor %}], | ||
backgroundColor: [ | ||
'rgba(0, 137, 132, .2)', | ||
], | ||
borderColor: [ | ||
'rgba(0, 10, 130, .7)', | ||
], | ||
borderWidth: 2 | ||
} | ||
] | ||
}; | ||
options = { | ||
responsive: true | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters