Skip to content

Commit

Permalink
Merge pull request #59 from H2-invent/feature/adhocMeeting
Browse files Browse the repository at this point in the history
Feature/adhoc meeting
  • Loading branch information
holema authored Feb 7, 2021
2 parents 263cedd + 450b496 commit d66151c
Show file tree
Hide file tree
Showing 11 changed files with 201 additions and 36 deletions.
10 changes: 10 additions & 0 deletions assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -622,3 +622,13 @@ label.required:after {
background-color: white;
}
}
.breakWord{
word-break: break-all;
padding-right: 5px;
}
.noBreak{
white-space: nowrap;
}
#modalAdressbook a[aria-expanded="true"] {
background: white;
}
8 changes: 7 additions & 1 deletion assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,15 @@ $(document).ready(function () {
$(document).on('click', '.confirmHref', function (e) {
e.preventDefault();
var url = $(this).prop('href');
var text = $(this).data('text');
if(typeof text === 'undefined'){

text = 'Wollen Sie die Aktion durchführen?'
}
console.log(text);
$.confirm({
title: 'Bestätigung',
content: 'Wollen Sie die Aktion durchführen?',
content: text,
theme: 'material',
buttons: {
confirm: {
Expand Down
63 changes: 63 additions & 0 deletions src/Controller/AdHocMeetingController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

namespace App\Controller;

use App\Entity\Rooms;
use App\Entity\Server;
use App\Entity\User;
use App\Service\RoomService;
use App\Service\UserService;
use phpDocumentor\Reflection\Types\This;
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\Contracts\Translation\TranslatorInterface;

class AdHocMeetingController extends AbstractController
{
/**
* @Route("/room/adhoc/meeting/{userId}/{serverId}", name="add_hoc_meeting")
* @ParamConverter("user", class="App\Entity\User",options={"mapping": {"userId": "id"}})
* @ParamConverter("server", class="App\Entity\Server",options={"mapping": {"serverId": "id"}})
*/
public function index(User $user, Server $server, UserService $userService,TranslatorInterface $translator): Response
{

if(!in_array($user,$this->getUser()->getAddressbook()->toArray())){
return $this->redirectToRoute('dashboard',array('snack'=>$translator->trans('Fehler, Der User wurde nicht gefunden')));
}
$servers = $this->getUser()->getServers()->toarray();
$default = $this->getDoctrine()->getRepository(Server::class)->find($this->getParameter('default_jitsi_server_id'));

if ($default && !in_array($default,$servers)) {
$servers[] = $default;
}

if(!in_array($server,$servers)){
return $this->redirectToRoute('dashboard',array('snack'=>$translator->trans('Fehler, Der Server wurde nicht gefunden')));
}
$room = new Rooms();
$room->setModerator($this->getUser());
$room->setStart(new \DateTime());
$room->setEnddate((new \DateTime())->modify('+ 1 hour'));
$room->setDuration(60);
$room->setSequence(0);
$room->setUidReal(md5(uniqid()));
$room->setUid(rand(01, 99) . time());
$room->setServer($server);
$room->setName($translator->trans('Konferenz mit {n}',array('{n}'=>$user->getEmail())));
$room->setOnlyRegisteredUsers(false);
$em = $this->getDoctrine()->getManager();
$em->persist($room);
$em->flush();
$user->addRoom($room);
$em->persist($user);
$this->getUser()->addRoom($room);
$em->persist($this->getUser());
$em->flush();
$userService->addUser($user,$room);
$userService->addUser($this->getUser(),$room);
return $this->redirectToRoute('dashboard',array('snack'=>$translator->trans('Konferenz erfolgreich erstellt')));
}
}
11 changes: 10 additions & 1 deletion src/Controller/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,21 @@ public function dashboard(Request $request)
$roomsPast = $this->getDoctrine()->getRepository(Rooms::class)->findRoomsInPast($this->getUser());
$roomsNow = $this->getDoctrine()->getRepository(Rooms::class)->findRuningRooms($this->getUser());
$roomsToday = $this->getDoctrine()->getRepository(Rooms::class)->findTodayRooms($this->getUser());

$servers = $this->getUser()->getServers()->toarray();
$default = $this->getDoctrine()->getRepository(Server::class)->find($this->getParameter('default_jitsi_server_id'));

if ($default && !in_array($default,$servers)) {
$servers[] = $default;
}

return $this->render('dashboard/index.html.twig', [
'roomsFuture' => $future,
'roomsPast' => $roomsPast,
'runningRooms'=>$roomsNow,
'todayRooms' => $roomsToday,
'snack' => $request->get('snack')
'snack' => $request->get('snack'),
'servers'=>$servers,
]);
}

Expand Down
6 changes: 5 additions & 1 deletion src/Controller/RoomController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ public function newRoom(Request $request, UserService $userService, TranslatorIn
}
$servers = $this->getUser()->getServers()->toarray();
$default = $this->getDoctrine()->getRepository(Server::class)->find($this->getParameter('default_jitsi_server_id'));
if ($default) {

if ($default && !in_array($default,$servers)) {
$servers[] = $default;
}


$form = $this->createForm(RoomType::class, $room, ['server' => $servers, 'action' => $this->generateUrl('room_new', ['id' => $room->getId()])]);
try {
$form->handleRequest($request);
Expand All @@ -75,6 +77,8 @@ public function newRoom(Request $request, UserService $userService, TranslatorIn
if ($request->get('id')) {
foreach ($room->getUser() as $user) {
$userService->editRoom($user, $room);


}
} else {
$userService->addUser($room->getModerator(), $room);
Expand Down
63 changes: 43 additions & 20 deletions src/Service/MailerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@


use App\Entity\Server;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Mailer\Transport\TransportInterface;
Expand All @@ -21,63 +22,85 @@ class MailerService
private $swift;
private $parameter;
private $kernel;
public function __construct(ParameterBagInterface $parameterBag, TransportInterface $smtp, \Swift_Mailer $swift_Mailer, KernelInterface $kernel)
private $logger;
private $customMailer;

public function __construct(LoggerInterface $logger, ParameterBagInterface $parameterBag, TransportInterface $smtp, \Swift_Mailer $swift_Mailer, KernelInterface $kernel)
{
$this->smtp = $smtp;
$this->swift = $swift_Mailer;
$this->parameter = $parameterBag;
$this->kernel = $kernel;
$this->logger = $logger;
$this->customMailer = null;
}

public function sendViaCustomSmtp(Server $server) {
$transport = (new \Swift_SmtpTransport(
$server->getSmtpHost(),
$server->getSmtpPort(),
$server->getSmtpEncryption()))
->setUsername($server->getSmtpUsername())
->setPassword($server->getSmtpPassword());

$customMailer = new \Swift_Mailer($transport);
public function buildTransport(Server $server)
{

return $customMailer;
if ($server->getSmtpHost()) {
$this->logger->debug('Build new Transport: ' . $server->getSmtpHost());
$tmpTransport = (new \Swift_SmtpTransport(
$server->getSmtpHost(),
$server->getSmtpPort(),
$server->getSmtpEncryption()))
->setUsername($server->getSmtpUsername())
->setPassword($server->getSmtpPassword());
$tmpMailer = new \Swift_Mailer($tmpTransport);
if ($this->customMailer !== $tmpMailer) {
$this->customMailer = $tmpMailer;
}
}
}

public function sendEmail($to, $betreff, $content, $server, $attachment = array())
public function sendEmail($to, $betreff, $content, Server $server, $attachment = array())
{
$this->sendViaSwiftMailer($to, $betreff, $content, $server, $attachment);

try {
$this->logger->debug('Mail To: ' . $to);
$this->sendViaSwiftMailer($to, $betreff, $content, $server, $attachment);

} catch (\Exception $e) {
$this->logger->error($e->getMessage());
}

}

private function sendViaSwiftMailer($to, $betreff, $content, Server $server, $attachment = array())
{
if ($server->getSmtpHost()){
$this->buildTransport($server);
if ($server->getSmtpHost()) {
$this->logger->debug($server->getSmtpEmail());
$sender = $server->getSmtpEmail();
$senderName = $server->getSmtpSenderName();
}else {
} else {
$sender = $this->parameter->get('registerEmailAdress');
$senderName = $this->parameter->get('registerEmailName');
}
$message = (new \Swift_Message($betreff))
->setFrom(array($sender => $senderName))
->setTo($to)
->setBody(

$content
, 'text/html'
);
foreach ($attachment as $data) {
$message->attach(new \Swift_Attachment($data['body'], $data['filename'], $data['type']));
};

try {
if ($server->getSmtpHost()) {
if ($this->kernel->getEnvironment() === 'dev'){
if ($this->kernel->getEnvironment() === 'dev') {
$message->setTo($this->parameter->get('delivery_addresses'));
}
$this->sendViaCustomSmtp($server)->send($message);
}else {
$this->logger->debug('Send from Custom Mailer');
$this->customMailer->send($message);
} else {
$this->swift->send($message);
}
}catch (\Exception $e) {
} catch (\Exception $e) {
$this->swift->send($message);
$this->logger->error($e->getMessage());
}
}
}
1 change: 0 additions & 1 deletion src/Service/NotificationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ function createIcs(Rooms $rooms, User $user, $url, $method = 'REQUEST')

function sendNotification($content, $subject, User $user, Server $server, $attachement = array())
{

$this->mailer->sendEmail(
$user->getEmail(),
$subject,
Expand Down
1 change: 1 addition & 0 deletions src/Service/UserService.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ function addUser(User $user, Rooms $room)

function editRoom(User $user, Rooms $room)
{

$url = $this->generateUrl($room, $user);
$content = $this->twig->render('email/editRoom.html.twig', ['user' => $user, 'room' => $room, 'url' => $url]);
$subject = $this->translator->trans('Videokonferenz wurde bearbeitet');
Expand Down
42 changes: 30 additions & 12 deletions templates/base/__addressBookModal.html.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<div class="modal fade right" id="modalAdressbook" tabindex="-1" role="dialog" aria-labelledby="exampleModalPreviewLabel" aria-hidden="true">

<div class="modal fade right" id="modalAdressbook" tabindex="-1" role="dialog"
aria-labelledby="exampleModalPreviewLabel" aria-hidden="true">
<div class="modal-dialog modal-full-height modal-right" role="document">
<div class="modal-content" style="height: 100vh;display: flex; flex-direction: column">
<div class="modal-header">
Expand All @@ -9,18 +11,34 @@
</div>
<div class="modal-body" style="flex-grow: 1;overflow-y: auto">
<div style="">
<ul class="list-group">
{% set name = null %}
{% for u in app.user.addressbook|sort((a, b) => a.email|lower <=> b.email|lower) %}
{% if u.email|first|upper != name %}
{{ u.email|first|upper }}
{% set name = u.email|first|upper %}
{% endif %}
<ul class="list-group">
{% set name = null %}
{% for u in app.user.addressbook|sort((a, b) => a.email|lower <=> b.email|lower) %}
{% if u.email|first|upper != name %}
{{ u.email|first|upper }}
{% set name = u.email|first|upper %}
{% endif %}

<li class="list-group-item" style="display: flex; justify-content: space-between"><span>{{ u.email }} </span><span><a class="confirmHref" href="{{ path('adressbook_remove_user',{'id':u.id}) }}"><i class="fa fa-trash"></i> </a></span> </li>
{% endfor %}
</ul>
</div>
<li class="list-group-item" style="display: flex; justify-content: space-between">
<span class="breakWord">{{ u.email }} </span>
<span class="noBreak">
<a class="caretdown dropdown-toggle mr-1 text-success" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
<i class="fa fa-phone"></i>
</a>
<div class="dropdown-menu">

{% for s in servers %}
<a class="dropdown-item confirmHref" data-text="{{ 'Wollen Sie mit diesem Teilnehmer eine Konferenz starten'|trans }}"
href="{{ path('add_hoc_meeting',{'serverId':s.id,'userId':u.id}) }}">{{ s.url }}</a>

{% endfor %}
</div>
<a class="confirmHref" href="{{ path('adressbook_remove_user',{'id':u.id}) }}"><i
class="fa fa-trash"></i> </a></span></li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
Expand Down
16 changes: 16 additions & 0 deletions translations/messages+intl-icu.en.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,22 @@
wird ist mit dem Open Source Tool Jitsi gut bedient. Jitsi ist eine Alternative zu Zoom. Sie
speichert keine Nutzerdaten und ermöglicht die verschlüsselte Anwendung.</target>
</trans-unit>
<trans-unit id="cfdSBrO" resname="Fehler, Der User wurde nicht gefunden">
<source>Fehler, Der User wurde nicht gefunden</source>
<target>__Fehler, Der User wurde nicht gefunden</target>
</trans-unit>
<trans-unit id="_jBye0V" resname="Fehler, Der Server wurde nicht gefunden">
<source>Fehler, Der Server wurde nicht gefunden</source>
<target>__Fehler, Der Server wurde nicht gefunden</target>
</trans-unit>
<trans-unit id="f3YYUGJ" resname="Konferenz mit {n}">
<source>Konferenz mit {n}</source>
<target>__Konferenz mit {n}</target>
</trans-unit>
<trans-unit id="AHH1fKI" resname="Wollen Sie mit diesem Teilnehmer eine Konferenz starten">
<source>Wollen Sie mit diesem Teilnehmer eine Konferenz starten</source>
<target>__Wollen Sie mit diesem Teilnehmer eine Konferenz starten</target>
</trans-unit>
</body>
</file>
</xliff>
16 changes: 16 additions & 0 deletions translations/messages+intl-icu.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,22 @@
wird ist mit dem Open Source Tool Jitsi gut bedient. Jitsi ist eine Alternative zu Zoom. Sie
speichert keine Nutzerdaten und ermöglicht die verschlüsselte Anwendung.</target>
</trans-unit>
<trans-unit id="cfdSBrO" resname="Fehler, Der User wurde nicht gefunden">
<source>Fehler, Der User wurde nicht gefunden</source>
<target>__Fehler, Der User wurde nicht gefunden</target>
</trans-unit>
<trans-unit id="_jBye0V" resname="Fehler, Der Server wurde nicht gefunden">
<source>Fehler, Der Server wurde nicht gefunden</source>
<target>__Fehler, Der Server wurde nicht gefunden</target>
</trans-unit>
<trans-unit id="f3YYUGJ" resname="Konferenz mit {n}">
<source>Konferenz mit {n}</source>
<target>__Konferenz mit {n}</target>
</trans-unit>
<trans-unit id="AHH1fKI" resname="Wollen Sie mit diesem Teilnehmer eine Konferenz starten">
<source>Wollen Sie mit diesem Teilnehmer eine Konferenz starten</source>
<target>__Wollen Sie mit diesem Teilnehmer eine Konferenz starten</target>
</trans-unit>
</body>
</file>
</xliff>

0 comments on commit d66151c

Please sign in to comment.