Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions app/Root/config/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,18 @@ const editLink: RouteConfig = {
visibility: 'is-authenticated',
};

const createGalleryAlbum: RouteConfig = {
path: '/galleries/new',
load: () => import('#views/Galleries/GalleryForm'),
visibility: 'is-authenticated',
};

const editGalleryAlbum: RouteConfig = {
path: '/galleries/:id/edit',
load: () => import('#views/Galleries/GalleryForm'),
visibility: 'is-authenticated',
};

const routes = {
home,
login,
Expand Down Expand Up @@ -239,6 +251,8 @@ const routes = {
documents,
onlineInteractive,
galleries,
createGalleryAlbum,
editGalleryAlbum,
editTeamMember,
links,
createLink,
Expand Down
14 changes: 14 additions & 0 deletions app/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@ export const statusFilterOptions = [

export const errorMessage = 'Something went wrong. Please try again. ';

export function getReadableFileSize(bytes: number | null | undefined): string {
if (!bytes || bytes <= 0) {
return '0 B';
}
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
const exponent = Math.min(
Math.floor(Math.log(bytes) / Math.log(1024)),
units.length - 1,
);
const value = bytes / (1024 ** exponent);
// Show one decimal place for KB and larger, none for bytes
return `${exponent === 0 ? value : value.toFixed(1)} ${units[exponent]}`;
}

interface ServerError {
field: string;
messages: string | null;
Expand Down
Loading
Loading