mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-11 09:44:21 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
b00a232fbb
4 changed files with 85 additions and 14 deletions
|
|
@ -86,7 +86,7 @@ const renderRepoItem = (response: IWebSocketData, element: Element, type: string
|
||||||
<span class="b3-list-item__action b3-tooltips b3-tooltips__w" data-type="rollback" aria-label="${window.siyuan.languages.rollback}"><svg><use xlink:href="#iconUndo"></use></svg></span>`;
|
<span class="b3-list-item__action b3-tooltips b3-tooltips__w" data-type="rollback" aria-label="${window.siyuan.languages.rollback}"><svg><use xlink:href="#iconUndo"></use></svg></span>`;
|
||||||
}
|
}
|
||||||
let repoHTML = "";
|
let repoHTML = "";
|
||||||
response.data.snapshots.forEach((item: { memo: string, id: string, hCreated: string, count: number, hSize: string, tag: string }) => {
|
response.data.snapshots.forEach((item: { memo: string, id: string, hCreated: string, count: number, hSize: string, tag: string, typesCount: { type: string, count: number }[] }) => {
|
||||||
if (isMobile()) {
|
if (isMobile()) {
|
||||||
repoHTML += `<li class="b3-list-item b3-list-item--two">
|
repoHTML += `<li class="b3-list-item b3-list-item--two">
|
||||||
<div class="b3-list-item__first">
|
<div class="b3-list-item__first">
|
||||||
|
|
@ -110,7 +110,17 @@ const renderRepoItem = (response: IWebSocketData, element: Element, type: string
|
||||||
<div>
|
<div>
|
||||||
<span class="ft__smaller ft__on-surface">${item.hCreated}</span>
|
<span class="ft__smaller ft__on-surface">${item.hCreated}</span>
|
||||||
<span class="b3-list-item__meta">${window.siyuan.languages.fileSize} ${item.hSize}</span>
|
<span class="b3-list-item__meta">${window.siyuan.languages.fileSize} ${item.hSize}</span>
|
||||||
<span class="b3-list-item__meta">${window.siyuan.languages.fileCount} ${item.count}</span>
|
<span class="b3-list-item__meta">${window.siyuan.languages.fileCount} ${item.count}</span>`
|
||||||
|
let statHTML = "";
|
||||||
|
if (item.typesCount && 0 < item.typesCount.length) {
|
||||||
|
statHTML += `
|
||||||
|
<span class="b3-list-item__meta">
|
||||||
|
${item.typesCount.map((type: { type: string, count: number }) => {
|
||||||
|
return `${type.type} ${type.count}`;
|
||||||
|
}).join(" ")}`
|
||||||
|
}
|
||||||
|
repoHTML += `${statHTML}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
${actionHTML}
|
${actionHTML}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ require (
|
||||||
github.com/panjf2000/ants/v2 v2.7.0
|
github.com/panjf2000/ants/v2 v2.7.0
|
||||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||||
github.com/radovskyb/watcher v1.0.7
|
github.com/radovskyb/watcher v1.0.7
|
||||||
github.com/siyuan-note/dejavu v0.0.0-20221214060041-f7b64a7eb12a
|
github.com/siyuan-note/dejavu v0.0.0-20221214071109-67333a5acbcb
|
||||||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75
|
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75
|
||||||
github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da
|
github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da
|
||||||
github.com/siyuan-note/filelock v0.0.0-20221117095924-e1947438a35e
|
github.com/siyuan-note/filelock v0.0.0-20221117095924-e1947438a35e
|
||||||
|
|
|
||||||
|
|
@ -361,8 +361,8 @@ github.com/shurcooL/reactions v0.0.0-20181006231557-f2e0b4ca5b82/go.mod h1:TCR1l
|
||||||
github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||||
github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4=
|
github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4=
|
||||||
github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw=
|
github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw=
|
||||||
github.com/siyuan-note/dejavu v0.0.0-20221214060041-f7b64a7eb12a h1:9sAurbeois47ROtvJ9EcQFWfJIdL7C6fPZm29PhTBXg=
|
github.com/siyuan-note/dejavu v0.0.0-20221214071109-67333a5acbcb h1:fS8iB5d7x57eyfvNjqlDOTL9XglVCSBtGoa5e3nQTkY=
|
||||||
github.com/siyuan-note/dejavu v0.0.0-20221214060041-f7b64a7eb12a/go.mod h1:aarwJw3uJaqNoIGVLmyhZjMCjI+xAzwrMIg05scqmtc=
|
github.com/siyuan-note/dejavu v0.0.0-20221214071109-67333a5acbcb/go.mod h1:aarwJw3uJaqNoIGVLmyhZjMCjI+xAzwrMIg05scqmtc=
|
||||||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75 h1:Bi7/7f29LW+Fm0cHc0J1NO1cZqyJwljSWVmfOqVZgaE=
|
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75 h1:Bi7/7f29LW+Fm0cHc0J1NO1cZqyJwljSWVmfOqVZgaE=
|
||||||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75/go.mod h1:H8fyqqAbp9XreANjeSbc72zEdFfKTXYN34tc1TjZwtw=
|
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75/go.mod h1:H8fyqqAbp9XreANjeSbc72zEdFfKTXYN34tc1TjZwtw=
|
||||||
github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da h1:/jNhl7LC+9BhkWvNxuJDdsNfA/2wvfuj9mqWx4CbV90=
|
github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da h1:/jNhl7LC+9BhkWvNxuJDdsNfA/2wvfuj9mqWx4CbV90=
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -53,7 +54,18 @@ func init() {
|
||||||
subscribeEvents()
|
subscribeEvents()
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetRepoSnapshots(page int) (logs []*dejavu.Log, pageCount, totalCount int, err error) {
|
type Snapshot struct {
|
||||||
|
*dejavu.Log
|
||||||
|
TypesCount []*TypeCount `json:"typesCount"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TypeCount struct {
|
||||||
|
Type string `json:"type"`
|
||||||
|
Count int `json:"count"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetRepoSnapshots(page int) (ret []*Snapshot, pageCount, totalCount int, err error) {
|
||||||
|
ret = []*Snapshot{}
|
||||||
if 1 > len(Conf.Repo.Key) {
|
if 1 > len(Conf.Repo.Key) {
|
||||||
err = errors.New(Conf.Language(26))
|
err = errors.New(Conf.Language(26))
|
||||||
return
|
return
|
||||||
|
|
@ -64,7 +76,7 @@ func GetRepoSnapshots(page int) (logs []*dejavu.Log, pageCount, totalCount int,
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
logs, pageCount, totalCount, err = repo.GetIndexLogs(page, 32)
|
logs, pageCount, totalCount, err := repo.GetIndexLogs(page, 32)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
if dejavu.ErrNotFoundIndex == err {
|
if dejavu.ErrNotFoundIndex == err {
|
||||||
logs = []*dejavu.Log{}
|
logs = []*dejavu.Log{}
|
||||||
|
|
@ -75,6 +87,51 @@ func GetRepoSnapshots(page int) (logs []*dejavu.Log, pageCount, totalCount int,
|
||||||
logging.LogErrorf("get data repo index logs failed: %s", err)
|
logging.LogErrorf("get data repo index logs failed: %s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = buildSnapshots(logs)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildSnapshots(logs []*dejavu.Log) (ret []*Snapshot) {
|
||||||
|
for _, l := range logs {
|
||||||
|
typesCount := statTypesByPath(l.Files)
|
||||||
|
ret = append(ret, &Snapshot{
|
||||||
|
Log: l,
|
||||||
|
TypesCount: typesCount,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func statTypesByPath(files []*entity.File) (ret []*TypeCount) {
|
||||||
|
for _, f := range files {
|
||||||
|
ext := path.Ext(f.Path)
|
||||||
|
|
||||||
|
found := false
|
||||||
|
for _, tc := range ret {
|
||||||
|
if tc.Type == ext {
|
||||||
|
tc.Count++
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
ret = append(ret, &TypeCount{Type: ext, Count: 1})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Slice(ret, func(i, j int) bool { return ret[i].Count > ret[j].Count })
|
||||||
|
if 10 < len(ret) {
|
||||||
|
otherCount := 0
|
||||||
|
for _, tc := range ret[10:] {
|
||||||
|
tc.Count += otherCount
|
||||||
|
}
|
||||||
|
other := &TypeCount{
|
||||||
|
Type: "Other",
|
||||||
|
Count: otherCount,
|
||||||
|
}
|
||||||
|
ret = append(ret[:10], other)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -333,6 +390,7 @@ func RemoveCloudRepoTag(tag string) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetCloudRepoTagSnapshots() (ret []*dejavu.Log, err error) {
|
func GetCloudRepoTagSnapshots() (ret []*dejavu.Log, err error) {
|
||||||
|
ret = []*dejavu.Log{}
|
||||||
if 1 > len(Conf.Repo.Key) {
|
if 1 > len(Conf.Repo.Key) {
|
||||||
err = errors.New(Conf.Language(26))
|
err = errors.New(Conf.Language(26))
|
||||||
return
|
return
|
||||||
|
|
@ -343,14 +401,16 @@ func GetCloudRepoTagSnapshots() (ret []*dejavu.Log, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ret, err = repo.GetCloudRepoTagLogs(map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar})
|
logs, err := repo.GetCloudRepoTagLogs(map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar})
|
||||||
if 1 > len(ret) {
|
if nil != err {
|
||||||
ret = []*dejavu.Log{}
|
return
|
||||||
}
|
}
|
||||||
|
ret = logs
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetTagSnapshots() (ret []*dejavu.Log, err error) {
|
func GetTagSnapshots() (ret []*Snapshot, err error) {
|
||||||
|
ret = []*Snapshot{}
|
||||||
if 1 > len(Conf.Repo.Key) {
|
if 1 > len(Conf.Repo.Key) {
|
||||||
err = errors.New(Conf.Language(26))
|
err = errors.New(Conf.Language(26))
|
||||||
return
|
return
|
||||||
|
|
@ -361,10 +421,11 @@ func GetTagSnapshots() (ret []*dejavu.Log, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ret, err = repo.GetTagLogs()
|
logs, err := repo.GetTagLogs()
|
||||||
if 1 > len(ret) {
|
if nil != err {
|
||||||
ret = []*dejavu.Log{}
|
return
|
||||||
}
|
}
|
||||||
|
ret = buildSnapshots(logs)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue