mirror of
https://github.com/sigmasternchen/MyTube
synced 2025-03-15 21:08:55 +00:00
links can now be deleted
This commit is contained in:
parent
daf162b373
commit
f2a8ed241b
6 changed files with 99 additions and 32 deletions
|
@ -24,4 +24,27 @@
|
||||||
|
|
||||||
.customNavbar {
|
.customNavbar {
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-content {
|
||||||
|
margin-left: 3%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deleteToggle:after {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deleteConfirm {
|
||||||
|
text-align: center;
|
||||||
|
padding: 1vw;
|
||||||
|
font-size: 1vw;
|
||||||
|
min-width: 14vw;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deleteButton {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-wrap {
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
|
@ -134,23 +134,4 @@
|
||||||
|
|
||||||
.length {
|
.length {
|
||||||
top: calc(9 / 16 * 100% + 4% + 5%);
|
top: calc(9 / 16 * 100% + 4% + 5%);
|
||||||
}
|
|
||||||
|
|
||||||
.no-content {
|
|
||||||
margin-left: 3%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.deleteToggle:after {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.deleteConfirm {
|
|
||||||
text-align: center;
|
|
||||||
padding: 1vw;
|
|
||||||
font-size: 1vw;
|
|
||||||
min-width: 14vw;
|
|
||||||
}
|
|
||||||
|
|
||||||
.deleteButton {
|
|
||||||
color: red;
|
|
||||||
}
|
}
|
|
@ -26,6 +26,7 @@ use Symfony\Component\Routing\Annotation\Route;
|
||||||
class DashboardController extends AbstractController
|
class DashboardController extends AbstractController
|
||||||
{
|
{
|
||||||
public const DELETE_VIDEO_CSRF_TOKEN_ID = "delete-video";
|
public const DELETE_VIDEO_CSRF_TOKEN_ID = "delete-video";
|
||||||
|
public const DELETE_LINK_CSRF_TOKEN_ID = "delete-link";
|
||||||
|
|
||||||
private $userService;
|
private $userService;
|
||||||
private $videoService;
|
private $videoService;
|
||||||
|
@ -107,7 +108,7 @@ class DashboardController extends AbstractController
|
||||||
/**
|
/**
|
||||||
* @Route("/video/delete", name="app_video_delete", methods={"POST"})
|
* @Route("/video/delete", name="app_video_delete", methods={"POST"})
|
||||||
*/
|
*/
|
||||||
public function delete(Request $request): Response
|
public function deleteVideo(Request $request): Response
|
||||||
{
|
{
|
||||||
$token = $request->request->get("csrfToken");
|
$token = $request->request->get("csrfToken");
|
||||||
$videoId = $request->request->get("videoId");
|
$videoId = $request->request->get("videoId");
|
||||||
|
@ -241,4 +242,36 @@ class DashboardController extends AbstractController
|
||||||
"form" => $form->createView()
|
"form" => $form->createView()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route("/links/delete", name="app_link_delete", methods={"POST"})
|
||||||
|
*/
|
||||||
|
public function deleteLink(Request $request): Response
|
||||||
|
{
|
||||||
|
$token = $request->request->get("csrfToken");
|
||||||
|
$linkId = $request->request->get("linkId");
|
||||||
|
|
||||||
|
if (!$this->isCsrfTokenValid(self::DELETE_LINK_CSRF_TOKEN_ID, $token)) {
|
||||||
|
throw new AccessDeniedHttpException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$linkId) {
|
||||||
|
throw new BadRequestHttpException();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$linkId = $this->uuidMapper->fromString($linkId);
|
||||||
|
} catch (ConversionException $e) {
|
||||||
|
throw new BadRequestHttpException();
|
||||||
|
}
|
||||||
|
|
||||||
|
$link = $this->videoLinkService->get($linkId);
|
||||||
|
if ($link == null || $link->getCreator() != $this->userService->getLoggedInUser()) {
|
||||||
|
throw new AccessDeniedHttpException();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->videoLinkService->delete($link);
|
||||||
|
|
||||||
|
return $this->redirectToRoute("app_links");
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -58,4 +58,10 @@ class VideoLinkRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
$this->_em->flush();
|
$this->_em->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delete(VideoLink $link)
|
||||||
|
{
|
||||||
|
$this->_em->remove($link);
|
||||||
|
$this->_em->flush();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,4 +58,9 @@ class VideoLinkService
|
||||||
{
|
{
|
||||||
$this->videoLinkRepository->save($videoLink);
|
$this->videoLinkRepository->save($videoLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delete(VideoLink $link)
|
||||||
|
{
|
||||||
|
$this->videoLinkRepository->delete($link);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -13,12 +13,10 @@
|
||||||
create a link for.
|
create a link for.
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
{% set deleteCsrfToken = csrf_token(constant("App\\Controller\\DashboardController::DELETE_LINK_CSRF_TOKEN_ID")) %}
|
||||||
<div class="links bg-light shadow-5">
|
<div class="links bg-light shadow-5">
|
||||||
<table class="table table-hover">
|
<table class="table table-hover">
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
|
||||||
<input type="checkbox">
|
|
||||||
</td>
|
|
||||||
<td></td>
|
<td></td>
|
||||||
<th>
|
<th>
|
||||||
Video
|
Video
|
||||||
|
@ -39,14 +37,10 @@
|
||||||
Time left
|
Time left
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
Link
|
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for link in links %}
|
{% for link in links %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
|
||||||
<input type="checkbox">
|
|
||||||
</td>
|
|
||||||
<td>
|
<td>
|
||||||
{% if not link.viewable() %}
|
{% if not link.viewable() %}
|
||||||
<i class="fas fa-exclamation-circle"></i>
|
<i class="fas fa-exclamation-circle"></i>
|
||||||
|
@ -91,11 +85,36 @@
|
||||||
-
|
-
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td class="no-wrap">
|
||||||
<button class="btn btn-primary btn-floating" onclick="clipboard('{{ url("app_watch_page", {
|
<div class="btn-group" role="group">
|
||||||
linkId: link.customId,
|
<button class="btn btn-link" onclick="clipboard('{{ url("app_watch_page", {
|
||||||
videoId: link.video.customId
|
linkId: link.customId,
|
||||||
}) }}')"><i class="fas fa-clipboard"></i></button>
|
videoId: link.video.customId
|
||||||
|
}) }}')"><i class="fas fa-clipboard"></i>
|
||||||
|
</button>
|
||||||
|
<form action="{{ path("app_link_delete") }}" method="POST">
|
||||||
|
<input type="hidden" name="linkId" value="{{ link.customId }}">
|
||||||
|
<input type="hidden" name="csrfToken" value="{{ deleteCsrfToken }}">
|
||||||
|
<button class="btn btn-link dropdown-toggle deleteToggle" style="color: red;"
|
||||||
|
id="{{ link.customId }}-deleteDropDown"
|
||||||
|
data-mdb-toggle="dropdown"
|
||||||
|
aria-expanded="false"
|
||||||
|
onclick="">
|
||||||
|
<i class="fas fa-trash-alt"></i>
|
||||||
|
</button>
|
||||||
|
<div class="dropdown-menu dropdown-menu-end deleteConfirm"
|
||||||
|
id="{{ link.customId }}-deleteDropDownMenu"
|
||||||
|
aria-labelledby="{{ link.customId }}-deleteDropDown">
|
||||||
|
Do you really want to delete this link?<br/>
|
||||||
|
<button class="btn btn-link deleteButton">YES</button>
|
||||||
|
<button class="btn btn-primary" onclick="removeClass('show', [
|
||||||
|
'#{{ link.customId }}-deleteDropDown',
|
||||||
|
'#{{ link.customId }}-deleteDropDownMenu'
|
||||||
|
]); return false;">NO
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
Loading…
Reference in a new issue