mirror of
https://github.com/umami-software/umami.git
synced 2026-02-19 20:15:41 +01:00
Merge 05cc18882c into 03adb6b7e1
This commit is contained in:
commit
e6458a383a
7 changed files with 593 additions and 307 deletions
|
|
@ -8,10 +8,40 @@ export function DashboardPage() {
|
|||
const { formatMessage, labels } = useMessages();
|
||||
|
||||
return (
|
||||
<PageBody>
|
||||
<Column margin="2">
|
||||
<PageHeader title={formatMessage(labels.dashboard)}></PageHeader>
|
||||
</Column>
|
||||
</PageBody>
|
||||
<section style={{ marginBottom: 60 }}>
|
||||
<PageHeader title={formatMessage(labels.dashboard)}>
|
||||
{!editing && hasData && <DashboardSettingsButton />}
|
||||
</PageHeader>
|
||||
{!hasData && (
|
||||
<EmptyPlaceholder message={formatMessage(messages.noWebsitesConfigured)}>
|
||||
<LinkButton href={renderTeamUrl('/settings')}>
|
||||
<Icon rotate={dir === 'rtl' ? 180 : 0}>
|
||||
<Icons.ArrowRight />
|
||||
</Icon>
|
||||
<Text>{formatMessage(messages.goToSettings)}</Text>
|
||||
</LinkButton>
|
||||
</EmptyPlaceholder>
|
||||
)}
|
||||
{hasData && (
|
||||
<>
|
||||
{editing && <DashboardEdit teamId={teamId} />}
|
||||
{!editing && (
|
||||
<>
|
||||
<WebsiteChartList
|
||||
websites={result?.data as any}
|
||||
showCharts={showCharts}
|
||||
limit={pageSize}
|
||||
/>
|
||||
<Pager
|
||||
page={Number(page) || 1}
|
||||
pageSize={pageSize}
|
||||
count={result?.count}
|
||||
onPageChange={handlePageChange}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,18 +94,18 @@ export const DATE_FUNCTIONS = {
|
|||
},
|
||||
};
|
||||
|
||||
export const DATE_FORMATS = {
|
||||
minute: 'yyyy-MM-dd HH:mm',
|
||||
hour: 'yyyy-MM-dd HH',
|
||||
day: 'yyyy-MM-dd',
|
||||
week: "yyyy-'W'II",
|
||||
month: 'yyyy-MM',
|
||||
year: 'yyyy',
|
||||
const TIMEZONE_MAPPINGS: Record<string, string> = {
|
||||
'Asia/Calcutta': 'Asia/Kolkata',
|
||||
};
|
||||
|
||||
export function normalizeTimezone(timezone: string): string {
|
||||
return TIMEZONE_MAPPINGS[timezone] || timezone;
|
||||
}
|
||||
|
||||
export function isValidTimezone(timezone: string) {
|
||||
try {
|
||||
Intl.DateTimeFormat(undefined, { timeZone: timezone });
|
||||
const normalizedTimezone = normalizeTimezone(timezone);
|
||||
Intl.DateTimeFormat(undefined, { timeZone: normalizedTimezone });
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { z } from 'zod';
|
||||
import { isValidTimezone } from '@/lib/date';
|
||||
import { isValidTimezone, normalizeTimezone } from '@/lib/date';
|
||||
import { UNIT_TYPES } from './constants';
|
||||
|
||||
export const timezoneParam = z.string().refine(value => isValidTimezone(value), {
|
||||
|
|
@ -49,9 +49,9 @@ export const pagingParams = {
|
|||
pageSize: z.coerce.number().int().positive().optional(),
|
||||
};
|
||||
|
||||
export const sortingParams = {
|
||||
orderBy: z.string().optional(),
|
||||
};
|
||||
export const timezoneParam = z.string().refine((value: string) => isValidTimezone(value), {
|
||||
message: 'Invalid timezone',
|
||||
}).transform((value: string) => normalizeTimezone(value));
|
||||
|
||||
export const userRoleParam = z.enum(['admin', 'user', 'view-only']);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue