Skip to content

Commit e8491d8

Browse files
authored
Add size info to bucket list api (#122)
Using madmin.AccountUsageInfo since that api includes size already. Also includes integration with UI.
1 parent 35c3b53 commit e8491d8

File tree

8 files changed

+214
-188
lines changed

8 files changed

+214
-188
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ require (
1717
github.com/jessevdk/go-flags v1.4.0
1818
github.com/json-iterator/go v1.1.9
1919
github.com/minio/cli v1.22.0
20-
github.com/minio/mc v0.0.0-20200515191050-09c31c4ab28c
21-
github.com/minio/minio v0.0.0-20200501193630-d1c8e9f31ba0
20+
github.com/minio/mc v0.0.0-20200515235434-3b479cf92ed6
21+
github.com/minio/minio v0.0.0-20200516011754-9cac385aecdb
2222
github.com/minio/minio-go/v6 v6.0.56-0.20200502013257-a81c8c13cc3f
2323
github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 // indirect
2424
github.com/satori/go.uuid v1.2.0

go.sum

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
239239
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
240240
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
241241
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
242+
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
242243
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
243244
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
244245
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
@@ -338,12 +339,16 @@ github.com/klauspost/compress v1.10.3 h1:OP96hzwJVBIHYU52pVTI6CczrxPvrGfgqF9N5eT
338339
github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
339340
github.com/klauspost/cpuid v1.2.2 h1:1xAgYebNnsb9LKCdLOvFWtAxGU/33mjJtyOVbmUa0Us=
340341
github.com/klauspost/cpuid v1.2.2/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
342+
github.com/klauspost/cpuid v1.2.4 h1:EBfaK0SWSwk+fgk6efYFWdzl8MwRWoOO1gkmiaTXPW4=
343+
github.com/klauspost/cpuid v1.2.4/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
341344
github.com/klauspost/pgzip v1.2.1 h1:oIPZROsWuPHpOdMVWLuJZXwgjhrW8r1yEX8UqMyeNHM=
342345
github.com/klauspost/pgzip v1.2.1/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
343346
github.com/klauspost/readahead v1.3.1 h1:QqXNYvm+VvqYcbrRT4LojUciM0XrznFRIDrbHiJtu/0=
344347
github.com/klauspost/readahead v1.3.1/go.mod h1:AH9juHzNH7xqdqFHrMRSHeH2Ps+vFf+kblDqzPFiLJg=
345348
github.com/klauspost/reedsolomon v1.9.3 h1:N/VzgeMfHmLc+KHMD1UL/tNkfXAt8FnUqlgXGIduwAY=
346349
github.com/klauspost/reedsolomon v1.9.3/go.mod h1:CwCi+NUr9pqSVktrkN+Ondf06rkhYZ/pcNv7fu+8Un4=
350+
github.com/klauspost/reedsolomon v1.9.7 h1:+azeqnT4iNG9UEcWC+7utJ4xXQ9S8pSlkZor0DOArEQ=
351+
github.com/klauspost/reedsolomon v1.9.7/go.mod h1:+8WD025Xpby8/kG5h/HDPIFhiiuGEtZOKw+5Y4drAD8=
347352
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
348353
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
349354
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
@@ -399,15 +404,14 @@ github.com/minio/highwayhash v1.0.0 h1:iMSDhgUILCr0TNm8LWlSjF8N0ZIj2qbO8WHp6Q/J2
399404
github.com/minio/highwayhash v1.0.0/go.mod h1:xQboMTeM9nY9v/LlAOxFctujiv5+Aq2hR5dxBpaMbdc=
400405
github.com/minio/lsync v1.0.1 h1:AVvILxA976xc27hstd1oR+X9PQG0sPSom1MNb1ImfUs=
401406
github.com/minio/lsync v1.0.1/go.mod h1:tCFzfo0dlvdGl70IT4IAK/5Wtgb0/BrTmo/jE8pArKA=
402-
github.com/minio/mc v0.0.0-20200515191050-09c31c4ab28c h1:G4ZTNwiiJ73folxqNXZpWQofxus2fGJG7hKxYNrtvRM=
403-
github.com/minio/mc v0.0.0-20200515191050-09c31c4ab28c/go.mod h1:U3Jgk0bcSjn+QPUMisrS6nxCWOoQ6rYWSvLCB30apuU=
407+
github.com/minio/mc v0.0.0-20200515235434-3b479cf92ed6 h1:2SrKe2vLDLwvnYkYrJelrzyGW8t/8HCbr9yDsw+8XSI=
408+
github.com/minio/mc v0.0.0-20200515235434-3b479cf92ed6/go.mod h1:U3Jgk0bcSjn+QPUMisrS6nxCWOoQ6rYWSvLCB30apuU=
404409
github.com/minio/minio v0.0.0-20200421050159-282c9f790a03/go.mod h1:zBua5AiljGs1Irdl2XEyiJjvZVCVDIG8gjozzRBcVlw=
405-
github.com/minio/minio v0.0.0-20200501193630-d1c8e9f31ba0 h1:QxIz36O01LbKqJiz6HKeKCOC2afgydspkpahQ807msY=
406-
github.com/minio/minio v0.0.0-20200501193630-d1c8e9f31ba0/go.mod h1:Vhlqz7Se0EgpgFiVxpvzF4Zz/h2LMx+EPKH96Aera5U=
410+
github.com/minio/minio v0.0.0-20200516011754-9cac385aecdb h1:CQC7D3UDnUycuxhwImcVhMSLet/RbShosAnYcvMtEB8=
411+
github.com/minio/minio v0.0.0-20200516011754-9cac385aecdb/go.mod h1:wymaytM/HELuwdz7BGZHmQ3XKq2SxPsLeGxyOCaCLiA=
407412
github.com/minio/minio-go/v6 v6.0.53 h1:8jzpwiOzZ5Iz7/goFWqNZRICbyWYShbb5rARjrnSCNI=
408413
github.com/minio/minio-go/v6 v6.0.53/go.mod h1:DIvC/IApeHX8q1BAMVCXSXwpmrmM+I+iBvhvztQorfI=
409-
github.com/minio/minio-go/v6 v6.0.55-0.20200424204115-7506d2996b22 h1:nZEve4vdUhwHBoV18zRvPDgjL6NYyDJE5QJvz3l9bRs=
410-
github.com/minio/minio-go/v6 v6.0.55-0.20200424204115-7506d2996b22/go.mod h1:KQMM+/44DSlSGSQWSfRrAZ12FVMmpWNuX37i2AX0jfI=
414+
github.com/minio/minio-go/v6 v6.0.55-0.20200425081427-89eebdef2af0/go.mod h1:KQMM+/44DSlSGSQWSfRrAZ12FVMmpWNuX37i2AX0jfI=
411415
github.com/minio/minio-go/v6 v6.0.56-0.20200502013257-a81c8c13cc3f h1:ifHrI8+exqLi5RztIWWKS5k+Wu+W7DJisVXwNaCH2zs=
412416
github.com/minio/minio-go/v6 v6.0.56-0.20200502013257-a81c8c13cc3f/go.mod h1:KQMM+/44DSlSGSQWSfRrAZ12FVMmpWNuX37i2AX0jfI=
413417
github.com/minio/parquet-go v0.0.0-20200414234858-838cfa8aae61 h1:pUSI/WKPdd77gcuoJkSzhJ4wdS8OMDOsOu99MtpXEQA=
@@ -609,11 +613,19 @@ go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
609613
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
610614
go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU=
611615
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
616+
go.uber.org/atomic v1.6.0 h1:Ezj3JGmsOnG1MoRWQkPBsKLe9DwWD9QeXzTRzzldNVk=
617+
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
612618
go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI=
613619
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
620+
go.uber.org/multierr v1.5.0 h1:KCa4XfM8CWFCpxXRGok+Q0SS/0XBhMDbHHGABQLvD2A=
621+
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
622+
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4=
623+
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
614624
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
615625
go.uber.org/zap v1.11.0 h1:gSmpCfs+R47a4yQPAI4xJ0IPDLTRGXskm6UelqNXpqE=
616626
go.uber.org/zap v1.11.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
627+
go.uber.org/zap v1.15.0 h1:ZZCA22JRF2gQE5FoNmhmrf7jeJJ2uhqDUNRYKm8dvmM=
628+
go.uber.org/zap v1.15.0/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc=
617629
golang.org/x/arch v0.0.0-20190909030613-46d78d1859ac/go.mod h1:flIaEI6LNU6xOCD5PaJvn9wGP0agmIOqjrtsKGRguv4=
618630
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
619631
golang.org/x/crypto v0.0.0-20181106171534-e4dc69e5b2fd/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
@@ -622,6 +634,7 @@ golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576/go.mod h1:djNgcEr1/C05ACk
622634
golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
623635
golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
624636
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
637+
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
625638
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
626639
golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
627640
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
@@ -637,6 +650,9 @@ golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTk
637650
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
638651
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
639652
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
653+
golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs=
654+
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
655+
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
640656
golang.org/x/mod v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ=
641657
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
642658
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -717,8 +733,11 @@ golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBn
717733
golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
718734
golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
719735
golang.org/x/tools v0.0.0-20190617190820-da514acc4774/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
736+
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
720737
golang.org/x/tools v0.0.0-20190914235951-31e00f45c22e h1:nOOVVcLC+/3MeovP40q5lCiWmP1Z1DaN8yn8ngU63hw=
721738
golang.org/x/tools v0.0.0-20190914235951-31e00f45c22e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
739+
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
740+
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
722741
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
723742
golang.org/x/tools v0.0.0-20200428211428-0c9eba77bc32 h1:Xvf3ZQTm5bjXPxhI7g+dwqsCqadK1rcNtwtszuatetk=
724743
golang.org/x/tools v0.0.0-20200428211428-0c9eba77bc32/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
@@ -788,4 +807,6 @@ gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
788807
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
789808
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
790809
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
810+
honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM=
811+
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
791812
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=

portal-ui/bindata_assetfs.go

Lines changed: 98 additions & 121 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

portal-ui/src/common/utils.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,17 @@
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
export const units = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
17+
export const units = [
18+
"B",
19+
"KiB",
20+
"MiB",
21+
"GiB",
22+
"TiB",
23+
"PiB",
24+
"EiB",
25+
"ZiB",
26+
"YiB",
27+
];
1828
export const niceBytes = (x: string) => {
1929
let l = 0,
2030
n = parseInt(x, 10) || 0;

portal-ui/src/screens/Console/Buckets/ListBuckets/ListBuckets.tsx

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,49 +30,50 @@ import AddBucket from "./AddBucket";
3030
import DeleteBucket from "./DeleteBucket";
3131
import { MinTablePaginationActions } from "../../../../common/MinTablePaginationActions";
3232
import { CreateIcon } from "../../../../icons";
33+
import { niceBytes } from "../../../../common/utils";
3334

3435
const styles = (theme: Theme) =>
3536
createStyles({
3637
seeMore: {
37-
marginTop: theme.spacing(3)
38+
marginTop: theme.spacing(3),
3839
},
3940
paper: {
4041
display: "flex",
4142
overflow: "auto",
42-
flexDirection: "column"
43+
flexDirection: "column",
4344
},
4445

4546
addSideBar: {
4647
width: "320px",
47-
padding: "20px"
48+
padding: "20px",
4849
},
4950
errorBlock: {
50-
color: "red"
51+
color: "red",
5152
},
5253
tableToolbar: {
5354
paddingLeft: theme.spacing(2),
54-
paddingRight: theme.spacing(0)
55+
paddingRight: theme.spacing(0),
5556
},
5657
minTableHeader: {
5758
color: "#393939",
5859
"& tr": {
5960
"& th": {
60-
fontWeight: "bold"
61-
}
62-
}
61+
fontWeight: "bold",
62+
},
63+
},
6364
},
6465
actionsTray: {
6566
textAlign: "right",
6667
"& button": {
67-
marginLeft: 10
68-
}
68+
marginLeft: 10,
69+
},
6970
},
7071
searchField: {
7172
background: "#FFFFFF",
7273
padding: 12,
7374
borderRadius: 5,
74-
boxShadow: "0px 3px 6px #00000012"
75-
}
75+
boxShadow: "0px 3px 6px #00000012",
76+
},
7677
});
7778

7879
interface IListBucketsProps {
@@ -108,7 +109,7 @@ class ListBuckets extends React.Component<
108109
rowsPerPage: 10,
109110
deleteOpen: false,
110111
selectedBucket: "",
111-
filterBuckets: ""
112+
filterBuckets: "",
112113
};
113114

114115
fetchRecords() {
@@ -122,7 +123,7 @@ class ListBuckets extends React.Component<
122123
loading: false,
123124
records: res.buckets || [],
124125
totalRecords: !res.buckets ? 0 : res.total,
125-
error: ""
126+
error: "",
126127
});
127128
// if we get 0 results, and page > 0 , go down 1 page
128129
if (
@@ -174,7 +175,7 @@ class ListBuckets extends React.Component<
174175
rowsPerPage,
175176
deleteOpen,
176177
selectedBucket,
177-
filterBuckets
178+
filterBuckets,
178179
} = this.state;
179180

180181
const offset = page * rowsPerPage;
@@ -196,7 +197,7 @@ class ListBuckets extends React.Component<
196197

197198
const tableActions = [
198199
{ type: "view", to: `/buckets`, sendOnlyId: true },
199-
{ type: "delete", onClick: confirmDeleteBucket, sendOnlyId: true }
200+
{ type: "delete", onClick: confirmDeleteBucket, sendOnlyId: true },
200201
];
201202

