diff --git a/public/css/base.css b/public/css/base.css index a6ad0b2..f1f6832 100644 --- a/public/css/base.css +++ b/public/css/base.css @@ -4,4 +4,12 @@ .navbar { margin-bottom: 50px; +} + +.hidden { + height: 1px; + width: 1px; + position: absolute; + top: -10px; + left: -1px; } \ No newline at end of file diff --git a/public/css/links.css b/public/css/links.css index 8bc43f7..4704e57 100644 --- a/public/css/links.css +++ b/public/css/links.css @@ -1,4 +1,7 @@ -.link { - margin-top: 2vw; - padding: 1vw; +.links { +} + +.links img { + height: 40px; + margin-right: 5px; } \ No newline at end of file diff --git a/public/css/toasts.css b/public/css/toasts.css new file mode 100644 index 0000000..be7522d --- /dev/null +++ b/public/css/toasts.css @@ -0,0 +1,24 @@ +.customToast { + position: fixed; + right: 100px; + background-color: #3c3c3c; + color: lightgrey; + font-size: 20px; + padding: 10px 20px 10px 20px; + transition: top 0.2s linear, opacity 0.1s linear; +} + +.customToastStart { + opacity: 0; + top: 200px; +} + +.customToastMain { + opacity: 1; + top: 100px; +} + +.customToastStop { + opacity: 0; + top: 0; +} \ No newline at end of file diff --git a/public/js/clipboard.js b/public/js/clipboard.js new file mode 100644 index 0000000..430a8a8 --- /dev/null +++ b/public/js/clipboard.js @@ -0,0 +1,10 @@ +function clipboard(str) { + var clipboardField = document.createElement("textarea"); + clipboardField.value = str; + document.body.appendChild(clipboardField); + clipboardField.select(); + clipboardField.setSelectionRange(0, 99999); + document.execCommand("copy"); + document.body.removeChild(clipboardField); + toast("Copied to clipboard."); +} \ No newline at end of file diff --git a/public/js/toasts.js b/public/js/toasts.js new file mode 100644 index 0000000..443dcdb --- /dev/null +++ b/public/js/toasts.js @@ -0,0 +1,24 @@ +(function () { + let toastCounter = 0; + + const toastTime = 3000; + + window.toast = function (str) { + let id = "toast" + toastCounter++; + let element = document.createElement("div"); + element.id = id; + element.className = "customToast customToastStart"; + element.innerText = str; + + document.body.appendChild(element); + window.setTimeout(function () { + element.className = "customToast customToastMain"; + }, 0); + window.setTimeout(function () { + element.className = "customToast customToastStop"; + }, toastTime); + window.setTimeout(function () { + document.body.removeChild(element); + }, toastTime + 1000) + } +})(); \ No newline at end of file diff --git a/src/Controller/DashboardController.php b/src/Controller/DashboardController.php index 76e5fb0..46b6698 100644 --- a/src/Controller/DashboardController.php +++ b/src/Controller/DashboardController.php @@ -107,6 +107,12 @@ class DashboardController extends AbstractController $user = $this->userService->getLoggedInUser(); $links = $this->videoLinkService->getAll($user); + foreach ($links as $link) { + $link->setCustomId($this->uuidMapper->toString($link->getId())); + $video = $link->getVideo(); + $video->setCustomId($this->uuidMapper->toString($video->getId())); + } + return $this->render("dashboard/links.html.twig", [ "links" => $links ]); diff --git a/src/Entity/VideoLink.php b/src/Entity/VideoLink.php index e859ead..182c36e 100644 --- a/src/Entity/VideoLink.php +++ b/src/Entity/VideoLink.php @@ -21,6 +21,7 @@ class VideoLink * @ORM\CustomIdGenerator(class=UuidGenerator::class) */ private $id; + private $customId; /** * @ORM\ManyToOne(targetEntity=Video::class, inversedBy="videoLinks") @@ -147,4 +148,15 @@ class VideoLink return $this; } + + public function getCustomId(): string + { + return $this->customId; + } + + public function setCustomId($customId): self + { + $this->customId = $customId; + return $this; + } } diff --git a/templates/base.html.twig b/templates/base.html.twig index 25e4c66..caa35ca 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -9,6 +9,7 @@ + {% block stylesheets %}{% endblock %} @@ -67,6 +68,8 @@ {% block body %}{% endblock %} + + {% block javascripts %}{% endblock %} diff --git a/templates/dashboard/links.html.twig b/templates/dashboard/links.html.twig index 00420bd..fca841b 100644 --- a/templates/dashboard/links.html.twig +++ b/templates/dashboard/links.html.twig @@ -6,10 +6,86 @@ {% endblock %} {% block body %} - Links - {% for link in links %} - - {% endfor %} + {% endblock %} \ No newline at end of file