@dexteel/mesf-core 3.11.2 → 3.11.4
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/index.d.ts +2 -2
- package/dist/index.esm.js +128 -154
- package/dist/services/ApiService.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * from "./MESFMain";
|
|
2
1
|
export * from "./account";
|
|
2
|
+
export * from "./context/axiosInstance";
|
|
3
|
+
export * from "./MESFMain";
|
|
3
4
|
export * from "./components/modals/modal.mesf";
|
|
4
5
|
export * from "./configuration";
|
|
5
6
|
export * from "./context/UTLSettingContext";
|
|
6
7
|
export * from "./context/assetContext";
|
|
7
|
-
export * from "./context/axiosInstance";
|
|
8
8
|
export * from "./context/userContext";
|
|
9
9
|
export * from "./controls";
|
|
10
10
|
export * from "./services";
|
package/dist/index.esm.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import React__default, { useState, useRef, useEffect, Component, createContext, useContext, useMemo, useCallback, lazy, Suspense } from 'react';
|
|
3
|
-
import { Outlet, useNavigate, useSearchParams, Link, useParams, Navigate, Routes, Route, BrowserRouter } from 'react-router-dom';
|
|
4
1
|
import { Typography, TextField, FormHelperText, CircularProgress as CircularProgress$1, Grid as Grid$1, Snackbar as Snackbar$1, makeStyles as makeStyles$1, createStyles as createStyles$1, Dialog as Dialog$1, DialogTitle as DialogTitle$2, DialogContent as DialogContent$2, List, ListItem, ListItemText, DialogActions as DialogActions$2 } from '@material-ui/core';
|
|
5
2
|
import { get as get$1, isEmpty } from 'lodash-es';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import React__default, { useState, useRef, useEffect, Component, createContext, useContext, useMemo, useCallback, lazy, Suspense } from 'react';
|
|
6
5
|
import { Alert as Alert$1, Modal as Modal$2, Navbar, Container, Nav, NavDropdown } from 'react-bootstrap';
|
|
7
6
|
import DialogTitle$1 from '@material-ui/core/DialogTitle';
|
|
8
7
|
import DialogContent$1 from '@material-ui/core/DialogContent';
|
|
9
8
|
import DialogActions$1 from '@material-ui/core/DialogActions';
|
|
10
9
|
import Dialog from '@material-ui/core/Dialog';
|
|
11
10
|
import Button from '@material-ui/core/Button';
|
|
11
|
+
import { Outlet, useNavigate, useSearchParams, Link, useParams, Navigate, Routes, Route, BrowserRouter } from 'react-router-dom';
|
|
12
12
|
import { useMsal, MsalProvider } from '@azure/msal-react';
|
|
13
13
|
import { LogLevel, PublicClientApplication } from '@azure/msal-browser';
|
|
14
14
|
import { useComplexState } from 'use-complex-state';
|
|
@@ -17,7 +17,6 @@ import MenuItem from '@material-ui/core/MenuItem';
|
|
|
17
17
|
import MenuList from '@material-ui/core/MenuList';
|
|
18
18
|
import Paper from '@material-ui/core/Paper';
|
|
19
19
|
import Grid from '@material-ui/core/Grid';
|
|
20
|
-
import axios from 'axios';
|
|
21
20
|
import PersonPinCircleIcon from '@material-ui/icons/PersonPinCircle';
|
|
22
21
|
import moment from 'moment';
|
|
23
22
|
import { withStyles, alpha, makeStyles, createStyles, useTheme } from '@material-ui/core/styles';
|
|
@@ -59,6 +58,7 @@ import TreeItem from '@material-ui/lab/TreeItem';
|
|
|
59
58
|
import TreeView from '@material-ui/lab/TreeView';
|
|
60
59
|
import { useSpring, animated } from 'react-spring';
|
|
61
60
|
import CardActions from '@material-ui/core/CardActions';
|
|
61
|
+
import axios from 'axios';
|
|
62
62
|
|
|
63
63
|
/******************************************************************************
|
|
64
64
|
Copyright (c) Microsoft Corporation.
|
|
@@ -4708,6 +4708,107 @@ var Configuration$1 = /** @class */ (function () {
|
|
|
4708
4708
|
}());
|
|
4709
4709
|
|
|
4710
4710
|
var base$2 = document.getElementsByTagName('base')[0].getAttribute('href') || '/';
|
|
4711
|
+
function renewToken() {
|
|
4712
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4713
|
+
var refreshToken, config, fd, response, token;
|
|
4714
|
+
return __generator(this, function (_a) {
|
|
4715
|
+
switch (_a.label) {
|
|
4716
|
+
case 0:
|
|
4717
|
+
refreshToken = localStorage.getItem("refreshToken");
|
|
4718
|
+
if (!refreshToken) {
|
|
4719
|
+
throw new Error('refresh token does not exist');
|
|
4720
|
+
}
|
|
4721
|
+
config = new Configuration$1();
|
|
4722
|
+
fd = new FormData();
|
|
4723
|
+
fd.append('refreshToken', refreshToken);
|
|
4724
|
+
return [4 /*yield*/, axios.post("".concat(config.API_AUTH_URL, "/refresh"), fd, {
|
|
4725
|
+
headers: {
|
|
4726
|
+
"Content-Type": 'application/json'
|
|
4727
|
+
},
|
|
4728
|
+
params: {
|
|
4729
|
+
refreshToken: refreshToken
|
|
4730
|
+
}
|
|
4731
|
+
})];
|
|
4732
|
+
case 1:
|
|
4733
|
+
response = _a.sent();
|
|
4734
|
+
token = response.data.result;
|
|
4735
|
+
if (token) {
|
|
4736
|
+
return [2 /*return*/, [token, refreshToken]];
|
|
4737
|
+
}
|
|
4738
|
+
else {
|
|
4739
|
+
throw new Error("Token is not valid");
|
|
4740
|
+
}
|
|
4741
|
+
}
|
|
4742
|
+
});
|
|
4743
|
+
});
|
|
4744
|
+
}
|
|
4745
|
+
function isUnauthorizedError(error) {
|
|
4746
|
+
var _a = error.response, status = _a.status; _a.statusText;
|
|
4747
|
+
return status === 401;
|
|
4748
|
+
}
|
|
4749
|
+
var axiosInstance = axios.create({
|
|
4750
|
+
headers: {
|
|
4751
|
+
Authorization: "Bearer ".concat(getTokenFromLS())
|
|
4752
|
+
}
|
|
4753
|
+
});
|
|
4754
|
+
var refreshingFunc;
|
|
4755
|
+
axiosInstance.interceptors.response.use(function (res) { return res; }, function (error) { return __awaiter(void 0, void 0, void 0, function () {
|
|
4756
|
+
var originalConfig, token, _a, newToken, newRefreshToken, innerError_1;
|
|
4757
|
+
return __generator(this, function (_b) {
|
|
4758
|
+
switch (_b.label) {
|
|
4759
|
+
case 0:
|
|
4760
|
+
originalConfig = error.config;
|
|
4761
|
+
if (originalConfig.headers.MESF_Retries === 1) {
|
|
4762
|
+
localStorage.removeItem("token");
|
|
4763
|
+
localStorage.removeItem("refreshToken");
|
|
4764
|
+
window.location.href = "".concat(base$2, "logout?message=Session%20expired&redirectTo=").concat(window.location.href);
|
|
4765
|
+
}
|
|
4766
|
+
token = getTokenFromLS();
|
|
4767
|
+
if (!token || !isUnauthorizedError(error)) {
|
|
4768
|
+
return [2 /*return*/, Promise.reject(error)];
|
|
4769
|
+
}
|
|
4770
|
+
_b.label = 1;
|
|
4771
|
+
case 1:
|
|
4772
|
+
_b.trys.push([1, 7, 8, 9]);
|
|
4773
|
+
// the trick here, that `refreshingFunc` is global, e.g. 2 expired requests will get the same function pointer and await same function.
|
|
4774
|
+
if (!refreshingFunc)
|
|
4775
|
+
refreshingFunc = renewToken();
|
|
4776
|
+
return [4 /*yield*/, refreshingFunc];
|
|
4777
|
+
case 2:
|
|
4778
|
+
_a = _b.sent(), newToken = _a[0], newRefreshToken = _a[1];
|
|
4779
|
+
localStorage.setItem("token", newToken);
|
|
4780
|
+
localStorage.setItem("refreshToken", newRefreshToken);
|
|
4781
|
+
axiosInstance.defaults.headers.Authorization = "Bearer ".concat(newToken);
|
|
4782
|
+
originalConfig.headers.Authorization = "Bearer ".concat(newToken);
|
|
4783
|
+
originalConfig.headers.MESF_Retries = 1;
|
|
4784
|
+
_b.label = 3;
|
|
4785
|
+
case 3:
|
|
4786
|
+
_b.trys.push([3, 5, , 6]);
|
|
4787
|
+
return [4 /*yield*/, axios.request(originalConfig)];
|
|
4788
|
+
case 4: return [2 /*return*/, _b.sent()];
|
|
4789
|
+
case 5:
|
|
4790
|
+
innerError_1 = _b.sent();
|
|
4791
|
+
// if original req failed with 401 again - it means server returned not valid token for refresh request
|
|
4792
|
+
if (isUnauthorizedError(innerError_1)) {
|
|
4793
|
+
return [2 /*return*/, innerError_1];
|
|
4794
|
+
}
|
|
4795
|
+
return [2 /*return*/, innerError_1];
|
|
4796
|
+
case 6: return [3 /*break*/, 9];
|
|
4797
|
+
case 7:
|
|
4798
|
+
_b.sent();
|
|
4799
|
+
localStorage.removeItem("token");
|
|
4800
|
+
localStorage.removeItem("refreshToken");
|
|
4801
|
+
window.location.href = "".concat(base$2, "logout?message=Session%20expired&redirectTo=").concat(window.location.href);
|
|
4802
|
+
return [3 /*break*/, 9];
|
|
4803
|
+
case 8:
|
|
4804
|
+
refreshingFunc = undefined;
|
|
4805
|
+
return [7 /*endfinally*/];
|
|
4806
|
+
case 9: return [2 /*return*/];
|
|
4807
|
+
}
|
|
4808
|
+
});
|
|
4809
|
+
}); }, {});
|
|
4810
|
+
|
|
4811
|
+
var base$1 = document.getElementsByTagName('base')[0].getAttribute('href') || '/';
|
|
4711
4812
|
var MESApiService = /** @class */ (function () {
|
|
4712
4813
|
function MESApiService() {
|
|
4713
4814
|
this.config = new Configuration$1();
|
|
@@ -4838,38 +4939,12 @@ var MESApiService = /** @class */ (function () {
|
|
|
4838
4939
|
};
|
|
4839
4940
|
MESApiService.prototype.loginWithWindowsAuthentication = function () {
|
|
4840
4941
|
return __awaiter(this, void 0, void 0, function () {
|
|
4841
|
-
var isError, data;
|
|
4842
|
-
var _this = this;
|
|
4843
4942
|
return __generator(this, function (_a) {
|
|
4844
|
-
this.
|
|
4845
|
-
|
|
4846
|
-
data = {};
|
|
4847
|
-
return [2 /*return*/, fetch(this.config.API_AUTH_URL + '/authenticate/windows', {
|
|
4848
|
-
method: "POST",
|
|
4849
|
-
mode: "cors",
|
|
4850
|
-
credentials: 'include',
|
|
4943
|
+
return [2 /*return*/, axiosInstance.post(this.config.API_AUTH_URL + '/authenticate/windows', {}, {
|
|
4944
|
+
withCredentials: true,
|
|
4851
4945
|
headers: {
|
|
4852
4946
|
"Content-Type": "application/json"
|
|
4853
|
-
}
|
|
4854
|
-
body: JSON.stringify(data)
|
|
4855
|
-
})["catch"](function (errorMsg) {
|
|
4856
|
-
throw new FetchError(errorMsg.message, 404, "ERR_CONNECTION_REFUSED");
|
|
4857
|
-
})
|
|
4858
|
-
.then(function (response) {
|
|
4859
|
-
isError = { ok: response.ok, status: response.status, statusText: response.statusText };
|
|
4860
|
-
return response.json();
|
|
4861
|
-
})
|
|
4862
|
-
.then(function (object) {
|
|
4863
|
-
if (!isError.ok)
|
|
4864
|
-
throw new FetchError(isError.statusText, isError.status, object);
|
|
4865
|
-
return object;
|
|
4866
|
-
})["catch"](function (err) {
|
|
4867
|
-
_this.hasErrors = true;
|
|
4868
|
-
_this.error = err;
|
|
4869
|
-
return {
|
|
4870
|
-
hasErrors: true,
|
|
4871
|
-
error: err
|
|
4872
|
-
};
|
|
4947
|
+
}
|
|
4873
4948
|
})];
|
|
4874
4949
|
});
|
|
4875
4950
|
});
|
|
@@ -4930,7 +5005,7 @@ var MESApiService = /** @class */ (function () {
|
|
|
4930
5005
|
})
|
|
4931
5006
|
.then(function (response) {
|
|
4932
5007
|
if (response.status === 401) {
|
|
4933
|
-
window.location.href = "".concat(base$
|
|
5008
|
+
window.location.href = "".concat(base$1, "logout?message=Session%20expired&redirectTo=").concat(window.location.href);
|
|
4934
5009
|
}
|
|
4935
5010
|
isError = { ok: response.ok, status: response.status, statusText: response.statusText };
|
|
4936
5011
|
return response.json();
|
|
@@ -4982,7 +5057,7 @@ var MESApiService = /** @class */ (function () {
|
|
|
4982
5057
|
})
|
|
4983
5058
|
.then(function (response) {
|
|
4984
5059
|
if (response.status === 401) {
|
|
4985
|
-
window.location.href = "".concat(base$
|
|
5060
|
+
window.location.href = "".concat(base$1, "logout?message=Session%20expired&redirectTo=").concat(window.location.href);
|
|
4986
5061
|
}
|
|
4987
5062
|
isError = { ok: response.ok, status: response.status, statusText: response.statusText };
|
|
4988
5063
|
return response.json();
|
|
@@ -5037,7 +5112,7 @@ var MESApiService = /** @class */ (function () {
|
|
|
5037
5112
|
})
|
|
5038
5113
|
.then(function (response) {
|
|
5039
5114
|
if (response.status === 401) {
|
|
5040
|
-
window.location.href = "".concat(base$
|
|
5115
|
+
window.location.href = "".concat(base$1, "logout?message=Session%20expired&redirectTo=").concat(window.location.href);
|
|
5041
5116
|
}
|
|
5042
5117
|
isError = { ok: response.ok, status: response.status, statusText: response.statusText };
|
|
5043
5118
|
return response.json();
|
|
@@ -5090,7 +5165,7 @@ var MESApiService = /** @class */ (function () {
|
|
|
5090
5165
|
})
|
|
5091
5166
|
.then(function (response) {
|
|
5092
5167
|
if (response.status === 401) {
|
|
5093
|
-
window.location.href = "".concat(base$
|
|
5168
|
+
window.location.href = "".concat(base$1, "logout?message=Session%20expired&redirectTo=").concat(window.location.href);
|
|
5094
5169
|
}
|
|
5095
5170
|
isError = { ok: response.ok, status: response.status, statusText: response.statusText };
|
|
5096
5171
|
if (!isError.ok)
|
|
@@ -5159,7 +5234,7 @@ var MESApiService = /** @class */ (function () {
|
|
|
5159
5234
|
})
|
|
5160
5235
|
.then(function (response) {
|
|
5161
5236
|
if (response.status === 401) {
|
|
5162
|
-
window.location.href = "".concat(base$
|
|
5237
|
+
window.location.href = "".concat(base$1, "logout?message=Session%20expired&redirectTo=").concat(window.location.href);
|
|
5163
5238
|
}
|
|
5164
5239
|
isError = { ok: response.ok, status: response.status, statusText: response.statusText };
|
|
5165
5240
|
if (!isError.ok)
|
|
@@ -5810,23 +5885,25 @@ var LoginWithWindowsAuthentication = function () {
|
|
|
5810
5885
|
});
|
|
5811
5886
|
}); };
|
|
5812
5887
|
var login = useCallback(function (e) { return __awaiter(void 0, void 0, void 0, function () {
|
|
5813
|
-
var apiService, response;
|
|
5888
|
+
var apiService, response, e_1;
|
|
5814
5889
|
return __generator(this, function (_a) {
|
|
5815
5890
|
switch (_a.label) {
|
|
5816
5891
|
case 0:
|
|
5817
5892
|
apiService = new MESApiService();
|
|
5818
5893
|
e.preventDefault();
|
|
5819
|
-
|
|
5894
|
+
_a.label = 1;
|
|
5820
5895
|
case 1:
|
|
5896
|
+
_a.trys.push([1, 3, , 4]);
|
|
5897
|
+
return [4 /*yield*/, apiService.loginWithWindowsAuthentication()];
|
|
5898
|
+
case 2:
|
|
5821
5899
|
response = _a.sent();
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
return [2 /*return*/];
|
|
5900
|
+
saveUserData(response.data);
|
|
5901
|
+
return [3 /*break*/, 4];
|
|
5902
|
+
case 3:
|
|
5903
|
+
e_1 = _a.sent();
|
|
5904
|
+
setError(e_1);
|
|
5905
|
+
return [3 /*break*/, 4];
|
|
5906
|
+
case 4: return [2 /*return*/];
|
|
5830
5907
|
}
|
|
5831
5908
|
});
|
|
5832
5909
|
}); }, [setShowError,
|
|
@@ -5834,7 +5911,6 @@ var LoginWithWindowsAuthentication = function () {
|
|
|
5834
5911
|
saveUserData]);
|
|
5835
5912
|
useEffect(function () {
|
|
5836
5913
|
checkIfEnabled().then(function () {
|
|
5837
|
-
console.log('done');
|
|
5838
5914
|
});
|
|
5839
5915
|
}, []);
|
|
5840
5916
|
if (windowsAuthIsEnabled)
|
|
@@ -5846,8 +5922,7 @@ var LoginWithWindowsAuthentication = function () {
|
|
|
5846
5922
|
React__default.createElement("strong", null, "Bad credentials"),
|
|
5847
5923
|
React__default.createElement("p", null,
|
|
5848
5924
|
" ",
|
|
5849
|
-
error
|
|
5850
|
-
(error.internalError.message === undefined ? error.internalError : error.internalError.message))),
|
|
5925
|
+
error)),
|
|
5851
5926
|
React__default.createElement("div", { className: "row" },
|
|
5852
5927
|
React__default.createElement("button", { className: "btn btn-primary mes-button-primary mx-auto col-md-12 mt-3 ", role: "button", onClick: login }, "Windows Auth"))));
|
|
5853
5928
|
return null;
|
|
@@ -6174,7 +6249,7 @@ var Navigation = function (_a) {
|
|
|
6174
6249
|
var css = "body {\n margin: 0;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',\n 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',\n sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n background-color: #fafbfc !important;\n}\n.container-fluid-main{\n padding-right: 0px !important; \n padding-left: 0px !important;\n}\n\ncode {\n font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',\n monospace;\n}\n\n.mes-primary-color {\n background-color: #479dc4 !important;\n}\n.mes-button-primary{\n background-color: #479dc4 !important;\n border-color: #479dc4 !important;\n}\n\n.mes-selectable-datagrid .MuiDataGrid-row{\n cursor: pointer;\n}\n\n.mes-menu-top .navbar-brand{\n color: #FFFF !important;\n}\n.mes-menu-top .nav-link {\n color: #FFFF !important;\n}\n.mes-menu-top .navbar-toggler {\n color: #FFFF !important;\n}\n.mes-menu-top .navbar-text {\n color: #FFFF !important;\n}\n.mes-footer-login{\n position: absolute;\n bottom: 0;\n width: 100%;\n height: 10em;\n line-height: 60px;\n text-align:center;\n}\n.mes-filter-datepicker{\n padding: unset !important;\n border-top-left-radius: 0 !important;\n border-bottom-left-radius: 0 !important;\n padding-top: 0.375rem !important;\n padding-bottom: 0.375rem !important;\n padding-left: 0.75rem !important;\n cursor: pointer !important;\n max-width: 120px;\n}\n.mes-filter-datetimepicker{\n max-width: 97px;\n}\n.mes-not-rounded{\n border-radius: unset !important;\n}\n\n.mes-numeric{\n text-align: right;\n}\n.mes-drag-over{\n border: 3px dotted #666;\n background-color: #479dc4 !important;\n}\n.mes-drag-start{\n border: 3px solid #666;\n}\n\n.mes-selectable{\n cursor: pointer !important;\n}\n\n.mes-custom-select{\n width: auto !important;\n padding: 0.375rem 0 0.375rem 0 !important;\n background: unset !important;\n font-family: inherit !important;\n}\n.mes-custom-select .MuiSelect-select{\n padding-left: 14px;\n}\n\n.mes-custom-select::before{\n border-bottom: unset !important;\n}\n.mes-custom-select::after{\n border-bottom: unset !important;\n}\n.mes-no-border{\n border: unset;\n}\n.mes-no-border:focus-visible {\n outline: unset;\n}\n.mes-div-submenu{\n border-right: 1px solid #cfdbe2; \n}\n.mes-submenu a{\n width: 100% !important;\n /* color: rgba(0, 0, 0, 0.87); */\n color: #479dc4\n}\n.mes-submenu .Mui-selected{\n border-right: 3px solid #479dc4; \n}\n.mes-menu-group{\n font-size: 20px;\n line-height: 1.1;\n color: #929292; \n font-weight: normal; \n}\n\n/********************MUI DATAGRID*****************************/\n.Mui-selected{\n font-weight: bolder !important;\n opacity: 1 !important;\n}\n\n.mes-upload-control{\n\n}\n.mes-upload-control .file-box{\n /* border : 1px solid black; */\n height : 100px;\n position: relative; \n}\n.mes-upload-control .file-detail{\n position: absolute;\n left: 0px;\n top: 0px; \n z-index: 1;\n height: 100%;\n width: 100%;\n}\n\n.mes-upload-control input[type=file]{\n left: 0px;\n top: 0px;\n opacity: 0;\n z-index: 10000;\n height: 100%;\n cursor: pointer;\n}\n.mes-upload-control table{\n width: 100%;\n}\n.mes-upload-control td{\n font-size: 0.8rem !important;\n max-width:0;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;\n}\n\n\n.input-group-text{\n background-color: #ced2cc !important;\n /* border: 1px solid #ced4da !important; */\n /* color: #000000 !important; */\n}\n\n\n\n\n.content-wrapper {\n padding: 15px;\n width: 100%;\n border-top: 1px solid rgba(0, 0, 0, 0.15);\n margin-top: -1px;\n}\n.content-wrapper > .unwrap {\n margin: -15px;\n}\n@media only screen and (min-width: 768px) {\n .content-wrapper > .unwrap {\n margin: -20px;\n }\n}\n.content-wrapper > h3,\n.content-wrapper > .content-heading {\n font-size: 24px;\n line-height: 1.1;\n color: #929292;\n margin: -15px;\n margin-bottom: 20px;\n padding: 15px;\n font-weight: normal;\n background-color: #fafbfc;\n border-bottom: 1px solid #cfdbe2;\n}\n.content-wrapper > h3 > small,\n.content-wrapper > .content-heading > small {\n display: block;\n font-size: 12px;\n color: #909fa7;\n}\n.content-wrapper > button,\n.content-wrapper > .btn {\n margin: 10px 10px 0 0;\n}\n.content-wrapper .container,\n.content-wrapper .container-fluid {\n padding-left: 0;\n padding-right: 0;\n}\n@media only screen and (min-width: 768px) {\n .content-wrapper {\n padding: 20px;\n }\n .content-wrapper > h3,\n .content-wrapper > .content-heading {\n margin: -20px;\n margin-bottom: 5px;\n padding: 15px;\n }\n .content-wrapper > button,\n .content-wrapper > .btn {\n margin: 0;\n }\n}\n\n @media print {\n .sidebar,\n .topnavbar,\n .offsidebar,\n .btn {\n display: none !important;\n width: 0 !important;\n height: 0 !important;\n }\n .wrapper,\n .wrapper > section,\n .content-wrapper {\n margin: 0 !important;\n /* remove margin used for sidebar and expand the content */\n padding: 0 !important;\n width: 100% !important;\n }\n .content-wrapper {\n overflow: hidden !important;\n }\n }\n ";
|
|
6175
6250
|
n(css,{});
|
|
6176
6251
|
|
|
6177
|
-
var base
|
|
6252
|
+
var base = document.getElementsByTagName('base')[0].getAttribute('href') || '/';
|
|
6178
6253
|
function MESFMain(_a) {
|
|
6179
6254
|
var authentication = _a.authentication, routes = _a.routes, navbar = _a.navbar, configurations = _a.configurations, _b = _a.showAreaSelector, showAreaSelector = _b === void 0 ? false : _b;
|
|
6180
6255
|
return (React__default.createElement(AuthProvider, { authConfig: authentication },
|
|
@@ -6184,113 +6259,12 @@ function MESFMain(_a) {
|
|
|
6184
6259
|
React__default.createElement(RouterContext.Provider, { value: routes },
|
|
6185
6260
|
React__default.createElement(NavbarContext.Provider, { value: navbar },
|
|
6186
6261
|
React__default.createElement(ConfigurationContext.Provider, { value: configurations },
|
|
6187
|
-
React__default.createElement(BrowserRouter, { basename: base
|
|
6262
|
+
React__default.createElement(BrowserRouter, { basename: base },
|
|
6188
6263
|
React__default.createElement(Routes, null,
|
|
6189
6264
|
React__default.createElement(Route, { path: "/logout", element: React__default.createElement(Logout, null) })),
|
|
6190
6265
|
React__default.createElement(Navigation, { showAreaSelector: showAreaSelector }))))))))));
|
|
6191
6266
|
}
|
|
6192
6267
|
|
|
6193
|
-
var base = document.getElementsByTagName('base')[0].getAttribute('href') || '/';
|
|
6194
|
-
function renewToken() {
|
|
6195
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
6196
|
-
var refreshToken, config, fd, response, token;
|
|
6197
|
-
return __generator(this, function (_a) {
|
|
6198
|
-
switch (_a.label) {
|
|
6199
|
-
case 0:
|
|
6200
|
-
refreshToken = localStorage.getItem("refreshToken");
|
|
6201
|
-
if (!refreshToken) {
|
|
6202
|
-
throw new Error('refresh token does not exist');
|
|
6203
|
-
}
|
|
6204
|
-
config = new Configuration$1();
|
|
6205
|
-
fd = new FormData();
|
|
6206
|
-
fd.append('refreshToken', refreshToken);
|
|
6207
|
-
return [4 /*yield*/, axios.post("".concat(config.API_AUTH_URL, "/refresh"), fd, {
|
|
6208
|
-
headers: {
|
|
6209
|
-
"Content-Type": 'application/json'
|
|
6210
|
-
},
|
|
6211
|
-
params: {
|
|
6212
|
-
refreshToken: refreshToken
|
|
6213
|
-
}
|
|
6214
|
-
})];
|
|
6215
|
-
case 1:
|
|
6216
|
-
response = _a.sent();
|
|
6217
|
-
token = response.data.result;
|
|
6218
|
-
if (token) {
|
|
6219
|
-
return [2 /*return*/, [token, refreshToken]];
|
|
6220
|
-
}
|
|
6221
|
-
else {
|
|
6222
|
-
throw new Error("Token is not valid");
|
|
6223
|
-
}
|
|
6224
|
-
}
|
|
6225
|
-
});
|
|
6226
|
-
});
|
|
6227
|
-
}
|
|
6228
|
-
function isUnauthorizedError(error) {
|
|
6229
|
-
var _a = error.response, status = _a.status; _a.statusText;
|
|
6230
|
-
return status === 401;
|
|
6231
|
-
}
|
|
6232
|
-
var axiosInstance = axios.create({
|
|
6233
|
-
headers: {
|
|
6234
|
-
Authorization: "Bearer ".concat(getTokenFromLS())
|
|
6235
|
-
}
|
|
6236
|
-
});
|
|
6237
|
-
var refreshingFunc;
|
|
6238
|
-
axiosInstance.interceptors.response.use(function (res) { return res; }, function (error) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6239
|
-
var originalConfig, token, _a, newToken, newRefreshToken, innerError_1;
|
|
6240
|
-
return __generator(this, function (_b) {
|
|
6241
|
-
switch (_b.label) {
|
|
6242
|
-
case 0:
|
|
6243
|
-
originalConfig = error.config;
|
|
6244
|
-
if (originalConfig.headers.MESF_Retries === 1) {
|
|
6245
|
-
localStorage.removeItem("token");
|
|
6246
|
-
localStorage.removeItem("refreshToken");
|
|
6247
|
-
window.location.href = "".concat(base, "logout?message=Session%20expired&redirectTo=").concat(window.location.href);
|
|
6248
|
-
}
|
|
6249
|
-
token = getTokenFromLS();
|
|
6250
|
-
if (!token || !isUnauthorizedError(error)) {
|
|
6251
|
-
return [2 /*return*/, Promise.reject(error)];
|
|
6252
|
-
}
|
|
6253
|
-
_b.label = 1;
|
|
6254
|
-
case 1:
|
|
6255
|
-
_b.trys.push([1, 7, 8, 9]);
|
|
6256
|
-
// the trick here, that `refreshingFunc` is global, e.g. 2 expired requests will get the same function pointer and await same function.
|
|
6257
|
-
if (!refreshingFunc)
|
|
6258
|
-
refreshingFunc = renewToken();
|
|
6259
|
-
return [4 /*yield*/, refreshingFunc];
|
|
6260
|
-
case 2:
|
|
6261
|
-
_a = _b.sent(), newToken = _a[0], newRefreshToken = _a[1];
|
|
6262
|
-
localStorage.setItem("token", newToken);
|
|
6263
|
-
localStorage.setItem("refreshToken", newRefreshToken);
|
|
6264
|
-
axiosInstance.defaults.headers.Authorization = "Bearer ".concat(newToken);
|
|
6265
|
-
originalConfig.headers.Authorization = "Bearer ".concat(newToken);
|
|
6266
|
-
originalConfig.headers.MESF_Retries = 1;
|
|
6267
|
-
_b.label = 3;
|
|
6268
|
-
case 3:
|
|
6269
|
-
_b.trys.push([3, 5, , 6]);
|
|
6270
|
-
return [4 /*yield*/, axios.request(originalConfig)];
|
|
6271
|
-
case 4: return [2 /*return*/, _b.sent()];
|
|
6272
|
-
case 5:
|
|
6273
|
-
innerError_1 = _b.sent();
|
|
6274
|
-
// if original req failed with 401 again - it means server returned not valid token for refresh request
|
|
6275
|
-
if (isUnauthorizedError(innerError_1)) {
|
|
6276
|
-
return [2 /*return*/, innerError_1];
|
|
6277
|
-
}
|
|
6278
|
-
return [2 /*return*/, innerError_1];
|
|
6279
|
-
case 6: return [3 /*break*/, 9];
|
|
6280
|
-
case 7:
|
|
6281
|
-
_b.sent();
|
|
6282
|
-
localStorage.removeItem("token");
|
|
6283
|
-
localStorage.removeItem("refreshToken");
|
|
6284
|
-
window.location.href = "".concat(base, "logout?message=Session%20expired&redirectTo=").concat(window.location.href);
|
|
6285
|
-
return [3 /*break*/, 9];
|
|
6286
|
-
case 8:
|
|
6287
|
-
refreshingFunc = undefined;
|
|
6288
|
-
return [7 /*endfinally*/];
|
|
6289
|
-
case 9: return [2 /*return*/];
|
|
6290
|
-
}
|
|
6291
|
-
});
|
|
6292
|
-
}); }, {});
|
|
6293
|
-
|
|
6294
6268
|
var useDefaultAreaId = function () {
|
|
6295
6269
|
var _a = useUserContext(), userId = _a.state.userId, setDefaultAreaId = _a.actions.setDefaultAreaId;
|
|
6296
6270
|
return function () {
|
|
@@ -28,7 +28,7 @@ export declare class MESApiService {
|
|
|
28
28
|
changePassword(userId: string, password: string): Promise<any>;
|
|
29
29
|
authenticate(userName: string, password: string): Promise<any>;
|
|
30
30
|
loginWithAzureAD(accessToken: string): Promise<any>;
|
|
31
|
-
loginWithWindowsAuthentication(): Promise<any
|
|
31
|
+
loginWithWindowsAuthentication(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
32
32
|
uploadFiles(selectedFiles: File[], folderName?: string): Promise<any>;
|
|
33
33
|
call(procedure: string, parameters: any[], database?: string): Promise<any>;
|
|
34
34
|
callJSON(procedure: string, parameters: any[], database?: string): Promise<any>;
|