202203
const displayParsedDate = (date: string) => {
@@ -249,9 +250,9 @@ class ListBuckets extends React.Component<
249250
className={classes.searchField}
250251
id="search-resource"
251252
label=""
252-
onChange={val => {
253+
onChange={(val) => {
253254
this.setState({
254-
filterBuckets: val.target.value
255+
filterBuckets: val.target.value,
255256
});
256257
}}
257258
InputProps={{
@@ -260,7 +261,7 @@ class ListBuckets extends React.Component<
260261
<InputAdornment position="start">
261262
<SearchIcon />
262263
</InputAdornment>
263-
)
264+
),
264265
}}
265266
/>
266267
<Button
@@ -269,7 +270,7 @@ class ListBuckets extends React.Component<
269270
startIcon={<CreateIcon />}
270271
onClick={() => {
271272
this.setState({
272-
addScreenOpen: true
273+
addScreenOpen: true,
273274
});
274275
}}
275276
>
@@ -287,8 +288,13 @@ class ListBuckets extends React.Component<
287288
{
288289
label: "Creation Date",
289290
elementKey: "creation_date",
290-
renderFunction: displayParsedDate
291-
}
291+
renderFunction: displayParsedDate,
292+
},
293+
{
294+
label: "Size",
295+
elementKey: "size",
296+
renderFunction: niceBytes,
297+
},
292298
]}
293299
isLoading={loading}
294300
records={filteredRecords}
@@ -302,11 +308,11 @@ class ListBuckets extends React.Component<
302308
page: page,
303309
SelectProps: {
304310
inputProps: { "aria-label": "rows per page" },
305-
native: true
311+
native: true,
306312
},
307313
onChangePage: handleChangePage,
308314
onChangeRowsPerPage: handleChangeRowsPerPage,
309-
ActionsComponent: MinTablePaginationActions
315+
ActionsComponent: MinTablePaginationActions,
310316
}}
311317
/>
312318
</Grid>

