команды

main
parent e5ce956b0c
commit 783940c1a1

@ -1,7 +1,7 @@
{ {
"name": "nano4", "name": "nano4",
"private": true, "private": true,
"version": "0.0.0", "version": "1.0.3",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite --port 8080", "dev": "vite --port 8080",

@ -10,24 +10,22 @@
// ======= команды ================= // ======= команды =================
function move(e) { function move(e) {
let id = e.detail.id; let id = e.detail.id;
// console.log("move image id: ", id); let filename = e.detail.filename;
axios.get("/album/inz").then((response) => { let url = `/images/move/${id}?filename=${filename}`
let imgs = response.data.map((image) => { axios.get(url).then((response) => {
image.selected = false; let status = response.data
return image; images = images.filter(img => img.Id !== id);
}); console.log("status: ", status);
// console.log("imgs: ", imgs);
images = imgs;
}); });
} }
function trash(e) { function trash(e) {
let id = e.detail.id; let id = e.detail.id;
let filename = e.detail.filename; let filename = e.detail.filename;
// console.log("trash image id: ", id);
axios.get(`/images/trash/${id}?filename=${filename}`).then((response) => { axios.get(`/images/trash/${id}?filename=${filename}`).then((response) => {
let status = response.data let status = response.data
console.log("status: ", status); console.log("status: ", status);
images = images.filter(img => img.Id !== id);
}); });
} }

@ -8,10 +8,13 @@
console.log("selected:", block) 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', dispatch('move',
{ {
id: id, id: img.Id,
filename: filename,
}); });
} }
@ -91,7 +94,7 @@
<button <button
type="button" type="button"
class="rounded-full hover:bg-default hover:bg-primary" class="rounded-full hover:bg-default hover:bg-primary"
on:click={() => command_move(image.Id)} on:click={() => command_move(image)}
> >
<svg class="p-2 w-8 h-8 fill-neutral-100" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"> <svg class="p-2 w-8 h-8 fill-neutral-100" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512">
<path d="M400 255.4V240 208c0-8.8-7.2-16-16-16H352 336 289.5c-50.9 0-93.9 33.5-108.3 79.6c-3.3-9.4-5.2-19.8-5.2-31.6c0-61.9 50.1-112 112-112h48 16 32c8.8 0 16-7.2 16-16V80 64.6L506 160 400 255.4zM336 240h16v48c0 17.7 14.3 32 32 32h3.7c7.9 0 15.5-2.9 21.4-8.2l139-125.1c7.6-6.8 11.9-16.5 11.9-26.7s-4.3-19.9-11.9-26.7L409.9 8.9C403.5 3.2 395.3 0 386.7 0C367.5 0 352 15.5 352 34.7V80H336 304 288c-88.4 0-160 71.6-160 160c0 60.4 34.6 99.1 63.9 120.9c5.9 4.4 11.5 8.1 16.7 11.2c4.4 2.7 8.5 4.9 11.9 6.6c3.4 1.7 6.2 3 8.2 3.9c2.2 1 4.6 1.4 7.1 1.4h2.5c9.8 0 17.8-8 17.8-17.8c0-7.8-5.3-14.7-11.6-19.5l0 0c-.4-.3-.7-.5-1.1-.8c-1.7-1.1-3.4-2.5-5-4.1c-.8-.8-1.7-1.6-2.5-2.6s-1.6-1.9-2.4-2.9c-1.8-2.5-3.5-5.3-5-8.5c-2.6-6-4.3-13.3-4.3-22.4c0-36.1 29.3-65.5 65.5-65.5H304h32zM72 32C32.2 32 0 64.2 0 104V440c0 39.8 32.2 72 72 72H408c39.8 0 72-32.2 72-72V376c0-13.3-10.7-24-24-24s-24 10.7-24 24v64c0 13.3-10.7 24-24 24H72c-13.3 0-24-10.7-24-24V104c0-13.3 10.7-24 24-24h64c13.3 0 24-10.7 24-24s-10.7-24-24-24H72z" /> <path d="M400 255.4V240 208c0-8.8-7.2-16-16-16H352 336 289.5c-50.9 0-93.9 33.5-108.3 79.6c-3.3-9.4-5.2-19.8-5.2-31.6c0-61.9 50.1-112 112-112h48 16 32c8.8 0 16-7.2 16-16V80 64.6L506 160 400 255.4zM336 240h16v48c0 17.7 14.3 32 32 32h3.7c7.9 0 15.5-2.9 21.4-8.2l139-125.1c7.6-6.8 11.9-16.5 11.9-26.7s-4.3-19.9-11.9-26.7L409.9 8.9C403.5 3.2 395.3 0 386.7 0C367.5 0 352 15.5 352 34.7V80H336 304 288c-88.4 0-160 71.6-160 160c0 60.4 34.6 99.1 63.9 120.9c5.9 4.4 11.5 8.1 16.7 11.2c4.4 2.7 8.5 4.9 11.9 6.6c3.4 1.7 6.2 3 8.2 3.9c2.2 1 4.6 1.4 7.1 1.4h2.5c9.8 0 17.8-8 17.8-17.8c0-7.8-5.3-14.7-11.6-19.5l0 0c-.4-.3-.7-.5-1.1-.8c-1.7-1.1-3.4-2.5-5-4.1c-.8-.8-1.7-1.6-2.5-2.6s-1.6-1.9-2.4-2.9c-1.8-2.5-3.5-5.3-5-8.5c-2.6-6-4.3-13.3-4.3-22.4c0-36.1 29.3-65.5 65.5-65.5H304h32zM72 32C32.2 32 0 64.2 0 104V440c0 39.8 32.2 72 72 72H408c39.8 0 72-32.2 72-72V376c0-13.3-10.7-24-24-24s-24 10.7-24 24v64c0 13.3-10.7 24-24 24H72c-13.3 0-24-10.7-24-24V104c0-13.3 10.7-24 24-24h64c13.3 0 24-10.7 24-24s-10.7-24-24-24H72z" />

