This commit is contained in:
Liang Ding 2022-07-05 21:21:47 +08:00
parent 9350d5d224
commit 4bfe4490a7
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
5 changed files with 41 additions and 21 deletions

View file

@ -114,13 +114,13 @@ const renderRepo = (element: Element, currentPage: number) => {
} else {
previousElement.setAttribute("disabled", "disabled");
}
fetchPost("/api/repo/getRepoIndexLogs", {page: currentPage}, (response) => {
fetchPost("/api/repo/getRepoSnapshots", {page: currentPage}, (response) => {
if (currentPage < response.data.pageCount) {
nextElement.removeAttribute("disabled");
} else {
nextElement.setAttribute("disabled", "disabled");
}
if (response.data.logs.length === 0) {
if (response.data.snapshots.length === 0) {
element.lastElementChild.innerHTML = `<li class="b3-list--empty">${window.siyuan.languages.emptyContent}</li>`;
return;
}

View file

@ -43,7 +43,7 @@ func checkoutRepo(c *gin.Context) {
}
}
func getRepoIndexLogs(c *gin.Context) {
func getRepoSnapshots(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
@ -66,6 +66,22 @@ func getRepoIndexLogs(c *gin.Context) {
}
}
func getRepoTagSnapshots(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
snapshots, err := model.GetTagSnapshots()
if nil != err {
ret.Code = -1
ret.Msg = err.Error()
return
}
ret.Data = map[string]interface{}{
"snapshots": snapshots,
}
}
func createSnapshot(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)

View file

@ -257,7 +257,8 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/repo/createSnapshot", model.CheckAuth, createSnapshot)
ginServer.Handle("POST", "/api/repo/tagSnapshot", model.CheckAuth, tagSnapshot)
ginServer.Handle("POST", "/api/repo/checkoutRepo", model.CheckAuth, checkoutRepo)
ginServer.Handle("POST", "/api/repo/getRepoIndexLogs", model.CheckAuth, getRepoIndexLogs)
ginServer.Handle("POST", "/api/repo/getRepoSnapshots", model.CheckAuth, getRepoSnapshots)
ginServer.Handle("POST", "/api/repo/getRepoTagSnapshots", model.CheckAuth, getRepoTagSnapshots)
ginServer.Handle("POST", "/api/notification/pushMsg", model.CheckAuth, pushMsg)
ginServer.Handle("POST", "/api/notification/pushErrMsg", model.CheckAuth, pushErrMsg)

View file

@ -112,7 +112,7 @@ require (
replace github.com/mattn/go-sqlite3 => github.com/88250/go-sqlite3 v1.14.13-0.20220412041952-88c3aaa8595e
//replace github.com/siyuan-note/dejavu => D:\88250\dejavu
replace github.com/siyuan-note/dejavu => D:\88250\dejavu
//replace github.com/siyuan-note/httpclient => D:\88250\httpclient
//replace github.com/siyuan-note/filelock => D:\88250\filelock
//replace github.com/88250/lute => D:\gogogo\src\github.com\88250\lute

View file

@ -27,7 +27,6 @@ import (
"github.com/88250/gulu"
"github.com/siyuan-note/dejavu"
"github.com/siyuan-note/dejavu/entity"
"github.com/siyuan-note/encryption"
"github.com/siyuan-note/eventbus"
"github.com/siyuan-note/filelock"
@ -194,6 +193,21 @@ func CheckoutRepo(id string) (err error) {
return
}
func GetTagSnapshots() (ret []*dejavu.Log, err error) {
if 1 > len(Conf.Repo.Key) {
err = errors.New(Conf.Language(26))
return
}
repo, err := newRepository()
if nil != err {
return
}
ret, err = repo.GetTagLogs()
return
}
func TagSnapshot(id, name string) (err error) {
if 1 > len(Conf.Repo.Key) {
err = errors.New(Conf.Language(26))
@ -452,36 +466,25 @@ func subscribeEvents() {
contextPushMsg(context, msg)
})
eventbus.Subscribe(dejavu.EvtSyncBeforeDownloadCloudLatest, func(context map[string]interface{}) {
eventbus.Subscribe(dejavu.EvtBeforeDownloadCloudIndex, func(context map[string]interface{}) {
msg := "Downloading data repository latest..."
util.SetBootDetails(msg)
contextPushMsg(context, msg)
})
eventbus.Subscribe(dejavu.EvtSyncAfterDownloadCloudLatest, func(context map[string]interface{}, latest *entity.Index) {
msg := fmt.Sprintf("Downloaded latest [%s]", latest.ID[:7])
util.SetBootDetails(msg)
contextPushMsg(context, msg)
//util.LogInfof(msg)
//for _, index := range indexes {
// util.LogInfof(" [%s]", index.ID)
//}
})
eventbus.Subscribe(dejavu.EvtSyncBeforeDownloadCloudFile, func(context map[string]interface{}, id string) {
eventbus.Subscribe(dejavu.EvtBeforeDownloadCloudFile, func(context map[string]interface{}, id string) {
msg := "Downloading data repository object [" + id + "]"
util.SetBootDetails(msg)
contextPushMsg(context, msg)
})
eventbus.Subscribe(dejavu.EvtSyncBeforeDownloadCloudChunk, func(context map[string]interface{}, id string) {
eventbus.Subscribe(dejavu.EvtBeforeDownloadCloudChunk, func(context map[string]interface{}, id string) {
msg := "Downloading data repository object [" + id + "]"
util.SetBootDetails(msg)
contextPushMsg(context, msg)
})
eventbus.Subscribe(dejavu.EvtSyncBeforeUploadObject, func(context map[string]interface{}, id string) {
eventbus.Subscribe(dejavu.EvtBeforeUploadObject, func(context map[string]interface{}, id string) {
msg := "Uploading data repository object [" + id + "]"
util.SetBootDetails(msg)
contextPushMsg(context, msg)