Skip to content

Commit

Permalink
Merge pull request #2643 from ever-co/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
evereq authored Jun 18, 2024
2 parents 22c9f73 + 4265b74 commit 38a2111
Show file tree
Hide file tree
Showing 64 changed files with 1,993 additions and 344 deletions.
16 changes: 8 additions & 8 deletions apps/extensions/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2356,11 +2356,11 @@ brace-expansion@^1.1.7:
concat-map "0.0.1"

braces@^3.0.2, braces@~3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==
version "3.0.3"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789"
integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==
dependencies:
fill-range "^7.0.1"
fill-range "^7.1.1"

browserslist@4.22.1:
version "4.22.1"
Expand Down Expand Up @@ -3105,10 +3105,10 @@ figures@^5.0.0:
escape-string-regexp "^5.0.0"
is-unicode-supported "^1.2.0"

fill-range@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40"
integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==
fill-range@^7.1.1:
version "7.1.1"
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292"
integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==
dependencies:
to-regex-range "^5.0.1"

Expand Down
16 changes: 8 additions & 8 deletions apps/mobile/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4416,11 +4416,11 @@ brace-expansion@^2.0.1:
balanced-match "^1.0.0"

braces@^3.0.2, braces@~3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==
version "3.0.3"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789"
integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==
dependencies:
fill-range "^7.0.1"
fill-range "^7.1.1"

browser-process-hrtime@^1.0.0:
version "1.0.0"
Expand Down Expand Up @@ -7011,10 +7011,10 @@ file-type@^4.0.0:
resolved "https://registry.yarnpkg.com/file-type/-/file-type-4.4.0.tgz#1b600e5fca1fbdc6e80c0a70c71c8dba5f7906c5"
integrity sha512-f2UbFQEk7LXgWpi5ntcO86OeA/cC80fuDDDaX/fZ2ZGel+AF7leRQqBBW1eJNiiQkrZlAoM6P+VYP5P6bOlDEQ==

fill-range@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40"
integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==
fill-range@^7.1.1:
version "7.1.1"
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292"
integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==
dependencies:
to-regex-range "^5.0.1"

Expand Down
15 changes: 4 additions & 11 deletions apps/server-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
"build:renderer": "cross-env NODE_ENV=production TS_NODE_TRANSPILE_ONLY=true webpack --config ./.erb/configs/webpack.config.renderer.prod.ts",
"postinstall": "ts-node .erb/scripts/check-native-dep.js && electron-builder install-app-deps && npm run build:dll",
"lint": "cross-env NODE_ENV=development eslint . --ext .js,.jsx,.ts,.tsx",
"pack:mac": "electron-builder build --mac --publish never && npm run build:dll",
"pack:win": "electron-builder build --win --publish never && npm run build:dll",
"pack:linux": "electron-builder build --linux --publish never && npm run build:dll",
"pack:mac": "electron-builder build --mac --publish always && npm run build:dll",
"pack:win": "electron-builder build --win --publish always && npm run build:dll",
"pack:linux": "electron-builder build --linux --publish always && npm run build:dll",
"package": "electron-builder build --publish never && npm run build:dll",
"rebuild": "electron-rebuild --parallel --types prod,dev,optional --module-dir release/app",
"start": "ts-node ./.erb/scripts/check-port-in-use.js && npm run start:renderer",
Expand Down Expand Up @@ -239,15 +239,8 @@
"publish": [
{
"provider": "github",
"repo": "ever-teams-web-server",
"repo": "ever-teams",
"releaseType": "release"
},
{
"provider": "spaces",
"name": "ever",
"region": "sfo3",
"path": "/ever-teams-web-server",
"acl": "public-read"
}
]
},
Expand Down
22 changes: 21 additions & 1 deletion apps/server-web/src/main/helpers/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,25 @@ export const EventLists = {
webServerStopped: 'WEB_SERVER_STOPPED',
webServerStart: 'WEB_SERVER_START',
webServerStop: 'WEB_SERVER_STOP',
gotoSetting: 'GO_TO_SETTING'
gotoSetting: 'GO_TO_SETTING',
UPDATE_AVAILABLE: 'UPDATE_AVAILABLE',
UPDATE_ERROR: 'UPDATE_ERROR',
UPDATE_NOT_AVAILABLE: 'UPDATE_NOT_AVAILABLE',
UPDATE_PROGRESS: 'UPDATE_PROGRESS',
UPDATE_DOWNLOADED: 'UPDATE_DOWNLOADED',
UPDATE_CANCELLED: 'UPDATE_CANCELLED'
}

