added file size
This commit is contained in:
parent
c20e894d52
commit
a24ed03e1f
@ -10,10 +10,10 @@ const DirectoryElement: React.FC<Props> = (props) => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<td>
|
<td>
|
||||||
📂
|
📂 {props.dir.name}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{props.dir.name}
|
|
||||||
</td>
|
</td>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
@ -16,15 +16,14 @@ const FileBrowser: React.FC = () => {
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Breadcrum path={path} onDirClick={(newPath)=>{
|
<Breadcrum path={path} onDirClick={(newPath)=>{
|
||||||
console.debug(newPath)
|
|
||||||
setPath(newPath)
|
setPath(newPath)
|
||||||
}}/>
|
}}/>
|
||||||
<div>
|
<div>
|
||||||
<table className="table table-striped table-hover">
|
<table className="table table-striped table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Icon</th>
|
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
|
<th>Size</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import React from "react"
|
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"
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
file: File
|
file: File
|
||||||
@ -10,10 +11,10 @@ const FileElement: React.FC<Props> = (props) => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<td>
|
<td>
|
||||||
📄
|
📄 {props.file.name}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{props.file.name}
|
{sizeToReadable(props.file.size)}
|
||||||
</td>
|
</td>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
7
src/functions/sizeToReadable.ts
Normal file
7
src/functions/sizeToReadable.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
function sizeToReadable(size: number): string {
|
||||||
|
const i = Math.floor(Math.log(size) / Math.log(1024))
|
||||||
|
return (size / Math.pow(1024, i)).toFixed(2) + " " + ["B", "kB", "MB", "GB", "TB"][i]
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default sizeToReadable
|
@ -33,7 +33,7 @@ export type File = {
|
|||||||
id: Scalars["ID"];
|
id: Scalars["ID"];
|
||||||
name?: Maybe<Scalars["String"]>;
|
name?: Maybe<Scalars["String"]>;
|
||||||
parent?: Maybe<Directory>;
|
parent?: Maybe<Directory>;
|
||||||
size?: Maybe<Scalars["Int"]>;
|
size: Scalars["Int"];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type RootQuery = {
|
export type RootQuery = {
|
||||||
@ -67,7 +67,7 @@ export type OpenDirQuery = (
|
|||||||
{ __typename?: "RootQuery" }
|
{ __typename?: "RootQuery" }
|
||||||
& { files: Array<Maybe<(
|
& { files: Array<Maybe<(
|
||||||
{ __typename?: "File" }
|
{ __typename?: "File" }
|
||||||
& Pick<File, "id" | "name">
|
& Pick<File, "id" | "name" | "size">
|
||||||
)>>, directorys: Array<Maybe<(
|
)>>, directorys: Array<Maybe<(
|
||||||
{ __typename?: "Directory" }
|
{ __typename?: "Directory" }
|
||||||
& Pick<Directory, "id" | "name">
|
& Pick<Directory, "id" | "name">
|
||||||
@ -80,6 +80,7 @@ export const OpenDirDocument = gql`
|
|||||||
files(path: $path) {
|
files(path: $path) {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
|
size
|
||||||
}
|
}
|
||||||
directorys(path: $path) {
|
directorys(path: $path) {
|
||||||
id
|
id
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -2,6 +2,7 @@ query openDir($path: String!) {
|
|||||||
files(path:$path){
|
files(path:$path){
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
|
size
|
||||||
}
|
}
|
||||||
directorys(path: $path){
|
directorys(path: $path){
|
||||||
id
|
id
|
||||||
|
Loading…
Reference in New Issue
Block a user