diff --git a/public/css/dashboard.css b/public/css/dashboard.css
index c73ddc2..764af49 100644
--- a/public/css/dashboard.css
+++ b/public/css/dashboard.css
@@ -95,4 +95,26 @@
.link:hover a {
color: grey;
+}
+
+.transcodingProgress {
+ position: absolute;
+ width: 100%;
+ height: 100%;
+ bottom: 0;
+}
+
+.transcodingProgress .value {
+ width: 100%;
+ color: lightgrey;
+ text-align: center;
+ position: absolute;
+ bottom: 5%;
+}
+
+.transcodingProgress .bar {
+ position: absolute;
+ bottom: 0;
+ height: 2%;
+ background-color: lightgrey;
}
\ No newline at end of file
diff --git a/public/js/ajax.js b/public/js/ajax.js
new file mode 100644
index 0000000..098df80
--- /dev/null
+++ b/public/js/ajax.js
@@ -0,0 +1,21 @@
+function ajaxGet(url, callback) {
+ var http = new XMLHttpRequest();
+ http.open("GET", url, true);
+ http.onreadystatechange = function () {
+ if (http.readyState === 4) {
+ callback(http.responseText);
+ }
+ }
+ http.send(null);
+}
+
+function ajaxPost(url, data, callback) {
+ var http = new XMLHttpRequest();
+ http.open("POST", url, true);
+ http.onreadystatechange = function () {
+ if (http.readyState === 4) {
+ callback(http.responseText);
+ }
+ }
+ http.send(data);
+}
\ No newline at end of file
diff --git a/src/Controller/DashboardController.php b/src/Controller/DashboardController.php
index 46b6698..287198c 100644
--- a/src/Controller/DashboardController.php
+++ b/src/Controller/DashboardController.php
@@ -15,8 +15,11 @@ use App\Service\VideoService;
use Doctrine\DBAL\Types\ConversionException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormError;
+use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
+use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\Routing\Annotation\Route;
class DashboardController extends AbstractController
@@ -94,6 +97,36 @@ class DashboardController extends AbstractController
]);
}
+ /**
+ * @Route("/upload/{videoId}", name="app_upload_status")
+ */
+ public function uploadStatus($videoId): Response
+ {
+ if (!$this->isGranted("ROLE_USER")) {
+ // not logged in
+ return $this->redirectToRoute("app_login");
+ }
+
+ try {
+ $videoId = $this->uuidMapper->fromString($videoId);
+ } catch (ConversionException $e) {
+ throw new BadRequestHttpException();
+ }
+
+ $video = $this->videoService->get($videoId);
+
+ if ($video == null || $video->getUploader() != $this->userService->getLoggedInUser()) {
+ throw new AccessDeniedHttpException();
+ }
+
+ return new JsonResponse([
+ "id" => $this->uuidMapper->toString($video->getId()),
+ "state" => $video->getStateString(),
+ "stateId" => $video->getState(),
+ "progress" => $video->getTranscodingProgress()
+ ]);
+ }
+
/**
* @Route("/links", name="app_links")
*/
diff --git a/src/Entity/Video.php b/src/Entity/Video.php
index b575bac..979088b 100644
--- a/src/Entity/Video.php
+++ b/src/Entity/Video.php
@@ -73,9 +73,9 @@ class Video
private $length;
/**
- * @ORM\Column(type="integer", nullable=true)
+ * @ORM\Column(type="integer")
*/
- private $transcodingProgress;
+ private $transcodingProgress = 0;
public function __construct()
{
diff --git a/templates/base.html.twig b/templates/base.html.twig
index caa35ca..5217992 100644
--- a/templates/base.html.twig
+++ b/templates/base.html.twig
@@ -70,6 +70,7 @@
+
{% block javascripts %}{% endblock %}