diff --git a/apps/server-web/src/main/helpers/constant.ts b/apps/server-web/src/main/helpers/constant.ts index b6bc8e792..b2ebfcb96 100644 --- a/apps/server-web/src/main/helpers/constant.ts +++ b/apps/server-web/src/main/helpers/constant.ts @@ -17,6 +17,7 @@ export const EventLists = { SERVER_WINDOW: 'SERVER_WINDOW', RESTART_SERVER: 'RESTART_SERVER', CHANGE_THEME: 'CHANGE_THEME', + SETUP_WINDOW: 'SETUP_WINDOW' } export const SettingPageTypeMessage = { diff --git a/apps/server-web/src/main/helpers/interfaces/i-server.ts b/apps/server-web/src/main/helpers/interfaces/i-server.ts index 469c87b9d..072dcc572 100644 --- a/apps/server-web/src/main/helpers/interfaces/i-server.ts +++ b/apps/server-web/src/main/helpers/interfaces/i-server.ts @@ -3,6 +3,7 @@ interface GeneralConfig { autoUpdate?: boolean updateCheckPeriode?: string theme?: string + setup?: boolean [key: string]: any } diff --git a/apps/server-web/src/main/main.ts b/apps/server-web/src/main/main.ts index 33ad2a1c0..254355e84 100644 --- a/apps/server-web/src/main/main.ts +++ b/apps/server-web/src/main/main.ts @@ -1,4 +1,4 @@ -import path from 'path' +import path from 'path'; import { app, ipcMain, Tray, dialog, BrowserWindow, shell } from 'electron'; import { DesktopServer } from './helpers/desktop-server'; import { LocalStore } from './helpers/services/libs/desktop-store'; @@ -40,6 +40,7 @@ let intervalUpdate: NodeJS.Timeout; let tray: Tray; let settingWindow: BrowserWindow | null = null; let logWindow: BrowserWindow | null = null; +let setupWindow: BrowserWindow | any = null; let SettingMenu: any = null; let ServerWindowMenu: any = null; @@ -149,13 +150,14 @@ const installExtensions = async () => { }; -const createWindow = async (type: 'SETTING_WINDOW' | 'LOG_WINDOW') => { +const createWindow = async (type: 'SETTING_WINDOW' | 'LOG_WINDOW' | 'SETUP_WINDOW') => { if (isDebug) { await installExtensions(); } const defaultOptionWindow = { title: app.name, + frame: true, show: false, width: 1024, height: 728, @@ -199,6 +201,15 @@ const createWindow = async (type: 'SETTING_WINDOW' | 'LOG_WINDOW') => { } ServerWindowMenu.buildMenu(); break; + case 'SETUP_WINDOW': + setupWindow = new BrowserWindow(defaultOptionWindow); + url = resolveHtmlPath('index.html', 'setup'); + setupWindow?.loadURL(url); + mainBindings(ipcMain, setupWindow, fs); + setupWindow.on('closed', () => { + setupWindow = null; + }) + break; default: break; } @@ -418,7 +429,17 @@ const onInitApplication = () => { (async () => { await app.whenReady() - onInitApplication(); + const storeConfig:WebServer = LocalStore.getStore('config'); + if (storeConfig?.general?.setup) { + onInitApplication(); + } else { + if (!setupWindow) { + await createWindow('SETUP_WINDOW'); + } + if (setupWindow) { + setupWindow?.show() + } + } })() app.on('window-all-closed', () => { @@ -453,12 +474,23 @@ ipcMain.on(IPC_TYPES.SETTING_PAGE, async (event, arg) => { } } ) - event.sender.send(IPC_TYPES.SETTING_PAGE, { - type: SettingPageTypeMessage.mainResponse, data: { - status: true, - isServerRun: isServerRun - } - }); + if (arg.isSetup) { + LocalStore.updateConfigSetting({ + general: { + setup: true + } + }); + setupWindow?.close(); + onInitApplication(); + eventEmitter.emit(EventLists.SERVER_WINDOW); + } else { + event.sender.send(IPC_TYPES.SETTING_PAGE, { + type: SettingPageTypeMessage.mainResponse, data: { + status: true, + isServerRun: isServerRun + } + }); + } break; case SettingPageTypeMessage.checkUpdate: updater.checkUpdate(); diff --git a/apps/server-web/src/renderer/App.css b/apps/server-web/src/renderer/App.css index f6d269756..7ec5f474b 100644 --- a/apps/server-web/src/renderer/App.css +++ b/apps/server-web/src/renderer/App.css @@ -453,7 +453,7 @@ html.dark { } .switch-root[data-state='checked'] { - background-color: rgb(96 165 250/var(--tw-bg-opacity)); + @apply bg-violet-800 } .switch-thumb { diff --git a/apps/server-web/src/renderer/App.tsx b/apps/server-web/src/renderer/App.tsx index 3ad4a3986..dbeebce43 100644 --- a/apps/server-web/src/renderer/App.tsx +++ b/apps/server-web/src/renderer/App.tsx @@ -3,18 +3,20 @@ import { HashRouter as Router, Routes, Route } from 'react-router-dom'; import './App.css'; import { Setting } from './pages/Setting'; import i18next from 'i18next'; -import { ServerPage } from './pages/Server'; import { ThemeProvider, useTheme } from './ThemeContext'; +import SetupPage from './pages/Setup'; +import { ServerPage } from './pages/Server'; export default function App() { const [language, setLanguage] = useState('en'); const { theme } = useTheme(); const setTheme = async (htmlElement: HTMLElement) => { - const currentTheme = await window.electron.ipcRenderer.invoke('current-theme'); + const currentTheme = + await window.electron.ipcRenderer.invoke('current-theme'); htmlElement.classList.remove('dark', 'light'); htmlElement.classList.toggle(currentTheme || theme); - } + }; useEffect(() => { const htmlElement = document.documentElement; @@ -26,7 +28,7 @@ export default function App() { console.log(value); htmlElement.classList.remove('dark', 'light'); htmlElement.classList.toggle(value.data); - }) + }); i18next.changeLanguage(language); }, [language]); return ( @@ -35,6 +37,7 @@ export default function App() { } /> } /> + } /> diff --git a/apps/server-web/src/renderer/components/About.tsx b/apps/server-web/src/renderer/components/About.tsx index 2e8807d71..0a1260f48 100644 --- a/apps/server-web/src/renderer/components/About.tsx +++ b/apps/server-web/src/renderer/components/About.tsx @@ -4,7 +4,7 @@ import { IAbout } from '../libs/interfaces'; export const AboutComponent = (props: IAbout) => { return (
-
+
diff --git a/apps/server-web/src/renderer/components/Server.tsx b/apps/server-web/src/renderer/components/Server.tsx index 9acf59048..e985469b1 100644 --- a/apps/server-web/src/renderer/components/Server.tsx +++ b/apps/server-web/src/renderer/components/Server.tsx @@ -20,7 +20,7 @@ export const ServerComponent = (props: IServerComponent) => { <>
-
+
@@ -97,7 +97,7 @@ export const ServerComponent = (props: IServerComponent) => {
-
+
diff --git a/apps/server-web/src/renderer/components/svgs/CheckIcon.tsx b/apps/server-web/src/renderer/components/svgs/CheckIcon.tsx new file mode 100644 index 000000000..47ee82088 --- /dev/null +++ b/apps/server-web/src/renderer/components/svgs/CheckIcon.tsx @@ -0,0 +1,18 @@ +const CheckIcon = ({ className }: { className?: string }) => ( + + + +); + +export default CheckIcon; diff --git a/apps/server-web/src/renderer/pages/Server.tsx b/apps/server-web/src/renderer/pages/Server.tsx index ab018e213..be91e7efb 100644 --- a/apps/server-web/src/renderer/pages/Server.tsx +++ b/apps/server-web/src/renderer/pages/Server.tsx @@ -49,17 +49,17 @@ export function ServerPage() {
-
+
- Server Logs + Server Logs -
+
{logs.length > 0 && logs.map((log, i) => (
diff --git a/apps/server-web/src/renderer/pages/Setup.tsx b/apps/server-web/src/renderer/pages/Setup.tsx new file mode 100644 index 000000000..864466f1f --- /dev/null +++ b/apps/server-web/src/renderer/pages/Setup.tsx @@ -0,0 +1,41 @@ +import { useState } from 'react'; +import AdvancedSetting from './setup/AdvancedSetting'; +import Landing from './setup/Landing'; +import CheckIcon from '../components/svgs/CheckIcon'; +const steps: number[] = [1, 2]; +const SetupPage = () => { + const [currentStep, setCurrentStep] = useState(1); + + const letsGo = () => { + setCurrentStep(2); + }; + + const goBack = () => { + setCurrentStep(1); + }; + + return ( +
+
+
+
+ {currentStep === 1 ? 1 : } +
+
+
+ 2 +
+
+
+ {currentStep === 1 ? ( + + ) : ( + + )} +
+ ); +}; + +export default SetupPage; diff --git a/apps/server-web/src/renderer/pages/setup/AdvancedSetting.tsx b/apps/server-web/src/renderer/pages/setup/AdvancedSetting.tsx new file mode 100644 index 000000000..9dc92f497 --- /dev/null +++ b/apps/server-web/src/renderer/pages/setup/AdvancedSetting.tsx @@ -0,0 +1,151 @@ +import { useTranslation } from 'react-i18next'; +import { IServerSetting } from '../../libs/interfaces'; +import { useState } from 'react'; +import { SettingPageTypeMessage } from '../../libs/constant'; +type Props = { + back: () => void; +}; + +const AdvancedSetting = (props: Props) => { + const { t } = useTranslation(); + const [serverSetting, setServerSetting] = useState({ + PORT: 3000, + GAUZY_API_SERVER_URL: 'http://localhost:3030', + NEXT_PUBLIC_GAUZY_API_SERVER_URL: 'http://localhost:3030', + }); + const saveSetting = (e: any) => { + e.preventDefault(); + + window.electron.ipcRenderer.sendMessage('setting-page', { + data: serverSetting, + type: SettingPageTypeMessage.saveSetting, + isSetup: true, + }); + }; + const handleChange = (event: any) => { + const { id, value } = event.target; + setServerSetting((prevData: any) => ({ ...prevData, [id]: value })); + }; + return ( + <> +
+

+ Are you ready for some advanced settings? +

+

+ This is the final step where you can get to the nitty-gritty of your + Gauzy Platform. +

+
+ + {/* Input Fields */} + +
+
+
+
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+
+ {/* Buttons */} +
+ +
+ + +
+
+ + + ); +}; + +export default AdvancedSetting; diff --git a/apps/server-web/src/renderer/pages/setup/Landing.tsx b/apps/server-web/src/renderer/pages/setup/Landing.tsx new file mode 100644 index 000000000..06ee23568 --- /dev/null +++ b/apps/server-web/src/renderer/pages/setup/Landing.tsx @@ -0,0 +1,46 @@ +import { EverTeamsLogo } from '../../components/svgs/index'; +type props = { + nextAction: () => void; +}; +const Landing = (props: props) => { + return ( +
+
+ +
+ +
+
+ +
+

+ Welcome to Ever® Teams - Open-Source Business Management Platform + (ERP/CRM/HRM) +

+

+ Ever Teams Desktop App provides the full functionality of the Gauzy + Platform available directly on your desktop computer or a laptop. In + addition, it allows tracking work time, activity recording, and the + ability to receive tracking reminders/notifications. +

+
+ + {/* Button */} +
+ +
+
+ ); +}; + +export default Landing;