Skip to content

Commit

Permalink
Merge pull request #3581 from ever-co/stage
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
evereq authored Feb 3, 2025
2 parents f66b183 + b8b4f81 commit 6c90829
Show file tree
Hide file tree
Showing 59 changed files with 1,197 additions and 725 deletions.
2 changes: 2 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"adipiscing",
"aliqua",
"alldays",
"alluser",
"allteams",
"amet",
"Andross",
"animatable",
Expand Down
2 changes: 1 addition & 1 deletion .scripts/configure.electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function modifiedNextServer() {
}
}

function updateWebConstant(setDesktopApp) {
function updateWebConstant(setDesktopApp:boolean) {
const filePath = path.resolve(__dirname, '../apps/web/app/constants.ts');
try {
let fileContent = fs.readFileSync(filePath, 'utf8');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export class DesktopServerWebEnvironmentContent implements IContentGenerator {
NEXT_PUBLIC_GAUZY_API_SERVER_URL: '${variable.NEXT_PUBLIC_GAUZY_API_SERVER_URL}',
DESKTOP_WEB_SERVER_HOSTNAME: '${variable.DESKTOP_WEB_SERVER_HOSTNAME}',
TERM_OF_SERVICE: '${variable.TERM_OF_SERVICE}',
PRIVACY_POLICY: '${variable.PRIVACY_POLICY}'
PRIVACY_POLICY: '${variable.PRIVACY_POLICY}',
AUTH_SECRET: '${variable.AUTH_SECRET}'
`;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export interface IDesktopEnvironment extends Env {
GAUZY_API_SERVER_URL: string;
NEXT_PUBLIC_GAUZY_API_SERVER_URL: string;
DESKTOP_WEB_SERVER_HOSTNAME: string;
AUTH_SECRET: string;
}
6 changes: 5 additions & 1 deletion .scripts/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type Env = Readonly<{
DESKTOP_WEB_SERVER_HOSTNAME: string;
TERM_OF_SERVICE: string;
PRIVACY_POLICY: string;
AUTH_SECRET: string;
}>

export const env = cleanEnv(process.env, {
Expand Down Expand Up @@ -77,5 +78,8 @@ export const env = cleanEnv(process.env, {
}),
PRIVACY_POLICY: str({
default: 'https://ever.team/privacy'
})
}),
AUTH_SECRET: str({
default: 'development_auth_secret'
})
});
3 changes: 2 additions & 1 deletion apps/server-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"react-i18next": "^14.1.0",
"@radix-ui/react-switch": "^1.1.0",
"classnames": "^2.5.1",
"fast-glob": "^3.3.2"
"fast-glob": "^3.3.2",
"sharp": "^0.33.4"
},
"devDependencies": {
"electron": "28.1.0",
Expand Down
36 changes: 19 additions & 17 deletions apps/server-web/release/app/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
{
"name": "ever-teams-web-server",
"version": "0.1.0",
"description": "Ever Teams Web Server",
"license": "AGPL-3.0",
"author": {
"name": "Ever Co. LTD",
"email": "ever@ever.co",
"url": "https://ever.co"
},
"main": "./dist/main/main.js",
"scripts": {
"rebuild": "node -r ts-node/register ../../.erb/scripts/electron-rebuild.js",
"postinstall": "npm run rebuild && npm run link-modules",
"link-modules": "node -r ts-node/register ../../.erb/scripts/link-modules.ts"
},
"dependencies": {}
}
"name": "ever-teams-server-web",
"version": "0.1.0",
"description": "Ever Teams Server Web",
"license": "AGPL-3.0",
"author": {
"name": "Ever Co. LTD",
"email": "ever@ever.co",
"url": "https://ever.co"
},
"main": "./dist/main/main.js",
"scripts": {
"rebuild": "node -r ts-node/register ../../.erb/scripts/electron-rebuild.js",
"postinstall": "npm run rebuild && npm run link-modules",
"link-modules": "node -r ts-node/register ../../.erb/scripts/link-modules.ts"
},
"dependencies": {
"sharp": "^0.33.4"
}
}
14 changes: 10 additions & 4 deletions apps/server-web/src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ import { debounce } from 'lodash';
import WindowFactory from './windows/window-factory';
import { setupTitlebar } from 'custom-electron-titlebar/main';


console.log = Log.log;
Object.assign(console, Log.functions);


app.name = config.DESCRIPTION;

const eventEmitter = new EventEmitter();
Expand Down Expand Up @@ -112,6 +110,11 @@ const handleMinimizeButton = (windowTypes: IWindowTypes) => {
}
}

const handleMenuLanguage = () => {
logWindow?.webContents?.send('refresh-menu');
settingWindow?.webContents?.send('refresh-menu');
}

Log.hooks.push((message: any, transport) => {
if (transport !== Log.transports.file) {
return message;
Expand All @@ -134,7 +137,7 @@ Log.hooks.push((message: any, transport) => {
logWindow.webContents.send(IPC_TYPES.SERVER_PAGE, {
type: LOG_TYPES.SERVER_LOG,
msg
});
})
}
}

Expand Down Expand Up @@ -287,7 +290,9 @@ const runServer = async () => {
{ api: serverPath },
{
...(envVal || {}),
IS_DESKTOP_APP: true
IS_DESKTOP_APP: true,
NEXT_SHARP_PATH: path.join(process.resourcesPath, 'app.asar', 'node_modules', 'sharp'),
AUTH_SECRET: config.AUTH_SECRET
},
undefined,
signal
Expand Down Expand Up @@ -337,6 +342,7 @@ const onInitApplication = () => {
} else {
Menu.setApplicationMenu(appMenu.buildTemplateMenu(WindowTypes.SETUP_WINDOW, i18nextMainBackend))
}
handleMenuLanguage()
}, 250));

eventEmitter.on(EventLists.webServerStop, async () => {
Expand Down
4 changes: 2 additions & 2 deletions apps/server-web/src/main/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ window.addEventListener('DOMContentLoaded', async () => {
}
const titleBar = new CustomTitlebar({
icon: iconPath,
backgroundColor: TitlebarColor.fromHex(themeColor[currentTheme]),
backgroundColor: TitlebarColor.fromHex(themeColor[currentTheme] || themeColor.light),
enableMnemonics: false,
iconSize: 16,
maximizable: false,
Expand All @@ -82,7 +82,7 @@ window.addEventListener('DOMContentLoaded', async () => {

ipcRenderer.on('themeSignal', (_, arg: any) => {
const theme: 'dark' | 'light' = arg.data;
titleBar.updateBackground(TitlebarColor.fromHex(themeColor[theme]));
titleBar.updateBackground(TitlebarColor.fromHex(themeColor[theme] || themeColor.light));
titleBar.refreshMenu();
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
"use client";
'use client';

import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { DateRangePicker } from "./date-range-picker";
import { DateRange } from "react-day-picker";
import { ITimeLogReportDailyChartProps } from "@/app/interfaces/timer/ITimerLog";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
import { DateRangePicker } from './date-range-picker';
import { DateRange } from 'react-day-picker';
import { ITimeLogReportDailyChartProps } from '@/app/interfaces/timer/ITimerLog';
import { TeamDashboardFilter } from './team-dashboard-filter';

interface DashboardHeaderProps {
onUpdateDateRange: (startDate: Date, endDate: Date) => void;
Expand All @@ -23,53 +18,22 @@ export function DashboardHeader({ onUpdateDateRange, onUpdateFilters }: Dashboar
}
};

const handleFilterChange = (value: string) => {
const today = new Date();
let startDate = new Date();
const endDate = today;

switch (value) {
case 'today':
startDate = today;
break;
case 'week':
startDate.setDate(today.getDate() - 7);
break;
case 'month':
startDate.setMonth(today.getMonth() - 1);
break;
default:
return;
}

onUpdateDateRange(startDate, endDate);
};

return (
<div className="flex justify-between items-center">
<h1 className="text-2xl font-semibold">Team Dashboard</h1>
<div className="flex gap-4 items-center">
<DateRangePicker onDateRangeChange={handleDateRangeChange} />
<Select defaultValue="filter" onValueChange={handleFilterChange}>
<SelectTrigger className="w-[100px]">
<SelectValue placeholder="Filter" />
</SelectTrigger>
<SelectContent>
<SelectItem value="filter">Filter</SelectItem>
<SelectItem value="today">Today</SelectItem>
<SelectItem value="week">This Week</SelectItem>
<SelectItem value="month">This Month</SelectItem>
</SelectContent>
</Select>
<TeamDashboardFilter />
<Select defaultValue="export">
<SelectTrigger className="w-[100px]">
<SelectTrigger className="w-[100px] border border-[#E4E4E7] dark:border-[#2D2D2D] dark:bg-dark--theme-light">
<SelectValue placeholder="Export" />
</SelectTrigger>
<SelectContent>
<SelectContent className="dark:bg-dark--theme-light">
<SelectItem value="export">Export</SelectItem>
<SelectItem value="csv">CSV</SelectItem>
<SelectItem value="pdf">PDF</SelectItem>
<SelectItem value="excel">Excel</SelectItem>
<SelectItem value="xlsx">XLSX</SelectItem>
</SelectContent>
</Select>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,30 @@ import {
} from 'date-fns';
import { DateRange } from 'react-day-picker';
import { useTranslations } from 'next-intl';
import { SettingsIcon } from './team-icon';

interface DateRangePickerProps {
className?: string;
onDateRangeChange?: (range: DateRange | undefined) => void;
}

export function DateRangePicker({ className, onDateRangeChange }: DateRangePickerProps) {
const t=useTranslations();
const t = useTranslations();
const [dateRange, setDateRange] = React.useState<DateRange | undefined>({
from: new Date(),
to: new Date()
});
const [isPopoverOpen, setIsPopoverOpen] = React.useState(false);
const [currentMonth, setCurrentMonth] = React.useState<Date>(new Date());

const handleDateRangeChange = (range: DateRange | undefined) => {
try {
setDateRange(range);
onDateRangeChange?.(range);
} catch (error) {
console.error('Error handling date range change:', error);
}
};
const handleDateRangeChange = (range: DateRange | undefined) => {
try {
setDateRange(range);
onDateRangeChange?.(range);
} catch (error) {
console.error('Error handling date range change:', error);
}
};

const predefinedRanges = [
{
Expand Down Expand Up @@ -105,7 +106,7 @@ export function DateRangePicker({ className, onDateRangeChange }: DateRangePicke
}
},
{
label:t('common.THIS_MONTH'),
label: t('common.THIS_MONTH'),
action: () => {
const today = new Date();
handleDateRangeChange({
Expand Down Expand Up @@ -146,33 +147,45 @@ export function DateRangePicker({ className, onDateRangeChange }: DateRangePicke

if (isSameYear(range.from, range.to)) {
if (isSameMonth(range.from, range.to)) {
return `${format(range.from, 'd')} - ${format(range.to, 'd MMM yyyy')}`;
return `${format(range.from, 'MMM d')} - ${format(range.to, 'd yyyy')}`;
}
return `${format(range.from, 'd MMM')} - ${format(range.to, 'd MMM yyyy')}`;
return `${format(range.from, 'MMM d')} - ${format(range.to, 'd MMM yyyy')}`;
}
return `${format(range.from, 'd MMM yyyy')} - ${format(range.to, 'd MMM yyyy')}`;
return `${format(range.from, 'MMM d')} - ${format(range.to, 'd MMM yyyy')}`;
};

return (
<Popover open={isPopoverOpen} onOpenChange={setIsPopoverOpen}>
<PopoverTrigger asChild>
<Button
variant="outline"
className={cn(
'justify-between gap-2 px-3 py-2 min-w-[240px] text-center flex items-center',
!dateRange && 'text-muted-foreground',
className
)}
>
{dateRange ? formatDateRange(dateRange) : t('common.SELECT')}
<ChevronDown className="w-4 h-4" />
</Button>
<div className="flex items-center border border-[#E4E4E7] dark:border-[#2D2D2D] rounded-md w-[225px]">
<Button
variant="outline"
className={cn(
'flex items-center justify-between gap-2 px-3 py-1 w-[196px] h-[36px] bg-white dark:bg-dark--theme-light rounded-r-none',
!dateRange && 'text-muted-foreground',
className
)}
>
{dateRange ? formatDateRange(dateRange) : t('common.SELECT')}
<ChevronDown className="w-4 h-4" />
</Button>
<button
onClick={() => {
/* Add handler */
}}
title="Open settings"
aria-label="Open settings"
className="flex items-center justify-center gap-2 px-2 py-1 w-[36px] h-[36px] bg-white dark:bg-dark--theme-light border-l border-l-[#E4E4E7] dark:border-l-[#2D2D2D] rounded-r-md"
>
<SettingsIcon />
</button>
</div>
</PopoverTrigger>
<PopoverContent
onClick={(e) => e.stopPropagation()}
onMouseDown={(e) => e.stopPropagation()}
onChange={(e) => e.stopPropagation()}
className="p-0 w-auto"
className="p-0 w-auto dark:bg-dark--theme-light dark:border-[#2D2D2D] border border-[#E4E4E7] rounded-md"
align="center"
>
<div className="flex flex-row-reverse">
Expand Down
Loading

0 comments on commit 6c90829

Please sign in to comment.