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}) }) }