diff --git a/app/src/gallery/Gallery.svelte b/app/src/gallery/Gallery.svelte
index 2948888..1ad84df 100644
--- a/app/src/gallery/Gallery.svelte
+++ b/app/src/gallery/Gallery.svelte
@@ -23,21 +23,18 @@
function trash(e) {
let id = e.detail.id;
+ let filename = e.detail.filename;
// console.log("trash image id: ", id);
- axios.get(`/trash/${id}`).then((response) => {
- let imgs = response.data.map((image) => {
- image.selected = false;
- return image;
- });
- // console.log("imgs: ", imgs);
- images = imgs;
+ axios.get(`/images/trash/${id}?filename=${filename}`).then((response) => {
+ let status = response.data
+ console.log("status: ", status);
});
}
onMount(() => {
- axios.get("/album/scool").then((response) => {
+ axios.get("/images/list").then((response) => {
images = response.data;
- console.log("images: ", images);
+ console.log("получено images: ", images);
initTE({ Lightbox });
});
});
diff --git a/app/src/gallery/Images.svelte b/app/src/gallery/Images.svelte
index e9d96f5..41daa93 100644
--- a/app/src/gallery/Images.svelte
+++ b/app/src/gallery/Images.svelte
@@ -15,10 +15,13 @@
});
}
- function command_trash(id) {
+ function command_trash(img) {
+ let items = img.Url.split("/")
+ let filename = items[items.length-1]
dispatch('trash',
{
- id: id,
+ id: img.Id,
+ filename: filename,
});
}
@@ -29,9 +32,9 @@
function command_select(id) {
console.log("select: " + id);
- let image = images.find((image) => image.id == id);
+ let image = images.find((image) => image.Id == id);
if (image) {
- console.log("select image: " + image.id);
+ console.log("select image: " + image.Id);
image.selected = !image.selected;
} else {
console.log("selected image not found");
@@ -43,15 +46,15 @@
{#each images as image}
-
+
-
{image.id}
+
{image.Id}
-
\ No newline at end of file
diff --git a/main.go b/main.go
index fcc5856..c1dd71a 100644
--- a/main.go
+++ b/main.go
@@ -19,22 +19,22 @@ func makeAccessLog() *accesslog.AccessLog {
// Initialize a new access log middleware.
ac := accesslog.File("./access.log")
// Remove this line to disable logging to console:
- ac.AddOutput(os.Stdout)
+ // ac.AddOutput(os.Stdout)
// The default configuration:
- ac.Delim = '|'
- ac.TimeFormat = "2006-01-02 15:04:05"
- ac.Async = false
- ac.IP = true
- ac.BytesReceivedBody = true
- ac.BytesSentBody = true
- ac.BytesReceived = false
- ac.BytesSent = false
- ac.BodyMinify = true
- ac.RequestBody = true
- ac.ResponseBody = false
- ac.KeepMultiLineError = true
- ac.PanicLog = accesslog.LogHandler
+ // ac.Delim = '|'
+ // ac.TimeFormat = "2006-01-02 15:04:05"
+ // ac.Async = false
+ // ac.IP = true
+ // ac.BytesReceivedBody = true
+ // ac.BytesSentBody = true
+ // ac.BytesReceived = false
+ // ac.BytesSent = false
+ // ac.BodyMinify = true
+ // ac.RequestBody = true
+ // ac.ResponseBody = false
+ // ac.KeepMultiLineError = true
+ // ac.PanicLog = accesslog.LogHandler
// Default line format if formatter is missing:
// Time|Latency|Code|Method|Path|IP|Path Params Query Fields|Bytes Received|Bytes Sent|Request|Response|
@@ -53,12 +53,14 @@ func makeAccessLog() *accesslog.AccessLog {
func newApp(db *sqlx.DB) *iris.Application {
app := iris.Default()
app.HandleDir("/", iris.Dir("./app/dist"))
+ app.HandleDir("/images/get/", iris.Dir("d:/pics"))
app.Logger().SetOutput(os.Stdout)
//imagesAPI := app.Party("/img")
//imagesAPI.Use(iris.Compression)
// app.Get("/albums", albums(db))
app.PartyFunc("/album", albums(db))
+ app.PartyFunc("/images", images(db))
//app.Run(iris.TLS("127.0.0.1:443", "mycert.crt", "mykey.key"))
// $ openssl req -new -newkey rsa:4096 -x509 -sha256 \
@@ -102,11 +104,49 @@ func getAlbums(db *sqlx.DB) []Album {
func albums(db *sqlx.DB) func(iris.Party) {
return func(r iris.Party) {
r.Get("/list", func(ctx iris.Context) {
- ctx.Application().Logger().Infof("запрос списка альбомов")
+ ctx.Application().Logger().Infof("запрос списка альбомов ")
albums := getAlbums(db)
ctx.JSON(albums)
})
+ r.Get("/get/{album}", func(ctx iris.Context) {
+ album := ctx.Params().Get("album")
+ if album == "local" {
+ ctx.Application().Logger().Infof("запрос локального альбома")
+ images := getLocalImages()
+ ctx.JSON(images)
+ } else {
+ ctx.Application().Logger().Infof("запрос альбома: %s", album)
+ ctx.JSON(iris.Map{"message": "hello", "status": iris.StatusOK})
+ }
+ })
+ }
+}
+func images(db *sqlx.DB) func(iris.Party) {
+ return func(r iris.Party) {
+ r.Get("/list", func(ctx iris.Context) {
+ ctx.Application().Logger().Infof("запрос списка картинок")
+ images := getLocalImages()
+ ctx.JSON(images)
+ })
+ r.Get("/trash/{id}", func(ctx iris.Context) {
+ id := ctx.Params().Get("id")
+ filename := ctx.Request().URL.Query().Get("filename")
+ ctx.Application().Logger().Infof("удаление картинки[%s]: %s", id, filename)
+
+ ctx.JSON(iris.Map{"filename": filename})
+ })
+ }
+}
+
+func getLocalImages() []Image {
+ images := []Image{}
+ list, err := os.ReadDir("d:/pics")
+ checkError("read dir", err)
+ for n, f := range list {
+ img := Image{Id: n, Url: "/images/get/" + f.Name()}
+ images = append(images, img)
}
+ return images
}
type Image struct {
diff --git a/mycert.crt b/mycert.crt
deleted file mode 100644
index 5bf57f8..0000000
--- a/mycert.crt
+++ /dev/null
@@ -1,32 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIFezCCA2OgAwIBAgIUBbzVC72lEOMsMe54lVPVN2HZEk0wDQYJKoZIhvcNAQEL
-BQAwTTELMAkGA1UEBhMCUlUxEzARBgNVBAgMClNvbWUtU3RhdGUxDDAKBgNVBAcM
-A1VmYTENMAsGA1UECgwEaG9tZTEMMAoGA1UEAwwDdGFkMB4XDTI0MDEzMDEyMzcx
-NFoXDTI1MDEyOTEyMzcxNFowTTELMAkGA1UEBhMCUlUxEzARBgNVBAgMClNvbWUt
-U3RhdGUxDDAKBgNVBAcMA1VmYTENMAsGA1UECgwEaG9tZTEMMAoGA1UEAwwDdGFk
-MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA9pgpUsZJSUZ5K0NKSTSz
-ZLMzP1WXYSg2x+3+2hV4szH/53NZFqx7AlQQtD6kBhHf6ASUMcT7bazTlz+DTeZZ
-qenRSO+xnvW9cfhBbZF8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WN7JR4wBByGSN2agVnMcqk+a0
-EtQ9l2idwUf6CWZkmm1R2nbU/7xUy6T15jWATeQpVsG0rZv76J673Wx1KXQEYiqc
-JCDCCDBL1+eZnhhpb+2fmMwK5cEoOY5VVodyz7Id97yxmWBRvtk9ZpXO+oPXyv2Q
-TpZfv6dbrmOTZWjOpoZ3mDSVW6D9P2cQKlm6WB0wEnYs6fQ8Al7OsAvZvpudgXP3
-ur3zwRBS06jZTCbfUWXUBU+0uSzyDn6TxFje1AU5u+DFsl0SHxg8KljZ+rO0cs8r
-JukCsy2mFLKsp20JOpW8RwB9p2FbK+TH8EtnKquE0/DdvWqL/WBiqDQ8aIFI2Jlm
-Ar04LG6RtAQwLQD7d09E
------END CERTIFICATE-----
diff --git a/mykey.key b/mykey.key
deleted file mode 100644
index ec9901e..0000000
--- a/mykey.key
+++ /dev/null
@@ -1,52 +0,0 @@
------BEGIN PRIVATE KEY-----
-MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQD2mClSxklJRnkr
-Q0pJNLNkszM/VZdhKDbH7f7aFXizMf/nc1kWrHsCVBC0PqQGEd/oBJQxxPttrNOX
-P4NN5lmp6dFI77Ge9b1x+EFtkXxBaYhJqosiWQt26qO6/dDUn9/bwTjso9CIkh5s
-EeRgE1Xo4uyFFVT9VTOQg0BZJFjZ2TW8AJETvgYSFhUhqRRRgmha9368EF9cxpwo
-kO/lpQOQ/Gs8MbC/n+NQenCJilTffc0BWInYPwCLoBBtLVodrLVx7IZnbmcPKKTP
-umWQwwVKevgeHLgplH7b07n7dEYCcAzCVBaVN7J1fFxE7hLZlELDEuIwnTw1lMVE
-DcjI1MUeo7jXRDQLNp7Bmg0xy3pDzcEvdIc1eQiUo54v/3SsHZuM69mn5OiD7IJR
-sBgbQrV8p/bJV8gGDZceUyqoOSfssjbRt/cp97R3zF1p92pOrZ9/JQYm5Rn7Ean/
-4wFWrUQRLExcAXOvSHwsevEVO6uJkLh16XqxHkV0T2Mqq1S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bGoCzKSFGE7Xjh7cHvTbB+aOy1i1M4NRkalcYyGnhwDYAz3aoMWSe+Wg3SG
-nWI0cw0bgHe/TNnPlkXbtTpbH5U3VIYRwdL1w1TwUQs/r2tzSjJj/lsuS6nUv7qK
-IMXJ6ZwOUhJiQPfLThSdsnrmVCOzcvSlmGyyFxIGRKNQNN0BojQc/gbvYXlnU1uE
-828CggEAI3478H4WfeA0AYS7AwNmdjGWPknyk1tM8AIWtQqtPJBb6wjRIFAjc93a
-OPZm2fK/i1ml/9Dtnlhl+55GGkJjZ9Yf+nSMO6KZFGwwgRnbzl0ojYO9btk/7K42
-yvWAl5ZHqsmWOTD9tt2ick/65DQ8HGh3FkRdOMEM+zoiDOXjrmFOHGkjPNYF1aNj
-apoVE5EktgWkDo4N0tHtKHyaKuVtCwdc0QnKHzSpVmsAOus+aGSQvLzBFAxK2YyH
-8IZy/jhSSov6/FJO9d0H+J3Ss/1iRsUXKWuAziQWiK4yafy8ga55rL8SOci6nbNC
-qXe5D3T3DqUaqe1FSksWxTU4Zb4GEA==
------END PRIVATE KEY-----
diff --git a/os.Stdout b/os.Stdout
deleted file mode 100644
index dc3a83a..0000000
--- a/os.Stdout
+++ /dev/null
@@ -1,4 +0,0 @@
-1706685145769,0s,404,GET,/album/scool,127.0.0.1,0,-1
-1706685147112,579.1µs,304,GET,/,127.0.0.1,0,-1
-1706685147144,908.5µs,404,GET,/album/scool,127.0.0.1,0,-1
-1706685148780,205.1804ms,200,GET,/album/list,127.0.0.1,0,3021