export const SettingPageTypeMessage = {
loadSetting: 'load-setting',
checkUpdate: 'check-for-update',
updateAvailable: 'update-available',
downloadingUpdate: 'downloading-update',
downloaded: 'downloaded-update',
installUpdate: 'install-update',
saveSetting: 'save-setting',
updateError: 'update-error',
upToDate: 'uptodate',
mainResponse: 'main-response',
showVersion: 'show-version'
}
94 changes: 75 additions & 19 deletions apps/server-web/src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import { DesktopServer } from './helpers/desktop-server';
import { LocalStore } from './helpers/services/libs/desktop-store';
import { EventEmitter } from 'events';
import { defaultTrayMenuItem, _initTray, updateTrayMenu } from './tray';
import { EventLists } from './helpers/constant';
import { EventLists, SettingPageTypeMessage } from './helpers/constant';
import { resolveHtmlPath } from './util';
import Updater from './updater';

const eventEmiter = new EventEmitter();
const eventEmitter = new EventEmitter();

const controller = new AbortController();
const { signal } = controller;
const isPack = app.isPackaged;
const desktopServer = new DesktopServer(false, eventEmiter);
const desktopServer = new DesktopServer(false, eventEmitter);
const isProd = process.env.NODE_ENV === 'production';

// const appPath = app.getAppPath();
Expand All @@ -21,8 +22,9 @@ let isServerRun: boolean;

let tray:Tray;
let settingWindow: BrowserWindow | null = null;
const updater = new Updater(eventEmitter);

const trayMenuItems = defaultTrayMenuItem(eventEmiter);
const trayMenuItems = defaultTrayMenuItem(eventEmitter);

const RESOURCES_PATH = app.isPackaged
? path.join(process.resourcesPath, 'assets/icons/gauzy')
Expand Down Expand Up @@ -138,47 +140,83 @@ const getEnvApi = () => {
return setting;
};

const SendMessageToSettingWindow = (type: string, data: any) => {
settingWindow?.webContents.send('setting-page', {
type,
data
});
}

const onInitApplication = () => {
LocalStore.setDefaultServerConfig(); // check and set default config
tray = _initTray(trayMenuItems, getAssetPath('icon.png'));
eventEmiter.on(EventLists.webServerStart, async () => {
updateTrayMenu('SERVER_START', { enabled: false }, eventEmiter, tray, trayMenuItems);
eventEmitter.on(EventLists.webServerStart, async () => {
updateTrayMenu('SERVER_START', { enabled: false }, eventEmitter, tray, trayMenuItems);
isServerRun = true;
await runServer();
})

eventEmiter.on(EventLists.webServerStop, async () => {
eventEmitter.on(EventLists.webServerStop, async () => {
isServerRun = false;
await stopServer();
})

eventEmiter.on(EventLists.webServerStarted, () => {
eventEmitter.on(EventLists.webServerStarted, () => {
console.log(EventLists.webServerStarted)
updateTrayMenu('SERVER_START', { enabled: false }, eventEmiter, tray, trayMenuItems);
updateTrayMenu('SERVER_STOP', { enabled: true }, eventEmiter, tray, trayMenuItems);
updateTrayMenu('SERVER_STATUS', { label: 'Status: Started' }, eventEmiter, tray, trayMenuItems);
updateTrayMenu('SERVER_START', { enabled: false }, eventEmitter, tray, trayMenuItems);
updateTrayMenu('SERVER_STOP', { enabled: true }, eventEmitter, tray, trayMenuItems);
updateTrayMenu('SERVER_STATUS', { label: 'Status: Started' }, eventEmitter, tray, trayMenuItems);
isServerRun = true;
})

eventEmiter.on(EventLists.webServerStopped, () => {
eventEmitter.on(EventLists.webServerStopped, () => {
console.log(EventLists.webServerStopped);
updateTrayMenu('SERVER_STOP', { enabled: false }, eventEmiter, tray, trayMenuItems);
updateTrayMenu('SERVER_START', { enabled: true }, eventEmiter, tray, trayMenuItems);
updateTrayMenu('SERVER_STATUS', { label: 'Status: Stopped' }, eventEmiter, tray, trayMenuItems);
updateTrayMenu('SERVER_STOP', { enabled: false }, eventEmitter, tray, trayMenuItems);
updateTrayMenu('SERVER_START', { enabled: true }, eventEmitter, tray, trayMenuItems);
updateTrayMenu('SERVER_STATUS', { label: 'Status: Stopped' }, eventEmitter, tray, trayMenuItems);
isServerRun = false;
})

eventEmiter.on(EventLists.gotoSetting, async () => {
eventEmitter.on(EventLists.gotoSetting, async () => {
if (!settingWindow) {
await createWindow()
}
const serverSetting = LocalStore.getStore('config');
console.log('setting data', serverSetting);
settingWindow?.show();
settingWindow?.webContents.once('did-finish-load', () => {
settingWindow?.webContents.send('load_setting', serverSetting);
SendMessageToSettingWindow(SettingPageTypeMessage.loadSetting, serverSetting);
})
})

eventEmitter.on(EventLists.UPDATE_AVAILABLE, (data)=> {
console.log('UPDATE_AVAILABLE', data);
SendMessageToSettingWindow(SettingPageTypeMessage.updateAvailable, data);
})

eventEmitter.on(EventLists.UPDATE_ERROR, (data)=> {
console.log('UPDATE_ERROR', data);
SendMessageToSettingWindow(SettingPageTypeMessage.updateError, {message: JSON.stringify(data)});
})

eventEmitter.on(EventLists.UPDATE_NOT_AVAILABLE, (data)=> {
console.log('UPDATE_NOT_AVAILABLE', data);
SendMessageToSettingWindow(SettingPageTypeMessage.upToDate, data);
})

eventEmitter.on(EventLists.UPDATE_PROGRESS, (data)=> {
console.log('UPDATE_PROGRESS', data.percent);
SendMessageToSettingWindow(SettingPageTypeMessage.downloadingUpdate, {percent: Math.floor(data.percent || 0)});
})

eventEmitter.on(EventLists.UPDATE_DOWNLOADED, (data)=> {
console.log('UPDATE_DOWNLOADED', data);
SendMessageToSettingWindow(SettingPageTypeMessage.downloaded, data);
})

eventEmitter.on(EventLists.UPDATE_CANCELLED, (data)=> {
console.log('UPDATE_CANCELLED', data);
})
}

(async () => {
Expand All @@ -195,8 +233,26 @@ ipcMain.on('message', async (event, arg) => {
event.reply('message', `${arg} World!`)
})

ipcMain.on('save_setting', (event, arg) => {
LocalStore.updateConfigSetting(arg);
ipcMain.on('setting-page', (event, arg) => {
console.log('main setting page', arg);
switch (arg.type) {
case SettingPageTypeMessage.saveSetting:
LocalStore.updateConfigSetting(arg.data);
event.sender.send('setting-page', { type: SettingPageTypeMessage.mainResponse, data: true });
break;
case SettingPageTypeMessage.checkUpdate:
updater.checkUpdate();
break;
case SettingPageTypeMessage.installUpdate:
updater.installUpdate();
break;
case SettingPageTypeMessage.showVersion:
const currentVersion = app.getVersion();
event.sender.send('setting-page', { type: SettingPageTypeMessage.showVersion, data: currentVersion})
break;
default:
break;
}
})

app.on('before-quit', async (e) => {
Expand Down
5 changes: 4 additions & 1 deletion apps/server-web/src/main/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
/* eslint no-unused-vars: off */
import { contextBridge, ipcRenderer, IpcRendererEvent } from 'electron';

export type Channels = 'ipc-example';
export type Channels = 'setting-page' | 'ipc-renderer';

const electronHandler = {
ipcRenderer: {
sendMessage(channel: Channels, ...args: unknown[]) {
ipcRenderer.send(channel, ...args);
},
sendMessageSync(channel: Channels, ...args: unknown[]) {
ipcRenderer.sendSync(channel, ...args);
},
on(channel: Channels, func: (...args: unknown[]) => void) {
const subscription = (_event: IpcRendererEvent, ...args: unknown[]) =>
func(...args);
Expand Down
45 changes: 45 additions & 0 deletions apps/server-web/src/main/updater.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { autoUpdater, } from 'electron-updater';
import log from 'electron-log';
import EventEmitter from 'events';
import { EventLists } from './helpers/constant';

class AppUpdater {
constructor(eventEmitter: EventEmitter) {
log.transports.file.level = 'info';
autoUpdater.logger = log;
autoUpdater.on('update-available', () => {
eventEmitter.emit(EventLists.UPDATE_AVAILABLE);
})

autoUpdater.on('error', (message) => {
eventEmitter.emit(EventLists.UPDATE_ERROR, message);
})

autoUpdater.on('update-not-available', (info) => {
eventEmitter.emit(EventLists.UPDATE_NOT_AVAILABLE, info);
})

autoUpdater.on('download-progress', (info) => {
eventEmitter.emit(EventLists.UPDATE_PROGRESS, info);
})

autoUpdater.on('update-downloaded', (data) => {
eventEmitter.emit(EventLists.UPDATE_DOWNLOADED, data);
})

autoUpdater.on('update-cancelled', (info) => {
eventEmitter.emit(EventLists.UPDATE_CANCELLED, info);
})
// autoUpdater.checkForUpdatesAndNotify();
}

checkUpdate() {
autoUpdater.checkForUpdates();
}

installUpdate() {
autoUpdater.quitAndInstall();
}
}

export default AppUpdater;
18 changes: 18 additions & 0 deletions apps/server-web/src/renderer/components/About.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { EverTeamsLogo } from './svgs';
type Props = {
version: string;
};
export const AboutComponent = (props: Props) => {
return (
<div className="flex min-h-screen items-center justify-center bg-gray-100">
<div className="rounded-lg bg-gray-50 px-16 py-14">
<div className="flex justify-center">
<EverTeamsLogo />
</div>
<h2 className="w-[230px] text-center text-gray-600 mt-10">
V {props.version}
</h2>
</div>
</div>
);
};
Loading

0 comments on commit 38a2111

Please sign in to comment.