mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-19 16:10:12 +01:00
🎨 Database gallery view https://github.com/siyuan-note/siyuan/issues/10414
This commit is contained in:
parent
8eb37bd735
commit
218bbe2000
3 changed files with 38 additions and 8 deletions
|
|
@ -27,6 +27,29 @@ import (
|
|||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
func changeAttrViewLayout(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
arg, ok := util.JsonArg(c, ret)
|
||||
if !ok {
|
||||
c.JSON(http.StatusOK, ret)
|
||||
return
|
||||
}
|
||||
|
||||
blockID := arg["blockID"].(string)
|
||||
avID := arg["avID"].(string)
|
||||
layoutType := arg["layoutType"].(av.LayoutType)
|
||||
err := model.ChangeAttrViewLayout(blockID, avID, layoutType)
|
||||
if err != nil {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
c.JSON(http.StatusOK, ret)
|
||||
return
|
||||
}
|
||||
|
||||
ret = renderAttrView(avID, "", "", 1, -1)
|
||||
c.JSON(http.StatusOK, ret)
|
||||
}
|
||||
|
||||
func duplicateAttributeViewBlock(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
|
@ -532,10 +555,9 @@ func renderHistoryAttributeView(c *gin.Context) {
|
|||
|
||||
func renderAttributeView(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
arg, ok := util.JsonArg(c, ret)
|
||||
if !ok {
|
||||
c.JSON(http.StatusOK, ret)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -563,7 +585,13 @@ func renderAttributeView(c *gin.Context) {
|
|||
query = queryArg.(string)
|
||||
}
|
||||
|
||||
view, attrView, err := model.RenderAttributeView(id, viewID, query, page, pageSize)
|
||||
ret = renderAttrView(id, viewID, query, page, pageSize)
|
||||
c.JSON(http.StatusOK, ret)
|
||||
}
|
||||
|
||||
func renderAttrView(avID, viewID, query string, page, pageSize int) (ret *gulu.Result) {
|
||||
ret = gulu.Ret.NewResult()
|
||||
view, attrView, err := model.RenderAttributeView(avID, viewID, query, page, pageSize)
|
||||
if err != nil {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
|
|
@ -602,6 +630,7 @@ func renderAttributeView(c *gin.Context) {
|
|||
"view": view,
|
||||
"isMirror": av.IsMirror(attrView.ID),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func getCurrentAttrViewImages(c *gin.Context) {
|
||||
|
|
|
|||
|
|
@ -455,6 +455,7 @@ func ServeAPI(ginServer *gin.Engine) {
|
|||
ginServer.Handle("POST", "/api/av/duplicateAttributeViewBlock", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, duplicateAttributeViewBlock)
|
||||
ginServer.Handle("POST", "/api/av/appendAttributeViewDetachedBlocksWithValues", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, appendAttributeViewDetachedBlocksWithValues)
|
||||
ginServer.Handle("POST", "/api/av/getCurrentAttrViewImages", model.CheckAuth, getCurrentAttrViewImages)
|
||||
ginServer.Handle("POST", "/api/av/changeAttrViewLayout", model.CheckAuth, changeAttrViewLayout)
|
||||
|
||||
ginServer.Handle("POST", "/api/ai/chatGPT", model.CheckAuth, model.CheckAdminRole, chatGPT)
|
||||
ginServer.Handle("POST", "/api/ai/chatGPTWithAction", model.CheckAuth, model.CheckAdminRole, chatGPTWithAction)
|
||||
|
|
|
|||
|
|
@ -53,25 +53,25 @@ func (tx *Transaction) doSetAttrViewBlockView(operation *Operation) (ret *TxErr)
|
|||
}
|
||||
|
||||
func (tx *Transaction) doChangeAttrViewLayout(operation *Operation) (ret *TxErr) {
|
||||
err := changeAttrViewLayout(operation)
|
||||
err := ChangeAttrViewLayout(operation.BlockID, operation.AvID, operation.Layout)
|
||||
if err != nil {
|
||||
return &TxErr{code: TxErrWriteAttributeView, id: operation.AvID, msg: err.Error()}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func changeAttrViewLayout(operation *Operation) (err error) {
|
||||
attrView, err := av.ParseAttributeView(operation.AvID)
|
||||
func ChangeAttrViewLayout(blockID, avID string, layout av.LayoutType) (err error) {
|
||||
attrView, err := av.ParseAttributeView(avID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
view, err := getAttrViewViewByBlockID(attrView, operation.BlockID)
|
||||
view, err := getAttrViewViewByBlockID(attrView, blockID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
newLayout := operation.Layout
|
||||
newLayout := layout
|
||||
if newLayout == view.LayoutType {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue