diff --git a/manifest.toml b/manifest.toml index 51f5b35..5666759 100644 --- a/manifest.toml +++ b/manifest.toml @@ -1,9 +1,10 @@ packaging_format = 2 id = "albumik" name = "Albumik" +logo = "assets/albumik-logo.png" description.en = "Lightweight private photo album with folder permissions and guest uploads" description.pl = "Lekki prywatny album zdjęć z katalogami, gośćmi i akceptacją zdjęć" -version = "0.1.0~ynh1" +version = "0.1.1~ynh1" maintainers = ["Filip"] [upstream] diff --git a/web/app.js b/web/app.js index 84265ee..8826d24 100644 --- a/web/app.js +++ b/web/app.js @@ -221,3 +221,94 @@ $('#rejectPhotoBtn').addEventListener('click', async()=>{ }); init(); + +function renderAccountView() { + const main = document.querySelector("#content") || document.querySelector("main") || document.querySelector(".main"); + if (!main) return; + + const user = state.user || {}; + main.innerHTML = ` +
+

Moje konto

+

Zmień swoje hasło i sprawdź informacje o koncie.

+
+ +
+

Dane konta

+
Login${escapeHtml(user.username || '')}
+
Nazwa${escapeHtml(user.display_name || '')}
+
Rola${escapeHtml(user.role || '')}
+
+ +
+

Zmiana hasła

+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ `; + + document.querySelector("#changePasswordForm")?.addEventListener("submit", async (e) => { + e.preventDefault(); + const fd = new FormData(e.currentTarget); + const current_password = fd.get("current_password"); + const new_password = fd.get("new_password"); + const repeat_password = fd.get("repeat_password"); + const err = document.querySelector("#changePasswordError"); + + if (new_password !== repeat_password) { + err.textContent = "Nowe hasła nie są takie same."; + return; + } + + try { + const res = await api("/api/me/password", { + method: "POST", + body: JSON.stringify({ current_password, new_password }) + }); + + if (!res.ok) { + err.textContent = res.error || "Nie udało się zmienić hasła."; + return; + } + + err.style.color = "#16a34a"; + err.textContent = "Hasło zostało zmienione."; + e.currentTarget.reset(); + } catch (ex) { + err.textContent = "Błąd połączenia z serwerem."; + } + }); +} + +function escapeHtml(value) { + return String(value ?? "") + .replaceAll("&", "&") + .replaceAll("<", "<") + .replaceAll(">", ">") + .replaceAll('"', """) + .replaceAll("'", "'"); +} + +document.addEventListener("click", (e) => { + const btn = e.target.closest("[data-view='account']"); + if (!btn) return; + e.preventDefault(); + state.currentView = "account"; + document.querySelectorAll(".nav-btn").forEach(b => b.classList.remove("active")); + btn.classList.add("active"); + renderAccountView(); +}); diff --git a/web/assets/albumik-logo.png b/web/assets/albumik-logo.png new file mode 100644 index 0000000..8745871 Binary files /dev/null and b/web/assets/albumik-logo.png differ diff --git a/web/index.html b/web/index.html index 03ec54e..ccb419e 100644 --- a/web/index.html +++ b/web/index.html @@ -4,12 +4,12 @@ Albumik - +