diff --git a/src/js/pages/keys/index.ts b/src/js/pages/keys/index.ts index f1b3d0d..b22fecc 100644 --- a/src/js/pages/keys/index.ts +++ b/src/js/pages/keys/index.ts @@ -7,8 +7,6 @@ import {init as initImport} from "./import"; import {init as initTable} from "./table"; import {init as initUserLists} from "./userlists"; import {initShare} from "./share"; -import {init as initEditModal} from "./modals/edit"; -import {init as initDeleteModal} from "./modals/delete"; document.addEventListener('DOMContentLoaded', () => { const triggerTabList = document.querySelectorAll('#key-tab button') @@ -25,7 +23,4 @@ document.addEventListener('DOMContentLoaded', () => { initTable(); initUserLists(); initShare(); - - initEditModal(); - initDeleteModal(); }) \ No newline at end of file diff --git a/src/js/pages/keys/modals/delete.ts b/src/js/pages/keys/modals/delete.ts deleted file mode 100644 index 24286c8..0000000 --- a/src/js/pages/keys/modals/delete.ts +++ /dev/null @@ -1,42 +0,0 @@ -import {getCurrentlySelectedList} from "../userlists"; - -export function init() { - const modalElem = document.querySelector('#delete-list-modal'); - - if (!modalElem) { - return; - } - - modalElem.addEventListener('show.bs.modal', () => { - const listSelect = document.querySelector('#list-select'); - const text = listSelect?.selectedOptions[0].text ?? ''; - - const listnameElem = modalElem.querySelector('.list-name'); - if (!listnameElem) { - return; - } - listnameElem.textContent = text; - }) - - modalElem.querySelector('.js--yes') - ?.addEventListener('click', async () => { - const id = getCurrentlySelectedList(); - - const formData = new FormData(); - formData.append('id', id?.toString() ?? '-1'); - - const response = await fetch( - `/api/web/keys/list/delete`, - { - method: 'POST', - body: formData - } - ); - - if (!response.ok) { - throw new Error(response.statusText); - } - - window.location.reload(); - }) -} diff --git a/src/js/pages/keys/modals/edit.ts b/src/js/pages/keys/modals/edit.ts deleted file mode 100644 index 6c79cee..0000000 --- a/src/js/pages/keys/modals/edit.ts +++ /dev/null @@ -1,18 +0,0 @@ -export function init() { - const modalElem = document.querySelector('#edit-list-modal'); - - if (!modalElem) { - return; - } - - modalElem.addEventListener('show.bs.modal', () => { - const listSelect = document.querySelector('#list-select'); - const text = listSelect?.selectedOptions[0].text ?? ''; - - const listnameElem = modalElem.querySelector('.list-name'); - if (!listnameElem) { - return; - } - listnameElem.textContent = text; - }) -} \ No newline at end of file diff --git a/src/php/Routing/Api/Web/DeleteKeyList.php b/src/php/Routing/Api/Web/DeleteKeyList.php deleted file mode 100644 index db550cb..0000000 --- a/src/php/Routing/Api/Web/DeleteKeyList.php +++ /dev/null @@ -1,70 +0,0 @@ -loginHandler->isLoggedIn()) { - throw new UnauthorizedException(); - } - - $user = $this->loginHandler->getCurrentUser(); - if (!$user->getPermission()->hasLevel(UserPermission::PROVIDER)) { - throw new ForbiddenException(); - } - - $body = $request->getParsedBody(); - if (!array_key_exists('id', $body)) { - throw new BadRequestException(); - } - - $id = $body['id']; - $list = $this->entityManager->getRepository(GamesList::class)->findOneBy( - [ - 'id' => $id, - 'owner' => $user, - ] - ); - - if ($list === null) { - throw new BadRequestException(); - } - - $this->entityManager->remove($list); - - $keys = $this->entityManager->getRepository(Key::class)->findBy( - [ - 'list' => $list - ] - ); - foreach ($keys as $key) { - $this->entityManager->remove($key); - } - - $this->entityManager->flush(); - - return new Response(); - } -} \ No newline at end of file diff --git a/src/php/Routing/Api/Web/WebAPIRoutes.php b/src/php/Routing/Api/Web/WebAPIRoutes.php index 66347f4..02f2033 100644 --- a/src/php/Routing/Api/Web/WebAPIRoutes.php +++ b/src/php/Routing/Api/Web/WebAPIRoutes.php @@ -14,7 +14,6 @@ final class WebAPIRoutes $group->post('/keys/import/perform', ImportKeysRoute::class); $group->post('/keys/list/create', CreateKeyListRoute::class); - $group->post('/keys/list/delete',DeleteKeyList::class); $group->get('/share/search', SearchForUsers::class); $group->post('/share/add', AddUserToList::class); diff --git a/src/templates/pages/key-manager.php b/src/templates/pages/key-manager.php index 0248605..4182414 100644 --- a/src/templates/pages/key-manager.php +++ b/src/templates/pages/key-manager.php @@ -19,17 +19,12 @@ $this->layout('layout/main', [ 'resourceEntry' => 'keys' ]);
-
- - -
+
@@ -156,56 +151,4 @@ $this->layout('layout/main', [ 'resourceEntry' => 'keys' ]); - - - - - end() ?>