Skip to content

Commit

Permalink
web/satellite/v2: add usage to projects table
Browse files Browse the repository at this point in the history
This change adds storage and bandwidth usages to the projects table.

Issue: #6561

Change-Id: I85d234456948e0c09b877e5b7fca2ec780af7b29
  • Loading branch information
wilfred-asomanii authored and Storj Robot committed Jan 22, 2024
1 parent db76608 commit cb2125c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions web/satellite/src/api/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export class ProjectsHttpApi implements ProjectsApi {
false,
p.memberCount,
p.edgeURLOverrides,
p.storageUsed,
p.bandwidthUsed,
));
}

Expand Down
2 changes: 2 additions & 0 deletions web/satellite/src/types/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ export class Project {
public isSelected: boolean = false,
public memberCount: number = 0,
public edgeURLOverrides?: EdgeURLOverrides,
public storageUsed: number = 0,
public bandwidthUsed: number = 0,
) {}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ const headers = [
{ title: 'Project', key: 'name', align: 'start' },
{ title: 'Role', key: 'role' },
{ title: 'Members', key: 'memberCount' },
{ title: 'Storage', key: 'storageUsed', sortable: false },
{ title: 'Bandwidth', key: 'bandwidthUsed', sortable: false },
{ title: 'Date Added', key: 'createdAt' },
{ title: 'Actions', key: 'actions', sortable: false, width: '0' },
];
Expand Down
2 changes: 2 additions & 0 deletions web/satellite/vuetify-poc/src/types/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export class ProjectItemModel {
public role: ProjectItemRole,
public memberCount: number | null,
public createdAt: Date,
public storageUsed: string = '',
public bandwidthUsed: string = '',
) {}
}

Expand Down
15 changes: 15 additions & 0 deletions web/satellite/vuetify-poc/src/views/Projects.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ import { useBillingStore } from '@/store/modules/billingStore';
import { RouteName } from '@poc/router';
import { AnalyticsEvent } from '@/utils/constants/analyticsEventNames';
import { useAnalyticsStore } from '@/store/modules/analyticsStore';
import { Dimensions, Size } from '@/utils/bytesSize';
import ProjectCard from '@poc/components/ProjectCard.vue';
import PageTitleComponent from '@poc/components/PageTitleComponent.vue';
Expand Down Expand Up @@ -184,6 +185,8 @@ const items = computed((): ProjectItemModel[] => {
project.ownerId === usersStore.state.user.id ? ProjectRole.Owner : ProjectRole.Member,
project.memberCount,
new Date(project.createdAt),
formattedValue(new Size(project.storageUsed, 2)),
formattedValue(new Size(project.bandwidthUsed, 2)),
)).sort((projA, projB) => {
if (projA.role === ProjectRole.Owner && projB.role === ProjectRole.Member) return -1;
if (projA.role === ProjectRole.Member && projB.role === ProjectRole.Owner) return 1;
Expand Down Expand Up @@ -221,6 +224,18 @@ function onInviteClicked(item: ProjectItemModel): void {
isAddMemberDialogShown.value = true;
}
/**
* Formats value to needed form and returns it.
*/
function formattedValue(value: Size): string {
switch (value.label) {
case Dimensions.Bytes:
return '0';
default:
return `${value.formattedBytes.replace(/\.0+$/, '')}${value.label}`;
}
}
onMounted(() => {
if (configStore.state.config.nativeTokenPaymentsEnabled && configStore.state.config.billingFeaturesEnabled) {
Promise.all([
Expand Down

0 comments on commit cb2125c

Please sign in to comment.