2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt odlux
4 * =================================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6 * =================================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
16 * ============LICENSE_END==========================================================================
19 import * as React from 'react';
20 import * as ReactDOM from 'react-dom';
22 import { ThemeProvider, Theme, StyledEngineProvider } from '@mui/material/styles';
24 import { Frame } from './views/frame';
26 import { User } from './models/authentication';
28 import { AddErrorInfoAction } from './actions/errorActions';
29 import { loginUserAction } from './actions/authentication';
31 import { applicationStoreCreator } from './store/applicationStore';
32 import { ApplicationStoreProvider } from './flux/connect';
34 import { startHistoryListener } from './middleware/navigation';
35 import { startSoreService } from './services/storeService';
37 import { startUserSessionService } from './services/userSessionService';
38 import { startNotificationService } from './services/notificationService';
40 import { startBroadcastChannel } from './services/broadcastService';
42 import theme from './design/default';
43 import '!style-loader!css-loader!./app.css';
45 declare module '@mui/material/styles' {
50 url: string, // image url of a company logo, which will be presented in the ui header
51 height: number, // image height [px] as delivered by the url
52 width: number, // image width [px] as delivered by the url
53 logoHeight: number // height in [px] of the logo (see url) within the ui header
59 interface DeprecatedThemeOptions {
65 declare module '@mui/styles/defaultTheme' {
66 // eslint-disable-next-line @typescript-eslint/no-empty-interface (remove this line if you don't have the rule enabled)
67 interface DefaultTheme extends Theme {}
70 export { configureApplication } from "./handlers/applicationStateHandler";
72 export const transportPCEUrl = "transportPCEUrl";
74 export const runApplication = () => {
76 const initialToken = localStorage.getItem("userToken");
77 const applicationStore = applicationStoreCreator();
79 startBroadcastChannel(applicationStore);
80 startUserSessionService(applicationStore);
83 applicationStore.dispatch(loginUserAction(User.fromString(initialToken) || undefined));
86 window.onerror = function (msg: string, url: string, line: number, col: number, error: Error) {
87 // Note that col & error are new to the HTML 5 spec and may not be
88 // supported in every browser. It worked for me in Chrome.
89 var extra = !col ? '' : '\ncolumn: ' + col;
90 extra += !error ? '' : '\nerror: ' + error;
92 // You can view the information in an alert to see things working like this:
93 applicationStore.dispatch(new AddErrorInfoAction({ error, message: msg, url, line, col, info: { extra } }));
95 var suppressErrorAlert = true;
96 // If you return true, then error alerts (like in older versions of
97 // Internet Explorer) will be suppressed.
98 return suppressErrorAlert;
102 startSoreService(applicationStore);
103 startHistoryListener(applicationStore);
104 startNotificationService(applicationStore);
106 const App = (): JSX.Element => (
107 <ApplicationStoreProvider applicationStore={applicationStore} >
108 <StyledEngineProvider injectFirst>
109 <ThemeProvider theme={theme}>
112 </StyledEngineProvider>
113 </ApplicationStoreProvider>
116 ReactDOM.render(<App />, document.getElementById('app'));