@iankibetsh/shframework 4.5.3 → 4.5.5
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/dist/library.mjs.css +43 -43
- package/dist/library.js +99 -41
- package/dist/library.mjs +98 -41
- package/package.json +1 -1
|
@@ -1,4 +1,36 @@
|
|
|
1
1
|
|
|
2
|
+
.sh-phone{
|
|
3
|
+
display: flex;
|
|
4
|
+
width: 100%;
|
|
5
|
+
align-items: center;
|
|
6
|
+
padding: 0 0.25rem;
|
|
7
|
+
}
|
|
8
|
+
.phone-country{
|
|
9
|
+
width: 2rem;
|
|
10
|
+
border: none;
|
|
11
|
+
align-self: center;
|
|
12
|
+
outline: none !important;
|
|
13
|
+
padding: 0.4rem;
|
|
14
|
+
border-right: 1px solid #0003;
|
|
15
|
+
}
|
|
16
|
+
.phone-number{
|
|
17
|
+
width: calc(100% - 2.2rem);
|
|
18
|
+
border: none;
|
|
19
|
+
align-self: center;
|
|
20
|
+
outline: none;
|
|
21
|
+
margin-bottom: 0;
|
|
22
|
+
padding: 0.4rem;
|
|
23
|
+
}
|
|
24
|
+
.sh-phone img{
|
|
25
|
+
padding: 0.125rem;
|
|
26
|
+
width: 2rem;
|
|
27
|
+
height: 2rem;
|
|
28
|
+
}
|
|
29
|
+
.phone-number::placeholder{
|
|
30
|
+
font-weight: 300;
|
|
31
|
+
opacity: 0.5;
|
|
32
|
+
}
|
|
33
|
+
|
|
2
34
|
.colored-toast.swal2-icon-success {
|
|
3
35
|
background-color: #a5dc86 !important;
|
|
4
36
|
}
|
|
@@ -31,36 +63,20 @@
|
|
|
31
63
|
color: white;
|
|
32
64
|
}
|
|
33
65
|
|
|
34
|
-
.sh-
|
|
35
|
-
|
|
36
|
-
width: 100%;
|
|
37
|
-
align-items: center;
|
|
38
|
-
padding: 0 0.25rem;
|
|
39
|
-
}
|
|
40
|
-
.phone-country{
|
|
41
|
-
width: 2rem;
|
|
42
|
-
border: none;
|
|
43
|
-
align-self: center;
|
|
44
|
-
outline: none !important;
|
|
45
|
-
padding: 0.4rem;
|
|
46
|
-
border-right: 1px solid #0003;
|
|
66
|
+
.sh-selected-item{
|
|
67
|
+
line-height: unset!important;
|
|
47
68
|
}
|
|
48
|
-
.
|
|
49
|
-
|
|
50
|
-
border: none;
|
|
51
|
-
align-self: center;
|
|
52
|
-
outline: none;
|
|
53
|
-
margin-bottom: 0;
|
|
54
|
-
padding: 0.4rem;
|
|
69
|
+
.sh-suggestion-input{
|
|
70
|
+
padding: 0.375rem 0.75rem;
|
|
55
71
|
}
|
|
56
|
-
.sh-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
height: 2rem;
|
|
72
|
+
.sh-suggest{
|
|
73
|
+
margin-bottom: 1rem;
|
|
74
|
+
padding: 0rem 0rem;
|
|
60
75
|
}
|
|
61
|
-
.
|
|
62
|
-
|
|
63
|
-
|
|
76
|
+
.sh-suggest-control::after{
|
|
77
|
+
margin-top: auto;
|
|
78
|
+
margin-bottom: auto;
|
|
79
|
+
margin-right: 0.255em;
|
|
64
80
|
}
|
|
65
81
|
|
|
66
82
|
.permissions-main {
|
|
@@ -95,22 +111,6 @@
|
|
|
95
111
|
flex-grow: 1;
|
|
96
112
|
}
|
|
97
113
|
|
|
98
|
-
.sh-selected-item{
|
|
99
|
-
line-height: unset!important;
|
|
100
|
-
}
|
|
101
|
-
.sh-suggestion-input{
|
|
102
|
-
padding: 0.375rem 0.75rem;
|
|
103
|
-
}
|
|
104
|
-
.sh-suggest{
|
|
105
|
-
margin-bottom: 1rem;
|
|
106
|
-
padding: 0rem 0rem;
|
|
107
|
-
}
|
|
108
|
-
.sh-suggest-control::after{
|
|
109
|
-
margin-top: auto;
|
|
110
|
-
margin-bottom: auto;
|
|
111
|
-
margin-right: 0.255em;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
114
|
.callout{
|
|
115
115
|
--bs-link-color-rgb: 110,168,254;
|
|
116
116
|
--bs-code-color: #e685b5;
|
package/dist/library.js
CHANGED
|
@@ -38,7 +38,7 @@ function getItem (key) {
|
|
|
38
38
|
function removeItem (key) {
|
|
39
39
|
return localStorage.removeItem(key)
|
|
40
40
|
}
|
|
41
|
-
var
|
|
41
|
+
var shStorage = {
|
|
42
42
|
setItem,
|
|
43
43
|
getItem,
|
|
44
44
|
removeItem
|
|
@@ -144,21 +144,21 @@ const signOutUser = () => {
|
|
|
144
144
|
const logoutApiEndPoint = getShConfig('logoutApiEndpoint', 'auth/logout');
|
|
145
145
|
console.log(loginUrl, logoutApiEndPoint);
|
|
146
146
|
shApis.doPost(logoutApiEndPoint).then(res => {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
147
|
+
shStorage.removeItem('access_token');
|
|
148
|
+
shStorage.removeItem('user');
|
|
149
|
+
shStorage.removeItem('last_activity');
|
|
150
150
|
window.location.href = loginUrl;
|
|
151
151
|
}).catch(ex => {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
152
|
+
shStorage.removeItem('access_token');
|
|
153
|
+
shStorage.removeItem('user');
|
|
154
|
+
shStorage.removeItem('last_activity');
|
|
155
155
|
window.location.href = loginUrl;
|
|
156
156
|
});
|
|
157
157
|
};
|
|
158
158
|
|
|
159
159
|
|
|
160
160
|
function getShConfig(key = null, def = ''){
|
|
161
|
-
const config =
|
|
161
|
+
const config = shStorage.getItem('ShConfig') ?? {};
|
|
162
162
|
if (key) {
|
|
163
163
|
return config[key] ?? def
|
|
164
164
|
}
|
|
@@ -296,17 +296,17 @@ function logoutUser(){
|
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
298
|
function sessionRestored(){
|
|
299
|
-
const timeout =
|
|
300
|
-
const last_activity =
|
|
299
|
+
const timeout = shStorage.getItem('sessionTimeout') * 60;
|
|
300
|
+
const last_activity = shStorage.getItem('last_activity');
|
|
301
301
|
const pastSeconds = moment__default["default"]().diff(last_activity, 'seconds');
|
|
302
|
-
if(!
|
|
302
|
+
if(!shStorage.getItem('access_token'))
|
|
303
303
|
return false
|
|
304
304
|
return pastSeconds < timeout
|
|
305
305
|
}
|
|
306
306
|
const checkSession = function (isCheking) {
|
|
307
|
-
const timeout =
|
|
308
|
-
const last_activity =
|
|
309
|
-
if (
|
|
307
|
+
const timeout = shStorage.getItem('sessionTimeout');
|
|
308
|
+
const last_activity = shStorage.getItem('last_activity');
|
|
309
|
+
if (shStorage.getItem('access_token')) {
|
|
310
310
|
const pastMinutes = moment__default["default"]().diff(last_activity, 'minutes');
|
|
311
311
|
const pastSeconds = moment__default["default"]().diff(last_activity, 'seconds');
|
|
312
312
|
if(pastMinutes >= timeout) {
|
|
@@ -364,17 +364,17 @@ async function shSwalLogout (seconds = 30) {
|
|
|
364
364
|
window.ShConfirmation = null;
|
|
365
365
|
clearInterval(window.shInterval);
|
|
366
366
|
const timeNow = moment__default["default"]().toISOString();
|
|
367
|
-
|
|
367
|
+
shStorage.setItem('last_activity', timeNow);
|
|
368
368
|
startSession();
|
|
369
369
|
}
|
|
370
370
|
})
|
|
371
371
|
}
|
|
372
372
|
function startSession () {
|
|
373
373
|
const timeNow = moment__default["default"]().toISOString();
|
|
374
|
-
const accessToken =
|
|
374
|
+
const accessToken = shStorage.getItem('access_token');
|
|
375
375
|
if (accessToken) {
|
|
376
|
-
|
|
377
|
-
const timout =
|
|
376
|
+
shStorage.setItem('last_activity', timeNow);
|
|
377
|
+
const timout = shStorage.getItem('sessionTimeout');
|
|
378
378
|
const interval = (timout * 60 *1000) / 3;
|
|
379
379
|
window.shInterval = setInterval(()=>{
|
|
380
380
|
checkSession();
|
|
@@ -386,7 +386,7 @@ const updateSession = () =>{
|
|
|
386
386
|
startSession();
|
|
387
387
|
}
|
|
388
388
|
const timeNow = moment__default["default"]().toISOString();
|
|
389
|
-
|
|
389
|
+
shStorage.setItem('last_activity', timeNow);
|
|
390
390
|
};
|
|
391
391
|
|
|
392
392
|
const graphQlEndpoint = 'sh-ql';
|
|
@@ -407,7 +407,7 @@ function doGet (endPoint, data,extraConfig) {
|
|
|
407
407
|
updateSession();
|
|
408
408
|
let config = {
|
|
409
409
|
headers: {
|
|
410
|
-
Authorization: 'Bearer ' +
|
|
410
|
+
Authorization: 'Bearer ' + shStorage.getItem('access_token')
|
|
411
411
|
}
|
|
412
412
|
};
|
|
413
413
|
if (extraConfig) {
|
|
@@ -423,7 +423,7 @@ function doPost (endPoint, data, extraConfig) {
|
|
|
423
423
|
updateSession();
|
|
424
424
|
const config = {
|
|
425
425
|
headers: {
|
|
426
|
-
Authorization: 'Bearer ' +
|
|
426
|
+
Authorization: 'Bearer ' + shStorage.getItem('access_token')
|
|
427
427
|
}
|
|
428
428
|
};
|
|
429
429
|
if (extraConfig) {
|
|
@@ -438,7 +438,7 @@ function doDelete (endPoint, data, extraConfig) {
|
|
|
438
438
|
updateSession();
|
|
439
439
|
const config = {
|
|
440
440
|
headers: {
|
|
441
|
-
Authorization: 'Bearer ' +
|
|
441
|
+
Authorization: 'Bearer ' + shStorage.getItem('access_token')
|
|
442
442
|
}
|
|
443
443
|
};
|
|
444
444
|
if (extraConfig) {
|
|
@@ -453,7 +453,7 @@ function doPut (endPoint, data, extraConfig) {
|
|
|
453
453
|
updateSession();
|
|
454
454
|
const config = {
|
|
455
455
|
headers: {
|
|
456
|
-
Authorization: 'Bearer ' +
|
|
456
|
+
Authorization: 'Bearer ' + shStorage.getItem('access_token')
|
|
457
457
|
}
|
|
458
458
|
};
|
|
459
459
|
if (extraConfig) {
|
|
@@ -469,7 +469,7 @@ function doPatch (endPoint, data, extraConfig) {
|
|
|
469
469
|
updateSession();
|
|
470
470
|
const config = {
|
|
471
471
|
headers: {
|
|
472
|
-
Authorization: 'Bearer ' +
|
|
472
|
+
Authorization: 'Bearer ' + shStorage.getItem('access_token')
|
|
473
473
|
}
|
|
474
474
|
};
|
|
475
475
|
if (extraConfig) {
|
|
@@ -4054,7 +4054,7 @@ const useUserStore = pinia.defineStore('user-store', {
|
|
|
4054
4054
|
setUser (){
|
|
4055
4055
|
let user = null;
|
|
4056
4056
|
try {
|
|
4057
|
-
user =
|
|
4057
|
+
user = shStorage.getItem('user') ? shStorage.getItem('user') : null;
|
|
4058
4058
|
} catch (error) {
|
|
4059
4059
|
user= null;
|
|
4060
4060
|
}
|
|
@@ -4078,7 +4078,7 @@ const useUserStore = pinia.defineStore('user-store', {
|
|
|
4078
4078
|
if (typeof(user) === 'undefined') {
|
|
4079
4079
|
user = res.data;
|
|
4080
4080
|
}
|
|
4081
|
-
|
|
4081
|
+
shStorage.setItem('user',user);
|
|
4082
4082
|
user.signOut = this.signOut;
|
|
4083
4083
|
user.logout = this.signOut;
|
|
4084
4084
|
user.logOut = this.signOut;
|
|
@@ -4101,7 +4101,7 @@ const useUserStore = pinia.defineStore('user-store', {
|
|
|
4101
4101
|
}).catch((reason) => {
|
|
4102
4102
|
if (reason.response && reason.response.status) {
|
|
4103
4103
|
if(reason.response.status === 401) {
|
|
4104
|
-
|
|
4104
|
+
shStorage.setItem('user',null);
|
|
4105
4105
|
this.user = null;
|
|
4106
4106
|
}
|
|
4107
4107
|
this.loggedOut = true;
|
|
@@ -4115,7 +4115,7 @@ const useUserStore = pinia.defineStore('user-store', {
|
|
|
4115
4115
|
}
|
|
4116
4116
|
}
|
|
4117
4117
|
const timeNow = moment__default["default"]().toISOString();
|
|
4118
|
-
|
|
4118
|
+
shStorage.setItem('session_start',timeNow);
|
|
4119
4119
|
},
|
|
4120
4120
|
signOut () {
|
|
4121
4121
|
shRepo.signOutUser();
|
|
@@ -4127,7 +4127,7 @@ const useUserStore = pinia.defineStore('user-store', {
|
|
|
4127
4127
|
this.setUser();
|
|
4128
4128
|
},
|
|
4129
4129
|
setAccessToken (accessToken) {
|
|
4130
|
-
|
|
4130
|
+
shStorage.setItem('access_token', accessToken);
|
|
4131
4131
|
this.setUser();
|
|
4132
4132
|
}
|
|
4133
4133
|
},
|
|
@@ -5097,7 +5097,7 @@ const __default__ = {
|
|
|
5097
5097
|
},
|
|
5098
5098
|
setCachedData: function (){
|
|
5099
5099
|
if (this.cacheKey) {
|
|
5100
|
-
this.records =
|
|
5100
|
+
this.records = shStorage.getItem('sh_table_cache_' + this.cacheKey, null);
|
|
5101
5101
|
}
|
|
5102
5102
|
},
|
|
5103
5103
|
reloadData: function (page, append){
|
|
@@ -5136,7 +5136,7 @@ const __default__ = {
|
|
|
5136
5136
|
const response = req.data.data;
|
|
5137
5137
|
this.$emit('dataLoaded', response);
|
|
5138
5138
|
if (this.page < 2 && this.cacheKey) {
|
|
5139
|
-
|
|
5139
|
+
shStorage.setItem('sh_table_cache_' + this.cacheKey, response.data);
|
|
5140
5140
|
}
|
|
5141
5141
|
this.pagination_data = {
|
|
5142
5142
|
current: response.current_page,
|
|
@@ -5805,11 +5805,6 @@ const setCounts = (res) => {
|
|
|
5805
5805
|
}
|
|
5806
5806
|
});
|
|
5807
5807
|
};
|
|
5808
|
-
const activetab = (tab) => {
|
|
5809
|
-
if (props.activeTab) {
|
|
5810
|
-
return props.activeTab === tab ? 'active' : 'active'
|
|
5811
|
-
}
|
|
5812
|
-
};
|
|
5813
5808
|
|
|
5814
5809
|
return (_ctx, _cache) => {
|
|
5815
5810
|
const _component_router_link = vue.resolveComponent("router-link");
|
|
@@ -5826,7 +5821,7 @@ return (_ctx, _cache) => {
|
|
|
5826
5821
|
}, [
|
|
5827
5822
|
vue.createVNode(_component_router_link, {
|
|
5828
5823
|
onClick: $event => (setTab(tab)),
|
|
5829
|
-
"active-class":
|
|
5824
|
+
"active-class": 'active',
|
|
5830
5825
|
class: vue.normalizeClass(["nav-link text-capitalize", 'sh_tab_' + tab]),
|
|
5831
5826
|
to: __props.baseUrl+'/tab/'+tab,
|
|
5832
5827
|
role: "tab"
|
|
@@ -5835,7 +5830,7 @@ return (_ctx, _cache) => {
|
|
|
5835
5830
|
vue.createTextVNode(vue.toDisplayString(tab.replace(/_/g, ' ')), 1 /* TEXT */)
|
|
5836
5831
|
]),
|
|
5837
5832
|
_: 2 /* DYNAMIC */
|
|
5838
|
-
}, 1032 /* PROPS, DYNAMIC_SLOTS */, ["onClick", "
|
|
5833
|
+
}, 1032 /* PROPS, DYNAMIC_SLOTS */, ["onClick", "to", "class"])
|
|
5839
5834
|
]))
|
|
5840
5835
|
}), 128 /* KEYED_FRAGMENT */))
|
|
5841
5836
|
], 2 /* CLASS */),
|
|
@@ -7144,7 +7139,7 @@ const ShFrontend = {
|
|
|
7144
7139
|
install: (app, options) => {
|
|
7145
7140
|
if(options.sessionTimeout){
|
|
7146
7141
|
app.provide('sessionTimeout',options.sessionTimeout);
|
|
7147
|
-
|
|
7142
|
+
shStorage.setItem('sessionTimeout',options.sessionTimeout);
|
|
7148
7143
|
}
|
|
7149
7144
|
const shFormElements = options.shFormElementClasses ?? {};
|
|
7150
7145
|
|
|
@@ -7212,7 +7207,7 @@ const ShFrontend = {
|
|
|
7212
7207
|
const allowKeys = [];
|
|
7213
7208
|
Object.keys(options).map(key=> ((!['string','integer','number'].includes(typeof options[key]) && !allowKeys.includes(key)) || removeKeys.includes(key)) && delete options[key]);
|
|
7214
7209
|
|
|
7215
|
-
|
|
7210
|
+
shStorage.setItem('ShConfig',options);
|
|
7216
7211
|
}
|
|
7217
7212
|
};
|
|
7218
7213
|
|
|
@@ -7229,6 +7224,68 @@ var shGql = {
|
|
|
7229
7224
|
mutate
|
|
7230
7225
|
};
|
|
7231
7226
|
|
|
7227
|
+
/**
|
|
7228
|
+
* useShFetch is a custom hook for fetching data from a given URL and caching it.
|
|
7229
|
+
* @param {string} url - The URL to fetch data from.
|
|
7230
|
+
* @param {string} path - The path to drill down to the data in the response.
|
|
7231
|
+
* @param {string} cacheKey - The key to use when caching the data.
|
|
7232
|
+
* @returns {object} An object containing the status, loading state, error, data, and a function to refetch the data.
|
|
7233
|
+
*/
|
|
7234
|
+
const useShFetch = (url, path, cacheKey) => {
|
|
7235
|
+
const status = vue.ref('pending');
|
|
7236
|
+
const loading = vue.ref(false);
|
|
7237
|
+
const error = vue.ref(null);
|
|
7238
|
+
const data = vue.ref(null);
|
|
7239
|
+
|
|
7240
|
+
vue.onMounted(() => {
|
|
7241
|
+
reFetchData();
|
|
7242
|
+
});
|
|
7243
|
+
|
|
7244
|
+
/**
|
|
7245
|
+
* Fetches data from the given URL and updates the status, loading state, error, and data refs.
|
|
7246
|
+
* If a cacheKey is provided and there is cached data for that key, the cached data is used instead of fetching.
|
|
7247
|
+
*/
|
|
7248
|
+
const reFetchData = () => {
|
|
7249
|
+
loading.value = true;
|
|
7250
|
+
status.value = 'loading';
|
|
7251
|
+
if (cacheKey && shStorage.getItem(cacheKey)) {
|
|
7252
|
+
data.value = shStorage.getItem(cacheKey);
|
|
7253
|
+
status.value = 'success';
|
|
7254
|
+
loading.value = false;
|
|
7255
|
+
} else {
|
|
7256
|
+
shApis.doGet(url).then(response => {
|
|
7257
|
+
status.value = 'success';
|
|
7258
|
+
let res = response.data;
|
|
7259
|
+
if (path) {
|
|
7260
|
+
let pathArr = path.split('.');
|
|
7261
|
+
for (let i = 0; i < pathArr.length; i++) {
|
|
7262
|
+
res = res[pathArr[i]];
|
|
7263
|
+
}
|
|
7264
|
+
}
|
|
7265
|
+
data.value = res;
|
|
7266
|
+
if (cacheKey) {
|
|
7267
|
+
shStorage.setItem(cacheKey, res);
|
|
7268
|
+
}
|
|
7269
|
+
})
|
|
7270
|
+
.catch(res => {
|
|
7271
|
+
status.value = 'error';
|
|
7272
|
+
error.value = res.message ? res.message : (res.error ? res.error : 'An unexpected error occurred');
|
|
7273
|
+
})
|
|
7274
|
+
.finally(() => {
|
|
7275
|
+
loading.value = false;
|
|
7276
|
+
});
|
|
7277
|
+
}
|
|
7278
|
+
};
|
|
7279
|
+
|
|
7280
|
+
return {
|
|
7281
|
+
status,
|
|
7282
|
+
loading,
|
|
7283
|
+
error,
|
|
7284
|
+
data,
|
|
7285
|
+
reFetchData
|
|
7286
|
+
}
|
|
7287
|
+
};
|
|
7288
|
+
|
|
7232
7289
|
exports.Countries = countries;
|
|
7233
7290
|
exports.ManagePermissions = script$8;
|
|
7234
7291
|
exports.ShAutoForm = script$o;
|
|
@@ -7255,6 +7312,7 @@ exports.ShTabs = script$c;
|
|
|
7255
7312
|
exports.shApis = shApis;
|
|
7256
7313
|
exports.shGql = shGql;
|
|
7257
7314
|
exports.shRepo = shRepo;
|
|
7258
|
-
exports.shStorage =
|
|
7315
|
+
exports.shStorage = shStorage;
|
|
7259
7316
|
exports.useAppStore = useAppStore;
|
|
7317
|
+
exports.useShFetch = useShFetch;
|
|
7260
7318
|
exports.useUserStore = useUserStore;
|
package/dist/library.mjs
CHANGED
|
@@ -26,7 +26,7 @@ function getItem (key) {
|
|
|
26
26
|
function removeItem (key) {
|
|
27
27
|
return localStorage.removeItem(key)
|
|
28
28
|
}
|
|
29
|
-
var
|
|
29
|
+
var shStorage = {
|
|
30
30
|
setItem,
|
|
31
31
|
getItem,
|
|
32
32
|
removeItem
|
|
@@ -132,21 +132,21 @@ const signOutUser = () => {
|
|
|
132
132
|
const logoutApiEndPoint = getShConfig('logoutApiEndpoint', 'auth/logout');
|
|
133
133
|
console.log(loginUrl, logoutApiEndPoint);
|
|
134
134
|
shApis.doPost(logoutApiEndPoint).then(res => {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
shStorage.removeItem('access_token');
|
|
136
|
+
shStorage.removeItem('user');
|
|
137
|
+
shStorage.removeItem('last_activity');
|
|
138
138
|
window.location.href = loginUrl;
|
|
139
139
|
}).catch(ex => {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
140
|
+
shStorage.removeItem('access_token');
|
|
141
|
+
shStorage.removeItem('user');
|
|
142
|
+
shStorage.removeItem('last_activity');
|
|
143
143
|
window.location.href = loginUrl;
|
|
144
144
|
});
|
|
145
145
|
};
|
|
146
146
|
|
|
147
147
|
|
|
148
148
|
function getShConfig(key = null, def = ''){
|
|
149
|
-
const config =
|
|
149
|
+
const config = shStorage.getItem('ShConfig') ?? {};
|
|
150
150
|
if (key) {
|
|
151
151
|
return config[key] ?? def
|
|
152
152
|
}
|
|
@@ -284,17 +284,17 @@ function logoutUser(){
|
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
286
|
function sessionRestored(){
|
|
287
|
-
const timeout =
|
|
288
|
-
const last_activity =
|
|
287
|
+
const timeout = shStorage.getItem('sessionTimeout') * 60;
|
|
288
|
+
const last_activity = shStorage.getItem('last_activity');
|
|
289
289
|
const pastSeconds = moment().diff(last_activity, 'seconds');
|
|
290
|
-
if(!
|
|
290
|
+
if(!shStorage.getItem('access_token'))
|
|
291
291
|
return false
|
|
292
292
|
return pastSeconds < timeout
|
|
293
293
|
}
|
|
294
294
|
const checkSession = function (isCheking) {
|
|
295
|
-
const timeout =
|
|
296
|
-
const last_activity =
|
|
297
|
-
if (
|
|
295
|
+
const timeout = shStorage.getItem('sessionTimeout');
|
|
296
|
+
const last_activity = shStorage.getItem('last_activity');
|
|
297
|
+
if (shStorage.getItem('access_token')) {
|
|
298
298
|
const pastMinutes = moment().diff(last_activity, 'minutes');
|
|
299
299
|
const pastSeconds = moment().diff(last_activity, 'seconds');
|
|
300
300
|
if(pastMinutes >= timeout) {
|
|
@@ -352,17 +352,17 @@ async function shSwalLogout (seconds = 30) {
|
|
|
352
352
|
window.ShConfirmation = null;
|
|
353
353
|
clearInterval(window.shInterval);
|
|
354
354
|
const timeNow = moment().toISOString();
|
|
355
|
-
|
|
355
|
+
shStorage.setItem('last_activity', timeNow);
|
|
356
356
|
startSession();
|
|
357
357
|
}
|
|
358
358
|
})
|
|
359
359
|
}
|
|
360
360
|
function startSession () {
|
|
361
361
|
const timeNow = moment().toISOString();
|
|
362
|
-
const accessToken =
|
|
362
|
+
const accessToken = shStorage.getItem('access_token');
|
|
363
363
|
if (accessToken) {
|
|
364
|
-
|
|
365
|
-
const timout =
|
|
364
|
+
shStorage.setItem('last_activity', timeNow);
|
|
365
|
+
const timout = shStorage.getItem('sessionTimeout');
|
|
366
366
|
const interval = (timout * 60 *1000) / 3;
|
|
367
367
|
window.shInterval = setInterval(()=>{
|
|
368
368
|
checkSession();
|
|
@@ -374,7 +374,7 @@ const updateSession = () =>{
|
|
|
374
374
|
startSession();
|
|
375
375
|
}
|
|
376
376
|
const timeNow = moment().toISOString();
|
|
377
|
-
|
|
377
|
+
shStorage.setItem('last_activity', timeNow);
|
|
378
378
|
};
|
|
379
379
|
|
|
380
380
|
const graphQlEndpoint = 'sh-ql';
|
|
@@ -395,7 +395,7 @@ function doGet (endPoint, data,extraConfig) {
|
|
|
395
395
|
updateSession();
|
|
396
396
|
let config = {
|
|
397
397
|
headers: {
|
|
398
|
-
Authorization: 'Bearer ' +
|
|
398
|
+
Authorization: 'Bearer ' + shStorage.getItem('access_token')
|
|
399
399
|
}
|
|
400
400
|
};
|
|
401
401
|
if (extraConfig) {
|
|
@@ -411,7 +411,7 @@ function doPost (endPoint, data, extraConfig) {
|
|
|
411
411
|
updateSession();
|
|
412
412
|
const config = {
|
|
413
413
|
headers: {
|
|
414
|
-
Authorization: 'Bearer ' +
|
|
414
|
+
Authorization: 'Bearer ' + shStorage.getItem('access_token')
|
|
415
415
|
}
|
|
416
416
|
};
|
|
417
417
|
if (extraConfig) {
|
|
@@ -426,7 +426,7 @@ function doDelete (endPoint, data, extraConfig) {
|
|
|
426
426
|
updateSession();
|
|
427
427
|
const config = {
|
|
428
428
|
headers: {
|
|
429
|
-
Authorization: 'Bearer ' +
|
|
429
|
+
Authorization: 'Bearer ' + shStorage.getItem('access_token')
|
|
430
430
|
}
|
|
431
431
|
};
|
|
432
432
|
if (extraConfig) {
|
|
@@ -441,7 +441,7 @@ function doPut (endPoint, data, extraConfig) {
|
|
|
441
441
|
updateSession();
|
|
442
442
|
const config = {
|
|
443
443
|
headers: {
|
|
444
|
-
Authorization: 'Bearer ' +
|
|
444
|
+
Authorization: 'Bearer ' + shStorage.getItem('access_token')
|
|
445
445
|
}
|
|
446
446
|
};
|
|
447
447
|
if (extraConfig) {
|
|
@@ -457,7 +457,7 @@ function doPatch (endPoint, data, extraConfig) {
|
|
|
457
457
|
updateSession();
|
|
458
458
|
const config = {
|
|
459
459
|
headers: {
|
|
460
|
-
Authorization: 'Bearer ' +
|
|
460
|
+
Authorization: 'Bearer ' + shStorage.getItem('access_token')
|
|
461
461
|
}
|
|
462
462
|
};
|
|
463
463
|
if (extraConfig) {
|
|
@@ -4042,7 +4042,7 @@ const useUserStore = defineStore('user-store', {
|
|
|
4042
4042
|
setUser (){
|
|
4043
4043
|
let user = null;
|
|
4044
4044
|
try {
|
|
4045
|
-
user =
|
|
4045
|
+
user = shStorage.getItem('user') ? shStorage.getItem('user') : null;
|
|
4046
4046
|
} catch (error) {
|
|
4047
4047
|
user= null;
|
|
4048
4048
|
}
|
|
@@ -4066,7 +4066,7 @@ const useUserStore = defineStore('user-store', {
|
|
|
4066
4066
|
if (typeof(user) === 'undefined') {
|
|
4067
4067
|
user = res.data;
|
|
4068
4068
|
}
|
|
4069
|
-
|
|
4069
|
+
shStorage.setItem('user',user);
|
|
4070
4070
|
user.signOut = this.signOut;
|
|
4071
4071
|
user.logout = this.signOut;
|
|
4072
4072
|
user.logOut = this.signOut;
|
|
@@ -4089,7 +4089,7 @@ const useUserStore = defineStore('user-store', {
|
|
|
4089
4089
|
}).catch((reason) => {
|
|
4090
4090
|
if (reason.response && reason.response.status) {
|
|
4091
4091
|
if(reason.response.status === 401) {
|
|
4092
|
-
|
|
4092
|
+
shStorage.setItem('user',null);
|
|
4093
4093
|
this.user = null;
|
|
4094
4094
|
}
|
|
4095
4095
|
this.loggedOut = true;
|
|
@@ -4103,7 +4103,7 @@ const useUserStore = defineStore('user-store', {
|
|
|
4103
4103
|
}
|
|
4104
4104
|
}
|
|
4105
4105
|
const timeNow = moment().toISOString();
|
|
4106
|
-
|
|
4106
|
+
shStorage.setItem('session_start',timeNow);
|
|
4107
4107
|
},
|
|
4108
4108
|
signOut () {
|
|
4109
4109
|
shRepo.signOutUser();
|
|
@@ -4115,7 +4115,7 @@ const useUserStore = defineStore('user-store', {
|
|
|
4115
4115
|
this.setUser();
|
|
4116
4116
|
},
|
|
4117
4117
|
setAccessToken (accessToken) {
|
|
4118
|
-
|
|
4118
|
+
shStorage.setItem('access_token', accessToken);
|
|
4119
4119
|
this.setUser();
|
|
4120
4120
|
}
|
|
4121
4121
|
},
|
|
@@ -5085,7 +5085,7 @@ const __default__ = {
|
|
|
5085
5085
|
},
|
|
5086
5086
|
setCachedData: function (){
|
|
5087
5087
|
if (this.cacheKey) {
|
|
5088
|
-
this.records =
|
|
5088
|
+
this.records = shStorage.getItem('sh_table_cache_' + this.cacheKey, null);
|
|
5089
5089
|
}
|
|
5090
5090
|
},
|
|
5091
5091
|
reloadData: function (page, append){
|
|
@@ -5124,7 +5124,7 @@ const __default__ = {
|
|
|
5124
5124
|
const response = req.data.data;
|
|
5125
5125
|
this.$emit('dataLoaded', response);
|
|
5126
5126
|
if (this.page < 2 && this.cacheKey) {
|
|
5127
|
-
|
|
5127
|
+
shStorage.setItem('sh_table_cache_' + this.cacheKey, response.data);
|
|
5128
5128
|
}
|
|
5129
5129
|
this.pagination_data = {
|
|
5130
5130
|
current: response.current_page,
|
|
@@ -5793,11 +5793,6 @@ const setCounts = (res) => {
|
|
|
5793
5793
|
}
|
|
5794
5794
|
});
|
|
5795
5795
|
};
|
|
5796
|
-
const activetab = (tab) => {
|
|
5797
|
-
if (props.activeTab) {
|
|
5798
|
-
return props.activeTab === tab ? 'active' : 'active'
|
|
5799
|
-
}
|
|
5800
|
-
};
|
|
5801
5796
|
|
|
5802
5797
|
return (_ctx, _cache) => {
|
|
5803
5798
|
const _component_router_link = resolveComponent("router-link");
|
|
@@ -5814,7 +5809,7 @@ return (_ctx, _cache) => {
|
|
|
5814
5809
|
}, [
|
|
5815
5810
|
createVNode(_component_router_link, {
|
|
5816
5811
|
onClick: $event => (setTab(tab)),
|
|
5817
|
-
"active-class":
|
|
5812
|
+
"active-class": 'active',
|
|
5818
5813
|
class: normalizeClass(["nav-link text-capitalize", 'sh_tab_' + tab]),
|
|
5819
5814
|
to: __props.baseUrl+'/tab/'+tab,
|
|
5820
5815
|
role: "tab"
|
|
@@ -5823,7 +5818,7 @@ return (_ctx, _cache) => {
|
|
|
5823
5818
|
createTextVNode(toDisplayString(tab.replace(/_/g, ' ')), 1 /* TEXT */)
|
|
5824
5819
|
]),
|
|
5825
5820
|
_: 2 /* DYNAMIC */
|
|
5826
|
-
}, 1032 /* PROPS, DYNAMIC_SLOTS */, ["onClick", "
|
|
5821
|
+
}, 1032 /* PROPS, DYNAMIC_SLOTS */, ["onClick", "to", "class"])
|
|
5827
5822
|
]))
|
|
5828
5823
|
}), 128 /* KEYED_FRAGMENT */))
|
|
5829
5824
|
], 2 /* CLASS */),
|
|
@@ -7132,7 +7127,7 @@ const ShFrontend = {
|
|
|
7132
7127
|
install: (app, options) => {
|
|
7133
7128
|
if(options.sessionTimeout){
|
|
7134
7129
|
app.provide('sessionTimeout',options.sessionTimeout);
|
|
7135
|
-
|
|
7130
|
+
shStorage.setItem('sessionTimeout',options.sessionTimeout);
|
|
7136
7131
|
}
|
|
7137
7132
|
const shFormElements = options.shFormElementClasses ?? {};
|
|
7138
7133
|
|
|
@@ -7200,7 +7195,7 @@ const ShFrontend = {
|
|
|
7200
7195
|
const allowKeys = [];
|
|
7201
7196
|
Object.keys(options).map(key=> ((!['string','integer','number'].includes(typeof options[key]) && !allowKeys.includes(key)) || removeKeys.includes(key)) && delete options[key]);
|
|
7202
7197
|
|
|
7203
|
-
|
|
7198
|
+
shStorage.setItem('ShConfig',options);
|
|
7204
7199
|
}
|
|
7205
7200
|
};
|
|
7206
7201
|
|
|
@@ -7217,4 +7212,66 @@ var shGql = {
|
|
|
7217
7212
|
mutate
|
|
7218
7213
|
};
|
|
7219
7214
|
|
|
7220
|
-
|
|
7215
|
+
/**
|
|
7216
|
+
* useShFetch is a custom hook for fetching data from a given URL and caching it.
|
|
7217
|
+
* @param {string} url - The URL to fetch data from.
|
|
7218
|
+
* @param {string} path - The path to drill down to the data in the response.
|
|
7219
|
+
* @param {string} cacheKey - The key to use when caching the data.
|
|
7220
|
+
* @returns {object} An object containing the status, loading state, error, data, and a function to refetch the data.
|
|
7221
|
+
*/
|
|
7222
|
+
const useShFetch = (url, path, cacheKey) => {
|
|
7223
|
+
const status = ref('pending');
|
|
7224
|
+
const loading = ref(false);
|
|
7225
|
+
const error = ref(null);
|
|
7226
|
+
const data = ref(null);
|
|
7227
|
+
|
|
7228
|
+
onMounted(() => {
|
|
7229
|
+
reFetchData();
|
|
7230
|
+
});
|
|
7231
|
+
|
|
7232
|
+
/**
|
|
7233
|
+
* Fetches data from the given URL and updates the status, loading state, error, and data refs.
|
|
7234
|
+
* If a cacheKey is provided and there is cached data for that key, the cached data is used instead of fetching.
|
|
7235
|
+
*/
|
|
7236
|
+
const reFetchData = () => {
|
|
7237
|
+
loading.value = true;
|
|
7238
|
+
status.value = 'loading';
|
|
7239
|
+
if (cacheKey && shStorage.getItem(cacheKey)) {
|
|
7240
|
+
data.value = shStorage.getItem(cacheKey);
|
|
7241
|
+
status.value = 'success';
|
|
7242
|
+
loading.value = false;
|
|
7243
|
+
} else {
|
|
7244
|
+
shApis.doGet(url).then(response => {
|
|
7245
|
+
status.value = 'success';
|
|
7246
|
+
let res = response.data;
|
|
7247
|
+
if (path) {
|
|
7248
|
+
let pathArr = path.split('.');
|
|
7249
|
+
for (let i = 0; i < pathArr.length; i++) {
|
|
7250
|
+
res = res[pathArr[i]];
|
|
7251
|
+
}
|
|
7252
|
+
}
|
|
7253
|
+
data.value = res;
|
|
7254
|
+
if (cacheKey) {
|
|
7255
|
+
shStorage.setItem(cacheKey, res);
|
|
7256
|
+
}
|
|
7257
|
+
})
|
|
7258
|
+
.catch(res => {
|
|
7259
|
+
status.value = 'error';
|
|
7260
|
+
error.value = res.message ? res.message : (res.error ? res.error : 'An unexpected error occurred');
|
|
7261
|
+
})
|
|
7262
|
+
.finally(() => {
|
|
7263
|
+
loading.value = false;
|
|
7264
|
+
});
|
|
7265
|
+
}
|
|
7266
|
+
};
|
|
7267
|
+
|
|
7268
|
+
return {
|
|
7269
|
+
status,
|
|
7270
|
+
loading,
|
|
7271
|
+
error,
|
|
7272
|
+
data,
|
|
7273
|
+
reFetchData
|
|
7274
|
+
}
|
|
7275
|
+
};
|
|
7276
|
+
|
|
7277
|
+
export { countries as Countries, script$8 as ManagePermissions, script$o as ShAutoForm, script$j as ShCanvas, script$9 as ShCanvasBtn, script$4 as ShCardLayout, script$g as ShConfirmAction, script$n as ShDropDownForm, script$b as ShDynamicTabs, script$w as ShForm, ShFrontend, script$m as ShModal, script$a as ShModalBtn, script$l as ShModalForm, script$k as ShModalFormAuto, script$y as ShPhone, script$5 as ShQueryPopups, script$e as ShRange, script$7 as ShRoutePopups, script$f as ShSilentAction, script$x as ShSuggest, script$d as ShTable, script$c as ShTabs, shApis, shGql, shRepo, shStorage, useAppStore, useShFetch, useUserStore };
|