Merge pull request #540 from ylei-tsubame/rebuild-web
Web UI: patch 520, 401, 518, 514, and additional small issuesmain
commit
ba4addd653
46 changed files with 221 additions and 86 deletions
File diff suppressed because one or more lines are too long
@ -0,0 +1,45 @@ |
|||||||
|
import { useEffect, useMemo } from 'react'; |
||||||
|
|
||||||
|
import useCookieJar from './useCookieJar'; |
||||||
|
|
||||||
|
const useSessionExpiryCheck = (): void => { |
||||||
|
const { getSession } = useCookieJar(); |
||||||
|
|
||||||
|
// Put session in memo to avoid triggering useEffect multiple times.
|
||||||
|
const session = useMemo(() => getSession(), [getSession]); |
||||||
|
|
||||||
|
useEffect(() => { |
||||||
|
if (!session) return () => null; |
||||||
|
|
||||||
|
const { expires } = session; |
||||||
|
|
||||||
|
const deadline = new Date(expires).getTime(); |
||||||
|
const nao = Date.now(); |
||||||
|
const diff = deadline - nao; |
||||||
|
|
||||||
|
const tid = setTimeout(() => { |
||||||
|
if (!window) return; |
||||||
|
|
||||||
|
const { location } = window; |
||||||
|
const { pathname, search } = location; |
||||||
|
|
||||||
|
if ( |
||||||
|
/^\/login/.test(pathname) || |
||||||
|
(/^\/init/.test(pathname) && !search.includes('re=1')) |
||||||
|
) |
||||||
|
return; |
||||||
|
|
||||||
|
location.replace('/login'); |
||||||
|
}, diff); |
||||||
|
|
||||||
|
if (window) { |
||||||
|
window.addEventListener('beforeunload', () => clearTimeout(tid), { |
||||||
|
once: true, |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
return () => clearTimeout(tid); |
||||||
|
}, [session]); |
||||||
|
}; |
||||||
|
|
||||||
|
export default useSessionExpiryCheck; |
@ -0,0 +1,22 @@ |
|||||||
|
import api from './api'; |
||||||
|
import handleAPIError from './handleAPIError'; |
||||||
|
|
||||||
|
const setMapNetwork = ( |
||||||
|
value: 0 | 1, |
||||||
|
handleError?: (msg: Message) => void, |
||||||
|
): void => { |
||||||
|
api.put('/init/set-map-network', { value }).catch((error) => { |
||||||
|
const emsg = handleAPIError(error); |
||||||
|
|
||||||
|
emsg.children = ( |
||||||
|
<> |
||||||
|
Failed to {value ? 'enable' : 'disable'} network mapping.{' '} |
||||||
|
{emsg.children} |
||||||
|
</> |
||||||
|
); |
||||||
|
|
||||||
|
handleError?.call(null, emsg); |
||||||
|
}); |
||||||
|
}; |
||||||
|
|
||||||
|
export default setMapNetwork; |
@ -0,0 +1 @@ |
|||||||
|
self.__BUILD_MANIFEST=function(s,c,a,e,t,n,i,f,b,d,u,k,h,j,r,g,l,_){return{__rewrites:{beforeFiles:[],afterFiles:[],fallback:[]},"/":[s,a,e,f,b,h,"static/chunks/433-a3be905e7a7d3bfc.js",c,t,n,i,j,r,"static/chunks/pages/index-e791ea908d3ba943.js"],"/_error":["static/chunks/pages/_error-2280fa386d040b66.js"],"/anvil":[s,a,e,f,b,h,c,t,n,i,j,"static/chunks/pages/anvil-4cce8c1450ca6ceb.js"],"/config":[s,a,e,u,"static/chunks/519-4b7761e884c88eb9.js",c,t,n,i,d,k,g,"static/chunks/pages/config-f22ac92929f0daf0.js"],"/file-manager":["static/chunks/29107295-fbcfe2172188e46f.js",s,a,e,f,"static/chunks/176-7308c25ba374961e.js",c,t,i,d,"static/chunks/pages/file-manager-53de9163caaf5a86.js"],"/init":[s,a,f,b,u,l,c,t,n,i,_,"static/chunks/pages/init-ce942046cf0bafb2.js"],"/login":[s,a,e,c,t,n,d,k,"static/chunks/pages/login-6f7a93d56a339079.js"],"/manage-element":[s,a,e,f,b,u,l,"static/chunks/111-2605129c170ed35d.js",c,t,n,i,d,k,_,g,"static/chunks/pages/manage-element-8a411e7d32491cf4.js"],"/server":[s,e,"static/chunks/528-72edc50189f30fa9.js",c,r,"static/chunks/pages/server-8faafa80170f67f2.js"],sortedPages:["/","/_app","/_error","/anvil","/config","/file-manager","/init","/login","/manage-element","/server"]}}("static/chunks/412-ae4bab5809f6a209.js","static/chunks/62-2c80eba24b792af8.js","static/chunks/438-0147a63d98e89439.js","static/chunks/894-e57948de523bcf96.js","static/chunks/195-fa06e61dd4339031.js","static/chunks/987-1ff0d82724b0e58b.js","static/chunks/157-d1418743accab385.js","static/chunks/182-08683bbe95fbb010.js","static/chunks/900-af716a39aed22219.js","static/chunks/48-d4400834d0a31c6e.js","static/chunks/644-c7c6e21c71345aed.js","static/chunks/336-24770f9b2621610a.js","static/chunks/485-77798bccc4308d0e.js","static/chunks/898-e0785f5528d640fa.js","static/chunks/94-8322ed453a3c08f0.js","static/chunks/560-0ed707609765e23a.js","static/chunks/676-6159ce853338cc1f.js","static/chunks/86-afca85346d822222.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB(); |
@ -1 +0,0 @@ |
|||||||
self.__BUILD_MANIFEST=function(s,a,c,e,t,n,i,f,b,u,k,h,j,d,r,g,l,_){return{__rewrites:{beforeFiles:[],afterFiles:[],fallback:[]},"/":[s,c,e,f,b,j,"static/chunks/433-a3be905e7a7d3bfc.js",a,t,n,i,d,r,"static/chunks/pages/index-0771f2825962ebc3.js"],"/_error":["static/chunks/pages/_error-2280fa386d040b66.js"],"/anvil":[s,c,e,f,b,j,a,t,n,i,d,"static/chunks/pages/anvil-53b02ffa883f4c5a.js"],"/config":[s,c,e,k,"static/chunks/519-4b7761e884c88eb9.js",a,t,n,i,u,h,g,"static/chunks/pages/config-7be24d332b231569.js"],"/file-manager":["static/chunks/29107295-fbcfe2172188e46f.js",s,c,e,f,"static/chunks/176-7308c25ba374961e.js",a,t,i,u,"static/chunks/pages/file-manager-6501dafd856c22ec.js"],"/init":[s,c,f,b,k,l,a,t,n,i,_,"static/chunks/pages/init-7cf62951388d0e3b.js"],"/login":[s,c,e,a,t,n,u,h,"static/chunks/pages/login-0b2f91a926538f7c.js"],"/manage-element":[s,c,e,f,b,k,l,"static/chunks/111-2605129c170ed35d.js",a,t,n,i,u,h,_,g,"static/chunks/pages/manage-element-3ed34f8c3a72590a.js"],"/server":[s,e,"static/chunks/528-72edc50189f30fa9.js",a,r,"static/chunks/pages/server-d4d91dcbacc827c4.js"],sortedPages:["/","/_app","/_error","/anvil","/config","/file-manager","/init","/login","/manage-element","/server"]}}("static/chunks/412-ae4bab5809f6a209.js","static/chunks/62-2c80eba24b792af8.js","static/chunks/438-0147a63d98e89439.js","static/chunks/894-e57948de523bcf96.js","static/chunks/195-fa06e61dd4339031.js","static/chunks/987-1ff0d82724b0e58b.js","static/chunks/157-d1418743accab385.js","static/chunks/182-08683bbe95fbb010.js","static/chunks/900-af716a39aed22219.js","static/chunks/248-749f2bec4cb43d28.js","static/chunks/644-c7c6e21c71345aed.js","static/chunks/336-6e600f08d9387d72.js","static/chunks/485-77798bccc4308d0e.js","static/chunks/825-07aab1f379d63d3c.js","static/chunks/94-8322ed453a3c08f0.js","static/chunks/560-0ed707609765e23a.js","static/chunks/676-6159ce853338cc1f.js","static/chunks/86-447b52c8195dea3d.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB(); |
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,3 +1,11 @@ |
|||||||
type CookieJar = Record<string, unknown>; |
type CookieJar = Record<string, unknown>; |
||||||
|
|
||||||
type SessionUser = { name: string; uuid: string }; |
type SessionCookieUser = { |
||||||
|
name: string; |
||||||
|
uuid: string; |
||||||
|
}; |
||||||
|
|
||||||
|
type SessionCookie = { |
||||||
|
expires: string; |
||||||
|
user: SessionCookieUser; |
||||||
|
}; |
||||||
|
Loading…
Reference in new issue