@ -1,7 +1,7 @@
<script> <script>
import { onMount } from "svelte"; import { onMount } from "svelte";
import axios from "axios"; import axios from "axios";
import AlbumSelect from "./AlbumSelect.svelte"; // import AlbumSelect from "../navbar/AlbumSelect.svelte";
let album = "art"; let album = "art";
let images = []; let images = [];
@ -22,6 +22,5 @@
<div class="bg-blue-300 col-span-8 h-4"> <div class="bg-blue-300 col-span-8 h-4">
</div> </div>
<div class="bg-green-300 col-span-4 h-4"> <div class="bg-green-300 col-span-4 h-4">
<AlbumSelect />
</div> </div>
</div> </div>

@ -10,12 +10,18 @@
let albums = []; let albums = [];
let activeAlbum = "" let activeAlbum = ""
function selected(album) {
activeAlbum = album;
axios.get(`/album/dest/${album}`).then((response) => {
let status = response.data;
console.log(status)
});
}
onMount(() => { onMount(() => {
axios.get(`/album/list`).then((response) => { axios.get(`/album/list`).then((response) => {
albums = response.data; albums = response.data;
console.log("albums: ", albums);
activeAlbum = albums[0].Seria; activeAlbum = albums[0].Seria;
console.log("activeAlbum: ", albums[0]);
initTE({Dropdown, Ripple }); initTE({Dropdown, Ripple });
}); });
}); });
@ -55,14 +61,14 @@
data-te-dropdown-menu-ref> data-te-dropdown-menu-ref>
{#each albums as a} {#each albums as a}
<li> <li>
<a <button
class="w-full flex justify-between whitespace-nowrap bg-transparent px-4 py-2 text-sm font-normal text-neutral-700 hover:bg-neutral-100 active:text-neutral-800 active:no-underline disabled:pointer-events-none disabled:bg-transparent disabled:text-neutral-400 dark:text-neutral-200 dark:hover:bg-neutral-600" class="w-full flex justify-between whitespace-nowrap bg-transparent px-4 py-2 text-sm font-normal text-neutral-700 hover:bg-neutral-100 active:text-neutral-800 active:no-underline disabled:pointer-events-none disabled:bg-transparent disabled:text-neutral-400 dark:text-neutral-200 dark:hover:bg-neutral-600"
href="/{a.Seria}" on:click={() => selected(a.Seria)}
data-te-dropdown-item-ref data-te-dropdown-item-ref
> >
<span>{a.Seria}</span> <span>{a.Seria}</span>
<span>{a.Cnt}</span> <span>{a.Cnt}</span>
</a> </button>
</li> </li>
{/each} {/each}
</ul> </ul>

@ -2,6 +2,7 @@
import Search from "./Search.svelte"; import Search from "./Search.svelte";
import Logo from "./Logo.svelte"; import Logo from "./Logo.svelte";
import Links from "./Links.svelte"; import Links from "./Links.svelte";
import AlbumSelect from "./AlbumSelect.svelte";
</script> </script>
@ -10,6 +11,7 @@
<div class="flex w-full flex-wrap items-center justify-between px-3"> <div class="flex w-full flex-wrap items-center justify-between px-3">
<Logo /> <Logo />
<Links /> <Links />
<Search /> <AlbumSelect />
<!-- <Search /> -->
</div> </div>
</nav> </nav>

@ -13,6 +13,7 @@ import (
) )
var db *sqlx.DB var db *sqlx.DB
var selected string = ""
// Read the example and its comments carefully. // Read the example and its comments carefully.
func makeAccessLog() *accesslog.AccessLog { func makeAccessLog() *accesslog.AccessLog {
@ -108,6 +109,11 @@ func albums(db *sqlx.DB) func(iris.Party) {
albums := getAlbums(db) albums := getAlbums(db)
ctx.JSON(albums) 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) { r.Get("/get/{album}", func(ctx iris.Context) {
album := ctx.Params().Get("album") album := ctx.Params().Get("album")
if album == "local" { if album == "local" {
@ -133,6 +139,14 @@ func images(db *sqlx.DB) func(iris.Party) {
filename := ctx.Request().URL.Query().Get("filename") filename := ctx.Request().URL.Query().Get("filename")
ctx.Application().Logger().Infof("удаление картинки[%s]: %s", id, 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}) ctx.JSON(iris.Map{"filename": filename})
}) })
} }

Loading…
Cancel
Save