SymphonyElectron/src/renderer/preload-component.ts

100 lines
3.7 KiB
TypeScript
Raw Normal View History

2019-01-07 05:53:44 -06:00
import { ipcRenderer } from 'electron';
2018-10-29 13:52:58 -05:00
import * as React from 'react';
import * as ReactDOM from 'react-dom';
2019-01-07 05:53:44 -06:00
import { i18n } from '../common/i18n-preload';
import AboutBox from './components/about-app';
2019-01-07 05:53:44 -06:00
import BasicAuth from './components/basic-auth';
Merge TS context isolation branch onto Typescript master branch (#598) * Typescript 🎉 * Typescript 🎉 (logger, get-guid, string-format and throttle) * Refactor typescript code * consolidate all the utility functions to one file * refactor protocol handler feature * Typescript: Add code documentation Add pre-commit hooks * Typescript: Fix logger formatting * Typescript: Add support for react * Typescript: Completed about app * Typescript: Completed about app * Typescript: Completed about app * Typescript - Fix issues with about-app and add login to convert less to css * Typescript - Fix loading screen * Typescript - Add custom title bar * Typescript - Add method to get locale * Typescript - Add logic to clean up old logs * Typescript - Add set badge count api * Typescript - Complete application menu * Typescript - Add logic to translate menu items * Typescript - freeze window.ssf api * Typescript - Handle popup menu on alt key press * Typescript - Completed activity detection * Typescript - Completed screen snippet * Typescript - Add login to close screen snippet * Typescript - Completed window actions & snackbar, Updated i18n module * Typescript - Completed native crypto implementation & fixed bugs * Typescript - Completed Desktop capturer & screen picker implementation * Typescript - Optimize window actions * Typescript - Add support for child window * Typescript - fix pop url validation issue & browserify preload * Typescript - Completed context menu implementation and fixed screen snippet * Typescript - Completed screen sharing indicator and fixed i18n usage issue * Typescript - Fix i18n locale setting issue * Typescript - Completed download manager * Typescript - Completed Basic auth * Typescript - Network connectivity dialog * Typescript - Handle certificate error * Typescript - Add translation for certificate error dialog buttons * Typescript - Add gulp tasks to compile less, typescript and copy files * Typescript - Fix some issues with custom title bar, loading screen & screen snippet * Typescript - Remove ES2015 lib * :typescript: - Do not inject custom title bar for mac * :typescript: - Fix screen sharing indicator text and format string * Typescript - Fix esc to full screen * Typescript - handle multiple/single instance of the client and add safety checks * Typescript - Refactor code base * Typescript - Optimize window validation and fix screen picker issue * Typescript - Optimize protocol handler * typescript: logger unit test * typescript: activityDetection unit test (#560) * ELECTRON-1022 - Create app bridge that communicates between renderer and preload via postMessage * ELECTRON-1024 - Add support for screen share and screen sharing indicator * config unit test (#566) * ELECTRON-1024 - Fix screen sharing indicator close issue * ELECTRON-1022 - Bump Symphony version to 5.0.0 (1.55) * fixing jest coverage output report (#575) * protocol handle unit test (#576) * Typescript - Remove unwanted checks in protocol handler and add test cases * added more tests to increase coverage to 100 for protocol handler * Typescript download manager unit test (#579) * adding enzyme * download manager unit test * Typescript - Completed notification workflow * about app unit test * Typescript - Fix notification styles * fixing Compiler error: Generic type ReactElement<P, T> (#583) * fix app path on windows (#580) * basic auth unit test (#582) * screen picker unit test (#587) * screen picker unit test * screen sharing indicator unit test * loading screen unit test (#588) * improving snapshot using snapshotSerializers to remove unnecessary things (#596) * Typescript - Enforce braces for if/for/do/while statements. * Typescript - Fix Lint issues and Unit test * Typescript - Enable eofline (Ensure the file ends with a newline.) * Typescript - Update logger logic and format * Typescript - Provide option for user to set custom log path * Typescript - Fix eofline in css files * Typescript - ignore spec from compiling and remove unwanted rebuild command
2019-03-19 05:52:39 -05:00
import NotificationComp from './components/notification-comp';
import NotificationSettings from './components/notification-settings';
import ScreenPicker from './components/screen-picker';
import ScreenSharingFrame from './components/screen-sharing-frame';
import ScreenSharingIndicator from './components/screen-sharing-indicator';
import SnippingTool from './components/snipping-tool';
import Welcome from './components/welcome';
const enum components {
aboutApp = 'about-app',
screenPicker = 'screen-picker',
screenSharingIndicator = 'screen-sharing-indicator',
screenSharingFrame = 'screen-sharing-frame',
2019-01-07 05:53:44 -06:00
basicAuth = 'basic-auth',
Merge TS context isolation branch onto Typescript master branch (#598) * Typescript 🎉 * Typescript 🎉 (logger, get-guid, string-format and throttle) * Refactor typescript code * consolidate all the utility functions to one file * refactor protocol handler feature * Typescript: Add code documentation Add pre-commit hooks * Typescript: Fix logger formatting * Typescript: Add support for react * Typescript: Completed about app * Typescript: Completed about app * Typescript: Completed about app * Typescript - Fix issues with about-app and add login to convert less to css * Typescript - Fix loading screen * Typescript - Add custom title bar * Typescript - Add method to get locale * Typescript - Add logic to clean up old logs * Typescript - Add set badge count api * Typescript - Complete application menu * Typescript - Add logic to translate menu items * Typescript - freeze window.ssf api * Typescript - Handle popup menu on alt key press * Typescript - Completed activity detection * Typescript - Completed screen snippet * Typescript - Add login to close screen snippet * Typescript - Completed window actions & snackbar, Updated i18n module * Typescript - Completed native crypto implementation & fixed bugs * Typescript - Completed Desktop capturer & screen picker implementation * Typescript - Optimize window actions * Typescript - Add support for child window * Typescript - fix pop url validation issue & browserify preload * Typescript - Completed context menu implementation and fixed screen snippet * Typescript - Completed screen sharing indicator and fixed i18n usage issue * Typescript - Fix i18n locale setting issue * Typescript - Completed download manager * Typescript - Completed Basic auth * Typescript - Network connectivity dialog * Typescript - Handle certificate error * Typescript - Add translation for certificate error dialog buttons * Typescript - Add gulp tasks to compile less, typescript and copy files * Typescript - Fix some issues with custom title bar, loading screen & screen snippet * Typescript - Remove ES2015 lib * :typescript: - Do not inject custom title bar for mac * :typescript: - Fix screen sharing indicator text and format string * Typescript - Fix esc to full screen * Typescript - handle multiple/single instance of the client and add safety checks * Typescript - Refactor code base * Typescript - Optimize window validation and fix screen picker issue * Typescript - Optimize protocol handler * typescript: logger unit test * typescript: activityDetection unit test (#560) * ELECTRON-1022 - Create app bridge that communicates between renderer and preload via postMessage * ELECTRON-1024 - Add support for screen share and screen sharing indicator * config unit test (#566) * ELECTRON-1024 - Fix screen sharing indicator close issue * ELECTRON-1022 - Bump Symphony version to 5.0.0 (1.55) * fixing jest coverage output report (#575) * protocol handle unit test (#576) * Typescript - Remove unwanted checks in protocol handler and add test cases * added more tests to increase coverage to 100 for protocol handler * Typescript download manager unit test (#579) * adding enzyme * download manager unit test * Typescript - Completed notification workflow * about app unit test * Typescript - Fix notification styles * fixing Compiler error: Generic type ReactElement<P, T> (#583) * fix app path on windows (#580) * basic auth unit test (#582) * screen picker unit test (#587) * screen picker unit test * screen sharing indicator unit test * loading screen unit test (#588) * improving snapshot using snapshotSerializers to remove unnecessary things (#596) * Typescript - Enforce braces for if/for/do/while statements. * Typescript - Fix Lint issues and Unit test * Typescript - Enable eofline (Ensure the file ends with a newline.) * Typescript - Update logger logic and format * Typescript - Provide option for user to set custom log path * Typescript - Fix eofline in css files * Typescript - ignore spec from compiling and remove unwanted rebuild command
2019-03-19 05:52:39 -05:00
notification = 'notification-comp',
notificationSettings = 'notification-settings',
welcome = 'welcome',
snippingTool = 'snipping-tool',
}
const loadStyle = (style) => {
const styles = document.createElement('link');
styles.rel = 'stylesheet';
styles.type = 'text/css';
styles.href = `./styles/${style}.css`;
document.getElementsByTagName('head')[0].appendChild(styles);
};
2018-10-29 13:52:58 -05:00
/**
* Loads the appropriate component
*/
const load = () => {
2018-10-29 13:52:58 -05:00
const query = new URL(window.location.href).searchParams;
const componentName = query.get('componentName');
2018-10-29 13:52:58 -05:00
let component;
switch (componentName) {
case components.aboutApp:
loadStyle(components.aboutApp);
2018-10-29 13:52:58 -05:00
component = AboutBox;
document.title = i18n.t('About Symphony', 'AboutSymphony')();
2018-12-03 11:46:47 -06:00
break;
case components.screenPicker:
loadStyle(components.screenPicker);
document.title = i18n.t('Screen Picker - Symphony')();
component = ScreenPicker;
break;
case components.screenSharingIndicator:
loadStyle(components.screenSharingIndicator);
document.title = i18n.t('Screen Sharing Indicator - Symphony')();
component = ScreenSharingIndicator;
break;
case components.screenSharingFrame:
loadStyle(components.screenSharingFrame);
component = ScreenSharingFrame;
break;
case components.snippingTool:
loadStyle(components.snippingTool);
document.title = i18n.t('Symphony')();
component = SnippingTool;
break;
2019-01-07 05:53:44 -06:00
case components.basicAuth:
loadStyle(components.basicAuth);
document.title = i18n.t('Basic Authentication - Symphony')();
2019-01-07 05:53:44 -06:00
component = BasicAuth;
break;
Merge TS context isolation branch onto Typescript master branch (#598) * Typescript 🎉 * Typescript 🎉 (logger, get-guid, string-format and throttle) * Refactor typescript code * consolidate all the utility functions to one file * refactor protocol handler feature * Typescript: Add code documentation Add pre-commit hooks * Typescript: Fix logger formatting * Typescript: Add support for react * Typescript: Completed about app * Typescript: Completed about app * Typescript: Completed about app * Typescript - Fix issues with about-app and add login to convert less to css * Typescript - Fix loading screen * Typescript - Add custom title bar * Typescript - Add method to get locale * Typescript - Add logic to clean up old logs * Typescript - Add set badge count api * Typescript - Complete application menu * Typescript - Add logic to translate menu items * Typescript - freeze window.ssf api * Typescript - Handle popup menu on alt key press * Typescript - Completed activity detection * Typescript - Completed screen snippet * Typescript - Add login to close screen snippet * Typescript - Completed window actions & snackbar, Updated i18n module * Typescript - Completed native crypto implementation & fixed bugs * Typescript - Completed Desktop capturer & screen picker implementation * Typescript - Optimize window actions * Typescript - Add support for child window * Typescript - fix pop url validation issue & browserify preload * Typescript - Completed context menu implementation and fixed screen snippet * Typescript - Completed screen sharing indicator and fixed i18n usage issue * Typescript - Fix i18n locale setting issue * Typescript - Completed download manager * Typescript - Completed Basic auth * Typescript - Network connectivity dialog * Typescript - Handle certificate error * Typescript - Add translation for certificate error dialog buttons * Typescript - Add gulp tasks to compile less, typescript and copy files * Typescript - Fix some issues with custom title bar, loading screen & screen snippet * Typescript - Remove ES2015 lib * :typescript: - Do not inject custom title bar for mac * :typescript: - Fix screen sharing indicator text and format string * Typescript - Fix esc to full screen * Typescript - handle multiple/single instance of the client and add safety checks * Typescript - Refactor code base * Typescript - Optimize window validation and fix screen picker issue * Typescript - Optimize protocol handler * typescript: logger unit test * typescript: activityDetection unit test (#560) * ELECTRON-1022 - Create app bridge that communicates between renderer and preload via postMessage * ELECTRON-1024 - Add support for screen share and screen sharing indicator * config unit test (#566) * ELECTRON-1024 - Fix screen sharing indicator close issue * ELECTRON-1022 - Bump Symphony version to 5.0.0 (1.55) * fixing jest coverage output report (#575) * protocol handle unit test (#576) * Typescript - Remove unwanted checks in protocol handler and add test cases * added more tests to increase coverage to 100 for protocol handler * Typescript download manager unit test (#579) * adding enzyme * download manager unit test * Typescript - Completed notification workflow * about app unit test * Typescript - Fix notification styles * fixing Compiler error: Generic type ReactElement<P, T> (#583) * fix app path on windows (#580) * basic auth unit test (#582) * screen picker unit test (#587) * screen picker unit test * screen sharing indicator unit test * loading screen unit test (#588) * improving snapshot using snapshotSerializers to remove unnecessary things (#596) * Typescript - Enforce braces for if/for/do/while statements. * Typescript - Fix Lint issues and Unit test * Typescript - Enable eofline (Ensure the file ends with a newline.) * Typescript - Update logger logic and format * Typescript - Provide option for user to set custom log path * Typescript - Fix eofline in css files * Typescript - ignore spec from compiling and remove unwanted rebuild command
2019-03-19 05:52:39 -05:00
case components.notification:
loadStyle(components.notification);
document.title = i18n.t('Notification - Symphony')();
Merge TS context isolation branch onto Typescript master branch (#598) * Typescript 🎉 * Typescript 🎉 (logger, get-guid, string-format and throttle) * Refactor typescript code * consolidate all the utility functions to one file * refactor protocol handler feature * Typescript: Add code documentation Add pre-commit hooks * Typescript: Fix logger formatting * Typescript: Add support for react * Typescript: Completed about app * Typescript: Completed about app * Typescript: Completed about app * Typescript - Fix issues with about-app and add login to convert less to css * Typescript - Fix loading screen * Typescript - Add custom title bar * Typescript - Add method to get locale * Typescript - Add logic to clean up old logs * Typescript - Add set badge count api * Typescript - Complete application menu * Typescript - Add logic to translate menu items * Typescript - freeze window.ssf api * Typescript - Handle popup menu on alt key press * Typescript - Completed activity detection * Typescript - Completed screen snippet * Typescript - Add login to close screen snippet * Typescript - Completed window actions & snackbar, Updated i18n module * Typescript - Completed native crypto implementation & fixed bugs * Typescript - Completed Desktop capturer & screen picker implementation * Typescript - Optimize window actions * Typescript - Add support for child window * Typescript - fix pop url validation issue & browserify preload * Typescript - Completed context menu implementation and fixed screen snippet * Typescript - Completed screen sharing indicator and fixed i18n usage issue * Typescript - Fix i18n locale setting issue * Typescript - Completed download manager * Typescript - Completed Basic auth * Typescript - Network connectivity dialog * Typescript - Handle certificate error * Typescript - Add translation for certificate error dialog buttons * Typescript - Add gulp tasks to compile less, typescript and copy files * Typescript - Fix some issues with custom title bar, loading screen & screen snippet * Typescript - Remove ES2015 lib * :typescript: - Do not inject custom title bar for mac * :typescript: - Fix screen sharing indicator text and format string * Typescript - Fix esc to full screen * Typescript - handle multiple/single instance of the client and add safety checks * Typescript - Refactor code base * Typescript - Optimize window validation and fix screen picker issue * Typescript - Optimize protocol handler * typescript: logger unit test * typescript: activityDetection unit test (#560) * ELECTRON-1022 - Create app bridge that communicates between renderer and preload via postMessage * ELECTRON-1024 - Add support for screen share and screen sharing indicator * config unit test (#566) * ELECTRON-1024 - Fix screen sharing indicator close issue * ELECTRON-1022 - Bump Symphony version to 5.0.0 (1.55) * fixing jest coverage output report (#575) * protocol handle unit test (#576) * Typescript - Remove unwanted checks in protocol handler and add test cases * added more tests to increase coverage to 100 for protocol handler * Typescript download manager unit test (#579) * adding enzyme * download manager unit test * Typescript - Completed notification workflow * about app unit test * Typescript - Fix notification styles * fixing Compiler error: Generic type ReactElement<P, T> (#583) * fix app path on windows (#580) * basic auth unit test (#582) * screen picker unit test (#587) * screen picker unit test * screen sharing indicator unit test * loading screen unit test (#588) * improving snapshot using snapshotSerializers to remove unnecessary things (#596) * Typescript - Enforce braces for if/for/do/while statements. * Typescript - Fix Lint issues and Unit test * Typescript - Enable eofline (Ensure the file ends with a newline.) * Typescript - Update logger logic and format * Typescript - Provide option for user to set custom log path * Typescript - Fix eofline in css files * Typescript - ignore spec from compiling and remove unwanted rebuild command
2019-03-19 05:52:39 -05:00
component = NotificationComp;
break;
case components.notificationSettings:
document.title = i18n.t('Notification Settings - Symphony', 'NotificationSettings')();
loadStyle(components.notificationSettings);
component = NotificationSettings;
break;
case components.welcome:
document.title = i18n.t('WelcomeText', 'Welcome')();
loadStyle(components.welcome);
component = Welcome;
break;
2018-10-29 13:52:58 -05:00
}
2018-11-15 03:15:37 -06:00
const element = React.createElement(component);
ReactDOM.render(element, document.getElementById('Root'));
};
ipcRenderer.on('page-load', (_event, data) => {
2019-01-07 05:53:44 -06:00
const { locale, resource } = data;
i18n.setResource(locale, resource);
// Renders component as soon as the page is ready
load();
Merge TS context isolation branch onto Typescript master branch (#598) * Typescript 🎉 * Typescript 🎉 (logger, get-guid, string-format and throttle) * Refactor typescript code * consolidate all the utility functions to one file * refactor protocol handler feature * Typescript: Add code documentation Add pre-commit hooks * Typescript: Fix logger formatting * Typescript: Add support for react * Typescript: Completed about app * Typescript: Completed about app * Typescript: Completed about app * Typescript - Fix issues with about-app and add login to convert less to css * Typescript - Fix loading screen * Typescript - Add custom title bar * Typescript - Add method to get locale * Typescript - Add logic to clean up old logs * Typescript - Add set badge count api * Typescript - Complete application menu * Typescript - Add logic to translate menu items * Typescript - freeze window.ssf api * Typescript - Handle popup menu on alt key press * Typescript - Completed activity detection * Typescript - Completed screen snippet * Typescript - Add login to close screen snippet * Typescript - Completed window actions & snackbar, Updated i18n module * Typescript - Completed native crypto implementation & fixed bugs * Typescript - Completed Desktop capturer & screen picker implementation * Typescript - Optimize window actions * Typescript - Add support for child window * Typescript - fix pop url validation issue & browserify preload * Typescript - Completed context menu implementation and fixed screen snippet * Typescript - Completed screen sharing indicator and fixed i18n usage issue * Typescript - Fix i18n locale setting issue * Typescript - Completed download manager * Typescript - Completed Basic auth * Typescript - Network connectivity dialog * Typescript - Handle certificate error * Typescript - Add translation for certificate error dialog buttons * Typescript - Add gulp tasks to compile less, typescript and copy files * Typescript - Fix some issues with custom title bar, loading screen & screen snippet * Typescript - Remove ES2015 lib * :typescript: - Do not inject custom title bar for mac * :typescript: - Fix screen sharing indicator text and format string * Typescript - Fix esc to full screen * Typescript - handle multiple/single instance of the client and add safety checks * Typescript - Refactor code base * Typescript - Optimize window validation and fix screen picker issue * Typescript - Optimize protocol handler * typescript: logger unit test * typescript: activityDetection unit test (#560) * ELECTRON-1022 - Create app bridge that communicates between renderer and preload via postMessage * ELECTRON-1024 - Add support for screen share and screen sharing indicator * config unit test (#566) * ELECTRON-1024 - Fix screen sharing indicator close issue * ELECTRON-1022 - Bump Symphony version to 5.0.0 (1.55) * fixing jest coverage output report (#575) * protocol handle unit test (#576) * Typescript - Remove unwanted checks in protocol handler and add test cases * added more tests to increase coverage to 100 for protocol handler * Typescript download manager unit test (#579) * adding enzyme * download manager unit test * Typescript - Completed notification workflow * about app unit test * Typescript - Fix notification styles * fixing Compiler error: Generic type ReactElement<P, T> (#583) * fix app path on windows (#580) * basic auth unit test (#582) * screen picker unit test (#587) * screen picker unit test * screen sharing indicator unit test * loading screen unit test (#588) * improving snapshot using snapshotSerializers to remove unnecessary things (#596) * Typescript - Enforce braces for if/for/do/while statements. * Typescript - Fix Lint issues and Unit test * Typescript - Enable eofline (Ensure the file ends with a newline.) * Typescript - Update logger logic and format * Typescript - Provide option for user to set custom log path * Typescript - Fix eofline in css files * Typescript - ignore spec from compiling and remove unwanted rebuild command
2019-03-19 05:52:39 -05:00
});