From 783940c1a14c78a6a5e6f2c236779d4f84d8d5be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9=20=D0=A2?= =?UTF-8?q?=D1=83=D1=85=D1=82=D0=B0=D1=80=D0=BE=D0=B2?= Date: Thu, 1 Feb 2024 16:08:52 +0500 Subject: [PATCH] =?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=B0=D0=BD=D0=B4=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/package.json | 2 +- app/src/gallery/Gallery.svelte | 16 +++++++--------- app/src/gallery/Images.svelte | 9 ++++++--- app/src/move/Move.svelte | 3 +-- app/src/{move => navbar}/AlbumSelect.svelte | 16 +++++++++++----- app/src/navbar/Navbar.svelte | 4 +++- main.go | 14 ++++++++++++++ 7 files changed, 43 insertions(+), 21 deletions(-) rename app/src/{move => navbar}/AlbumSelect.svelte (90%) diff --git a/app/package.json b/app/package.json index 1c8c15f..b2b3d2e 100644 --- a/app/package.json +++ b/app/package.json @@ -1,7 +1,7 @@ { "name": "nano4", "private": true, - "version": "0.0.0", + "version": "1.0.3", "type": "module", "scripts": { "dev": "vite --port 8080", diff --git a/app/src/gallery/Gallery.svelte b/app/src/gallery/Gallery.svelte index 1ad84df..b5f7290 100644 --- a/app/src/gallery/Gallery.svelte +++ b/app/src/gallery/Gallery.svelte @@ -10,24 +10,22 @@ // ======= команды ================= function move(e) { let id = e.detail.id; - // console.log("move image id: ", id); - axios.get("/album/inz").then((response) => { - let imgs = response.data.map((image) => { - image.selected = false; - return image; - }); - // console.log("imgs: ", imgs); - images = imgs; + let filename = e.detail.filename; + let url = `/images/move/${id}?filename=${filename}` + axios.get(url).then((response) => { + let status = response.data + images = images.filter(img => img.Id !== id); + console.log("status: ", status); }); } function trash(e) { let id = e.detail.id; let filename = e.detail.filename; - // console.log("trash image id: ", id); axios.get(`/images/trash/${id}?filename=${filename}`).then((response) => { let status = response.data console.log("status: ", status); + images = images.filter(img => img.Id !== id); }); } diff --git a/app/src/gallery/Images.svelte b/app/src/gallery/Images.svelte index 41daa93..ff8e70b 100644 --- a/app/src/gallery/Images.svelte +++ b/app/src/gallery/Images.svelte @@ -8,10 +8,13 @@ console.log("selected:", block) } - function command_move(id) { + function command_move(img) { + let items = img.Url.split("/") + let filename = items[items.length-1] dispatch('move', { - id: id, + id: img.Id, + filename: filename, }); } @@ -91,7 +94,7 @@ {/each} diff --git a/app/src/navbar/Navbar.svelte b/app/src/navbar/Navbar.svelte index d4e35a7..1911e28 100644 --- a/app/src/navbar/Navbar.svelte +++ b/app/src/navbar/Navbar.svelte @@ -2,6 +2,7 @@ import Search from "./Search.svelte"; import Logo from "./Logo.svelte"; import Links from "./Links.svelte"; + import AlbumSelect from "./AlbumSelect.svelte"; @@ -10,6 +11,7 @@
- + +
\ No newline at end of file diff --git a/main.go b/main.go index c1dd71a..ee4f43d 100644 --- a/main.go +++ b/main.go @@ -13,6 +13,7 @@ import ( ) var db *sqlx.DB +var selected string = "" // Read the example and its comments carefully. func makeAccessLog() *accesslog.AccessLog { @@ -108,6 +109,11 @@ func albums(db *sqlx.DB) func(iris.Party) { albums := getAlbums(db) ctx.JSON(albums) }) + r.Get("/dest/{album}", func(ctx iris.Context) { + selected = ctx.Params().Get("album") + ctx.Application().Logger().Infof("выбор альбома: %s", selected) + ctx.JSON(iris.Map{"status": iris.StatusOK}) + }) r.Get("/get/{album}", func(ctx iris.Context) { album := ctx.Params().Get("album") if album == "local" { @@ -133,6 +139,14 @@ func images(db *sqlx.DB) func(iris.Party) { filename := ctx.Request().URL.Query().Get("filename") ctx.Application().Logger().Infof("удаление картинки[%s]: %s", id, filename) + ctx.JSON(iris.Map{"filename": filename}) + }) + r.Get("/move/{id}", func(ctx iris.Context) { + id := ctx.Params().Get("id") + filename := ctx.Request().URL.Query().Get("filename") + ctx.Application().Logger().Infof("перемещение картинки[%s]: %s в [%s]", + id, filename, selected) + ctx.JSON(iris.Map{"filename": filename}) }) }