restapi/client-admin.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ type MinioAdmin interface {
8484
stopProfiling(ctx context.Context) (io.ReadCloser, error)
8585
serviceTrace(ctx context.Context, allTrace, errTrace bool) <-chan madmin.ServiceTraceInfo
8686
getLogs(ctx context.Context, node string, lineCnt int, logKind string) <-chan madmin.LogInfo
87+
accountUsageInfo(ctx context.Context) (madmin.AccountUsageInfo, error)
8788
// Service Accounts
8889
addServiceAccount(ctx context.Context, policy *iampolicy.Policy) (mauth.Credentials, error)
8990
listServiceAccounts(ctx context.Context) (madmin.ListServiceAccountsResp, error)
@@ -228,6 +229,11 @@ func (ac adminClient) deleteServiceAccount(ctx context.Context, serviceAccount s
228229
return ac.client.DeleteServiceAccount(ctx, serviceAccount)
229230
}
230231

232+
// implements madmin.AccountingUsageInfo()
233+
func (ac adminClient) accountUsageInfo(ctx context.Context) (madmin.AccountUsageInfo, error) {
234+
return ac.client.AccountUsageInfo(ctx)
235+
}
236+
231237
func newMAdminClient(jwt string) (*madmin.AdminClient, error) {
232238
claims, err := auth.JWTAuthenticate(jwt)
233239
if err != nil {

restapi/user_buckets.go

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,43 +82,39 @@ func registerBucketsHandlers(api *operations.McsAPI) {
8282
})
8383
}
8484

85-
// listBuckets fetches a list of all buckets from MinIO Servers
86-
func listBuckets(ctx context.Context, client MinioClient) ([]*models.Bucket, error) {
87-
// Get list of all buckets owned by an authenticated user.
88-
// This call requires explicit authentication, no anonymous requests are
89-
// allowed for listing buckets.
90-
buckets, err := client.listBucketsWithContext(ctx)
85+
// getaAcountUsageInfo fetches a list of all buckets allowed to that particular client from MinIO Servers
86+
func getaAcountUsageInfo(ctx context.Context, client MinioAdmin) ([]*models.Bucket, error) {
87+
info, err := client.accountUsageInfo(ctx)
9188
if err != nil {
9289
return []*models.Bucket{}, err
9390
}
94-
9591
var bucketInfos []*models.Bucket
96-
for _, bucket := range buckets {
97-
bucketElem := &models.Bucket{Name: swag.String(bucket.Name), CreationDate: bucket.CreationDate.String()}
92+
for _, bucket := range info.Buckets {
93+
bucketElem := &models.Bucket{Name: swag.String(bucket.Name), CreationDate: bucket.Created.String(), Size: int64(bucket.Size)}
9894
bucketInfos = append(bucketInfos, bucketElem)
9995
}
100-
10196
return bucketInfos, nil
10297
}
10398

10499
// getListBucketsResponse performs listBuckets() and serializes it to the handler's output
105100
func getListBucketsResponse(sessionID string) (*models.ListBucketsResponse, error) {
106101
ctx, cancel := context.WithTimeout(context.Background(), time.Second*20)
107102
defer cancel()
108-
mClient, err := newMinioClient(sessionID)
103+
104+
mAdmin, err := newMAdminClient(sessionID)
109105
if err != nil {
110-
log.Println("error creating MinIO Client:", err)
106+
log.Println("error creating Madmin Client:", err)
111107
return nil, err
112108
}
113109
// create a minioClient interface implementation
114110
// defining the client to be used
115-
minioClient := minioClient{client: mClient}
116-
117-
buckets, err := listBuckets(ctx, minioClient)
111+
adminClient := adminClient{client: mAdmin}
112+
buckets, err := getaAcountUsageInfo(ctx, adminClient)
118113
if err != nil {
119-
log.Println("error listing buckets:", err)
114+
log.Println("error accountingUsageInfo:", err)
120115
return nil, err
121116
}
117+
122118
// serialize output
123119
listBucketsResponse := &models.ListBucketsResponse{
124120
Buckets: buckets,

0 commit comments

Comments
 (0)