Skip to content

Commit

Permalink
Merge pull request #92 from libsgh/dev
Browse files Browse the repository at this point in the history
v2.0.5
  • Loading branch information
libsgh authored Aug 15, 2021
2 parents e71f4bc + 580aef2 commit 0f57f0b
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 42 deletions.
1 change: 0 additions & 1 deletion entity/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ type FileNode struct {
}
type SearchNode struct {
FileNode
Dx string
AccountId string
}
type Paths struct {
Expand Down
26 changes: 8 additions & 18 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func GetFilesByPath(account entity.Account, path, pwd, sColumn, sOrder string) m
} else {
order_sql := ""
nl_column := "cache_time"
if sColumn != "default" {
if sColumn != "default" && sColumn != "null" {
order_sql = fmt.Sprintf(" ORDER BY is_folder desc, %s %s", sColumn, sOrder)
nl_column = sColumn
}
Expand Down Expand Up @@ -257,6 +257,10 @@ func GetFilesByPath(account entity.Account, path, pwd, sColumn, sOrder string) m

func SearchFilesByKey(key, sColumn, sOrder string) map[string]interface{} {
result := make(map[string]interface{})
acountIndex := make(map[string]interface{})
for i, account := range config.GloablConfig.Accounts {
acountIndex[account.Id] = fmt.Sprintf("/d_%d", i)
}
list := []entity.SearchNode{}
accouts := []entity.Account{}
defer func() {
Expand All @@ -266,7 +270,7 @@ func SearchFilesByKey(key, sColumn, sOrder string) map[string]interface{} {
}()
sql := `
SELECT
a.*,('/d_'||(select count(*) from account c where b.` + "`default`" + ` < c.` + "`default`" + ` and c.rowid < b.rowid)) as dx,b.id as account_id
a.*
FROM
file_node a
LEFT JOIN account b ON b.id = a.account_id
Expand All @@ -282,24 +286,9 @@ func SearchFilesByKey(key, sColumn, sOrder string) map[string]interface{} {
if len(accouts) > 0 {
for _, account := range accouts {
nfs := Util.FileSearch(account.RootId, "", key)
dx := "/d_0"
sql = `
SELECT
('/d_'||(select count(*) from account b where a.` + "`default`" + ` < b.` + "`default`" + ` and b.rowid < a.rowid )) as dx
FROM
account a
WHERE
a.id = ?
`
for i, ac := range config.GloablConfig.Accounts {
if ac.Id == account.Id {
dx = fmt.Sprintf("/d_%d", i)
break
}
}
//model.SqliteDb.Raw(sql, account.Id).Find(&dx)
for _, fs := range nfs {
sn := entity.SearchNode{fs, dx, account.Id}
sn := entity.SearchNode{fs, account.Id}
list = append(list, sn)
}
}
Expand Down Expand Up @@ -350,6 +339,7 @@ func SearchFilesByKey(key, sColumn, sOrder string) map[string]interface{} {
result["HasParent"] = false
result["ParentPath"] = PetParentPath("/")
result["SurportFolderDown"] = false
result["AcountIndex"] = acountIndex
return result
}

Expand Down
2 changes: 1 addition & 1 deletion static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ $(".search").bind('keydown', function(event) {
function initSort(){
var sColumn = $.cookie("SColumn");
var sOrder = $.cookie("SOrder");
if (sColumn == null || sColumn == "" || sColumn == "default"){
if (sColumn == "null" || sColumn == null || sColumn == "" || sColumn == "default"){
$('.default-check').prepend('<i class="check mdui-menu-item-icon mdui-icon material-icons">check</i>');
}else{
$('a[data-column='+sColumn+']:not(.sort-order-check)').prepend('<i class="check mdui-menu-item-icon mdui-icon material-icons">check</i>');
Expand Down
33 changes: 25 additions & 8 deletions templates/pan/bootstrap/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@
}
</style>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/jquery.cookie.min.js"></script>
</head>
<body>
{{ $SurportFolderDown := .SurportFolderDown }}
{{if .HasPwd}}
<script src="https://cdn.bootcdn.net/ajax/libs/jquery-cookie/1.0/jquery.cookie.min.js"></script>
<script>
promptPwd("{{ .FileId}}");
function promptPwd(fileId){
Expand Down Expand Up @@ -150,13 +150,13 @@
<tr>
{{if .IsFolder}}
<td class="file-name">
<a class="icon icon-dir" href="{{if $.SearchKey}}{{.Dx}}{{else}}{{$.DIndex}}{{end}}{{.Path}}"><i class="fa fa-folder" aria-hidden="true"></i>&nbsp;&nbsp;{{.FileName}}</a>
<a class="icon icon-dir" href="{{if $.SearchKey}}{{index $.AcountIndex .AccountId }}{{else}}{{$.DIndex}}{{end}}{{.Path}}"><i class="fa fa-folder" aria-hidden="true"></i>&nbsp;&nbsp;{{.FileName}}</a>
{{if $.SearchKey}}
<br><p style="margin-left: 30px">{{.Dx}}{{.Path}}</p>
<br><p style="margin-left: 30px">{{index $.AcountIndex .AccountId }}{{.Path}}</p>
{{end}}
</td>
{{else}}
<td class="file-name"><a class="icon icon-file" data-file-type="{{.FileType}}" data-media-type="{{.MediaType}}" data-title="{{.FileName}}" data-url="{{if $.SearchKey}}{{.Dx}}{{else}}{{$.DIndex}}{{end}}{{.Path}}" href="javascript:void(0);">
<td class="file-name"><a class="icon icon-file" data-file-type="{{.FileType}}" data-media-type="{{.MediaType}}" data-title="{{.FileName}}" data-url="{{if $.SearchKey}}{{index $.AcountIndex .AccountId }}{{else}}{{$.DIndex}}{{end}}{{.Path}}" href="javascript:void(0);">
{{if eq .MediaType 1}}
<i class="fa fa-file-image-o" aria-hidden="true"></i>
{{else if eq .MediaType 2}}
Expand All @@ -180,10 +180,10 @@
<i class="fa fa-file" aria-hidden="true"></i>
{{end}}
{{end}}
&nbsp;&nbsp;{{.FileName}} <i class="fa fa-copy copyBtn" data-path="{{if $.SearchKey}}{{.Dx}}{{else}}{{$.DIndex}}{{end}}{{.Path}}" data-clipboard-action="copy" data-toggle="tooltip" data-placement="bottom" title="复制链接" style="font-size: x-small" aria-hidden="true"></i>
&nbsp;&nbsp;{{.FileName}} <i class="fa fa-copy copyBtn" data-path="{{if $.SearchKey}}{{index $.AcountIndex .AccountId }}{{else}}{{$.DIndex}}{{end}}{{.Path}}" data-clipboard-action="copy" data-toggle="tooltip" data-placement="bottom" title="复制链接" style="font-size: x-small" aria-hidden="true"></i>
</a>
{{if $.SearchKey}}
<br><p style="margin-left: 30px">{{.Dx}}{{.Path}}</p>
<br><p style="margin-left: 30px">{{index $.AcountIndex .AccountId }}{{.Path}}</p>
{{end}}
</td>
{{end}}
Expand All @@ -196,7 +196,7 @@
<td class="file-size">-</td>
{{end}}
{{else}}
<td class="text-center"><a href="{{if $.SearchKey}}{{.Dx}}{{else}}{{$.DIndex}}{{end}}}{{.Path}}" target="_blank"><i class="fa fa-download" aria-hidden="true"></i></a></td>
<td class="text-center"><a href="{{if $.SearchKey}}{{index $.AcountIndex .AccountId }}{{else}}{{$.DIndex}}{{end}}}{{.Path}}" target="_blank"><i class="fa fa-download" aria-hidden="true"></i></a></td>
{{end}}
</tr>
{{end}}
Expand All @@ -215,13 +215,30 @@
<p id="content" class="card-text">
</p>
<script>
$("#content").html(marked($("#readme").val()));
var c = $("#readme").val();
if(c != ""){
$("#content").append(marked(c));
$("#content").show();
}else{
var fullUrl = encodeURI(window.location.protocol + "//"+window.location.host + "/api/public/raw/README.md");
$.ajax({
method: 'GET',
url: fullUrl,
success: function (data) {
if(data != ""){
$("#content").append(marked(data));
$("#content").show();
}
}
});
}
</script>
</div>
</div>
</div>
{{else}}
{{end}}
<div id="previewImages"></div>
<div class="col-sm-12">
<div class="text-center">
{{if eq $.Footer ""}}
Expand Down
33 changes: 25 additions & 8 deletions templates/pan/materialdesign/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@
}
</style>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/jquery.cookie.min.js"></script>
</head>
<body>
{{ $SurportFolderDown := .SurportFolderDown }}
{{if .HasPwd}}
<script src="https://cdn.bootcdn.net/ajax/libs/jquery-cookie/1.0/jquery.cookie.min.js"></script>
<script>
promptPwd("{{ .FileId}}");
function promptPwd(fileId){
Expand Down Expand Up @@ -151,13 +151,13 @@ <h2 id="heading">{{.Title}} {{ .Path }}</h2>
<tr>
{{if .IsFolder}}
<td class="file-name">
<a class="icon icon-dir" href="{{if $.SearchKey}}{{.Dx}}{{else}}{{$.DIndex}}{{end}}{{.Path}}"><i class="fa fa-folder" aria-hidden="true"></i>&nbsp;&nbsp;{{.FileName}}</a>
<a class="icon icon-dir" href="{{if $.SearchKey}}{{index $.AcountIndex .AccountId }}{{else}}{{$.DIndex}}{{end}}{{.Path}}"><i class="fa fa-folder" aria-hidden="true"></i>&nbsp;&nbsp;{{.FileName}}</a>
{{if $.SearchKey}}
<br><p style="margin-left: 45px">{{.Dx}}{{.Path}}</p>
<br><p style="margin-left: 45px">{{index $.AcountIndex .AccountId }}{{.Path}}</p>
{{end}}
</td>
{{else}}
<td class="file-name"><a class="icon icon-file" data-file-type="{{.FileType}}" data-media-type="{{.MediaType}}" data-title="{{.FileName}}" data-url="{{if $.SearchKey}}{{.Dx}}{{else}}{{$.DIndex}}{{end}}{{.Path}}" href="javascript:void(0);">
<td class="file-name"><a class="icon icon-file" data-file-type="{{.FileType}}" data-media-type="{{.MediaType}}" data-title="{{.FileName}}" data-url="{{if $.SearchKey}}{{index $.AcountIndex .AccountId }}{{else}}{{$.DIndex}}{{end}}{{.Path}}" href="javascript:void(0);">
{{if eq .MediaType 1}}
<i class="fa fa-file-image-o" aria-hidden="true"></i>
{{else if eq .MediaType 2}}
Expand All @@ -181,9 +181,9 @@ <h2 id="heading">{{.Title}} {{ .Path }}</h2>
<i class="fa fa-file" aria-hidden="true"></i>
{{end}}
{{end}}
&nbsp;&nbsp;{{.FileName}} <i class="fa fa-copy copyBtn" data-path="{{if $.SearchKey}}{{.Dx}}{{else}}{{$.DIndex}}{{end}}{{.Path}}" data-clipboard-action="copy" data-toggle="tooltip" data-placement="bottom" title="复制链接" style="font-size: x-small" aria-hidden="true"></i></a>
&nbsp;&nbsp;{{.FileName}} <i class="fa fa-copy copyBtn" data-path="{{if $.SearchKey}}{{index $.AcountIndex .AccountId }}{{else}}{{$.DIndex}}{{end}}{{.Path}}" data-clipboard-action="copy" data-toggle="tooltip" data-placement="bottom" title="复制链接" style="font-size: x-small" aria-hidden="true"></i></a>
{{if $.SearchKey}}
<br><p style="margin-left: 45px">{{.Dx}}{{.Path}}</p>
<br><p style="margin-left: 45px">{{index $.AcountIndex .AccountId }}{{.Path}}</p>
{{end}}
</td>
{{end}}
Expand All @@ -196,7 +196,7 @@ <h2 id="heading">{{.Title}} {{ .Path }}</h2>
<td class="file-size">-</td>
{{end}}
{{else}}
<td class="center-align"><a href="{{if $.SearchKey}}{{.Dx}}{{else}}{{$.DIndex}}{{end}}{{.Path}}" target="_blank"><i class="fa fa-download" aria-hidden="true"></i></a></td>
<td class="center-align"><a href="{{if $.SearchKey}}{{index $.AcountIndex .AccountId }}{{else}}{{$.DIndex}}{{end}}{{.Path}}" target="_blank"><i class="fa fa-download" aria-hidden="true"></i></a></td>
{{end}}
</tr>
{{end}}
Expand All @@ -211,12 +211,29 @@ <h2 id="heading">{{.Title}} {{ .Path }}</h2>
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<div id="content"></div>
<script>
$("#content").html(marked($("#readme").val()));
var c = $("#readme").val();
if(c != ""){
$("#content").append(marked(c));
$("#content").show();
}else{
var fullUrl = encodeURI(window.location.protocol + "//"+window.location.host + "/api/public/raw/README.md");
$.ajax({
method: 'GET',
url: fullUrl,
success: function (data) {
if(data != ""){
$("#content").append(marked(data));
$("#content").show();
}
}
});
}
</script>
</div>
</div>
</div>
{{end}}
<div id="previewImages"></div>
<div class="col s12 footer">
<div class="center-align">
{{if eq $.Footer ""}}
Expand Down
9 changes: 5 additions & 4 deletions templates/pan/mdui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
{{end}}
{{range .List}}
<li class="mdui-list-item mdui-ripple">
<div class="mdui-list-item-content icon-file-mdui" data-folder="{{.IsFolder}}" data-file-id="{{.FileId}}" data-file-type="{{.FileType}}" data-media-type="{{.MediaType}}" data-title="{{.FileName}}" data-url="{{if $.SearchKey}}{{.Dx}}{{else}}{{$.DIndex}}{{end}}{{.Path}}">
<div class="mdui-list-item-content icon-file-mdui" data-folder="{{.IsFolder}}" data-file-id="{{.FileId}}" data-file-type="{{.FileType}}" data-media-type="{{.MediaType}}" data-title="{{.FileName}}" data-url="{{if $.SearchKey}}{{index $.AcountIndex .AccountId }}{{else}}{{$.DIndex}}{{end}}{{.Path}}">
<div class="mdui-list-item-title wordWrap">
{{if .IsFolder}}
<i class="mdui-icon material-icons" style="margin: -3px 5px 0px 0px;">folder_open</i> {{.FileName}}
Expand Down Expand Up @@ -269,8 +269,9 @@
insert_drive_file
{{end}}
{{end}}
</i> {{.FileName}} <a href="javascript:void(0)" data-path="{{if $.SearchKey}}{{.Dx}}{{else}}{{$.DIndex}}{{end}}{{.Path}}" data-clipboard-action="copy" class="copyBtn mdui-icon material-icons mdui-text-color-theme-icon" mdui-tooltip="{content: '复制链接'}" style="font-size: x-small">content_copy</a>
<a href="{{if $.SearchKey}}{{.Dx}}{{else}}{{$.DIndex}}{{end}}{{.Path}}" class="mdui-float-right mdui-icon material-icons mdui-text-color-theme-icon">file_download</a>
</i> {{.FileName}} <a href="javascript:void(0)" data-path="{{if $.SearchKey}}{{index $.AcountIndex .AccountId }}{{else}}{{$.DIndex}}{{end}}{{.Path}}" data-clipboard-action="copy" class="copyBtn mdui-icon material-icons mdui-text-color-theme-icon" mdui-tooltip="{content: '复制链接'}" style="font-size: x-small">content_copy</a>

<a href="{{if $.SearchKey}}{{index $.AcountIndex .AccountId }}{{else}}{{$.DIndex}}{{end}}{{.Path}}" class="mdui-float-right mdui-icon material-icons mdui-text-color-theme-icon">file_download</a>
{{end}}
</div>
{{if .IsFolder}}
Expand All @@ -281,7 +282,7 @@
{{end}}
{{if $.SearchKey}}
<div class="mdui-list-item-text mdui-list-item-one-line">
{{.Dx}}{{.Path}}
{{index $.AcountIndex .AccountId }}{{.Path}}
</div>
{{end}}
</div>
Expand Down
4 changes: 2 additions & 2 deletions templates/pan/mdui/view-base.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/mdui.min.js"
integrity="sha384-gCMZcshYKOGRX9r6wbDrvF+TcCCswSHFucUzUPwka+Gr+uHgjlYvkABr95TCOz3A"
crossorigin="anonymous"
crossorigin="anonymous" -------------------------------------------------------
></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery-cookie/1.0/jquery.cookie.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery.cookie@1.4.1/jquery.cookie.min.js"></script>
<style>
.mdui-list-item,
.mdui-list-item:hover {
Expand Down

0 comments on commit 0f57f0b

Please sign in to comment.