update odlux stage 3
[ccsdk/features.git] / sdnr / wt / odlux / framework / src / app.tsx
1 /**\r
2  * ============LICENSE_START========================================================================\r
3  * ONAP : ccsdk feature sdnr wt odlux\r
4  * =================================================================================================\r
5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.\r
6  * =================================================================================================\r
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
8  * in compliance with the License. You may obtain a copy of the License at\r
9  *\r
10  * http://www.apache.org/licenses/LICENSE-2.0\r
11  *\r
12  * Unless required by applicable law or agreed to in writing, software distributed under the License\r
13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
14  * or implied. See the License for the specific language governing permissions and limitations under\r
15  * the License.\r
16  * ============LICENSE_END==========================================================================\r
17  */\r
18 /******************************************************************************\r
19  * Copyright 2018 highstreet technologies GmbH\r
20  *\r
21  * Licensed under the Apache License, Version 2.0 (the "License");\r
22  * you may not use this file except in compliance with the License.\r
23  * You may obtain a copy of the License at\r
24  *\r
25  *     http://www.apache.org/licenses/LICENSE-2.0\r
26  *\r
27  * Unless required by applicable law or agreed to in writing, software\r
28  * distributed under the License is distributed on an "AS IS" BASIS,\r
29  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
30  * See the License for the specific language governing permissions and\r
31  * limitations under the License.\r
32  *****************************************************************************/\r
33 \r
34 import * as React from 'react';\r
35 import * as ReactDOM from 'react-dom';\r
36 \r
37 import { MuiThemeProvider } from '@material-ui/core/styles';\r
38 \r
39 import { Frame } from './views/frame';\r
40 \r
41 import { AddErrorInfoAction } from './actions/errorActions';\r
42 \r
43 import { applicationStoreCreator } from './store/applicationStore';\r
44 import { ApplicationStoreProvider } from './flux/connect';\r
45 \r
46 import { startHistoryListener } from './middleware/navigation';\r
47 import { startRestService } from './services/restService';\r
48 \r
49 \r
50 import theme from './design/default';\r
51 import '!style-loader!css-loader!./app.css';\r
52 import { ReplaceAction } from './actions/navigationActions';\r
53 import { startForceLogoutService } from './services/forceLogoutService';\r
54 import { startNotificationService } from './services/notificationService';\r
55 \r
56 declare module '@material-ui/core/styles/createMuiTheme' {\r
57 \r
58   interface IDesign {\r
59     id: string,\r
60     name: string,\r
61     url: string,        // image url of a company logo, which will be presented in the ui header\r
62     height: number,     // image height [px] as delivered by the url\r
63     width: number,      // image width [px] as delivered by the url\r
64     logoHeight: number  // height in [px] of the logo (see url) within the ui header\r
65   }\r
66 \r
67   interface Theme {\r
68     design?: IDesign\r
69   }\r
70   interface ThemeOptions {\r
71     design?: IDesign\r
72   }\r
73 }\r
74 \r
75 export const runApplication = () => {\r
76   const applicationStore = applicationStoreCreator();\r
77 \r
78   window.onerror = function (msg: string, url: string, line: number, col: number, error: Error) {\r
79     // Note that col & error are new to the HTML 5 spec and may not be\r
80     // supported in every browser.  It worked for me in Chrome.\r
81     var extra = !col ? '' : '\ncolumn: ' + col;\r
82     extra += !error ? '' : '\nerror: ' + error;\r
83 \r
84     // You can view the information in an alert to see things working like this:\r
85     applicationStore.dispatch(new AddErrorInfoAction({ error, message: msg, url, line, col, info: { extra } }));\r
86 \r
87     var suppressErrorAlert = true;\r
88     // If you return true, then error alerts (like in older versions of\r
89     // Internet Explorer) will be suppressed.\r
90     return suppressErrorAlert;\r
91   };\r
92 \r
93   startRestService(applicationStore);\r
94   startHistoryListener(applicationStore);\r
95   startForceLogoutService(applicationStore);\r
96   startNotificationService(applicationStore);\r
97 \r
98   const App = (): JSX.Element => (\r
99     <ApplicationStoreProvider applicationStore={applicationStore} >\r
100       <MuiThemeProvider theme={theme}>\r
101         <Frame />\r
102       </MuiThemeProvider>\r
103     </ApplicationStoreProvider>\r
104   );\r
105 \r
106   ReactDOM.render(<App />, document.getElementById('app'));\r
107 \r
108 };\r