asab_webui_shell 27.5.2-alpha.0 → 27.5.4-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.
@@ -109,6 +109,10 @@ body {
109
109
  overflow-y: visible; // We want the full content to be displayed
110
110
  }
111
111
 
112
+ .progress {
113
+ display: none;
114
+ }
115
+
112
116
  }
113
117
 
114
118
  }
@@ -99,7 +99,9 @@ function Sidebar(props) {
99
99
  setSidebarBottomBranding((0, _BrandImage.getBrandImage)(props, theme, 'sidebarLogo'));
100
100
  }, [theme]);
101
101
  var toggleSidebarModal = () => setIsSmallResolution(!isSmallResolution);
102
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, windowWidth <= 768 ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
102
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, windowWidth <= 768 ? /*#__PURE__*/_react.default.createElement("div", {
103
+ id: "app-sidebar"
104
+ }, /*#__PURE__*/_react.default.createElement("div", {
103
105
  onClick: toggleSidebarModal
104
106
  }, /*#__PURE__*/_react.default.createElement("i", {
105
107
  className: "bi ms-2 bi-list text-primary fs-1"
@@ -11,21 +11,25 @@ var _locationReplace = require("../../components/locationReplace");
11
11
  class SeaCatAuthApi {
12
12
  /*
13
13
  SeaCat Auth Open ID Connect / OAuth2.0
14
-
15
- From config.js:
16
- module.exports = {
17
- app: {
18
- BASE_URL: 'http://localhost:3000',
19
- API_PATH: 'api',
20
- SERVICES: {openidconnect: 'openidconnect'},
21
- ...
14
+ From webpack.common.js:
15
+ To change a Client ID, set the seacat.auth.client_id configuration variable in the webpack.common.js file:
16
+ const { DefinePlugin } = require('webpack');
17
+ ...
18
+ new DefinePlugin({
19
+ 'LOCAL_CONFIG': JSON.stringify({
20
+ "seacat.auth.scope": "openid tenant userinfo:*",
21
+ "seacat.auth.client_id": "llm-microlink-webui",
22
+ }),
23
+ })
22
24
  */
23
25
 
24
26
  constructor(app) {
25
27
  this.App = app;
26
- var scope = this.App.Config.get('seacat.auth.scope');
27
- this.Scope = scope ? scope : "openid tenant userinfo:* batman";
28
- this.ClientId = "asab-webui-auth";
28
+ this.Scope = this.App.Config.get('seacat.auth.scope') || "openid tenant userinfo:* batman";
29
+ this.ClientId = this.App.Config.get('seacat.auth.client_id') || "asab-webui-auth";
30
+
31
+ // The console log is intentionally left here so that we can see the Client ID in the console
32
+ console.log('OpenID Connect Client ID:', this.ClientId);
29
33
  this.SeaCatAuthAPI = this.App.axiosCreate('seacat-auth');
30
34
  this.OidcAPI = this.App.axiosCreate('openidconnect');
31
35
  }
@@ -90,7 +94,6 @@ class SeaCatAuthApi {
90
94
  if (access_token != null) {
91
95
  headers.Authorization = 'Bearer ' + access_token;
92
96
  }
93
- console.log("userinfo", access_token, internal);
94
97
  if (internal) {
95
98
  return this.SeaCatAuthAPI.get('/openidconnect/userinfo', {
96
99
  headers: headers
@@ -32,11 +32,9 @@ class AuthModule extends _asab_webui_components.Module {
32
32
  // })
33
33
  // }),
34
34
  this.OAuthTokens = OAUTH_TOKENS;
35
- console.log("OAuthTokens from OAUTH_TOKENS (development mode!)", this.OAuthTokens);
36
35
  } else {
37
36
  // Read OAuth tokens from session storage
38
37
  this.OAuthTokens = JSON.parse(sessionStorage.getItem('SeaCatOAuth2Tokens'));
39
- console.log("OAuthTokens from session storage", this.OAuthTokens);
40
38
  }
41
39
  this.UserInfo = null;
42
40
  this.Api = new _api.SeaCatAuthApi(app);
@@ -333,6 +331,11 @@ class AuthModule extends _asab_webui_components.Module {
333
331
  if (this.UserInfo !== null) {
334
332
  resources = this.UserInfo.resources ? this.UserInfo.resources[currentTenant] : [];
335
333
  tenants = this.UserInfo.tenants ? this.UserInfo.tenants : [];
334
+ if (tenants == null || tenants.length === 0) {
335
+ var _this$UserInfo$resour;
336
+ // Fallback to tenant from resources if tenants list is not available
337
+ tenants = Object.keys((_this$UserInfo$resour = this.UserInfo.resources) !== null && _this$UserInfo$resour !== void 0 ? _this$UserInfo$resour : {}).filter(tenant => tenant !== '*');
338
+ }
336
339
  }
337
340
  var valid = tenants ? tenants.indexOf(currentTenant) !== -1 : false;
338
341
  // If user is superuser, then tenant access is granted
@@ -344,8 +347,8 @@ class AuthModule extends _asab_webui_components.Module {
344
347
  updateUserInfo() {
345
348
  var _this3 = this;
346
349
  return (0, _asyncToGenerator2.default)(function* () {
350
+ var _this3$UserInfo;
347
351
  var internal = _this3.OAuthTokens.internal || false;
348
- console.log("updateUserInfo", _this3.OAuthTokens, internal);
349
352
  if (!internal) {
350
353
  var _response$data;
351
354
  var response;
@@ -415,10 +418,20 @@ class AuthModule extends _asab_webui_components.Module {
415
418
  });
416
419
  }
417
420
 
418
- /** Check for TenantService and pass tenants list obtained from userinfo */
421
+ // Check for TenantService and pass tenants list obtained from userinfo resources
419
422
  var availableTenants = _this3.UserInfo.tenants;
423
+ if (availableTenants == null || availableTenants.length === 0) {
424
+ var _this3$UserInfo$resou;
425
+ // Fallback to tenant from resources if tenants list is not available
426
+ availableTenants = Object.keys((_this3$UserInfo$resou = _this3.UserInfo.resources) !== null && _this3$UserInfo$resou !== void 0 ? _this3$UserInfo$resou : {}).filter(tenant => tenant !== '*');
427
+ }
428
+ if (((_this3$UserInfo = _this3.UserInfo) === null || _this3$UserInfo === void 0 ? void 0 : _this3$UserInfo.tenants) == null) {
429
+ // This is a monkey patch to add the tenants list to the userinfo if missing
430
+ _this3.UserInfo['tenants'] = availableTenants;
431
+ }
420
432
  if (_this3.App.Services.TenantService) {
421
- yield _this3.App.Services.TenantService.setTenants(availableTenants, _this3._getAuthorizedTenant(_this3.UserInfo));
433
+ yield _this3.App.Services.TenantService.setTenants(availableTenants, _this3._getAuthorizedTenant(_this3.UserInfo) // Get the authorized tenant
434
+ );
422
435
  }
423
436
  return true;
424
437
  })();
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.default = TenantDropdown;
8
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
7
9
  var _react = _interopRequireWildcard(require("react"));
8
10
  var _asab_webui_components = require("asab_webui_components");
9
11
  var _reactI18next = require("react-i18next");
@@ -12,6 +14,10 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
12
14
  function TenantDropdown() {
13
15
  var _useTranslation = (0, _reactI18next.useTranslation)(),
14
16
  t = _useTranslation.t;
17
+ var _useState = (0, _react.useState)(false),
18
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
19
+ isOpen = _useState2[0],
20
+ setIsOpen = _useState2[1];
15
21
  var current = (0, _asab_webui_components.useAppSelector)(state => {
16
22
  var _state$tenant;
17
23
  return state === null || state === void 0 || (_state$tenant = state.tenant) === null || _state$tenant === void 0 ? void 0 : _state$tenant.current;
@@ -20,9 +26,12 @@ function TenantDropdown() {
20
26
  var _state$tenant2;
21
27
  return state === null || state === void 0 || (_state$tenant2 = state.tenant) === null || _state$tenant2 === void 0 ? void 0 : _state$tenant2.tenants;
22
28
  });
23
- return /*#__PURE__*/_react.default.createElement(_reactstrap.UncontrolledDropdown, {
29
+ var toggle = () => setIsOpen(prev => !prev);
30
+ return /*#__PURE__*/_react.default.createElement(_reactstrap.Dropdown, {
31
+ isOpen: isOpen,
32
+ toggle: toggle,
24
33
  direction: "down",
25
- title: t('tenant|Tenant')
34
+ title: t('General|Tenant')
26
35
  }, /*#__PURE__*/_react.default.createElement(_reactstrap.DropdownToggle, {
27
36
  nav: true,
28
37
  caret: true
@@ -30,17 +39,20 @@ function TenantDropdown() {
30
39
  className: "bi bi-house-lock pe-2"
31
40
  }), /*#__PURE__*/_react.default.createElement(TenantLabel, {
32
41
  tenant: current
33
- })), tenants && tenants.length > 0 ? /*#__PURE__*/_react.default.createElement(_reactstrap.DropdownMenu, {
34
- className: "shadow"
42
+ })), isOpen && (tenants === null || tenants === void 0 ? void 0 : tenants.length) > 0 && /*#__PURE__*/_react.default.createElement(_reactstrap.DropdownMenu, {
43
+ className: "shadow overflow-y-auto",
44
+ style: {
45
+ maxHeight: '20em'
46
+ }
35
47
  }, /*#__PURE__*/_react.default.createElement(_reactstrap.DropdownItem, {
36
48
  header: true
37
- }, "Tenants"), tenants.map((tenant, i) => /*#__PURE__*/_react.default.createElement(_reactstrap.DropdownItem, {
49
+ }, t('General|Tenants')), tenants.map((tenant, i) => /*#__PURE__*/_react.default.createElement(_reactstrap.DropdownItem, {
38
50
  key: i,
39
51
  tag: "a",
40
52
  href: '?tenant=' + tenant + '#/'
41
53
  }, /*#__PURE__*/_react.default.createElement(TenantLabel, {
42
54
  tenant: tenant
43
- })))) : null);
55
+ })))));
44
56
  }
45
57
  function TenantLabel(_ref) {
46
58
  var tenant = _ref.tenant;
@@ -1,10 +1,11 @@
1
1
  @page print-portrait {
2
- size: A4 portrait;
2
+ size: a4 portrait;
3
+ margin: 10mm;
3
4
  }
4
5
 
5
6
  @page print-landscape {
6
- size: A4 landscape;
7
- margin: 2cm 1cm 1.5cm;
7
+ size: a4 landscape;
8
+ margin: 10mm;
8
9
  }
9
10
 
10
11
  @media print {
@@ -79,7 +80,7 @@
79
80
  --table-row-hover-bg-color-rgb: var(--soft-gray-rgb);
80
81
 
81
82
  &.print-portrait {
82
- width: 900px;
83
+ width: 1200px;
83
84
  }
84
85
 
85
86
  #app {
@@ -95,25 +96,7 @@
95
96
  .card {
96
97
  box-shadow: none !important;
97
98
  border: 0 !important;
98
- .card-header {
99
- background-color: var(--white);
100
- &.print-card-header {
101
- min-height: auto;
102
- .flex-fill {
103
- height: auto;
104
- }
105
- }
106
99
 
107
- i:not(.text-warning) {
108
- display: none !important;
109
- }
110
- h3 {
111
- font-size: 32px !important;
112
- }
113
- }
114
- .card-body {
115
- color: inherit !important;
116
- }
117
100
  .card-footer, .card-footer-flex, .input-group {
118
101
  display: none !important;
119
102
  }
@@ -165,48 +148,25 @@
165
148
  }
166
149
  }
167
150
 
151
+ // Taken from here: https://github.com/react-grid-layout/react-grid-layout/issues/589
168
152
 
169
- .reports-container {
170
- margin-top: 0 !important; /* Remove margin-top to prevent blank first page */
171
- padding-top: 0 !important; /* Remove padding to prevent blank first page */
172
- padding-bottom: 0 !important; /* Remove bottom padding to prevent blank spaces at the endof the sheet */
173
- margin-bottom: 0 !important; /* Remove bottom margin to prevent blank spaces at the endof the sheet */
174
- .react-grid-layout {
175
- height: unset !important;
176
- display: table;
177
- text-align: center;
178
- .react-grid-item {
179
- display: inline-block;
180
- position: unset !important;
181
- transform: unset !important;
182
- text-align: initial;
183
- break-inside: avoid;
184
- }
185
- .react-grid-item:not(:has(.recharts-responsive-container)) {
186
- height: initial !important; /* Allow table widgets to expand and show all content */
187
- }
153
+ .react-grid-item {
154
+ position: unset !important;
155
+ transform: unset !important;
156
+ margin: 10px;
157
+ display: inline-block;
158
+
159
+ > div {
160
+ page-break-inside: avoid;
161
+ break-inside: avoid;
188
162
  }
189
163
  }
190
-
191
- .dashboard-container {
192
- &.display-print {
193
- .react-grid-layout {
194
- position: static !important;
195
- height: initial !important;
196
- .react-grid-item {
197
- display: block !important; /*avoid widgets breaking on transition between pages*/
198
- margin: 0 auto 20px;
199
- position: static !important;
200
- width: initial !important; /* Alternatively, set "width: initial !important;" */
201
- break-inside: avoid;
202
- page-break-inside: avoid; /*avoid widgets breaking on transition between pages*/
203
- }
204
- .react-grid-item:not(:has(.recharts-responsive-container)) {
205
- height: initial !important;
206
- }
207
- }
208
- }
164
+
165
+ .react-grid-layout {
166
+ height: unset !important;
167
+ display: table;
209
168
  }
169
+
210
170
  }
211
171
 
212
172
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asab_webui_shell",
3
- "version": "27.5.2-alpha.0",
3
+ "version": "27.5.4-alpha.1",
4
4
  "license": "BSD-3-Clause",
5
5
  "description": "TeskaLabs ASAB WebUI Shell Application",
6
6
  "contributors": [