mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 12:39:17 +00:00
displaying storage used by accounts
This commit is contained in:
parent
a9b1876ee6
commit
ead73db759
@ -3975,6 +3975,9 @@ components:
|
|||||||
type: boolean
|
type: boolean
|
||||||
seal:
|
seal:
|
||||||
type: string
|
type: string
|
||||||
|
storageUsed:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
|
||||||
Profile:
|
Profile:
|
||||||
type: object
|
type: object
|
||||||
|
@ -14,13 +14,18 @@ func GetNodeAccounts(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var accounts []store.Account
|
var accounts []store.Account
|
||||||
if err := store.DB.Preload("AccountDetail").Find(&accounts).Error; err != nil {
|
if err := store.DB.Preload("Assets").Preload("AccountDetail").Find(&accounts).Error; err != nil {
|
||||||
ErrResponse(w, http.StatusInternalServerError, err)
|
ErrResponse(w, http.StatusInternalServerError, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
profiles := []AccountProfile{}
|
profiles := []AccountProfile{}
|
||||||
for _, account := range accounts {
|
for _, account := range accounts {
|
||||||
|
var size int64
|
||||||
|
for _, asset := range account.Assets {
|
||||||
|
size += asset.Size
|
||||||
|
}
|
||||||
|
|
||||||
profiles = append(profiles, AccountProfile{
|
profiles = append(profiles, AccountProfile{
|
||||||
AccountID: uint32(account.ID),
|
AccountID: uint32(account.ID),
|
||||||
GUID: account.GUID,
|
GUID: account.GUID,
|
||||||
@ -30,6 +35,7 @@ func GetNodeAccounts(w http.ResponseWriter, r *http.Request) {
|
|||||||
Location: account.AccountDetail.Location,
|
Location: account.AccountDetail.Location,
|
||||||
ImageSet: account.AccountDetail.Image != "",
|
ImageSet: account.AccountDetail.Image != "",
|
||||||
Disabled: account.Disabled,
|
Disabled: account.Disabled,
|
||||||
|
StorageUsed: size,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,8 @@ type AccountProfile struct {
|
|||||||
Seal string `json:"seal,emitempty"`
|
Seal string `json:"seal,emitempty"`
|
||||||
|
|
||||||
Disabled bool `json:"disabled"`
|
Disabled bool `json:"disabled"`
|
||||||
|
|
||||||
|
StorageUsed int64 `json:"storageUsed"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//AccountStatus server settings for account
|
//AccountStatus server settings for account
|
||||||
|
@ -84,6 +84,7 @@ type Account struct {
|
|||||||
Forward string
|
Forward string
|
||||||
AccountDetail AccountDetail
|
AccountDetail AccountDetail
|
||||||
Apps []App
|
Apps []App
|
||||||
|
Assets []Asset
|
||||||
}
|
}
|
||||||
|
|
||||||
type AccountDetail struct {
|
type AccountDetail struct {
|
||||||
|
@ -75,7 +75,12 @@ export function AccountItem({ item, remove }) {
|
|||||||
<Logo url={state.imageUrl} width={32} height={32} radius={4} />
|
<Logo url={state.imageUrl} width={32} height={32} radius={4} />
|
||||||
</div>
|
</div>
|
||||||
<div className={state.activeClass}>
|
<div className={state.activeClass}>
|
||||||
<div className="handle">{ state.handle }</div>
|
<div className="handle">
|
||||||
|
<span>{ state.handle }</span>
|
||||||
|
{ state?.storage > 0 && (
|
||||||
|
<span className="storage">{ state.storage } { state.storageUnit }</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
<div className="guid">{ state.guid }</div>
|
<div className="guid">{ state.guid }</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="control">
|
<div className="control">
|
||||||
|
@ -51,6 +51,11 @@ export const AccountItemWrapper = styled.div`
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.storage {
|
||||||
|
color: #555555;
|
||||||
|
padding-left: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
.guid {
|
.guid {
|
||||||
font-size: 0.8em;
|
font-size: 0.8em;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
@ -22,6 +22,7 @@ export function useAccountItem(item, remove) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
||||||
updateState({
|
updateState({
|
||||||
disabled: item?.disabled,
|
disabled: item?.disabled,
|
||||||
activeClass: item?.disabled ? 'inactive' : 'active',
|
activeClass: item?.disabled ? 'inactive' : 'active',
|
||||||
@ -29,6 +30,8 @@ export function useAccountItem(item, remove) {
|
|||||||
name: item?.name,
|
name: item?.name,
|
||||||
guid: item?.guid,
|
guid: item?.guid,
|
||||||
handle: item?.handle,
|
handle: item?.handle,
|
||||||
|
storage: Math.floor(item?.storageUsed > 1073741824 ? item?.storageUsed / 1073741824 : item?.storageUsed / 1048576),
|
||||||
|
storageUnit: item?.storageUsed > 1073741824 ? "GB" : "MB",
|
||||||
imageUrl: item?.imageSet ? getAccountImageUrl(app.state.adminToken, item?.accountId) : null,
|
imageUrl: item?.imageSet ? getAccountImageUrl(app.state.adminToken, item?.accountId) : null,
|
||||||
});
|
});
|
||||||
}, [app.state.adminToken, item]);
|
}, [app.state.adminToken, item]);
|
||||||
|
Loading…
Reference in New Issue
Block a user