asab_webui_shell 25.1.12 → 25.1.13
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/components/locationReplace.js +4 -16
- package/dist/config/ConfigReducer.js +1 -1
- package/dist/config/ConfigService.js +116 -137
- package/dist/containers/AdvancedMode/reducer.js +2 -2
- package/dist/containers/Alerts/index.js +18 -30
- package/dist/containers/Alerts/reducer.js +5 -6
- package/dist/containers/Application.js +531 -673
- package/dist/containers/AttentionRequired/reducer.js +2 -2
- package/dist/containers/FullscreenMode/reducer.js +2 -2
- package/dist/containers/Header/ApplicationScreenTitle/ApplicationScreenTitle.js +15 -16
- package/dist/containers/Header/ApplicationScreenTitle/index.js +6 -6
- package/dist/containers/Header/Help/HelpButton.js +17 -27
- package/dist/containers/Header/Help/HelpService.js +13 -24
- package/dist/containers/Header/Preview/PreviewFlag.js +6 -5
- package/dist/containers/Header/Preview/PreviewService.js +13 -24
- package/dist/containers/Header/index.js +15 -17
- package/dist/containers/Header/reducer.js +4 -4
- package/dist/containers/Navigation/index.js +35 -55
- package/dist/containers/Navigation/reducer.js +7 -13
- package/dist/containers/RouteErrorHandler/ErrorContainer.js +17 -19
- package/dist/containers/RouteErrorHandler/index.js +28 -44
- package/dist/containers/Router/ApplicationRouter.js +14 -16
- package/dist/containers/Router/index.js +26 -42
- package/dist/containers/Router/reducer.js +3 -3
- package/dist/containers/Sidebar/NavbarBrand.js +14 -23
- package/dist/containers/Sidebar/SidebarBottomItem.js +16 -15
- package/dist/containers/Sidebar/SidebarIcon.js +9 -7
- package/dist/containers/Sidebar/SidebarItem.js +70 -85
- package/dist/containers/Sidebar/SidebarItemRenderer.js +20 -20
- package/dist/containers/Sidebar/index.js +20 -36
- package/dist/containers/Sidebar/reducer.js +3 -3
- package/dist/containers/Sidepanel/Sidepanel.js +18 -26
- package/dist/containers/Toast/ToastComponent.js +12 -12
- package/dist/containers/Toast/ToastContainer.js +19 -30
- package/dist/containers/Toast/reducer.js +3 -6
- package/dist/index.js +5 -5
- package/dist/modules/about/AboutScreen.js +30 -38
- package/dist/modules/about/index.js +8 -26
- package/dist/modules/auth/api.js +110 -156
- package/dist/modules/auth/components/SessionExpirationAlert.js +10 -9
- package/dist/modules/auth/header.js +25 -23
- package/dist/modules/auth/index.js +440 -692
- package/dist/modules/auth/reducer.js +2 -2
- package/dist/modules/auth/screens/AccessControlScreen.js +24 -25
- package/dist/modules/auth/screens/InvitationScreen.js +89 -128
- package/dist/modules/i18n/dropdown.js +24 -23
- package/dist/modules/i18n/index.js +20 -33
- package/dist/modules/i18n/reducer.js +2 -2
- package/dist/modules/i18n/service.js +48 -102
- package/dist/modules/tenant/TenantDropdown.js +28 -27
- package/dist/modules/tenant/access/AccessDeniedCard.js +28 -54
- package/dist/modules/tenant/index.js +16 -29
- package/dist/modules/tenant/reducer.js +1 -1
- package/dist/modules/tenant/service.js +123 -207
- package/dist/screens/InvalidRouteScreen.js +10 -9
- package/dist/screens/SuspenseScreen.js +11 -20
- package/dist/screens/UnauthorizedAccessScreen.js +18 -21
- package/dist/services/AttentionRequiredService.js +117 -142
- package/dist/services/BrandingService.js +63 -80
- package/dist/services/HeaderService.js +47 -66
- package/dist/services/ReduxService.js +11 -17
- package/dist/services/TitleService.js +13 -24
- package/dist/theme/ThemeButton.js +13 -10
- package/dist/theme/ThemeReducer.js +1 -1
- package/dist/theme/ThemeService.js +25 -38
- package/package.json +1 -1
|
@@ -1,169 +1,144 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
|
-
exports
|
|
8
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
12
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
13
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
6
|
+
exports.default = void 0;
|
|
14
7
|
var _asab_webui_components = require("asab_webui_components");
|
|
15
8
|
var _actions = require("../actions");
|
|
16
|
-
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
|
|
17
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
18
9
|
// Service handling attention required
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var _this;
|
|
10
|
+
class AttentionRequiredService extends _asab_webui_components.Service {
|
|
11
|
+
constructor(app) {
|
|
22
12
|
var serviceName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "AttentionRequiredService";
|
|
23
|
-
(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
_this.reconnectInterval = 5000; // initial reconnection interval (5 seconds)
|
|
28
|
-
return _this;
|
|
13
|
+
super(app, serviceName);
|
|
14
|
+
this.beaconWebSocket = null; // beacon websocket variable
|
|
15
|
+
this.reconnectTimeout = null; // timeout variable
|
|
16
|
+
this.reconnectInterval = 5000; // initial reconnection interval (5 seconds)
|
|
29
17
|
}
|
|
30
18
|
|
|
31
19
|
// Start beacon websocket connection on initialization
|
|
32
|
-
(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
value: function initialize() {
|
|
36
|
-
this.connectBeaconWebSocket();
|
|
37
|
-
}
|
|
20
|
+
initialize() {
|
|
21
|
+
this.connectBeaconWebSocket();
|
|
22
|
+
}
|
|
38
23
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
24
|
+
// Method for connection to beacon websocket
|
|
25
|
+
connectBeaconWebSocket() {
|
|
26
|
+
var _this$App;
|
|
27
|
+
// Retrieve current tenant
|
|
28
|
+
var currentTenant = (_this$App = this.App) === null || _this$App === void 0 || (_this$App = _this$App.Services) === null || _this$App === void 0 || (_this$App = _this$App.TenantService) === null || _this$App === void 0 ? void 0 : _this$App.getCurrentTenant();
|
|
29
|
+
// Gracefully reconnect if tenant was not found
|
|
30
|
+
if (!currentTenant) {
|
|
31
|
+
console.error("Beacon WebSocket error: Tenant was not found!");
|
|
32
|
+
this.reconnectBeaconWebSocket();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
var BeaconServiceClient = this.App.createWebSocket('asab-remote-control', "/beacon/".concat(currentTenant, "/ws"));
|
|
36
|
+
this.beaconWebSocket = BeaconServiceClient;
|
|
37
|
+
this.beaconWebSocket.onopen = () => {
|
|
38
|
+
// TODO: may be removed
|
|
39
|
+
console.log('Beacon WebSocket connection established.');
|
|
40
|
+
};
|
|
41
|
+
this.beaconWebSocket.onmessage = message => {
|
|
42
|
+
try {
|
|
43
|
+
var data = JSON.parse(message.data);
|
|
44
|
+
// TODO: implement some type based recognition
|
|
45
|
+
this.distributeData(data);
|
|
46
|
+
} catch (e) {
|
|
47
|
+
console.error("Error parsing Beacon WebSocket message data:", e);
|
|
48
|
+
this.distributeData({});
|
|
52
49
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
};
|
|
69
|
-
this.beaconWebSocket.onerror = function (error) {
|
|
70
|
-
console.error("Beacon WebSocket error:", error);
|
|
71
|
-
console.error("Beacon WebSocket is attempting to reconnect...");
|
|
72
|
-
_this2.distributeData({});
|
|
73
|
-
_this2.reconnectBeaconWebSocket();
|
|
74
|
-
};
|
|
75
|
-
this.beaconWebSocket.onclose = function () {
|
|
76
|
-
/*
|
|
77
|
-
WebSocket connection is closed by the browser automatically when user
|
|
78
|
-
leaves the application (not the screen).
|
|
79
|
-
*/
|
|
80
|
-
if (_this2.beaconWebSocket) {
|
|
81
|
-
// Close the WebSocket connection
|
|
82
|
-
_this2.beaconWebSocket.close();
|
|
83
|
-
|
|
84
|
-
// Clean up event listeners
|
|
85
|
-
_this2.beaconWebSocket.onopen = null;
|
|
86
|
-
_this2.beaconWebSocket.onmessage = null;
|
|
87
|
-
_this2.beaconWebSocket.onerror = null;
|
|
88
|
-
_this2.beaconWebSocket.onclose = null;
|
|
50
|
+
};
|
|
51
|
+
this.beaconWebSocket.onerror = error => {
|
|
52
|
+
console.error("Beacon WebSocket error:", error);
|
|
53
|
+
console.error("Beacon WebSocket is attempting to reconnect...");
|
|
54
|
+
this.distributeData({});
|
|
55
|
+
this.reconnectBeaconWebSocket();
|
|
56
|
+
};
|
|
57
|
+
this.beaconWebSocket.onclose = () => {
|
|
58
|
+
/*
|
|
59
|
+
WebSocket connection is closed by the browser automatically when user
|
|
60
|
+
leaves the application (not the screen).
|
|
61
|
+
*/
|
|
62
|
+
if (this.beaconWebSocket) {
|
|
63
|
+
// Close the WebSocket connection
|
|
64
|
+
this.beaconWebSocket.close();
|
|
89
65
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
66
|
+
// Clean up event listeners
|
|
67
|
+
this.beaconWebSocket.onopen = null;
|
|
68
|
+
this.beaconWebSocket.onmessage = null;
|
|
69
|
+
this.beaconWebSocket.onerror = null;
|
|
70
|
+
this.beaconWebSocket.onclose = null;
|
|
93
71
|
|
|
94
|
-
//
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
_this2.reconnectTimeout = null;
|
|
98
|
-
}
|
|
99
|
-
console.log("Beacon WebSocket connection closed.");
|
|
100
|
-
};
|
|
101
|
-
}
|
|
72
|
+
// Set WebSocket reference to null to free up memory
|
|
73
|
+
this.beaconWebSocket = null;
|
|
74
|
+
}
|
|
102
75
|
|
|
103
|
-
|
|
104
|
-
}, {
|
|
105
|
-
key: "reconnectBeaconWebSocket",
|
|
106
|
-
value: function reconnectBeaconWebSocket() {
|
|
107
|
-
var _this3 = this;
|
|
76
|
+
// Clear the reconnect timeout if it exists
|
|
108
77
|
if (this.reconnectTimeout) {
|
|
109
78
|
clearTimeout(this.reconnectTimeout);
|
|
79
|
+
this.reconnectTimeout = null;
|
|
110
80
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
81
|
+
console.log("Beacon WebSocket connection closed.");
|
|
82
|
+
};
|
|
83
|
+
}
|
|
114
84
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
85
|
+
// Method for reconnection to beacon websocket
|
|
86
|
+
reconnectBeaconWebSocket() {
|
|
87
|
+
if (this.reconnectTimeout) {
|
|
88
|
+
clearTimeout(this.reconnectTimeout);
|
|
119
89
|
}
|
|
90
|
+
this.reconnectTimeout = setTimeout(() => {
|
|
91
|
+
this.connectBeaconWebSocket();
|
|
92
|
+
}, this.reconnectInterval); // Retry connection after the reconnection interval
|
|
120
93
|
|
|
121
|
-
//
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
value: function distributeData(data) {
|
|
125
|
-
var transformedData = this.transformData(data);
|
|
126
|
-
this.App.Store.dispatch({
|
|
127
|
-
type: _actions.SET_ATTENTION_REQUIRED_BEACON,
|
|
128
|
-
beacon: transformedData
|
|
129
|
-
});
|
|
94
|
+
// Increase reconnection time by 5s, the limit is 60s (so that we dont overload the server)
|
|
95
|
+
if (this.reconnectInterval + 5000 <= 60000) {
|
|
96
|
+
this.reconnectInterval += 5000;
|
|
130
97
|
}
|
|
98
|
+
}
|
|
131
99
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
return inputData.reduce(function (acc, entry) {
|
|
141
|
-
var type = entry.type,
|
|
142
|
-
_c = entry._c,
|
|
143
|
-
reference_path = entry.reference_path;
|
|
100
|
+
// Method for distributing the data into redux store
|
|
101
|
+
distributeData(data) {
|
|
102
|
+
var transformedData = this.transformData(data);
|
|
103
|
+
this.App.Store.dispatch({
|
|
104
|
+
type: _actions.SET_ATTENTION_REQUIRED_BEACON,
|
|
105
|
+
beacon: transformedData
|
|
106
|
+
});
|
|
107
|
+
}
|
|
144
108
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
// Skip if no valid dynamic key is found
|
|
151
|
-
return acc;
|
|
152
|
-
}
|
|
153
|
-
var data = entry[dynamicKey];
|
|
154
|
-
// Ensure type is present in the accumulator
|
|
155
|
-
if (!acc[type]) {
|
|
156
|
-
acc[type] = {
|
|
157
|
-
count: 0,
|
|
158
|
-
data: []
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
// Push each entry into the data array
|
|
162
|
-
acc[type].data.push(data);
|
|
163
|
-
// Increment count for the type
|
|
164
|
-
acc[type].count += 1;
|
|
165
|
-
return acc;
|
|
166
|
-
}, {});
|
|
109
|
+
// Transform and group beacon data
|
|
110
|
+
transformData(inputData) {
|
|
111
|
+
// Validate if input data are array
|
|
112
|
+
if (!Array.isArray(inputData)) {
|
|
113
|
+
return {};
|
|
167
114
|
}
|
|
168
|
-
|
|
169
|
-
|
|
115
|
+
return inputData.reduce((acc, entry) => {
|
|
116
|
+
var {
|
|
117
|
+
type,
|
|
118
|
+
_c,
|
|
119
|
+
reference_path
|
|
120
|
+
} = entry;
|
|
121
|
+
|
|
122
|
+
// Identify the dynamic key (it could be 'library', 'configuration', 'services', etc.)
|
|
123
|
+
var dynamicKey = Object.keys(entry).find(key => typeof entry[key] === 'object' && entry[key] !== null && !Array.isArray(entry[key]));
|
|
124
|
+
if (!dynamicKey) {
|
|
125
|
+
// Skip if no valid dynamic key is found
|
|
126
|
+
return acc;
|
|
127
|
+
}
|
|
128
|
+
var data = entry[dynamicKey];
|
|
129
|
+
// Ensure type is present in the accumulator
|
|
130
|
+
if (!acc[type]) {
|
|
131
|
+
acc[type] = {
|
|
132
|
+
count: 0,
|
|
133
|
+
data: []
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
// Push each entry into the data array
|
|
137
|
+
acc[type].data.push(data);
|
|
138
|
+
// Increment count for the type
|
|
139
|
+
acc[type].count += 1;
|
|
140
|
+
return acc;
|
|
141
|
+
}, {});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
exports.default = AttentionRequiredService;
|
|
@@ -4,19 +4,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports
|
|
7
|
+
exports.default = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
12
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
13
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
14
9
|
var _asab_webui_components = require("asab_webui_components");
|
|
15
10
|
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; }
|
|
16
|
-
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
|
|
17
|
-
|
|
18
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
19
|
-
var BrandingService = exports["default"] = /*#__PURE__*/function (_Service) {
|
|
11
|
+
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; }
|
|
12
|
+
class BrandingService extends _asab_webui_components.Service {
|
|
20
13
|
/*
|
|
21
14
|
Branding service expects `header-logo-full.svg` and `header-logo-minimized.svg` SVG images
|
|
22
15
|
in `/public/media/logo/` directory:
|
|
@@ -24,81 +17,71 @@ var BrandingService = exports["default"] = /*#__PURE__*/function (_Service) {
|
|
|
24
17
|
* `header-logo-minimized.svg` dimensions: 50 x 50 pixels
|
|
25
18
|
*/
|
|
26
19
|
|
|
27
|
-
|
|
28
|
-
var _this;
|
|
20
|
+
constructor(app) {
|
|
29
21
|
var serviceName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "BrandingService";
|
|
30
|
-
(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
_this.sidebarLogo = undefined;
|
|
37
|
-
return _this;
|
|
22
|
+
super(app, serviceName);
|
|
23
|
+
this.state = [];
|
|
24
|
+
this.App = app;
|
|
25
|
+
this.brandImage = undefined;
|
|
26
|
+
this.defaultBrandImage = undefined;
|
|
27
|
+
this.sidebarLogo = undefined;
|
|
38
28
|
}
|
|
39
|
-
(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
this.brandImage = this.App.Config.get('brandImage');
|
|
45
|
-
this.defaultBrandImage = this.App.Config.get('defaultBrandImage');
|
|
46
|
-
this.sidebarLogo = this.App.Config.get('sidebarLogo');
|
|
47
|
-
}
|
|
29
|
+
initialize() {
|
|
30
|
+
if (this.App.Services.ConfigService) {
|
|
31
|
+
this.brandImage = this.App.Config.get('brandImage');
|
|
32
|
+
this.defaultBrandImage = this.App.Config.get('defaultBrandImage');
|
|
33
|
+
this.sidebarLogo = this.App.Config.get('sidebarLogo');
|
|
48
34
|
}
|
|
35
|
+
}
|
|
49
36
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
var _imgObject$
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
href: (_imgObject$href4 = imgObject.href) !== null && _imgObject$href4 !== void 0 ? _imgObject$href4 : '/'
|
|
79
|
-
});
|
|
80
|
-
}
|
|
37
|
+
/* This method returns object containing paths to branding depending on theme. It also takes care of filling in missing
|
|
38
|
+
values (e.g. when only minimized version was provided in the configuration, the method completes it with full version) */
|
|
39
|
+
_determineSources(imgObject, theme) {
|
|
40
|
+
var _imgObject$theme, _imgObject$theme2, _imgObject$theme3, _imgObject$theme4;
|
|
41
|
+
if ((_imgObject$theme = imgObject[theme]) !== null && _imgObject$theme !== void 0 && _imgObject$theme.minimized && (_imgObject$theme2 = imgObject[theme]) !== null && _imgObject$theme2 !== void 0 && _imgObject$theme2.full) {
|
|
42
|
+
var _imgObject$href;
|
|
43
|
+
return _objectSpread(_objectSpread({}, imgObject[theme]), {}, {
|
|
44
|
+
href: (_imgObject$href = imgObject.href) !== null && _imgObject$href !== void 0 ? _imgObject$href : '/'
|
|
45
|
+
});
|
|
46
|
+
} else if ((_imgObject$theme3 = imgObject[theme]) !== null && _imgObject$theme3 !== void 0 && _imgObject$theme3.minimized) {
|
|
47
|
+
var _imgObject$otherTheme, _imgObject$otherTheme2, _imgObject$href2;
|
|
48
|
+
return {
|
|
49
|
+
full: (_imgObject$otherTheme = imgObject === null || imgObject === void 0 || (_imgObject$otherTheme2 = imgObject.otherTheme) === null || _imgObject$otherTheme2 === void 0 ? void 0 : _imgObject$otherTheme2.full) !== null && _imgObject$otherTheme !== void 0 ? _imgObject$otherTheme : this.defaultBrandImage.full,
|
|
50
|
+
minimized: imgObject[theme].minimized,
|
|
51
|
+
href: (_imgObject$href2 = imgObject === null || imgObject === void 0 ? void 0 : imgObject.href) !== null && _imgObject$href2 !== void 0 ? _imgObject$href2 : '/'
|
|
52
|
+
};
|
|
53
|
+
} else if ((_imgObject$theme4 = imgObject[theme]) !== null && _imgObject$theme4 !== void 0 && _imgObject$theme4.full) {
|
|
54
|
+
var _imgObject$otherTheme3, _imgObject$otherTheme4, _imgObject$href3;
|
|
55
|
+
return {
|
|
56
|
+
full: imgObject[theme].full,
|
|
57
|
+
minimized: (_imgObject$otherTheme3 = imgObject === null || imgObject === void 0 || (_imgObject$otherTheme4 = imgObject.otherTheme) === null || _imgObject$otherTheme4 === void 0 ? void 0 : _imgObject$otherTheme4.minimized) !== null && _imgObject$otherTheme3 !== void 0 ? _imgObject$otherTheme3 : this.defaultBrandImage.minimized,
|
|
58
|
+
href: (_imgObject$href3 = imgObject === null || imgObject === void 0 ? void 0 : imgObject.href) !== null && _imgObject$href3 !== void 0 ? _imgObject$href3 : '/'
|
|
59
|
+
};
|
|
60
|
+
} else {
|
|
61
|
+
var _imgObject$href4;
|
|
62
|
+
return _objectSpread(_objectSpread({}, this.defaultBrandImage), {}, {
|
|
63
|
+
href: (_imgObject$href4 = imgObject.href) !== null && _imgObject$href4 !== void 0 ? _imgObject$href4 : '/'
|
|
64
|
+
});
|
|
81
65
|
}
|
|
66
|
+
}
|
|
82
67
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
} else if (!this.sidebarLogo[theme]) {
|
|
91
|
-
return this.sidebarLogo[theme === 'dark' ? 'light' : 'dark'];
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
/* if we have theme and we've managed to obtain appropriate branding from Config's get method. (this method checks if remote,
|
|
95
|
-
local or default configurations were set up (respectively) and returns the first one it comes across) Then, the `_determineSources`
|
|
96
|
-
method comes to play. */
|
|
97
|
-
if (theme && this.brandImage) {
|
|
98
|
-
return this._determineSources(this.brandImage, theme);
|
|
99
|
-
} else {
|
|
100
|
-
return this.defaultBrandImage;
|
|
68
|
+
// method getLogo returns correct brandImage object to be displayed on the front end based on theme and type (sidebbar logo or main logo)
|
|
69
|
+
getLogo(theme, type) {
|
|
70
|
+
if (type === 'sidebarLogo' && theme && this.sidebarLogo) {
|
|
71
|
+
if (this.sidebarLogo[theme]) {
|
|
72
|
+
return this.sidebarLogo[theme];
|
|
73
|
+
} else if (!this.sidebarLogo[theme]) {
|
|
74
|
+
return this.sidebarLogo[theme === 'dark' ? 'light' : 'dark'];
|
|
101
75
|
}
|
|
102
76
|
}
|
|
103
|
-
|
|
104
|
-
|
|
77
|
+
/* if we have theme and we've managed to obtain appropriate branding from Config's get method. (this method checks if remote,
|
|
78
|
+
local or default configurations were set up (respectively) and returns the first one it comes across) Then, the `_determineSources`
|
|
79
|
+
method comes to play. */
|
|
80
|
+
if (theme && this.brandImage) {
|
|
81
|
+
return this._determineSources(this.brandImage, theme);
|
|
82
|
+
} else {
|
|
83
|
+
return this.defaultBrandImage;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.default = BrandingService;
|
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
|
-
exports
|
|
8
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
11
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
12
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
6
|
+
exports.default = void 0;
|
|
13
7
|
var _asab_webui_components = require("asab_webui_components");
|
|
14
8
|
var _actions = require("../actions");
|
|
15
|
-
|
|
16
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
17
|
-
var HeaderService = exports["default"] = /*#__PURE__*/function (_Service) {
|
|
9
|
+
class HeaderService extends _asab_webui_components.Service {
|
|
18
10
|
/*
|
|
19
11
|
Header service expects `header-logo-full.svg` and `header-logo-minimized.svg` SVG images
|
|
20
12
|
in `/public/media/logo/` directory:
|
|
@@ -22,63 +14,52 @@ var HeaderService = exports["default"] = /*#__PURE__*/function (_Service) {
|
|
|
22
14
|
* `header-logo-minimized.svg` dimensions: 50 x 50 pixels
|
|
23
15
|
*/
|
|
24
16
|
|
|
25
|
-
|
|
26
|
-
var _this;
|
|
17
|
+
constructor(app) {
|
|
27
18
|
var serviceName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "HeaderService";
|
|
28
|
-
(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
super(app, serviceName);
|
|
20
|
+
this.Items = [];
|
|
21
|
+
}
|
|
22
|
+
initialize() {
|
|
23
|
+
this.App.ConfigService.addDefaults({
|
|
24
|
+
'defaultBrandImage': {
|
|
25
|
+
full: "media/logo/header-logo-full.svg",
|
|
26
|
+
minimized: "media/logo/header-logo-minimized.svg",
|
|
27
|
+
href: undefined
|
|
28
|
+
}
|
|
29
|
+
}, true);
|
|
32
30
|
}
|
|
33
|
-
(0, _inherits2["default"])(HeaderService, _Service);
|
|
34
|
-
return (0, _createClass2["default"])(HeaderService, [{
|
|
35
|
-
key: "initialize",
|
|
36
|
-
value: function initialize() {
|
|
37
|
-
this.App.ConfigService.addDefaults({
|
|
38
|
-
'defaultBrandImage': {
|
|
39
|
-
full: "media/logo/header-logo-full.svg",
|
|
40
|
-
minimized: "media/logo/header-logo-minimized.svg",
|
|
41
|
-
href: undefined
|
|
42
|
-
}
|
|
43
|
-
}, true);
|
|
44
|
-
}
|
|
45
31
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}, {
|
|
56
|
-
key: "addComponent",
|
|
57
|
-
value: function addComponent(component) {
|
|
58
|
-
this.Items.push({
|
|
59
|
-
'component': component.component,
|
|
60
|
-
'componentProps': component.componentProps,
|
|
61
|
-
'order': component.order,
|
|
62
|
-
'fullscreenVisible': component.fullscreenVisible
|
|
63
|
-
});
|
|
64
|
-
this.App.Store.dispatch({
|
|
65
|
-
type: _actions.SET_HEADER_NAVIGATION_ITEMS,
|
|
66
|
-
headerNavItems: this.Items
|
|
67
|
-
});
|
|
68
|
-
}
|
|
32
|
+
/*
|
|
33
|
+
Adding items to the header can be done by using addComponent:
|
|
34
|
+
const headerService = app.locateService("HeaderService");
|
|
35
|
+
headerService.addComponent({
|
|
36
|
+
component: NavLink,
|
|
37
|
+
componentProps: {children: "My redirect button", href: "#/redirect", style: {marginRight: "2rem"}},
|
|
38
|
+
order: 900
|
|
39
|
+
});
|
|
40
|
+
*/
|
|
69
41
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
42
|
+
addComponent(component) {
|
|
43
|
+
this.Items.push({
|
|
44
|
+
'component': component.component,
|
|
45
|
+
'componentProps': component.componentProps,
|
|
46
|
+
'order': component.order,
|
|
47
|
+
'fullscreenVisible': component.fullscreenVisible
|
|
48
|
+
});
|
|
49
|
+
this.App.Store.dispatch({
|
|
50
|
+
type: _actions.SET_HEADER_NAVIGATION_ITEMS,
|
|
51
|
+
headerNavItems: this.Items
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// This function removes a component from the Header
|
|
56
|
+
removeComponent(component) {
|
|
57
|
+
var filteredItems = this.Items.filter(item => item.component !== component);
|
|
58
|
+
this.Items = filteredItems;
|
|
59
|
+
this.App.Store.dispatch({
|
|
60
|
+
type: _actions.SET_HEADER_NAVIGATION_ITEMS,
|
|
61
|
+
headerNavItems: this.Items
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.default = HeaderService;
|
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
|
-
exports
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var ReduxService = exports["default"] = /*#__PURE__*/function () {
|
|
11
|
-
function ReduxService() {
|
|
12
|
-
(0, _classCallCheck2["default"])(this, ReduxService);
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
class ReduxService {
|
|
8
|
+
constructor() {
|
|
13
9
|
this.Reducers = {};
|
|
14
10
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
console.warn("Reducer with name ".concat(name, " already exists."));
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
this.Reducers[name] = reducer;
|
|
11
|
+
addReducer(name, reducer) {
|
|
12
|
+
if (name in this.Reducers) {
|
|
13
|
+
console.warn("Reducer with name ".concat(name, " already exists."));
|
|
14
|
+
return;
|
|
23
15
|
}
|
|
24
|
-
|
|
25
|
-
}
|
|
16
|
+
this.Reducers[name] = reducer;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.default = ReduxService;
|