Sfoglia il codice sorgente

added note editing

turos.robert 3 settimane fa
parent
commit
fb1132d24e

+ 0 - 5
cmds/webservice/bin/notes_folder/Scoala/notita-2026-03-06-195056.785738.json

@@ -1,5 +0,0 @@
-{
-  "titlu": "Scoala",
-  "continut": "Scoala\r\n",
-  "director": "Scoala"
-}

+ 0 - 5
cmds/webservice/bin/notes_folder/Test/notita-2026-03-06-195042.107546.json

@@ -1,5 +0,0 @@
-{
-  "titlu": "test",
-  "continut": "test",
-  "director": "Test"
-}

File diff suppressed because it is too large
+ 0 - 2
cmds/webservice/bin/notes_folder/TestFinal/notita-2026-03-07-180009.965642.json


+ 0 - 5
cmds/webservice/bin/notes_folder/istorie/Lala/notita-2026-03-06-211318.356942.json

@@ -1,5 +0,0 @@
-{
-  "titlu": "Dada",
-  "continut": "dasdwads",
-  "director": "./istorie"
-}

+ 0 - 5
cmds/webservice/bin/notes_folder/istorie/notita-2026-03-06-211318.356942.json

@@ -1,5 +0,0 @@
-{
-  "titlu": "Dada",
-  "continut": "dasdwads",
-  "director": "./istorie"
-}

+ 6 - 0
cmds/webservice/bin/notes_folder/wdadwa/notita-2026-03-08-141239.725642.json

@@ -0,0 +1,6 @@
+{
+  "titlu": "dwadw",
+  "continut": "Merge\r\n",
+  "director": "wdadwa",
+  "Path": "notes_folder/wdadwa/notita-2026-03-08-141239.725642.json"
+}

+ 23 - 5
cmds/webservice/bin/templates/edit_notes.tmpl

@@ -4,6 +4,7 @@
 <head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  <link rel="icon" type="image/png" href="/favicon.png">
   <title>Editează notița</title>
   <script src="https://cdn.tailwindcss.com"></script>
 </head>
@@ -26,6 +27,7 @@
           class="inline-flex items-center justify-center rounded-xl border border-[#313846] bg-[#171b22] px-4 py-3 text-sm font-semibold text-gray-200 transition hover:bg-[#20252f] hover:text-white">
           Înapoi la listă
         </a>
+
         <a href="/notes/?note={{.Path}}"
           class="inline-flex items-center justify-center rounded-xl border border-[#313846] bg-[#171b22] px-4 py-3 text-sm font-semibold text-gray-200 transition hover:bg-[#20252f] hover:text-white">
           Vezi notița
@@ -46,22 +48,37 @@
       <div class="p-6 md:p-8">
         <form method="POST" action="/api/update_note" class="space-y-6">
 
+          <!-- PATH către fișier -->
           <input type="hidden" name="path" value="{{.Path}}">
 
+          <!-- DIRECTORUL în care se află -->
+          <input type="hidden" name="director" value="{{.Folder}}">
+
+          <!-- Afișare folder (doar vizual) -->
+          <div>
+            <label class="block text-xs font-semibold text-gray-400 uppercase tracking-wider mb-2">
+              Folder
+            </label>
+            <div
+              class="w-full rounded-xl border border-[#323949] bg-[#1a1f29] px-4 py-3 text-sm text-gray-300">
+              {{.Folder}}
+            </div>
+          </div>
+
           <div>
             <label class="block text-xs font-semibold text-gray-400 uppercase tracking-wider mb-2">
               Titlu fișier
             </label>
-            <input type="text" name="titlu" value="{{.Titlu}}" placeholder="Titlul notiței"
-              class="w-full rounded-xl border border-[#323949] bg-[#1a1f29] px-4 py-3 text-sm text-gray-200 outline-none transition placeholder:text-gray-500 focus:border-[#7b58ad] focus:ring-2 focus:ring-[#7b58ad]/30">
+            <input type="text" name="titlu" value="{{.Titlu}}"
+              class="w-full rounded-xl border border-[#323949] bg-[#1a1f29] px-4 py-3 text-sm text-gray-200 outline-none transition focus:border-[#7b58ad] focus:ring-2 focus:ring-[#7b58ad]/30">
           </div>
 
           <div>
             <label class="block text-xs font-semibold text-gray-400 uppercase tracking-wider mb-2">
               Conținut notiță
             </label>
