Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Ceph Webapp Poc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Jacopo Gasparetto
Ceph Webapp Poc
Commits
b95d56dc
Commit
b95d56dc
authored
1 year ago
by
Jacopo Gasparetto
Browse files
Options
Downloads
Patches
Plain Diff
Add objects count and total size for buckets
parent
2d44e462
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/src/routes/Buckets/index.tsx
+31
-10
31 additions, 10 deletions
frontend/src/routes/Buckets/index.tsx
with
31 additions
and
10 deletions
frontend/src/routes/Buckets/index.tsx
+
31
−
10
View file @
b95d56dc
...
...
@@ -2,17 +2,37 @@ import { useState } from 'react';
import
{
Page
}
from
'
../../components/Page
'
;
import
APIService
from
"
../../services/APIService
"
;
type
RWAccess
=
{
read
:
boolean
write
:
boolean
}
type
BucketInfo
=
{
Name
:
string
,
CreationDate
:
string
;
name
:
string
,
creation_date
:
string
;
detail
:
Object
rw_access
:
RWAccess
objects
:
number
,
size
:
number
}
const
getHumanSize
=
(
size
:
number
)
=>
{
if
(
size
<
1000
)
return
`
${
size
}
B`
;
if
(
size
<
1000000
)
return
`
${(
size
/
1000
).
toFixed
(
1
)}
kB`
;
if
(
size
<
1000000000
)
return
`
${(
size
/
1000000
).
toFixed
(
1
)}
MB`
;
if
(
size
<
1000000000000
)
return
`
${(
size
/
1000000000
).
toFixed
(
1
)}
GB`
;
}
const
BucketView
=
(
bucketInfo
:
BucketInfo
)
=>
{
const
creationDate
=
new
Date
(
bucketInfo
.
CreationDate
);
const
creationDate
=
new
Date
(
bucketInfo
.
creation_date
);
const
size_byte
=
bucketInfo
.
size
;
return
(
<
div
className
=
"bg-slate-100 w-2/3 mb-4 p-4 rounded-lg"
>
<
h1
className
=
"text-2xl font-bold mb-2"
>
{
bucketInfo
.
Name
}
</
h1
>
<
h1
className
=
"text-2xl font-bold mb-2"
>
{
bucketInfo
.
name
}
</
h1
>
<
hr
className
=
"mb-2"
></
hr
>
<
p
>
Created:
{
creationDate
.
toString
()
}
</
p
>
<
p
><
b
>
Usage
</
b
>
:
{
getHumanSize
(
bucketInfo
.
size
)
}
</
p
>
<
p
><
b
>
Object
</
b
>
:
{
bucketInfo
.
objects
}
</
p
>
</
div
>
)
}
...
...
@@ -26,18 +46,19 @@ export const Buckets = () => {
APIService
.
get
(
"
buckets
"
)
.
then
(
data
=>
{
console
.
log
(
data
);
setBucketLists
(
data
[
"
B
uckets
"
]);
setBucketLists
(
data
[
"
b
uckets
"
]);
});
}
return
(
<
Page
title
=
'Buckets'
>
{
buckestList
.
map
(
bucketInfo
=>
{
buckestList
?
buckestList
.
map
(
bucketInfo
=>
<
BucketView
key
=
{
bucketInfo
.
N
ame
+
bucketInfo
.
C
reation
D
ate
}
Name
=
{
bucketInfo
.
Name
}
CreationDate
=
{
bucketInfo
.
CreationDate
}
/>
)
}
key
=
{
bucketInfo
.
n
ame
+
bucketInfo
.
c
reation
_d
ate
}
{
...
bucketInfo
}
/>
)
:
null
}
</
Page
>
)
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment