asab_webui_shell 25.1.12 → 25.2.1-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.
Files changed (78) hide show
  1. package/dist/components/locationReplace.js +4 -16
  2. package/dist/config/ConfigReducer.js +1 -1
  3. package/dist/config/ConfigService.js +116 -137
  4. package/dist/containers/AdvancedMode/reducer.js +2 -2
  5. package/dist/containers/Alerts/index.js +18 -30
  6. package/dist/containers/Alerts/reducer.js +5 -6
  7. package/dist/containers/Application.js +531 -673
  8. package/dist/containers/AttentionRequired/reducer.js +2 -2
  9. package/dist/containers/FullscreenMode/reducer.js +2 -2
  10. package/dist/containers/Header/ApplicationScreenTitle/ApplicationScreenTitle.js +15 -16
  11. package/dist/containers/Header/ApplicationScreenTitle/index.js +6 -6
  12. package/dist/containers/Header/Help/HelpButton.js +17 -27
  13. package/dist/containers/Header/Help/HelpService.js +13 -24
  14. package/dist/containers/Header/Preview/PreviewFlag.js +6 -5
  15. package/dist/containers/Header/Preview/PreviewService.js +13 -24
  16. package/dist/containers/Header/index.js +15 -17
  17. package/dist/containers/Header/reducer.js +4 -4
  18. package/dist/containers/Navigation/index.js +35 -55
  19. package/dist/containers/Navigation/reducer.js +7 -13
  20. package/dist/containers/RouteErrorHandler/ErrorContainer.js +17 -19
  21. package/dist/containers/RouteErrorHandler/index.js +28 -44
  22. package/dist/containers/Router/ApplicationRouter.js +14 -16
  23. package/dist/containers/Router/index.js +26 -42
  24. package/dist/containers/Router/reducer.js +3 -3
  25. package/dist/containers/Sidebar/NavbarBrand.js +14 -23
  26. package/dist/containers/Sidebar/SidebarBottomItem.js +16 -15
  27. package/dist/containers/Sidebar/SidebarIcon.js +9 -7
  28. package/dist/containers/Sidebar/SidebarItem.js +70 -85
  29. package/dist/containers/Sidebar/SidebarItemRenderer.js +20 -20
  30. package/dist/containers/Sidebar/index.js +20 -36
  31. package/dist/containers/Sidebar/reducer.js +3 -3
  32. package/dist/containers/Sidepanel/Sidepanel.js +18 -26
  33. package/dist/containers/Toast/ToastComponent.js +12 -12
  34. package/dist/containers/Toast/ToastContainer.js +19 -30
  35. package/dist/containers/Toast/reducer.js +3 -6
  36. package/dist/index.js +7 -6
  37. package/dist/modules/about/AboutScreen.js +30 -38
  38. package/dist/modules/about/index.js +8 -26
  39. package/dist/modules/auth/api.js +110 -156
  40. package/dist/modules/auth/components/SessionExpirationAlert.js +10 -9
  41. package/dist/modules/auth/header.js +25 -23
  42. package/dist/modules/auth/index.js +440 -692
  43. package/dist/modules/auth/reducer.js +2 -2
  44. package/dist/modules/auth/screens/AccessControlScreen.js +24 -25
  45. package/dist/modules/auth/screens/InvitationScreen.js +89 -128
  46. package/dist/modules/i18n/dropdown.js +24 -23
  47. package/dist/modules/i18n/index.js +20 -33
  48. package/dist/modules/i18n/reducer.js +2 -2
  49. package/dist/modules/i18n/service.js +48 -102
  50. package/dist/modules/tenant/TenantDropdown.js +28 -27
  51. package/dist/modules/tenant/access/AccessDeniedCard.js +28 -54
  52. package/dist/modules/tenant/index.js +16 -29
  53. package/dist/modules/tenant/reducer.js +1 -1
  54. package/dist/modules/tenant/service.js +123 -207
  55. package/dist/screens/InvalidRouteScreen.js +10 -9
  56. package/dist/screens/SuspenseScreen.js +11 -20
  57. package/dist/screens/SuspenseScreen.scss +5 -3
  58. package/dist/screens/UnauthorizedAccessScreen.js +18 -21
  59. package/dist/services/AttentionRequiredService.js +117 -142
  60. package/dist/services/BrandingService.js +63 -80
  61. package/dist/services/HeaderService.js +47 -66
  62. package/dist/services/ReduxService.js +11 -17
  63. package/dist/services/TitleService.js +13 -24
  64. package/dist/styles/components/alert.scss +53 -0
  65. package/dist/styles/components/button.scss +105 -0
  66. package/dist/styles/components/card.scss +174 -0
  67. package/dist/styles/components/form.scss +20 -0
  68. package/dist/styles/components/html.scss +18 -0
  69. package/dist/styles/constants/colors.scss +69 -0
  70. package/dist/styles/constants/index.scss +70 -0
  71. package/dist/styles/constants/theme-dark.scss +62 -0
  72. package/dist/styles/constants/theme-light.scss +53 -0
  73. package/dist/styles/constants/theme-print.scss +206 -0
  74. package/dist/styles/index.scss +15 -0
  75. package/dist/theme/ThemeButton.js +13 -10
  76. package/dist/theme/ThemeReducer.js +1 -1
  77. package/dist/theme/ThemeService.js +25 -38
  78. 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["default"] = void 0;
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
- var AttentionRequiredService = exports["default"] = /*#__PURE__*/function (_Service) {
20
- function AttentionRequiredService(app) {
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
- (0, _classCallCheck2["default"])(this, AttentionRequiredService);
24
- _this = _callSuper(this, AttentionRequiredService, [app, serviceName]);
25
- _this.beaconWebSocket = null; // beacon websocket variable
26
- _this.reconnectTimeout = null; // timeout variable
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
- (0, _inherits2["default"])(AttentionRequiredService, _Service);
33
- return (0, _createClass2["default"])(AttentionRequiredService, [{
34
- key: "initialize",
35
- value: function initialize() {
36
- this.connectBeaconWebSocket();
37
- }
20
+ initialize() {
21
+ this.connectBeaconWebSocket();
22
+ }
38
23
 
39
- // Method for connection to beacon websocket
40
- }, {
41
- key: "connectBeaconWebSocket",
42
- value: function connectBeaconWebSocket() {
43
- var _this$App,
44
- _this2 = this;
45
- // Retrieve current tenant
46
- 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();
47
- // Gracefully reconnect if tenant was not found
48
- if (!currentTenant) {
49
- console.error("Beacon WebSocket error: Tenant was not found!");
50
- this.reconnectBeaconWebSocket();
51
- return;
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
- var BeaconServiceClient = this.App.createWebSocket('asab-remote-control', "/beacon/".concat(currentTenant, "/ws"));
54
- this.beaconWebSocket = BeaconServiceClient;
55
- this.beaconWebSocket.onopen = function () {
56
- // TODO: may be removed
57
- console.log('Beacon WebSocket connection established.');
58
- };
59
- this.beaconWebSocket.onmessage = function (message) {
60
- try {
61
- var data = JSON.parse(message.data);
62
- // TODO: implement some type based recognition
63
- _this2.distributeData(data);
64
- } catch (e) {
65
- console.error("Error parsing Beacon WebSocket message data:", e);
66
- _this2.distributeData({});
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
- // Set WebSocket reference to null to free up memory
91
- _this2.beaconWebSocket = null;
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
- // Clear the reconnect timeout if it exists
95
- if (_this2.reconnectTimeout) {
96
- clearTimeout(_this2.reconnectTimeout);
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
- // Method for reconnection to beacon websocket
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
- this.reconnectTimeout = setTimeout(function () {
112
- _this3.connectBeaconWebSocket();
113
- }, this.reconnectInterval); // Retry connection after the reconnection interval
81
+ console.log("Beacon WebSocket connection closed.");
82
+ };
83
+ }
114
84
 
115
- // Increase reconnection time by 5s, the limit is 60s (so that we dont overload the server)
116
- if (this.reconnectInterval + 5000 <= 60000) {
117
- this.reconnectInterval += 5000;
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
- // Method for distributing the data into redux store
122
- }, {
123
- key: "distributeData",
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
- // Transform and group beacon data
133
- }, {
134
- key: "transformData",
135
- value: function transformData(inputData) {
136
- // Validate if input data are array
137
- if (!Array.isArray(inputData)) {
138
- return {};
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
- // Identify the dynamic key (it could be 'library', 'configuration', 'services', etc.)
146
- var dynamicKey = Object.keys(entry).find(function (key) {
147
- return (0, _typeof2["default"])(entry[key]) === 'object' && entry[key] !== null && !Array.isArray(entry[key]);
148
- });
149
- if (!dynamicKey) {
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
- }(_asab_webui_components.Service);
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["default"] = void 0;
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["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; }
17
- 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)); }
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
- function BrandingService(app) {
28
- var _this;
20
+ constructor(app) {
29
21
  var serviceName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "BrandingService";
30
- (0, _classCallCheck2["default"])(this, BrandingService);
31
- _this = _callSuper(this, BrandingService, [app, serviceName]);
32
- _this.state = [];
33
- _this.App = app;
34
- _this.brandImage = undefined;
35
- _this.defaultBrandImage = undefined;
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
- (0, _inherits2["default"])(BrandingService, _Service);
40
- return (0, _createClass2["default"])(BrandingService, [{
41
- key: "initialize",
42
- value: function initialize() {
43
- if (this.App.Services.ConfigService) {
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
- /* This method returns object containing paths to branding depending on theme. It also takes care of filling in missing
51
- values (e.g. when only minimized version was provided in the configuration, the method completes it with full version) */
52
- }, {
53
- key: "_determineSources",
54
- value: function _determineSources(imgObject, theme) {
55
- var _imgObject$theme, _imgObject$theme2, _imgObject$theme3, _imgObject$theme4;
56
- 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) {
57
- var _imgObject$href;
58
- return _objectSpread(_objectSpread({}, imgObject[theme]), {}, {
59
- href: (_imgObject$href = imgObject.href) !== null && _imgObject$href !== void 0 ? _imgObject$href : '/'
60
- });
61
- } else if ((_imgObject$theme3 = imgObject[theme]) !== null && _imgObject$theme3 !== void 0 && _imgObject$theme3.minimized) {
62
- var _imgObject$otherTheme, _imgObject$otherTheme2, _imgObject$href2;
63
- return {
64
- 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,
65
- minimized: imgObject[theme].minimized,
66
- href: (_imgObject$href2 = imgObject === null || imgObject === void 0 ? void 0 : imgObject.href) !== null && _imgObject$href2 !== void 0 ? _imgObject$href2 : '/'
67
- };
68
- } else if ((_imgObject$theme4 = imgObject[theme]) !== null && _imgObject$theme4 !== void 0 && _imgObject$theme4.full) {
69
- var _imgObject$otherTheme3, _imgObject$otherTheme4, _imgObject$href3;
70
- return {
71
- full: imgObject[theme].full,
72
- 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,
73
- href: (_imgObject$href3 = imgObject === null || imgObject === void 0 ? void 0 : imgObject.href) !== null && _imgObject$href3 !== void 0 ? _imgObject$href3 : '/'
74
- };
75
- } else {
76
- var _imgObject$href4;
77
- return _objectSpread(_objectSpread({}, this.defaultBrandImage), {}, {
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
- // method getLogo returns correct brandImage object to be displayed on the front end based on theme and type (sidebbar logo or main logo)
84
- }, {
85
- key: "getLogo",
86
- value: function getLogo(theme, type) {
87
- if (type === 'sidebarLogo' && theme && this.sidebarLogo) {
88
- if (this.sidebarLogo[theme]) {
89
- return this.sidebarLogo[theme];
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
- }(_asab_webui_components.Service);
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["default"] = void 0;
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
- 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)); }
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
- function HeaderService(app) {
26
- var _this;
17
+ constructor(app) {
27
18
  var serviceName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "HeaderService";
28
- (0, _classCallCheck2["default"])(this, HeaderService);
29
- _this = _callSuper(this, HeaderService, [app, serviceName]);
30
- _this.Items = [];
31
- return _this;
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
- Adding items to the header can be done by using addComponent:
48
- const headerService = app.locateService("HeaderService");
49
- headerService.addComponent({
50
- component: NavLink,
51
- componentProps: {children: "My redirect button", href: "#/redirect", style: {marginRight: "2rem"}},
52
- order: 900
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
- // This function removes a component from the Header
71
- }, {
72
- key: "removeComponent",
73
- value: function removeComponent(component) {
74
- var filteredItems = this.Items.filter(function (item) {
75
- return item.component !== component;
76
- });
77
- this.Items = filteredItems;
78
- this.App.Store.dispatch({
79
- type: _actions.SET_HEADER_NAVIGATION_ITEMS,
80
- headerNavItems: this.Items
81
- });
82
- }
83
- }]);
84
- }(_asab_webui_components.Service);
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["default"] = void 0;
8
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
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
- return (0, _createClass2["default"])(ReduxService, [{
16
- key: "addReducer",
17
- value: function addReducer(name, reducer) {
18
- if (name in this.Reducers) {
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;