-            <textarea name="notita" rows="18" placeholder="Conținutul notiței..."
-              class="w-full rounded-xl border border-[#323949] bg-[#1a1f29] px-4 py-3 text-sm text-gray-200 outline-none transition placeholder:text-gray-500 focus:border-[#7b58ad] focus:ring-2 focus:ring-[#7b58ad]/30 resize-y">{{.Continut}}</textarea>
+            <textarea name="notita" rows="18"
+              class="w-full rounded-xl border border-[#323949] bg-[#1a1f29] px-4 py-3 text-sm text-gray-200 outline-none transition focus:border-[#7b58ad] focus:ring-2 focus:ring-[#7b58ad]/30 resize-y">{{.Continut}}</textarea>
           </div>
 
           <div class="flex flex-col sm:flex-row gap-3 pt-2">
@@ -70,11 +87,12 @@
               Salvează modificările
             </button>
 
-            <a href="/notes/?note={{.Path}}"
+            <a href="/list_notes/"
               class="flex-1 rounded-xl border border-[#3a3f4b] bg-[#171a21] px-5 py-3 text-center text-sm font-semibold text-gray-200 transition hover:bg-[#20242d] hover:text-white">
               Anulează
             </a>
           </div>
+
         </form>
       </div>
 

BIN
cmds/webservice/bin/templates/favicon.ico


BIN
cmds/webservice/bin/templates/favicon.png


+ 1 - 0
cmds/webservice/bin/templates/index.html

@@ -4,6 +4,7 @@
 <head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  <link rel="icon" type="image/png" href="/favicon.png">
   <title>MyNotes</title>
   <script src="https://cdn.tailwindcss.com"></script>
 </head>

+ 1 - 0
cmds/webservice/bin/templates/list_notes.tmpl

@@ -4,6 +4,7 @@
 <head>
   <meta charset="UTF-8">
   <title>Notițe</title>
+  <link rel="icon" type="image/png" href="/favicon.png">
   <script src="https://cdn.tailwindcss.com"></script>
 </head>
 

+ 1 - 0
cmds/webservice/bin/templates/notita.tmpl

@@ -3,6 +3,7 @@
 <head>
     <meta charset="UTF-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <link rel="icon" type="image/png" href="/favicon.png">
     <title>{{.Titlu}}</title>
     <script src="https://cdn.tailwindcss.com"></script>
     <style>

+ 23 - 1
lib/server/handlers.go

@@ -67,8 +67,9 @@ func API(w http.ResponseWriter, r *http.Request) {
 				fmt.Fprintf(w, "ParseForm error: %+v , %s", err, n.Folder)
 				return
 			}
-			n.Path = path
+
 			fisier := fmt.Sprintf("notita-%s.json", time.Now().Format("2006-01-02-150405.999999"))
+			n.Path = filepath.Join("notes_folder", n.Folder, fisier)
 			//fmt.Println(fisier, r.Form)
 			//return
 
@@ -85,6 +86,27 @@ func API(w http.ResponseWriter, r *http.Request) {
 			} else {
 				http.Redirect(w, r, "/index.html", http.StatusSeeOther)
 			}
+		case "update_note":
+			r.ParseForm()
+			n := types.Notita{}
+			n.Titlu = r.Form.Get("titlu")
+			n.Path = r.Form.Get("path")
+			n.Folder = r.Form.Get("director")
+			n.Continut = r.Form.Get("notita")
+			fmt.Println(n.Path)
+			err := inout.ObjToFile(n.Path, n, true)
+			if err != nil {
+				w.WriteHeader(http.StatusInternalServerError)
+				fmt.Fprintf(w, "%+v", err)
+				return
+			}
+			referinta := r.Referer()
+			if referinta != "" {
+				http.Redirect(w, r, referinta, http.StatusSeeOther)
+			} else {
+				http.Redirect(w, r, "/index.html", http.StatusSeeOther)
+			}
+
 		}
 	}
 	w.WriteHeader(http.StatusMethodNotAllowed)

Some files were not shown because too many files changed in this diff