Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release #3343

Merged
merged 6 commits into from
Nov 18, 2024
Merged

Release #3343

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
2 changes: 1 addition & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@
"tinvitations",
"tnode",
"Togger",
"tomorow",
"tomorrow",
"Tongatapu",
"tota",
"TRANSFERT",
Expand Down
4 changes: 1 addition & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
},
"vsicons.presets.angular": true,
"deepscan.enable": true,
"cSpell.words": [
"Timepicker"
],
"cSpell.words": ["Timepicker"],
"files.exclude": {
"**/.git": true,
"**/.DS_Store": true,
Expand Down
15 changes: 15 additions & 0 deletions apps/server-web/src/locales/i18n/bg/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@
"OPEN_WEB": "Отворете уеб в браузъра",
"SERVER_WINDOW": "Прозорец на сървъра"
},
"MENU_APP": {
"ABOUT": "Относно",
"QUIT": "Изход",
"WINDOW": "Прозорец",
"SUBMENU": {
"SETTING": "Настройки",
"SERVER_WINDOW": "Сървърен прозорец",
"LEARN_MORE": "Научете повече",
"DOC": "Документация",
"SETTING_DEV": "Настройки за разработчици",
"SERVER_DEV": "Сървър за разработчици"
},
"DEV": "Разработчик",
"HELP": "Помощ"
},
"FORM": {
"FIELDS": {
"PORT": "ПРИСТАНИЩЕ",
Expand Down
15 changes: 15 additions & 0 deletions apps/server-web/src/locales/i18n/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@
"OPEN_WEB": "Open Web In Browser",
"SERVER_WINDOW": "Server Window"
},
"MENU_APP": {
"ABOUT": "About",
"QUIT": "Quit",
"WINDOW": "Window",
"SUBMENU": {
"SETTING": "Setting",
"SERVER_WINDOW": "Server Window",
"LEARN_MORE": "Learn More",
"DOC": "Documentation",
"SETTING_DEV": "Setting Dev.",
"SERVER_DEV": "Server Dev."
},
"DEV": "Developer",
"HELP": "Help"
},
"FORM": {
"FIELDS": {
"PORT": "PORT",
Expand Down
40 changes: 23 additions & 17 deletions apps/server-web/src/main/helpers/services/libs/desktop-store.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
import Store from 'electron-store';
import { WebServer } from '../../interfaces';
const store = new Store();
const DEFAULT_CONFIG:any = {
server: {
PORT: 3002,
GAUZY_API_SERVER_URL: 'http://localhost:3000',
NEXT_PUBLIC_GAUZY_API_SERVER_URL: 'http://localhost:3000',
DESKTOP_WEB_SERVER_HOSTNAME: '0.0.0.0'
},
general: {
lang: 'en',
autoUpdate: true,
updateCheckPeriode: '1140'
}
}
export const LocalStore = {
getStore: (source: string | 'config'): WebServer | any => {
return store.get(source);
Expand All @@ -24,22 +37,15 @@ export const LocalStore = {


setDefaultServerConfig: () => {
const defaultConfig: WebServer | any = store.get('config');
if (!defaultConfig || !defaultConfig.server || !defaultConfig.general) {
const config: WebServer = {
server: {
PORT: 3002,
GAUZY_API_SERVER_URL: 'http://localhost:3000',
NEXT_PUBLIC_GAUZY_API_SERVER_URL: 'http://localhost:3000',
DESKTOP_WEB_SERVER_HOSTNAME: '0.0.0.0'
},
general: {
lang: 'en',
autoUpdate: true,
updateCheckPeriode: '30'
}
}
store.set({ config });
}
const defaultConfig: WebServer | any = store.get('config') || {};
Object.keys(DEFAULT_CONFIG).forEach((key) => {
Object.keys(DEFAULT_CONFIG[key]).forEach((keySub) => {
defaultConfig[key] = defaultConfig[key] || {};
defaultConfig[key][keySub] = defaultConfig[key][keySub] || DEFAULT_CONFIG[key][keySub];
})
})
store.set({
config: defaultConfig
});
}
};
43 changes: 21 additions & 22 deletions apps/server-web/src/main/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'path';
import { app, ipcMain, Tray, dialog, BrowserWindow, shell } from 'electron';
import { app, ipcMain, Tray, dialog, BrowserWindow, shell, Menu } from 'electron';
import { DesktopServer } from './helpers/desktop-server';
import { LocalStore } from './helpers/services/libs/desktop-store';
import { EventEmitter } from 'events';
Expand All @@ -23,8 +23,6 @@ Object.assign(console, Log.functions);

app.name = config.DESCRIPTION;



const eventEmitter = new EventEmitter();

const controller = new AbortController();
Expand All @@ -43,6 +41,7 @@ let logWindow: BrowserWindow | null = null;
let setupWindow: BrowserWindow | any = null;
let SettingMenu: any = null;
let ServerWindowMenu: any = null;
const appMenu = new MenuBuilder(eventEmitter)

Log.hooks.push((message: any, transport) => {
if (transport !== Log.transports.file) {
Expand Down Expand Up @@ -93,6 +92,7 @@ i18nextMainBackend.on('initialized', () => {
});

let trayMenuItems: any = [];
let appMenuItems: any = [];

const RESOURCES_PATH = app.isPackaged
? path.join(process.resourcesPath, 'assets')
Expand Down Expand Up @@ -182,10 +182,7 @@ const createWindow = async (type: 'SETTING_WINDOW' | 'LOG_WINDOW' | 'SETUP_WINDO
settingWindow = null;
SettingMenu = null
});
if (!SettingMenu) {
SettingMenu = new MenuBuilder(settingWindow);
}
SettingMenu.buildMenu();
Menu.setApplicationMenu(appMenu.buildDefaultTemplate(appMenuItems, i18nextMainBackend))
break;
case 'LOG_WINDOW':
logWindow = new BrowserWindow(defaultOptionWindow);
Expand All @@ -196,10 +193,7 @@ const createWindow = async (type: 'SETTING_WINDOW' | 'LOG_WINDOW' | 'SETUP_WINDO
logWindow = null;
ServerWindowMenu = null
})
if (!ServerWindowMenu) {
ServerWindowMenu = new MenuBuilder(logWindow);
}
ServerWindowMenu.buildMenu();
Menu.setApplicationMenu(appMenu.buildDefaultTemplate(appMenuItems, i18nextMainBackend))
break;
case 'SETUP_WINDOW':
setupWindow = new BrowserWindow(defaultOptionWindow);
Expand All @@ -218,7 +212,7 @@ const createWindow = async (type: 'SETTING_WINDOW' | 'LOG_WINDOW' | 'SETUP_WINDO
const runServer = async () => {
console.log('Run the Server...');
try {
const envVal = getEnvApi();
const envVal: any = getEnvApi();

// Instantiate API and UI servers
await desktopServer.start(
Expand Down Expand Up @@ -262,14 +256,18 @@ const SendMessageToSettingWindow = (type: string, data: any) => {
}

const onInitApplication = () => {
LocalStore.setDefaultServerConfig(); // check and set default config
// check and set default config
LocalStore.setDefaultServerConfig();
createIntervalAutoUpdate()
trayMenuItems = trayMenuItems.length ? trayMenuItems : defaultTrayMenuItem(eventEmitter);
appMenuItems = appMenuItems.length ? appMenuItems : appMenu.defaultMenu();
tray = _initTray(trayMenuItems, getAssetPath('icons/icon.png'));
i18nextMainBackend.on('languageChanged', (lng) => {
if (i18nextMainBackend.isInitialized) {

trayMenuItems = trayMenuItems.length ? trayMenuItems : defaultTrayMenuItem(eventEmitter);
updateTrayMenu('none', {}, eventEmitter, tray, trayMenuItems, i18nextMainBackend);
Menu.setApplicationMenu(appMenu.buildDefaultTemplate(appMenuItems, i18nextMainBackend))
}
});
eventEmitter.on(EventLists.webServerStart, async () => {
Expand Down Expand Up @@ -425,6 +423,16 @@ const onInitApplication = () => {
const url = `http://127.0.0.1:${envConfig?.PORT}`
shell.openExternal(url)
})

eventEmitter.on(EventLists.SETTING_WINDOW_DEV, () => {
settingWindow?.webContents.toggleDevTools();
})

eventEmitter.on(EventLists.SERVER_WINDOW_DEV, () => {
logWindow?.webContents.toggleDevTools();
})

eventEmitter.emit(EventLists.SERVER_WINDOW);
}

(async () => {
Expand Down Expand Up @@ -452,7 +460,6 @@ ipcMain.on('message', async (event, arg) => {
})

ipcMain.on(IPC_TYPES.SETTING_PAGE, async (event, arg) => {
console.log('main setting page', arg);
switch (arg.type) {
case SettingPageTypeMessage.saveSetting:
const existingConfig = getEnvApi();
Expand Down Expand Up @@ -512,13 +519,6 @@ ipcMain.on(IPC_TYPES.SETTING_PAGE, async (event, arg) => {
case SettingPageTypeMessage.themeChange:
eventEmitter.emit(EventLists.CHANGE_THEME, arg.data)
break;
default:
break;
}
})

ipcMain.on(IPC_TYPES.UPDATER_PAGE, (event, arg) => {
switch (arg.type) {
case SettingPageTypeMessage.updateSetting:
LocalStore.updateConfigSetting({
general: {
Expand All @@ -529,7 +529,6 @@ ipcMain.on(IPC_TYPES.UPDATER_PAGE, (event, arg) => {
createIntervalAutoUpdate()
event.sender.send(IPC_TYPES.UPDATER_PAGE, { type: SettingPageTypeMessage.updateSettingResponse, data: true })
break;

default:
break;
}
Expand Down
137 changes: 0 additions & 137 deletions apps/server-web/src/main/main_.ts

This file was deleted.

Loading
Loading