mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
🎨 Reduce the delay in adding rows in database table view https://github.com/siyuan-note/siyuan/issues/10082
This commit is contained in:
parent
d5e098a285
commit
3bfbfbc7e9
3 changed files with 41 additions and 2 deletions
|
|
@ -26,6 +26,24 @@ import (
|
||||||
"github.com/siyuan-note/siyuan/kernel/util"
|
"github.com/siyuan-note/siyuan/kernel/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func getAttributeViewFilterSort(c *gin.Context) {
|
||||||
|
ret := gulu.Ret.NewResult()
|
||||||
|
defer c.JSON(http.StatusOK, ret)
|
||||||
|
|
||||||
|
arg, _ := util.JsonArg(c, ret)
|
||||||
|
if nil == arg {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
avID := arg["id"].(string)
|
||||||
|
|
||||||
|
filters, sorts := model.GetAttributeViewFilterSort(avID)
|
||||||
|
ret.Data = map[string]interface{}{
|
||||||
|
"filters": filters,
|
||||||
|
"sorts": sorts,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func searchAttributeViewNonRelationKey(c *gin.Context) {
|
func searchAttributeViewNonRelationKey(c *gin.Context) {
|
||||||
ret := gulu.Ret.NewResult()
|
ret := gulu.Ret.NewResult()
|
||||||
defer c.JSON(http.StatusOK, ret)
|
defer c.JSON(http.StatusOK, ret)
|
||||||
|
|
@ -72,9 +90,8 @@ func getAttributeView(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
id := arg["id"].(string)
|
id := arg["id"].(string)
|
||||||
av := model.GetAttributeView(id)
|
|
||||||
ret.Data = map[string]interface{}{
|
ret.Data = map[string]interface{}{
|
||||||
"av": av,
|
"av": model.GetAttributeView(id),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -396,6 +396,7 @@ func ServeAPI(ginServer *gin.Engine) {
|
||||||
ginServer.Handle("POST", "/api/av/getAttributeView", model.CheckAuth, model.CheckReadonly, getAttributeView)
|
ginServer.Handle("POST", "/api/av/getAttributeView", model.CheckAuth, model.CheckReadonly, getAttributeView)
|
||||||
ginServer.Handle("POST", "/api/av/searchAttributeViewRelationKey", model.CheckAuth, model.CheckReadonly, searchAttributeViewRelationKey)
|
ginServer.Handle("POST", "/api/av/searchAttributeViewRelationKey", model.CheckAuth, model.CheckReadonly, searchAttributeViewRelationKey)
|
||||||
ginServer.Handle("POST", "/api/av/searchAttributeViewNonRelationKey", model.CheckAuth, model.CheckReadonly, searchAttributeViewNonRelationKey)
|
ginServer.Handle("POST", "/api/av/searchAttributeViewNonRelationKey", model.CheckAuth, model.CheckReadonly, searchAttributeViewNonRelationKey)
|
||||||
|
ginServer.Handle("POST", "/api/av/getAttributeViewFilterSort", model.CheckAuth, model.CheckReadonly, getAttributeViewFilterSort)
|
||||||
|
|
||||||
ginServer.Handle("POST", "/api/ai/chatGPT", model.CheckAuth, chatGPT)
|
ginServer.Handle("POST", "/api/ai/chatGPT", model.CheckAuth, chatGPT)
|
||||||
ginServer.Handle("POST", "/api/ai/chatGPTWithAction", model.CheckAuth, chatGPTWithAction)
|
ginServer.Handle("POST", "/api/ai/chatGPTWithAction", model.CheckAuth, chatGPTWithAction)
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,27 @@ import (
|
||||||
"github.com/siyuan-note/siyuan/kernel/util"
|
"github.com/siyuan-note/siyuan/kernel/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func GetAttributeViewFilterSort(id string) (filters []*av.ViewFilter, sorts []*av.ViewSort) {
|
||||||
|
waitForSyncingStorages()
|
||||||
|
|
||||||
|
attrView, err := av.ParseAttributeView(id)
|
||||||
|
if nil != err {
|
||||||
|
logging.LogErrorf("parse attribute view [%s] failed: %s", id, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
filters = []*av.ViewFilter{}
|
||||||
|
sorts = []*av.ViewSort{}
|
||||||
|
for _, view := range attrView.Views {
|
||||||
|
switch view.LayoutType {
|
||||||
|
case av.LayoutTypeTable:
|
||||||
|
filters = view.Table.Filters
|
||||||
|
sorts = view.Table.Sorts
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func SearchAttributeViewNonRelationKey(avID, keyword string) (ret []*av.Key) {
|
func SearchAttributeViewNonRelationKey(avID, keyword string) (ret []*av.Key) {
|
||||||
waitForSyncingStorages()
|
waitForSyncingStorages()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue