diff --git a/README.md b/README.md index 00740cd..57160d6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,14 @@ # 🚀 Getting started with PomeloNote +## Setup +- run `npm i` +- get the .env file and save it to the root directory of the project +- set up Strapi + - go to `localhost:1337/admin` + - register an admin user + - go to Settings => Users&Permissions Plugin => Roles => Authenticated => Note => Select all + - Save + ### Starting the container with svelte and strapi: ``docker-compose up --build -d`` diff --git a/backend/strapi/src/api/note/controllers/note.js b/backend/strapi/src/api/note/controllers/note.js index 4f3cd54..84e7a8d 100644 --- a/backend/strapi/src/api/note/controllers/note.js +++ b/backend/strapi/src/api/note/controllers/note.js @@ -50,6 +50,9 @@ module.exports = createCoreController(noteUid, ({strapi}) => ({ lastViewed: Date.now() } }) + entry = await strapi.entityService.findOne(noteUid, noteId, { + populate: ['owners'], + }); return JSON.stringify(entry); } else { ctx.response.status = 403; diff --git a/frontend/svelte/package-lock.json b/frontend/svelte/package-lock.json index 63551ad..d5c5126 100644 --- a/frontend/svelte/package-lock.json +++ b/frontend/svelte/package-lock.json @@ -9,7 +9,9 @@ "version": "0.0.1", "dependencies": { "bootstrap-icons": "^1.9.1", - "nookies": "^2.5.2" + "nookies": "^2.5.2", + "sv-popup": "^0.2.5", + "webworker": "^0.8.4" }, "devDependencies": { "@sveltejs/adapter-auto": "next", @@ -2083,6 +2085,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/sv-popup": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/sv-popup/-/sv-popup-0.2.5.tgz", + "integrity": "sha512-JhBu4piXaauamT4vMEcFCydvxJ8e72G7c9F3caZVAPsiFqWPTYT3JDz99FlR+YCnbOp1emsZqqOPVvCwHgURog==" + }, "node_modules/svelte": { "version": "3.50.1", "resolved": "https://registry.npmjs.org/svelte/-/svelte-3.50.1.tgz", @@ -2358,6 +2365,14 @@ "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", "dev": true }, + "node_modules/webworker": { + "version": "0.8.4", + "resolved": "https://registry.npmjs.org/webworker/-/webworker-0.8.4.tgz", + "integrity": "sha512-zzsVxtHf+mCn0WuYLarSWfRGmX7JiYKkKvso5FYC7rJ9G8svwGQA5a51Sjq9D2c/rKVU6U/kyBcaI7gUTVlsJg==", + "engines": { + "node": ">=0.4.3" + } + }, "node_modules/whatwg-url": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", @@ -3824,6 +3839,11 @@ "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", "dev": true }, + "sv-popup": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/sv-popup/-/sv-popup-0.2.5.tgz", + "integrity": "sha512-JhBu4piXaauamT4vMEcFCydvxJ8e72G7c9F3caZVAPsiFqWPTYT3JDz99FlR+YCnbOp1emsZqqOPVvCwHgURog==" + }, "svelte": { "version": "3.50.1", "resolved": "https://registry.npmjs.org/svelte/-/svelte-3.50.1.tgz", @@ -3981,6 +4001,11 @@ "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", "dev": true }, + "webworker": { + "version": "0.8.4", + "resolved": "https://registry.npmjs.org/webworker/-/webworker-0.8.4.tgz", + "integrity": "sha512-zzsVxtHf+mCn0WuYLarSWfRGmX7JiYKkKvso5FYC7rJ9G8svwGQA5a51Sjq9D2c/rKVU6U/kyBcaI7gUTVlsJg==" + }, "whatwg-url": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", diff --git a/frontend/svelte/package.json b/frontend/svelte/package.json index 7ea33f8..81a0887 100644 --- a/frontend/svelte/package.json +++ b/frontend/svelte/package.json @@ -22,7 +22,9 @@ }, "type": "module", "dependencies": { + "bootstrap-icons": "^1.9.1", "nookies": "^2.5.2", - "bootstrap-icons": "^1.9.1" + "sv-popup": "^0.2.5", + "webworker": "^0.8.4" } } diff --git a/frontend/svelte/src/app.html b/frontend/svelte/src/app.html index 07daf74..9d5ca24 100644 --- a/frontend/svelte/src/app.html +++ b/frontend/svelte/src/app.html @@ -1,5 +1,5 @@ - + @@ -9,11 +9,5 @@
%sveltekit.body%
- - - + \ No newline at end of file diff --git a/frontend/svelte/src/routes/+page.svelte b/frontend/svelte/src/routes/+page.svelte index 8cf3cce..e744ac0 100644 --- a/frontend/svelte/src/routes/+page.svelte +++ b/frontend/svelte/src/routes/+page.svelte @@ -3,7 +3,9 @@ import {onMount} from "svelte"; import {StrapiNoteRepository} from "../models/repos/note/StrapiNoteRepository"; import {StrapiUserRepo} from "../models/repos/user/StrapiUserRepo"; + import {Content, Modal, Trigger} from "sv-popup"; + const sleep = (ms) => new Promise(r => setTimeout(r, ms)); const noteRepo: StrapiNoteRepository = StrapiNoteRepository.getInstance(); let notes: Note[]; @@ -13,7 +15,6 @@ notes.forEach(note => { note.lastViewed = new Date(note.lastViewed); }); - console.log(notes); }); /** @@ -23,7 +24,6 @@ const newTitle = "New Note"; const newNote = await addNote(newTitle); noteRepo.currentNoteId = newNote.id; - console.log(newNote.id); window.location = "/editor"; } @@ -32,23 +32,12 @@ * @param title The title of the new Note * @return The created Note Object */ - async function addNote(title: string) : Promise { + async function addNote(title: string): Promise { return await noteRepo.createNote({title: title,}); } /** - * Gives the user a prompt if they are sure to delete this note and deletes it if they confirm - * @param note The note to be deleted - */ - function deleteNotePrompt(note) { - const reallyDelete = confirm("Do you really want to delete this Note?"); - if (reallyDelete) { - deleteNote(note); - } - } - - /** - * Deletes the note from the "notes" Array + * Deletes the note from the "notes" Array and the database * @param note The note to be deleted */ function deleteNote(note) { @@ -73,13 +62,24 @@ } /** - * Handles a click on a note list element + * Sets the currentNoteId and redirects to the editor * @param note The note the user clicked on */ function onNoteLiClick(note) { noteRepo.currentNoteId = note.id; window.location = "/editor"; } + + /** + * Closes the modal (popup for deletion) + */ + async function closeModal() { + closeModalBool = true; + await sleep(1); + closeModalBool = false; + } + + let closeModalBool = false; @@ -95,6 +95,7 @@
+
@@ -121,10 +122,34 @@
- + + + +
+
Do you really want to delete the "{note.title}" note?
+
+
+
+ +
+
+ +
+
+
+ + + +
@@ -138,17 +163,11 @@