asab_webui_shell 27.8.5 → 28.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions.js +15 -15
- package/dist/components/branding/BrandImage.js +3 -5
- package/dist/components/locationReplace.js +5 -11
- package/dist/config/ConfigReducer.js +2 -4
- package/dist/config/ConfigService.js +7 -10
- package/dist/containers/Alerts/index.js +34 -45
- package/dist/containers/Alerts/reducer.js +19 -20
- package/dist/containers/Application.js +200 -207
- package/dist/containers/FullscreenMode/reducer.js +5 -10
- package/dist/containers/Header/ApplicationScreenTitle/ApplicationScreenTitle.js +27 -32
- package/dist/containers/Header/ApplicationScreenTitle/index.js +8 -10
- package/dist/containers/Header/Help/HelpButton.js +58 -55
- package/dist/containers/Header/Help/HelpService.js +3 -4
- package/dist/containers/Header/index.js +23 -23
- package/dist/containers/Header/reducer.js +13 -15
- package/dist/containers/Navigation/index.js +4 -6
- package/dist/containers/Navigation/reducer.js +7 -11
- package/dist/containers/RouteErrorHandler/ErrorContainer.js +47 -31
- package/dist/containers/RouteErrorHandler/index.js +26 -27
- package/dist/containers/Router/ApplicationHashRouter.js +7 -8
- package/dist/containers/Router/ApplicationRouter.js +38 -38
- package/dist/containers/Router/index.js +2 -4
- package/dist/containers/Router/reducer.js +7 -11
- package/dist/containers/Sidebar/NavbarBrand.js +30 -38
- package/dist/containers/Sidebar/SidebarBottomItem.js +42 -36
- package/dist/containers/Sidebar/SidebarIcon.js +12 -9
- package/dist/containers/Sidebar/SidebarItem.js +135 -132
- package/dist/containers/Sidebar/SidebarItemRenderer.js +25 -26
- package/dist/containers/Sidebar/index.js +55 -70
- package/dist/containers/Sidebar/reducer.js +7 -11
- package/dist/containers/Sidebar/utils/sidebarRouteMatch.js +12 -15
- package/dist/containers/Sidepanel/Sidepanel.js +35 -40
- package/dist/containers/Toast/ToastComponent.js +21 -15
- package/dist/containers/Toast/ToastContainer.js +23 -32
- package/dist/containers/Toast/reducer.js +14 -16
- package/dist/index.js +10 -10
- package/dist/modules/about/AboutScreen.js +80 -65
- package/dist/modules/about/index.js +3 -3
- package/dist/modules/attentionrequired/attentionRequiredReducer.js +5 -10
- package/dist/modules/attentionrequired/components/OfflineIndication.js +9 -7
- package/dist/modules/attentionrequired/connectivityReducer.js +5 -10
- package/dist/modules/attentionrequired/index.js +2 -3
- package/dist/modules/attentionrequired/service.js +21 -24
- package/dist/modules/auth/actions.js +1 -1
- package/dist/modules/auth/api.js +53 -61
- package/dist/modules/auth/components/LoginLoopCard.js +24 -15
- package/dist/modules/auth/components/SessionExpirationAlert.js +26 -18
- package/dist/modules/auth/header.js +69 -62
- package/dist/modules/auth/index.js +418 -458
- package/dist/modules/auth/reducer.js +11 -14
- package/dist/modules/auth/screens/AccessControlScreen.js +71 -50
- package/dist/modules/i18n/actions.js +1 -1
- package/dist/modules/i18n/dropdown.js +52 -46
- package/dist/modules/i18n/escapeHtmlMinimal.js +2 -2
- package/dist/modules/i18n/index.js +2 -2
- package/dist/modules/i18n/reducer.js +5 -10
- package/dist/modules/i18n/service.js +52 -73
- package/dist/modules/invite/InvitationScreen.js +162 -138
- package/dist/modules/invite/index.js +5 -4
- package/dist/modules/tenant/TenantDropdown.js +52 -58
- package/dist/modules/tenant/access/AccessDeniedCard.js +52 -52
- package/dist/modules/tenant/actions.js +1 -1
- package/dist/modules/tenant/index.js +2 -2
- package/dist/modules/tenant/reducer.js +2 -4
- package/dist/modules/tenant/service.js +74 -91
- package/dist/screens/InvalidRouteScreen.js +30 -20
- package/dist/screens/SuspenseScreen.js +26 -24
- package/dist/screens/UnauthorizedAccessScreen.js +44 -33
- package/dist/screens/UnsupportedBrowserScreen.js +44 -38
- package/dist/services/BrandingService.js +16 -24
- package/dist/services/HeaderService.js +4 -7
- package/dist/services/TitleService.js +19 -20
- package/dist/theme/ThemeButton.js +18 -14
- package/dist/theme/ThemeReducer.js +3 -5
- package/dist/theme/ThemeService.js +6 -8
- package/dist/theme/actions.js +1 -1
- package/dist/utils/browserSupport.js +18 -23
- package/dist/utils/extractTenantFromUrl.js +3 -3
- package/dist/utils/jsonParseWithBigInt.js +10 -9
- package/dist/utils/pageLifecycle.js +5 -5
- package/dist/utils/statusAlerts.js +1 -1
- package/package.json +12 -12
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.default = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
10
|
var _axios = _interopRequireDefault(require("axios"));
|
|
12
11
|
var _asab_webui_components = require("asab_webui_components");
|
|
@@ -41,10 +40,7 @@ var _SuspenseScreen = _interopRequireDefault(require("../screens/SuspenseScreen"
|
|
|
41
40
|
var _OfflineIndication = require("../modules/attentionrequired/components/OfflineIndication.js");
|
|
42
41
|
require("./Application.scss");
|
|
43
42
|
var _actions = require("../actions");
|
|
44
|
-
var
|
|
45
|
-
function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var r, c, a = Object.defineProperty, n = { __proto__: null, default: e }; if (Object(e) !== e) return n; if (cache || "function" != typeof WeakMap || (cache = new WeakMap()), cache) { if (cache.has(e)) return cache.get(e); cache.set(e, n); } for (c in e) "default" !== c && {}.hasOwnProperty.call(e, c) && ((r = a && Object.getOwnPropertyDescriptor(e, c)) && (r.get || r.set) ? a(n, c, r) : n[c] = e[c]); return n; }
|
|
46
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
47
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
43
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
48
44
|
class Application extends _react.Component {
|
|
49
45
|
constructor(props) {
|
|
50
46
|
super(props);
|
|
@@ -78,7 +74,7 @@ class Application extends _react.Component {
|
|
|
78
74
|
|
|
79
75
|
// The application can provide a list of keys that should be automatically parsed as BigInt, when received from the server in Axios call
|
|
80
76
|
// This is important to preserve 64bit numbers from the server such as IP addresses, timestamps etc.
|
|
81
|
-
this.JSONParseBigInt = new Set(props
|
|
77
|
+
this.JSONParseBigInt = new Set(props?.bigint);
|
|
82
78
|
|
|
83
79
|
/*
|
|
84
80
|
Prevent JSON.stringify from throwing on BigInt values (including inside React's
|
|
@@ -115,81 +111,75 @@ class Application extends _react.Component {
|
|
|
115
111
|
this.addSplashScreenRequestor(this);
|
|
116
112
|
this.state.splashscreenRequestors = this.SplashscreenRequestors.size;
|
|
117
113
|
var that = this;
|
|
118
|
-
function modules_init() {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
//
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
//
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// The initial load of the remote failed; it is ok in development environment
|
|
141
|
-
console.warn("Failed to load a remote module: ScriptExternalLoadError:", error.message);
|
|
142
|
-
} else {
|
|
143
|
-
console.error(error);
|
|
144
|
-
}
|
|
145
|
-
continue;
|
|
114
|
+
async function modules_init() {
|
|
115
|
+
// Instantiate statically imported modules
|
|
116
|
+
for (var i in props.modules) {
|
|
117
|
+
// The candidate can be:
|
|
118
|
+
// 1. { Module } from "asab_webui_components"
|
|
119
|
+
// 2. A promise that loads the remote module from the federated application
|
|
120
|
+
const modcandidate = props.modules[i];
|
|
121
|
+
let modloaded;
|
|
122
|
+
if (modcandidate.prototype instanceof _asab_webui_components.Module) {
|
|
123
|
+
// This is a Module from "asab_webui_components"
|
|
124
|
+
const mod = new modcandidate(that);
|
|
125
|
+
that.Modules.push(mod);
|
|
126
|
+
} else {
|
|
127
|
+
// This is load of the remote module from a federated application using promise
|
|
128
|
+
try {
|
|
129
|
+
modloaded = await Promise.resolve(modcandidate);
|
|
130
|
+
} catch (error) {
|
|
131
|
+
if (error instanceof Error && error.name == 'ScriptExternalLoadError') {
|
|
132
|
+
// The initial load of the remote failed; it is ok in development environment
|
|
133
|
+
console.warn("Failed to load a remote module: ScriptExternalLoadError:", error.message);
|
|
134
|
+
} else {
|
|
135
|
+
console.error(error);
|
|
146
136
|
}
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
147
139
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
var _mod = new modloaded.default(that); // We expect 'export default class ...Module extends Module'
|
|
154
|
-
that.Modules.push(_mod);
|
|
140
|
+
// Sanity check
|
|
141
|
+
if (!modloaded.default.prototype instanceof _asab_webui_components.Module) {
|
|
142
|
+
console.error("The default object from the remote is not a Module - skipping");
|
|
143
|
+
continue; // The load of the remote failed
|
|
155
144
|
}
|
|
145
|
+
const mod = new modloaded.default(that); // We expect 'export default class ...Module extends Module'
|
|
146
|
+
that.Modules.push(mod);
|
|
156
147
|
}
|
|
148
|
+
}
|
|
157
149
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
150
|
+
// Initialize statically imported modules
|
|
151
|
+
for (var i in that.Modules) {
|
|
152
|
+
let ret = that.Modules[i].initialize();
|
|
161
153
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
});
|
|
167
|
-
return _modules_init.apply(this, arguments);
|
|
154
|
+
// Transform result in the promise
|
|
155
|
+
// It unifies synchronous and asynchronous `initialize()` calls
|
|
156
|
+
await Promise.resolve(ret);
|
|
157
|
+
}
|
|
168
158
|
}
|
|
169
|
-
modules_init().then(
|
|
159
|
+
modules_init().then(async function () {
|
|
170
160
|
// Initialize all services
|
|
171
161
|
for (var i in that.Services) {
|
|
172
|
-
|
|
162
|
+
let ret = that.Services[i].initialize();
|
|
173
163
|
|
|
174
164
|
// Transform result in the promise
|
|
175
165
|
// It unifies synchronous and asynchronous `initialize()` calls
|
|
176
|
-
|
|
166
|
+
await Promise.resolve(ret);
|
|
177
167
|
}
|
|
178
168
|
that.removeSplashScreenRequestor(that);
|
|
179
|
-
})
|
|
169
|
+
});
|
|
180
170
|
}
|
|
181
171
|
getServiceURL(service) {
|
|
182
172
|
// Handle if service is unknown => return undefined
|
|
183
173
|
if (service == undefined) {
|
|
184
|
-
console.warn(
|
|
174
|
+
console.warn(`Service is undefined!`);
|
|
185
175
|
return undefined;
|
|
186
176
|
}
|
|
187
177
|
|
|
188
178
|
// Handle if SERVICES not provided, empty object will be used as default
|
|
189
|
-
|
|
179
|
+
let services = this.Config.get('SERVICES') ? this.Config.get('SERVICES') : {};
|
|
190
180
|
|
|
191
181
|
// Handle if service is not in SERVICES => use service as service_path
|
|
192
|
-
|
|
182
|
+
let service_path = services[service] ? services[service] : service;
|
|
193
183
|
|
|
194
184
|
// If service_path is complete URL, then return that URL
|
|
195
185
|
if (service_path.toString().indexOf('http://') !== -1 || service_path.toString().indexOf('https://') !== -1) {
|
|
@@ -201,7 +191,7 @@ class Application extends _react.Component {
|
|
|
201
191
|
}
|
|
202
192
|
|
|
203
193
|
// Obtain BASE_URL
|
|
204
|
-
|
|
194
|
+
let BASE_URL = undefined;
|
|
205
195
|
if (this.Config.get('BASE_URL') == undefined) {
|
|
206
196
|
// If BASE_URL has not been defined => take browser URL as BASE_URL
|
|
207
197
|
BASE_URL = window.location.protocol + '//' + window.location.host + window.location.pathname.replace(/\/$/, '');
|
|
@@ -210,7 +200,7 @@ class Application extends _react.Component {
|
|
|
210
200
|
BASE_URL = this.Config.get('BASE_URL');
|
|
211
201
|
} else {
|
|
212
202
|
// If BASE_URL has been defined but with relative path => take browser URL as BASE_URL and append relative path from BASE_URL behind the browser URL
|
|
213
|
-
|
|
203
|
+
let relative_base_url = this.Config.get('BASE_URL');
|
|
214
204
|
// Check if trailing slash has been added on first place of a BASE_URL string and if so, remove it
|
|
215
205
|
if (relative_base_url.indexOf("/", 0) == 0) {
|
|
216
206
|
relative_base_url = relative_base_url.substring(1);
|
|
@@ -219,7 +209,7 @@ class Application extends _react.Component {
|
|
|
219
209
|
}
|
|
220
210
|
|
|
221
211
|
// Compose service_url
|
|
222
|
-
|
|
212
|
+
let service_url = undefined;
|
|
223
213
|
if (this.Config.get('API_PATH') == undefined) {
|
|
224
214
|
// If API_PATH has not been defined => use /api to compose service_url
|
|
225
215
|
service_url = BASE_URL.replace(/\/$/, '') + '/api';
|
|
@@ -228,7 +218,7 @@ class Application extends _react.Component {
|
|
|
228
218
|
service_url = this.Config.get('API_PATH');
|
|
229
219
|
} else {
|
|
230
220
|
// If API_PATH has been defined => use API_PATH to compose service_url
|
|
231
|
-
|
|
221
|
+
let api_path = this.Config.get('API_PATH');
|
|
232
222
|
// Check if trailing slash has been added on first place of a API_PATH string and if so, remove it
|
|
233
223
|
if (api_path.indexOf("/", 0) == 0) {
|
|
234
224
|
api_path = api_path.substring(1);
|
|
@@ -289,22 +279,23 @@ class Application extends _react.Component {
|
|
|
289
279
|
* towards TeskaLabs API's, since it adds Bearer token to all calls.
|
|
290
280
|
*/
|
|
291
281
|
axiosCreate(service, props) {
|
|
292
|
-
|
|
282
|
+
const service_url = this.getServiceURL(service);
|
|
293
283
|
if (service_url == undefined) {
|
|
294
284
|
this.addAlert('danger', "ASABApplicationContainer|Service URL is undefined, please check service paths passed to axios", 5, true);
|
|
295
285
|
return undefined;
|
|
296
286
|
}
|
|
297
|
-
|
|
287
|
+
const axios = _axios.default.create({
|
|
288
|
+
...props,
|
|
298
289
|
transformResponse: res => res,
|
|
299
290
|
// Disable implicit JSON parsing, we explicitly parse JSON in the interceptor ( https://stackoverflow.com/questions/41013082/disable-json-parsing-in-axios )
|
|
300
291
|
baseURL: service_url
|
|
301
|
-
})
|
|
292
|
+
});
|
|
302
293
|
|
|
303
294
|
// Iterate through custom interceptors
|
|
304
|
-
for (
|
|
295
|
+
for (let interceptor of this.AxiosInterceptors.keys()) {
|
|
305
296
|
this.interceptorRequest(axios, interceptor);
|
|
306
297
|
}
|
|
307
|
-
|
|
298
|
+
const that = this;
|
|
308
299
|
|
|
309
300
|
/*
|
|
310
301
|
We want to be notified when networking activity is taking place,
|
|
@@ -313,11 +304,10 @@ class Application extends _react.Component {
|
|
|
313
304
|
define recognition of the requests from the service perspective
|
|
314
305
|
*/
|
|
315
306
|
axios.interceptors.request.use(function (config) {
|
|
316
|
-
var _config$headers, _config$headers2;
|
|
317
307
|
/* Usage of networking indicator is optional and can be set as following among other headers:
|
|
318
308
|
headers: { 'X-Networking-Indicator': 'off' }
|
|
319
309
|
*/
|
|
320
|
-
|
|
310
|
+
const networkingIndicatorOff = config?.headers?.['X-Networking-Indicator'] === 'off';
|
|
321
311
|
// Store flag in config for response interceptors to access
|
|
322
312
|
config._networkingIndicatorOff = networkingIndicatorOff;
|
|
323
313
|
if (!networkingIndicatorOff) {
|
|
@@ -325,7 +315,7 @@ class Application extends _react.Component {
|
|
|
325
315
|
}
|
|
326
316
|
that.pushPrintReadyIndicator();
|
|
327
317
|
// Remove the X-Networking-Indicator header before sending to service (its only for internal use)
|
|
328
|
-
|
|
318
|
+
delete config?.headers?.['X-Networking-Indicator'];
|
|
329
319
|
config.headers['X-App'] = "webui"; // Include X-App header in every axios API request
|
|
330
320
|
config.headers['X-Request-Id'] = that._generateUID(); // Include X-Request-Id header in every axios API request
|
|
331
321
|
return config;
|
|
@@ -335,7 +325,6 @@ class Application extends _react.Component {
|
|
|
335
325
|
|
|
336
326
|
// We want to remove the networking indicator when we receive the response
|
|
337
327
|
axios.interceptors.response.use(function (response) {
|
|
338
|
-
var _response$headers$con;
|
|
339
328
|
// Call the `popNetworkingIndicator` method to remove the networking indicator (e.g., loading spinner)
|
|
340
329
|
if (!response.config._networkingIndicatorOff) {
|
|
341
330
|
that.popNetworkingIndicator();
|
|
@@ -352,7 +341,7 @@ class Application extends _react.Component {
|
|
|
352
341
|
}
|
|
353
342
|
|
|
354
343
|
// Check if the response content type is 'application/json' or starts with 'application/json'
|
|
355
|
-
if (response
|
|
344
|
+
if (response?.headers['content-type']?.startsWith('application/json')) {
|
|
356
345
|
// If the response is JSON, then parse it with respect to BigInt
|
|
357
346
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse
|
|
358
347
|
try {
|
|
@@ -365,37 +354,31 @@ class Application extends _react.Component {
|
|
|
365
354
|
}
|
|
366
355
|
// If the request was satisfied (application/json and presence of BigInt) return the modified object. If not, we return unchanged object
|
|
367
356
|
return response;
|
|
368
|
-
},
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
} catch (e) {
|
|
381
|
-
console.error("Error parsing error of the error body:", e);
|
|
382
|
-
}
|
|
357
|
+
}, async function (error) {
|
|
358
|
+
if (!error.config?._networkingIndicatorOff) {
|
|
359
|
+
that.popNetworkingIndicator();
|
|
360
|
+
}
|
|
361
|
+
that.popPrintReadyIndicator();
|
|
362
|
+
const contentType = error?.response?.headers?.['content-type'];
|
|
363
|
+
// Check if the response content type is 'application/json' and data is a string
|
|
364
|
+
if (contentType?.startsWith('application/json') && typeof error?.response?.data === 'string') {
|
|
365
|
+
try {
|
|
366
|
+
error.response.data = JSON.parse(error.response.data);
|
|
367
|
+
} catch (e) {
|
|
368
|
+
console.error("Error parsing error of the error body:", e);
|
|
383
369
|
}
|
|
370
|
+
}
|
|
384
371
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
}
|
|
372
|
+
// Call registered response error interceptors (e.g. for 401 handling)
|
|
373
|
+
for (let interceptor of that.AxiosResponseErrorInterceptors.keys()) {
|
|
374
|
+
try {
|
|
375
|
+
await interceptor(error);
|
|
376
|
+
} catch (interceptorError) {
|
|
377
|
+
console.error("Error in AxiosResponseErrorInterceptors", interceptorError);
|
|
392
378
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
return _ref2.apply(this, arguments);
|
|
397
|
-
};
|
|
398
|
-
}());
|
|
379
|
+
}
|
|
380
|
+
return Promise.reject(error);
|
|
381
|
+
});
|
|
399
382
|
return axios;
|
|
400
383
|
}
|
|
401
384
|
|
|
@@ -450,7 +433,7 @@ class Application extends _react.Component {
|
|
|
450
433
|
}
|
|
451
434
|
|
|
452
435
|
// Replace http:// or https:// protocol with ws:// or wss://
|
|
453
|
-
|
|
436
|
+
let ws_service_url = service_url.replace(/(http)(s)?\:\/\//, "ws$2://");
|
|
454
437
|
return ws_service_url + subpath;
|
|
455
438
|
}
|
|
456
439
|
createWebSocket(service, subpath) {
|
|
@@ -469,15 +452,15 @@ class Application extends _react.Component {
|
|
|
469
452
|
Another default subprotocols are "app_webui" and "request_id_<uid>"
|
|
470
453
|
which define recognition of the requests from the service perspective
|
|
471
454
|
*/
|
|
472
|
-
|
|
473
|
-
for (
|
|
455
|
+
let subprotocols = ["asab", "app_webui", `request_id_${this._generateUID()}`];
|
|
456
|
+
for (let interceptor of this.WebSocketInterceptors.keys()) {
|
|
474
457
|
// Avoid pushing undefined interceptor values
|
|
475
458
|
if (interceptor) {
|
|
476
459
|
/*
|
|
477
460
|
Interceptor should be a function that returns the current subprotocol value
|
|
478
461
|
Otherwise use the value directly (for backward compatibility)
|
|
479
462
|
*/
|
|
480
|
-
|
|
463
|
+
const interceptorValue = typeof interceptor === 'function' ? interceptor() : interceptor;
|
|
481
464
|
if (interceptorValue) {
|
|
482
465
|
subprotocols.push(interceptorValue);
|
|
483
466
|
}
|
|
@@ -485,7 +468,7 @@ class Application extends _react.Component {
|
|
|
485
468
|
}
|
|
486
469
|
|
|
487
470
|
// Create new WebSocket based on socket URL
|
|
488
|
-
|
|
471
|
+
const socket = new WebSocket(socket_url, subprotocols);
|
|
489
472
|
return socket;
|
|
490
473
|
}
|
|
491
474
|
|
|
@@ -509,7 +492,7 @@ class Application extends _react.Component {
|
|
|
509
492
|
}
|
|
510
493
|
popPrintReadyIndicator() {
|
|
511
494
|
this.setState(prevState => {
|
|
512
|
-
|
|
495
|
+
const nextValue = prevState.printReadyIndicators - 1;
|
|
513
496
|
if (nextValue < 0) {
|
|
514
497
|
console.warn('printReadyIndicators would go negative, setting its value to 0. The value was:', nextValue);
|
|
515
498
|
}
|
|
@@ -520,14 +503,14 @@ class Application extends _react.Component {
|
|
|
520
503
|
}
|
|
521
504
|
registerService(service) {
|
|
522
505
|
if (service.Name in this.Services) {
|
|
523
|
-
console.warn(
|
|
506
|
+
console.warn(`Service ${service.Name} is already registered.`);
|
|
524
507
|
return;
|
|
525
508
|
}
|
|
526
509
|
this.Services[service.Name] = service;
|
|
527
510
|
}
|
|
528
511
|
locateService(name) {
|
|
529
512
|
if (!name in this.Services) {
|
|
530
|
-
console.warn(
|
|
513
|
+
console.warn(`Service ${name} doesn't exist.`);
|
|
531
514
|
return null;
|
|
532
515
|
}
|
|
533
516
|
return this.Services[name];
|
|
@@ -609,16 +592,16 @@ class Application extends _react.Component {
|
|
|
609
592
|
For print-ready, the initial value is set to 1, because we always start the application
|
|
610
593
|
with Splashscreen and therefore we dont need to increment the print-ready number here.
|
|
611
594
|
*/
|
|
612
|
-
|
|
595
|
+
const origLen = this.SplashscreenRequestors.size;
|
|
613
596
|
this.SplashscreenRequestors.add(obj);
|
|
614
597
|
if (origLen != this.SplashscreenRequestors.size) {
|
|
615
598
|
this.state.splashscreenRequestors = this.SplashscreenRequestors.size;
|
|
616
599
|
}
|
|
617
|
-
|
|
618
|
-
splashscreen
|
|
600
|
+
let splashscreen = document.getElementById('app-splashscreen'); // See public/index.html`
|
|
601
|
+
splashscreen?.classList.remove("d-none");
|
|
619
602
|
}
|
|
620
603
|
removeSplashScreenRequestor(obj) {
|
|
621
|
-
|
|
604
|
+
const origLen = this.SplashscreenRequestors.size;
|
|
622
605
|
this.SplashscreenRequestors.delete(obj);
|
|
623
606
|
if (origLen != this.SplashscreenRequestors.size) {
|
|
624
607
|
this.setState({
|
|
@@ -626,8 +609,8 @@ class Application extends _react.Component {
|
|
|
626
609
|
});
|
|
627
610
|
}
|
|
628
611
|
if (this.SplashscreenRequestors.size == 0) {
|
|
629
|
-
|
|
630
|
-
splashscreen
|
|
612
|
+
let splashscreen = document.getElementById('app-splashscreen'); // See public/index.html
|
|
613
|
+
splashscreen?.classList.add("d-none");
|
|
631
614
|
// Decrement print-ready indicator value if no splash screen requestors are present
|
|
632
615
|
this.popPrintReadyIndicator();
|
|
633
616
|
}
|
|
@@ -641,12 +624,8 @@ class Application extends _react.Component {
|
|
|
641
624
|
* info
|
|
642
625
|
* success
|
|
643
626
|
*/
|
|
644
|
-
addAlert(level, message) {
|
|
645
|
-
|
|
646
|
-
var expire = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 5;
|
|
647
|
-
var shouldBeTranslated = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
648
|
-
var component = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
|
|
649
|
-
(_this$AppStore$dispat = (_this$AppStore = this.AppStore).dispatch) === null || _this$AppStore$dispat === void 0 || _this$AppStore$dispat.call(_this$AppStore, {
|
|
627
|
+
addAlert(level, message, expire = 5, shouldBeTranslated = false, component = null) {
|
|
628
|
+
this.AppStore.dispatch?.({
|
|
650
629
|
type: _actions.ADD_ALERT,
|
|
651
630
|
level: level,
|
|
652
631
|
message: message,
|
|
@@ -667,27 +646,22 @@ class Application extends _react.Component {
|
|
|
667
646
|
- component - option to pass additional component of the alert message e.g. button (by default null)
|
|
668
647
|
addAlertFromException will always use "danger" color as its background and the full exception will be printed into the console
|
|
669
648
|
*/
|
|
670
|
-
addAlertFromException(exception, message) {
|
|
671
|
-
var _exception$response, _this$AppStore2, _exception$response2, _this$AppStore$dispat3, _this$AppStore4;
|
|
672
|
-
var expire = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 30;
|
|
673
|
-
var shouldBeTranslated = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
674
|
-
var component = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
|
|
649
|
+
addAlertFromException(exception, message, expire = 30, shouldBeTranslated = false, component = null) {
|
|
675
650
|
console.error(exception); // Log the whole exception in the browser
|
|
676
651
|
|
|
677
|
-
|
|
652
|
+
const exceptionStatus = exception?.response?.status;
|
|
678
653
|
// Indicate gateway timeout if the response status is 502, 503 or 504 and if so, then dont continue with the alert and display the offline indication
|
|
679
654
|
if ((exceptionStatus === 502 || exceptionStatus === 503 || exceptionStatus === 504) && this._indicateGatewayTimeout()) {
|
|
680
655
|
return;
|
|
681
656
|
}
|
|
682
657
|
// Skip 401 alert when session has expired
|
|
683
|
-
if (exceptionStatus === 401 &&
|
|
658
|
+
if (exceptionStatus === 401 && this.AppStore?.getState()?.auth?.sessionExpired) {
|
|
684
659
|
return;
|
|
685
660
|
}
|
|
686
661
|
// Handle specific response statuses and set the appropriate level and message
|
|
687
|
-
|
|
662
|
+
const statusAlert = _statusAlerts.STATUS_ALERTS[exceptionStatus];
|
|
688
663
|
if (statusAlert) {
|
|
689
|
-
|
|
690
|
-
(_this$AppStore$dispat2 = (_this$AppStore3 = this.AppStore).dispatch) === null || _this$AppStore$dispat2 === void 0 || _this$AppStore$dispat2.call(_this$AppStore3, {
|
|
664
|
+
this.AppStore.dispatch?.({
|
|
691
665
|
type: _actions.ADD_ALERT,
|
|
692
666
|
level: statusAlert.level,
|
|
693
667
|
message: statusAlert.message,
|
|
@@ -697,39 +671,53 @@ class Application extends _react.Component {
|
|
|
697
671
|
});
|
|
698
672
|
return;
|
|
699
673
|
}
|
|
700
|
-
|
|
674
|
+
let exceptionMessage = /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
675
|
+
children: message
|
|
676
|
+
});
|
|
701
677
|
/*
|
|
702
678
|
If the exception has an error_dict in the response data (error in the new format),
|
|
703
679
|
the ErrorHandler component is used to display the error,
|
|
704
680
|
along with the exception message in the form-text class.
|
|
705
681
|
*/
|
|
706
|
-
if (exception
|
|
707
|
-
exceptionMessage = /*#__PURE__*/
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
682
|
+
if (exception?.response?.data?.error_dict) {
|
|
683
|
+
exceptionMessage = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
684
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_asab_webui_components.ErrorHandler, {
|
|
685
|
+
error: exception.response.data
|
|
686
|
+
}), exception?.message && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
687
|
+
className: "form-text",
|
|
688
|
+
children: exception.message
|
|
689
|
+
})]
|
|
690
|
+
});
|
|
712
691
|
} else {
|
|
713
|
-
var _exception$response3;
|
|
714
692
|
/*
|
|
715
693
|
Capture the cases when service returns a message in the exception response data.
|
|
716
694
|
Add hoc messages are displayed in form-text class on the new line
|
|
717
695
|
*/
|
|
718
|
-
if (exception
|
|
719
|
-
exceptionMessage = /*#__PURE__*/
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
696
|
+
if (exception?.response?.data?.message) {
|
|
697
|
+
exceptionMessage = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
698
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h5", {
|
|
699
|
+
children: exceptionMessage
|
|
700
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
701
|
+
className: "mt-2",
|
|
702
|
+
style: {
|
|
703
|
+
whiteSpace: 'pre-wrap'
|
|
704
|
+
},
|
|
705
|
+
children: exception.response.data.message
|
|
706
|
+
})]
|
|
707
|
+
});
|
|
725
708
|
} else {
|
|
726
709
|
// Exception message is always present in the exception
|
|
727
|
-
exceptionMessage = /*#__PURE__*/
|
|
728
|
-
|
|
729
|
-
|
|
710
|
+
exceptionMessage = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
711
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h5", {
|
|
712
|
+
children: exceptionMessage
|
|
713
|
+
}), exception?.message && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
714
|
+
className: "mt-2",
|
|
715
|
+
children: exception.message
|
|
716
|
+
})]
|
|
717
|
+
});
|
|
730
718
|
}
|
|
731
719
|
}
|
|
732
|
-
|
|
720
|
+
this.AppStore.dispatch?.({
|
|
733
721
|
type: _actions.ADD_ALERT,
|
|
734
722
|
level: "danger",
|
|
735
723
|
message: exceptionMessage,
|
|
@@ -744,13 +732,12 @@ class Application extends _react.Component {
|
|
|
744
732
|
Each subsequent 504 resets the timer so the badge stays visible while gateway timeouts keep occurring
|
|
745
733
|
Returns true when the indication was shown, false when HeaderService is unavailable
|
|
746
734
|
*/
|
|
747
|
-
_indicateGatewayTimeout() {
|
|
748
|
-
|
|
749
|
-
var headerService = this.locateService('HeaderService');
|
|
735
|
+
_indicateGatewayTimeout(durationMs = 30000) {
|
|
736
|
+
const headerService = this.locateService('HeaderService');
|
|
750
737
|
if (!headerService) {
|
|
751
738
|
return false;
|
|
752
739
|
}
|
|
753
|
-
|
|
740
|
+
const isVisible = headerService.Items.some(item => item.component === _OfflineIndication.OfflineIndication);
|
|
754
741
|
if (!isVisible) {
|
|
755
742
|
headerService.addComponent({
|
|
756
743
|
component: _OfflineIndication.OfflineIndication,
|
|
@@ -773,12 +760,11 @@ class Application extends _react.Component {
|
|
|
773
760
|
It takes a parameter called "status" to indicate whether to turn the full-screen mode on or off.
|
|
774
761
|
*/
|
|
775
762
|
setFullScreenMode(status) {
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
if (status === 'on' && (state === null || state === void 0 || (_state$fullscreenmode = state.fullscreenmode) === null || _state$fullscreenmode === void 0 ? void 0 : _state$fullscreenmode.status) === 'on') {
|
|
763
|
+
const state = this.AppStore.getState();
|
|
764
|
+
if (status === 'on' && state?.fullscreenmode?.status === 'on') {
|
|
779
765
|
status = 'off';
|
|
780
766
|
}
|
|
781
|
-
|
|
767
|
+
this.AppStore.dispatch?.({
|
|
782
768
|
type: _actions.SET_FULLSCREEN_MODE,
|
|
783
769
|
status: status
|
|
784
770
|
});
|
|
@@ -795,52 +781,61 @@ class Application extends _react.Component {
|
|
|
795
781
|
/*#__PURE__*/
|
|
796
782
|
// When splashscreenRequestors is requested, the application is not rendered.
|
|
797
783
|
// This prevents race conditions during application init time.
|
|
798
|
-
|
|
799
|
-
app: this
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
784
|
+
(0, _jsxRuntime.jsx)(_asab_webui_components.AppStoreProvider, {
|
|
785
|
+
app: this,
|
|
786
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_asab_webui_components.PubSubProvider, {
|
|
787
|
+
app: this,
|
|
788
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Suspense, {
|
|
789
|
+
fallback: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {}),
|
|
790
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Alerts.default, {
|
|
791
|
+
app: this
|
|
792
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("main", {
|
|
793
|
+
id: "app-main",
|
|
794
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_AccessDeniedCard.default, {
|
|
795
|
+
app: this
|
|
796
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_LoginLoopCard.LoginLoopCard, {
|
|
797
|
+
app: this
|
|
798
|
+
})]
|
|
799
|
+
})]
|
|
800
|
+
})
|
|
801
|
+
})
|
|
802
|
+
})
|
|
813
803
|
);
|
|
814
|
-
return /*#__PURE__*/
|
|
815
|
-
app: this
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
804
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_asab_webui_components.AppStoreProvider, {
|
|
805
|
+
app: this,
|
|
806
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_asab_webui_components.PubSubProvider, {
|
|
807
|
+
app: this,
|
|
808
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Suspense, {
|
|
809
|
+
fallback: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {}),
|
|
810
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
811
|
+
id: "app-networking-indicator",
|
|
812
|
+
className: "progress-bar progress-bar-animated progress-bar-striped" + (this.state.networking == 0 ? " transparent" : "")
|
|
813
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Alerts.default, {
|
|
814
|
+
app: this
|
|
815
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_NavbarBrand.default, {
|
|
816
|
+
app: this
|
|
817
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Sidebar.default, {
|
|
818
|
+
app: this
|
|
819
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ToastContainer.default, {
|
|
820
|
+
app: this
|
|
821
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Header.default, {
|
|
822
|
+
app: this
|
|
823
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("main", {
|
|
824
|
+
id: "app-main",
|
|
825
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Suspense, {
|
|
826
|
+
fallback: /*#__PURE__*/(0, _jsxRuntime.jsx)(_SuspenseScreen.default, {
|
|
827
|
+
app: this
|
|
828
|
+
}) /*The suspense that captures lazy loading of the federated apps*/,
|
|
829
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ApplicationRouter.default, {
|
|
830
|
+
app: this
|
|
831
|
+
})
|
|
832
|
+
})
|
|
833
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Sidepanel.default, {
|
|
834
|
+
app: this
|
|
835
|
+
})]
|
|
836
|
+
})
|
|
837
|
+
})
|
|
838
|
+
});
|
|
844
839
|
}
|
|
845
840
|
}
|
|
846
841
|
|
|
@@ -852,9 +847,8 @@ Application.prototype._initConnectivitySubscription = function () {
|
|
|
852
847
|
if (this.PubSub && typeof this.PubSub.subscribe === 'function') {
|
|
853
848
|
if (!this._unsubscribeConnectivity) {
|
|
854
849
|
this._unsubscribeConnectivity = this.PubSub.subscribe('Application.status!', value => {
|
|
855
|
-
var _this$AppStore$dispat5, _this$AppStore6;
|
|
856
850
|
// Prefer store so UI updates predictably
|
|
857
|
-
|
|
851
|
+
this.AppStore.dispatch?.({
|
|
858
852
|
type: _actions.SET_CONNECTIVITY_STATUS,
|
|
859
853
|
status: value.status
|
|
860
854
|
});
|
|
@@ -875,8 +869,7 @@ Application.prototype._initConnectivitySubscription = function () {
|
|
|
875
869
|
Application.prototype._initPageLifecycleBridge = function () {
|
|
876
870
|
if (this._unsubscribePageHide) return;
|
|
877
871
|
this._unsubscribePageHide = (0, _pageLifecycle.subscribePageHide)(event => {
|
|
878
|
-
|
|
879
|
-
(_this$PubSub = this.PubSub) === null || _this$PubSub === void 0 || (_this$PubSub$publish = _this$PubSub.publish) === null || _this$PubSub$publish === void 0 || _this$PubSub$publish.call(_this$PubSub, 'Application.lifecycle!', {
|
|
872
|
+
this.PubSub?.publish?.('Application.lifecycle!', {
|
|
880
873
|
type: 'pagehide',
|
|
881
874
|
persisted: event.persisted
|
|
882
875
|
});
|