mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
Last Modified Sort (#174)
* Last Modified sorting
* Goimported the file so travis doesn't complain.
Former-commit-id: 06484c47f1426eb26be91032bc8269a74db2c75b [formerly 45a2fa0c020ec678e8780a7b1877013cccd709fd] [formerly 576db545eb2caee9497fa01cac64b95a9c73e8f7 [formerly b61a989958
]]
Former-commit-id: 574cce1c8c2dc2680149f829f491a45561ec08e1 [formerly 4aed04767c209ab1fe2d43b44eecdfcc15554552]
Former-commit-id: e95f9822151173fe30713e749a3a510d792d3636
This commit is contained in:
parent
1755d52019
commit
4a4db4f4ee
@ -20,12 +20,14 @@
|
|||||||
<i class="material-icons">{{ nameIcon }}</i>
|
<i class="material-icons">{{ nameIcon }}</i>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p :class="{ active: !nameSorted }" class="size" @click="sort('size')">
|
<p :class="{ active: sizeSorted }" class="size" @click="sort('size')">
|
||||||
<span>Size</span>
|
<span>Size</span>
|
||||||
<i class="material-icons">{{ sizeIcon }}</i>
|
<i class="material-icons">{{ sizeIcon }}</i>
|
||||||
</p>
|
</p>
|
||||||
|
<p :class="{ active: modifiedSorted }" class="modified" @click="sort('modified')">
|
||||||
<p class="modified">Last modified</p>
|
<span>Last modified</span>
|
||||||
|
<i class="material-icons">{{ modifiedIcon }}</i>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -86,6 +88,12 @@ export default {
|
|||||||
nameSorted () {
|
nameSorted () {
|
||||||
return (this.req.sort === 'name')
|
return (this.req.sort === 'name')
|
||||||
},
|
},
|
||||||
|
sizeSorted () {
|
||||||
|
return (this.req.sort === 'size')
|
||||||
|
},
|
||||||
|
modifiedSorted () {
|
||||||
|
return (this.req.sort === 'modified')
|
||||||
|
},
|
||||||
ascOrdered () {
|
ascOrdered () {
|
||||||
return (this.req.order === 'asc')
|
return (this.req.order === 'asc')
|
||||||
},
|
},
|
||||||
@ -97,7 +105,14 @@ export default {
|
|||||||
return 'arrow_downward'
|
return 'arrow_downward'
|
||||||
},
|
},
|
||||||
sizeIcon () {
|
sizeIcon () {
|
||||||
if (!this.nameSorted && this.ascOrdered) {
|
if (this.sizeSorted && this.ascOrdered) {
|
||||||
|
return 'arrow_downward'
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'arrow_upward'
|
||||||
|
},
|
||||||
|
modifiedIcon () {
|
||||||
|
if (this.modifiedSorted && this.ascOrdered) {
|
||||||
return 'arrow_downward'
|
return 'arrow_downward'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,10 +290,14 @@ export default {
|
|||||||
if (this.nameIcon === 'arrow_upward') {
|
if (this.nameIcon === 'arrow_upward') {
|
||||||
order = 'asc'
|
order = 'asc'
|
||||||
}
|
}
|
||||||
} else {
|
} else if (sort === 'size') {
|
||||||
if (this.sizeIcon === 'arrow_upward') {
|
if (this.sizeIcon === 'arrow_upward') {
|
||||||
order = 'asc'
|
order = 'asc'
|
||||||
}
|
}
|
||||||
|
} else if (sort === 'modified') {
|
||||||
|
if (this.modifiedIcon === 'arrow_upward') {
|
||||||
|
order = 'asc'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let path = this.$store.state.baseURL
|
let path = this.$store.state.baseURL
|
||||||
|
19
file.go
19
file.go
@ -328,6 +328,8 @@ func (l listing) ApplySort() {
|
|||||||
sort.Sort(sort.Reverse(byName(l)))
|
sort.Sort(sort.Reverse(byName(l)))
|
||||||
case "size":
|
case "size":
|
||||||
sort.Sort(sort.Reverse(bySize(l)))
|
sort.Sort(sort.Reverse(bySize(l)))
|
||||||
|
case "modified":
|
||||||
|
sort.Sort(sort.Reverse(byModified(l)))
|
||||||
default:
|
default:
|
||||||
// If not one of the above, do nothing
|
// If not one of the above, do nothing
|
||||||
return
|
return
|
||||||
@ -338,6 +340,8 @@ func (l listing) ApplySort() {
|
|||||||
sort.Sort(byName(l))
|
sort.Sort(byName(l))
|
||||||
case "size":
|
case "size":
|
||||||
sort.Sort(bySize(l))
|
sort.Sort(bySize(l))
|
||||||
|
case "modified":
|
||||||
|
sort.Sort(byModified(l))
|
||||||
default:
|
default:
|
||||||
sort.Sort(byName(l))
|
sort.Sort(byName(l))
|
||||||
return
|
return
|
||||||
@ -348,6 +352,7 @@ func (l listing) ApplySort() {
|
|||||||
// Implement sorting for listing
|
// Implement sorting for listing
|
||||||
type byName listing
|
type byName listing
|
||||||
type bySize listing
|
type bySize listing
|
||||||
|
type byModified listing
|
||||||
|
|
||||||
// By Name
|
// By Name
|
||||||
func (l byName) Len() int {
|
func (l byName) Len() int {
|
||||||
@ -392,6 +397,20 @@ func (l bySize) Less(i, j int) bool {
|
|||||||
return iSize < jSize
|
return iSize < jSize
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// By Modified
|
||||||
|
func (l byModified) Len() int {
|
||||||
|
return len(l.Items)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l byModified) Swap(i, j int) {
|
||||||
|
l.Items[i], l.Items[j] = l.Items[j], l.Items[i]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l byModified) Less(i, j int) bool {
|
||||||
|
iModified, jModified := l.Items[i].ModTime, l.Items[j].ModTime
|
||||||
|
return iModified.Sub(jModified) < 0
|
||||||
|
}
|
||||||
|
|
||||||
var textExtensions = [...]string{
|
var textExtensions = [...]string{
|
||||||
".md", ".markdown", ".mdown", ".mmark",
|
".md", ".markdown", ".mdown", ".mmark",
|
||||||
".asciidoc", ".adoc", ".ad",
|
".asciidoc", ".adoc", ".ad",
|
||||||
|
Loading…
Reference in New Issue
Block a user