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