mirror of
https://github.com/minio/minio.git
synced 2025-04-20 10:37:31 -04:00
parent
423aeb0d81
commit
9407dbf387
@ -26,13 +26,10 @@ export class StorageInfo extends React.Component {
|
|||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
const { used } = this.props.storageInfo
|
const { used } = this.props.storageInfo
|
||||||
|
if (!used || used == 0) {
|
||||||
if (!used) {
|
|
||||||
return <noscript />
|
return <noscript />
|
||||||
}
|
}
|
||||||
|
|
||||||
const totalUsed = used.reduce((v1, v2) => v1 + v2, 0)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="feh-used">
|
<div className="feh-used">
|
||||||
<div className="fehu-chart">
|
<div className="fehu-chart">
|
||||||
@ -41,7 +38,7 @@ export class StorageInfo extends React.Component {
|
|||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<span>Used: </span>
|
<span>Used: </span>
|
||||||
{humanize.filesize(totalUsed)}
|
{humanize.filesize(used)}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -21,7 +21,7 @@ import { StorageInfo } from "../StorageInfo"
|
|||||||
describe("StorageInfo", () => {
|
describe("StorageInfo", () => {
|
||||||
it("should render without crashing", () => {
|
it("should render without crashing", () => {
|
||||||
shallow(
|
shallow(
|
||||||
<StorageInfo storageInfo={{ used: [60] }} fetchStorageInfo={jest.fn()} />
|
<StorageInfo storageInfo={ {used: 60} } fetchStorageInfo={jest.fn()} />
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ describe("StorageInfo", () => {
|
|||||||
const fetchStorageInfo = jest.fn()
|
const fetchStorageInfo = jest.fn()
|
||||||
shallow(
|
shallow(
|
||||||
<StorageInfo
|
<StorageInfo
|
||||||
storageInfo={{ used: [60] }}
|
storageInfo={ {used: 60} }
|
||||||
fetchStorageInfo={fetchStorageInfo}
|
fetchStorageInfo={fetchStorageInfo}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
@ -40,7 +40,7 @@ describe("StorageInfo", () => {
|
|||||||
const fetchStorageInfo = jest.fn()
|
const fetchStorageInfo = jest.fn()
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<StorageInfo
|
<StorageInfo
|
||||||
storageInfo={{ used: null }}
|
storageInfo={ {used: 0} }
|
||||||
fetchStorageInfo={fetchStorageInfo}
|
fetchStorageInfo={fetchStorageInfo}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
@ -20,7 +20,9 @@ import * as actionsCommon from "../actions"
|
|||||||
|
|
||||||
jest.mock("../../web", () => ({
|
jest.mock("../../web", () => ({
|
||||||
StorageInfo: jest.fn(() => {
|
StorageInfo: jest.fn(() => {
|
||||||
return Promise.resolve({ storageInfo: { Used: [60] } })
|
return Promise.resolve({
|
||||||
|
used: 60
|
||||||
|
})
|
||||||
}),
|
}),
|
||||||
ServerInfo: jest.fn(() => {
|
ServerInfo: jest.fn(() => {
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
@ -39,7 +41,7 @@ describe("Common actions", () => {
|
|||||||
it("creates common/SET_STORAGE_INFO after fetching the storage details ", () => {
|
it("creates common/SET_STORAGE_INFO after fetching the storage details ", () => {
|
||||||
const store = mockStore()
|
const store = mockStore()
|
||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{ type: "common/SET_STORAGE_INFO", storageInfo: { used: [60] } }
|
{ type: "common/SET_STORAGE_INFO", storageInfo: { used: 60 } }
|
||||||
]
|
]
|
||||||
return store.dispatch(actionsCommon.fetchStorageInfo()).then(() => {
|
return store.dispatch(actionsCommon.fetchStorageInfo()).then(() => {
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
|
@ -21,11 +21,7 @@ describe("common reducer", () => {
|
|||||||
it("should return the initial state", () => {
|
it("should return the initial state", () => {
|
||||||
expect(reducer(undefined, {})).toEqual({
|
expect(reducer(undefined, {})).toEqual({
|
||||||
sidebarOpen: false,
|
sidebarOpen: false,
|
||||||
storageInfo: {
|
storageInfo: {used: 0},
|
||||||
total: [0],
|
|
||||||
free: [0],
|
|
||||||
used: [0]
|
|
||||||
},
|
|
||||||
serverInfo: {}
|
serverInfo: {}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -62,11 +58,11 @@ describe("common reducer", () => {
|
|||||||
{},
|
{},
|
||||||
{
|
{
|
||||||
type: actionsCommon.SET_STORAGE_INFO,
|
type: actionsCommon.SET_STORAGE_INFO,
|
||||||
storageInfo: { total: [100], free: [40] }
|
storageInfo: { }
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
).toEqual({
|
).toEqual({
|
||||||
storageInfo: { total: [100], free: [40] }
|
storageInfo: { }
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -33,8 +33,7 @@ export const fetchStorageInfo = () => {
|
|||||||
return function(dispatch) {
|
return function(dispatch) {
|
||||||
return web.StorageInfo().then(res => {
|
return web.StorageInfo().then(res => {
|
||||||
const storageInfo = {
|
const storageInfo = {
|
||||||
total: res.storageInfo.Total,
|
used: res.used
|
||||||
used: res.storageInfo.Used
|
|
||||||
}
|
}
|
||||||
dispatch(setStorageInfo(storageInfo))
|
dispatch(setStorageInfo(storageInfo))
|
||||||
})
|
})
|
||||||
|
@ -19,7 +19,7 @@ import * as actionsCommon from "./actions"
|
|||||||
export default (
|
export default (
|
||||||
state = {
|
state = {
|
||||||
sidebarOpen: false,
|
sidebarOpen: false,
|
||||||
storageInfo: { total: [0], free: [0], used: [0] },
|
storageInfo: {used: 0},
|
||||||
serverInfo: {}
|
serverInfo: {}
|
||||||
},
|
},
|
||||||
action
|
action
|
||||||
|
@ -114,7 +114,7 @@ func (web *webAPIHandlers) ServerInfo(r *http.Request, args *WebGenericArgs, rep
|
|||||||
|
|
||||||
// StorageInfoRep - contains storage usage statistics.
|
// StorageInfoRep - contains storage usage statistics.
|
||||||
type StorageInfoRep struct {
|
type StorageInfoRep struct {
|
||||||
StorageInfo StorageInfo `json:"storageInfo"`
|
Used uint64 `json:"used"`
|
||||||
UIVersion string `json:"uiVersion"`
|
UIVersion string `json:"uiVersion"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +129,8 @@ func (web *webAPIHandlers) StorageInfo(r *http.Request, args *WebGenericArgs, re
|
|||||||
if authErr != nil {
|
if authErr != nil {
|
||||||
return toJSONError(ctx, authErr)
|
return toJSONError(ctx, authErr)
|
||||||
}
|
}
|
||||||
reply.StorageInfo, _ = objectAPI.StorageInfo(ctx, false)
|
dataUsageInfo, _ := loadDataUsageFromBackend(ctx, objectAPI)
|
||||||
|
reply.Used = dataUsageInfo.ObjectsTotalSize
|
||||||
reply.UIVersion = browser.UIVersion
|
reply.UIVersion = browser.UIVersion
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user