add modtime column

This commit is contained in:
controlol 2021-11-02 21:07:49 +01:00
parent 322af54ec6
commit b5f42a7a28
2 changed files with 21 additions and 19 deletions

View File

@ -84,7 +84,7 @@ const BrowserWrapper = styled.div`
const GridFileBrowser = styled.div` const GridFileBrowser = styled.div`
display: grid; display: grid;
grid-template-columns: 1px 1fr 6rem; grid-template-columns: 1px 1fr 10rem 6rem;
align-items: center; align-items: center;
gap: .5rem 1.5rem; gap: .5rem 1.5rem;
width: 100%; width: 100%;
@ -144,21 +144,21 @@ const DirNameP = styled(FilenameP)`
cursor: pointer; cursor: pointer;
` `
// const ModifiedP = styled(EllipsisP)` const ModifiedP = styled(EllipsisP)`
// @media screen and (max-width: 1100px) { @media screen and (max-width: 1100px) {
// display: none; display: none;
// } }
// @media screen and (max-width: 800px) { @media screen and (max-width: 800px) {
// display: initial; display: initial;
// } }
// @media screen and (max-width: 600px) { @media screen and (max-width: 600px) {
// display: none; display: none;
// } }
// @media screen and (min-width: 1100px) { @media screen and (min-width: 1100px) {
// display: initial; display: initial;
// } }
// ` `
const SizeP = styled.p` const SizeP = styled.p`
@media screen and (max-width: 600px) { @media screen and (max-width: 600px) {
@ -434,7 +434,7 @@ class FileBrowser extends Component {
: :
<FilenameP onContextMenu={this.openMenu}>{ v.Name }</FilenameP> <FilenameP onContextMenu={this.openMenu}>{ v.Name }</FilenameP>
} }
{/* <ModifiedP> { v.modified.toLocaleString() } </ModifiedP> */} <ModifiedP> { v.ModTime?.toLocaleString() } </ModifiedP>
<SizeP> { !v.IsDir ? bytesToString(v.Size, {}) : "" } </SizeP> <SizeP> { !v.IsDir ? bytesToString(v.Size, {}) : "" } </SizeP>
</Fragment> </Fragment>
)) ))
@ -452,7 +452,7 @@ class FileBrowser extends Component {
// sort by name // sort by name
.sort((a,b) => this.state.orderBy === "name" ? this.state.orderAscending ? a.Name.localeCompare(b.Name, 'nl', { sensitivity: 'base' }) : b.Name.localeCompare(a.Name, 'nl', { sensitivity: 'base' }) : 0) .sort((a,b) => this.state.orderBy === "name" ? this.state.orderAscending ? a.Name.localeCompare(b.Name, 'nl', { sensitivity: 'base' }) : b.Name.localeCompare(a.Name, 'nl', { sensitivity: 'base' }) : 0)
// // sort by modified date // // sort by modified date
// .sort((a,b) => this.state.orderBy === "modified" ? this.state.orderAscending ? a.modified - b.modified : b.modified - a.modified : 0) .sort((a,b) => this.state.orderBy === "modified" ? this.state.orderAscending ? a.ModTime - b.ModTime : b.ModTime - a.ModTime : 0)
// sort by size // sort by size
.sort((a,b) => this.state.orderBy === "size" ? this.state.orderAscending ? a.Size - b.Size : b.Size - a.Size : 0) .sort((a,b) => this.state.orderBy === "size" ? this.state.orderAscending ? a.Size - b.Size : b.Size - a.Size : 0)
// // sort folders to top // // sort folders to top
@ -534,7 +534,7 @@ class FileBrowser extends Component {
/> />
} }
</FilenameP> </FilenameP>
{/* <ModifiedP onClick={() => this.updateOrder("modified")} style={{ position: "relative", cursor: "pointer" }}> <ModifiedP onClick={() => this.updateOrder("modified")} style={{ position: "relative", cursor: "pointer" }}>
modified modified
{ {
orderBy === "modified" && orderBy === "modified" &&
@ -548,7 +548,7 @@ class FileBrowser extends Component {
}} }}
/> />
} }
</ModifiedP> */} </ModifiedP>
<SizeP onClick={() => this.updateOrder("size")} style={{ position: "relative", cursor: "pointer" }}> <SizeP onClick={() => this.updateOrder("size")} style={{ position: "relative", cursor: "pointer" }}>
size size
{ {

View File

@ -69,6 +69,8 @@ class FileBrowserMenu extends Component {
.then(response => { .then(response => {
if (typeof response.data.list !== "object") return reject(new Error("Invalid response")) if (typeof response.data.list !== "object") return reject(new Error("Invalid response"))
response.data.list.forEach(v => v.ModTime = new Date(v.ModTime))
let { files } = this.state let { files } = this.state
files[brIndex] = response.data.list files[brIndex] = response.data.list
loading[brIndex] = false loading[brIndex] = false