added last modified field
This commit is contained in:
parent
21ae838025
commit
da85c3070c
@ -13,7 +13,8 @@ const DirectoryElement: React.FC<Props> = (props) => {
|
|||||||
📂 {props.dir.name}
|
📂 {props.dir.name}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
</td>
|
</td>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
@ -46,6 +46,7 @@ const FileBrowser: React.FC = () => {
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
|
<th>Last Modified</th>
|
||||||
<th>Size</th>
|
<th>Size</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -2,6 +2,7 @@ import React from "react"
|
|||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
import { File } from "../generated/graphql"
|
import { File } from "../generated/graphql"
|
||||||
import sizeToReadable from "../functions/sizeToReadable"
|
import sizeToReadable from "../functions/sizeToReadable"
|
||||||
|
import dateFormat from "../functions/dateFomat"
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
file: File
|
file: File
|
||||||
@ -13,9 +14,13 @@ const FileElement: React.FC<Props> = (props) => {
|
|||||||
<td>
|
<td>
|
||||||
📄 {props.file.name}
|
📄 {props.file.name}
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
{dateFormat(props.file.lastModified)}
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{sizeToReadable(props.file.size)}
|
{sizeToReadable(props.file.size)}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
19
src/functions/dateFomat.ts
Normal file
19
src/functions/dateFomat.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/**
|
||||||
|
* Transforms the DateTime given from the api to a human readable format
|
||||||
|
* @param date Date in ISO 8601 fomat
|
||||||
|
*/
|
||||||
|
function dateFormat(date:string | undefined | null): string {
|
||||||
|
if (!date) return ""
|
||||||
|
|
||||||
|
const parsedDate = new Date(date)
|
||||||
|
const now = new Date()
|
||||||
|
|
||||||
|
if (parsedDate.toDateString() === now.toDateString()){
|
||||||
|
return parsedDate.toLocaleTimeString()
|
||||||
|
}else{
|
||||||
|
return parsedDate.toLocaleDateString()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default dateFormat
|
@ -3,6 +3,7 @@ query openDir($path: String!) {
|
|||||||
id
|
id
|
||||||
name
|
name
|
||||||
size
|
size
|
||||||
|
lastModified
|
||||||
}
|
}
|
||||||
directorys(path: $path){
|
directorys(path: $path){
|
||||||
id
|
id
|
||||||
|
Loading…
Reference in New Issue
Block a user