namirasoft-account-react 1.3.77 → 1.3.78
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/config-overrides.js +72 -72
- package/dist/App.css +57 -0
- package/dist/IAccountProps.d.ts +22 -0
- package/dist/IAccountProps.js +3 -0
- package/dist/IAccountProps.js.map +10 -0
- package/dist/IRouterMaker.d.ts +8 -0
- package/dist/IRouterMaker.js +3 -0
- package/dist/IRouterMaker.js.map +1 -0
- package/dist/IRouterState.d.ts +5 -0
- package/dist/IRouterState.js +3 -0
- package/dist/IRouterState.js.map +1 -0
- package/dist/IStorageCookie.d.ts +10 -0
- package/dist/IStorageCookie.js +27 -0
- package/dist/IStorageCookie.js.map +1 -0
- package/dist/Messenger.d.ts +16 -0
- package/dist/Messenger.js +78 -0
- package/dist/Messenger.js.map +1 -0
- package/dist/Notification.d.ts +6 -0
- package/dist/Notification.js +3 -0
- package/dist/Notification.js.map +1 -0
- package/dist/NotificationType.d.ts +6 -0
- package/dist/NotificationType.js +11 -0
- package/dist/NotificationType.js.map +1 -0
- package/dist/RouterMaker.d.ts +25 -0
- package/dist/RouterMaker.js +125 -0
- package/dist/RouterMaker.js.map +1 -0
- package/dist/RouterMaker.jsx +118 -0
- package/dist/RouterMaker.jsx.map +1 -0
- package/dist/components/NSALayoutAction.d.ts +17 -0
- package/dist/components/NSALayoutAction.js +6 -0
- package/dist/components/NSALayoutAction.js.map +1 -0
- package/dist/components/NSALayoutAction.module.css +0 -0
- package/dist/components/NSAMessageDialog.module.css +62 -62
- package/dist/index.css +0 -0
- package/dist/layouts/NSALayoutList.d.ts +17 -0
- package/dist/layouts/NSALayoutList.js +19 -0
- package/dist/layouts/NSALayoutList.js.map +1 -0
- package/dist/layouts/NSASectionList.js +1 -1
- package/dist/layouts/NSASectionList.js.map +1 -1
- package/dist/layouts/NSASectionNew.d.ts +9 -0
- package/dist/layouts/NSASectionNew.js +5 -0
- package/dist/layouts/NSASectionNew.js.map +1 -0
- package/dist/pages/NSALoginPage.module.css +19 -19
- package/package.json +64 -64
- package/public/index.html +21 -21
- package/src/App.css +56 -56
- package/src/App.tsx +10 -10
- package/src/IEntityInfo.ts +23 -23
- package/src/INSARouterMaker.ts +8 -8
- package/src/INSARouterProps.ts +17 -17
- package/src/INSARouterState.ts +5 -5
- package/src/Info.ts +20 -20
- package/src/NSARouterMaker.tsx +138 -138
- package/src/components/NSADeleteModal.tsx +24 -24
- package/src/components/NSAMessageDialog.module.css +62 -62
- package/src/components/NSAMessageDialog.tsx +65 -65
- package/src/index.tsx +7 -7
- package/src/layouts/Actions.ts +92 -92
- package/src/layouts/NSALayout.tsx +193 -193
- package/src/layouts/NSASectionEdit.tsx +97 -97
- package/src/layouts/NSASectionList.tsx +105 -105
- package/src/layouts/NSASectionTabs.tsx +36 -36
- package/src/layouts/NSASectionView.tsx +15 -15
- package/src/main.ts +16 -16
- package/src/pages/NSALoginPage.module.css +19 -19
- package/src/pages/NSALoginPage.tsx +37 -37
- package/tsconfig.json +43 -43
package/src/App.css
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
@font-face {
|
|
2
|
-
font-family: inter;
|
|
3
|
-
src: url("../src/assets/fonts/Inter-Regular.ttf");
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
body {
|
|
7
|
-
margin: 0;
|
|
8
|
-
font-family: inter;
|
|
9
|
-
-webkit-font-smoothing: antialiased;
|
|
10
|
-
-moz-osx-font-smoothing: grayscale;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.toast-header {
|
|
14
|
-
padding: 16px !important;
|
|
15
|
-
justify-content: space-between !important;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.toast {
|
|
19
|
-
width: max-content !important;
|
|
20
|
-
max-width: 100%;
|
|
21
|
-
border: 8px;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.toast-body {
|
|
25
|
-
padding: 0 !important;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.btn-close {
|
|
29
|
-
background: url(./assets/images/icon_close.png) center/1em auto no-repeat !important;
|
|
30
|
-
opacity: 1 !important;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.nsa_font_16_bold {
|
|
34
|
-
font-size: 16px;
|
|
35
|
-
font-weight: 600;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.nsa_font_13_normal {
|
|
39
|
-
font-size: 13px;
|
|
40
|
-
font-weight: 300;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.nsa_font_12_normal {
|
|
44
|
-
font-size: 12px;
|
|
45
|
-
font-weight: 300;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/*Toast*/
|
|
49
|
-
.tost {
|
|
50
|
-
position: absolute;
|
|
51
|
-
min-width: max-content;
|
|
52
|
-
right: 0;
|
|
53
|
-
background: #f2f2f2 !important;
|
|
54
|
-
}
|
|
55
|
-
.toast-header{
|
|
56
|
-
justify-content: space-between !important;
|
|
1
|
+
@font-face {
|
|
2
|
+
font-family: inter;
|
|
3
|
+
src: url("../src/assets/fonts/Inter-Regular.ttf");
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
body {
|
|
7
|
+
margin: 0;
|
|
8
|
+
font-family: inter;
|
|
9
|
+
-webkit-font-smoothing: antialiased;
|
|
10
|
+
-moz-osx-font-smoothing: grayscale;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.toast-header {
|
|
14
|
+
padding: 16px !important;
|
|
15
|
+
justify-content: space-between !important;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.toast {
|
|
19
|
+
width: max-content !important;
|
|
20
|
+
max-width: 100%;
|
|
21
|
+
border: 8px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.toast-body {
|
|
25
|
+
padding: 0 !important;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.btn-close {
|
|
29
|
+
background: url(./assets/images/icon_close.png) center/1em auto no-repeat !important;
|
|
30
|
+
opacity: 1 !important;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.nsa_font_16_bold {
|
|
34
|
+
font-size: 16px;
|
|
35
|
+
font-weight: 600;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.nsa_font_13_normal {
|
|
39
|
+
font-size: 13px;
|
|
40
|
+
font-weight: 300;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.nsa_font_12_normal {
|
|
44
|
+
font-size: 12px;
|
|
45
|
+
font-weight: 300;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/*Toast*/
|
|
49
|
+
.tost {
|
|
50
|
+
position: absolute;
|
|
51
|
+
min-width: max-content;
|
|
52
|
+
right: 0;
|
|
53
|
+
background: #f2f2f2 !important;
|
|
54
|
+
}
|
|
55
|
+
.toast-header{
|
|
56
|
+
justify-content: space-between !important;
|
|
57
57
|
}
|
package/src/App.tsx
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import './App.css';
|
|
2
|
-
import { NSAMessageDialog } from './main';
|
|
3
|
-
|
|
4
|
-
export function App()
|
|
5
|
-
{
|
|
6
|
-
return (
|
|
7
|
-
<>
|
|
8
|
-
<NSAMessageDialog />
|
|
9
|
-
</>
|
|
10
|
-
);
|
|
1
|
+
import './App.css';
|
|
2
|
+
import { NSAMessageDialog } from './main';
|
|
3
|
+
|
|
4
|
+
export function App()
|
|
5
|
+
{
|
|
6
|
+
return (
|
|
7
|
+
<>
|
|
8
|
+
<NSAMessageDialog />
|
|
9
|
+
</>
|
|
10
|
+
);
|
|
11
11
|
};
|
package/src/IEntityInfo.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { FilterItem } from "namirasoft-core";
|
|
2
|
-
|
|
3
|
-
export interface IEntityInfo<EntityType extends { id: string }, EntityTypeInput = EntityType>
|
|
4
|
-
{
|
|
5
|
-
name: string;
|
|
6
|
-
server: {
|
|
7
|
-
get: (id: string) => Promise<EntityType>;
|
|
8
|
-
list: (filters: FilterItem[] | null, page: (number | null), size: (number | null)) => Promise<{
|
|
9
|
-
rows: EntityType[];
|
|
10
|
-
count: (number | null);
|
|
11
|
-
}>;
|
|
12
|
-
create: (entity: EntityTypeInput) => Promise<EntityType>;
|
|
13
|
-
update: (id: string, entity: EntityTypeInput) => Promise<EntityType>;
|
|
14
|
-
delete: (id: string) => Promise<void>;
|
|
15
|
-
};
|
|
16
|
-
client: {
|
|
17
|
-
getListURL: () => string;
|
|
18
|
-
getNewURL: () => string;
|
|
19
|
-
getCopyURL: (id: string) => string;
|
|
20
|
-
getEditURL: (id: string) => string;
|
|
21
|
-
getViewURL: (id: string) => string;
|
|
22
|
-
onSuccess?: (entity: EntityType) => void;
|
|
23
|
-
}
|
|
1
|
+
import { FilterItem } from "namirasoft-core";
|
|
2
|
+
|
|
3
|
+
export interface IEntityInfo<EntityType extends { id: string }, EntityTypeInput = EntityType>
|
|
4
|
+
{
|
|
5
|
+
name: string;
|
|
6
|
+
server: {
|
|
7
|
+
get: (id: string) => Promise<EntityType>;
|
|
8
|
+
list: (filters: FilterItem[] | null, page: (number | null), size: (number | null)) => Promise<{
|
|
9
|
+
rows: EntityType[];
|
|
10
|
+
count: (number | null);
|
|
11
|
+
}>;
|
|
12
|
+
create: (entity: EntityTypeInput) => Promise<EntityType>;
|
|
13
|
+
update: (id: string, entity: EntityTypeInput) => Promise<EntityType>;
|
|
14
|
+
delete: (id: string) => Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
client: {
|
|
17
|
+
getListURL: () => string;
|
|
18
|
+
getNewURL: () => string;
|
|
19
|
+
getCopyURL: (id: string) => string;
|
|
20
|
+
getEditURL: (id: string) => string;
|
|
21
|
+
getViewURL: (id: string) => string;
|
|
22
|
+
onSuccess?: (entity: EntityType) => void;
|
|
23
|
+
}
|
|
24
24
|
}
|
package/src/INSARouterMaker.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { INSARouterProps } from "./INSARouterProps";
|
|
3
|
-
|
|
4
|
-
export interface INSARouterMaker
|
|
5
|
-
{
|
|
6
|
-
on401(): void;
|
|
7
|
-
onRenderOnLogin(props: INSARouterProps): React.JSX.Element;
|
|
8
|
-
onRenderOnLogout(props: INSARouterProps, banned: boolean): React.JSX.Element;
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { INSARouterProps } from "./INSARouterProps";
|
|
3
|
+
|
|
4
|
+
export interface INSARouterMaker
|
|
5
|
+
{
|
|
6
|
+
on401(): void;
|
|
7
|
+
onRenderOnLogin(props: INSARouterProps): React.JSX.Element;
|
|
8
|
+
onRenderOnLogout(props: INSARouterProps, banned: boolean): React.JSX.Element;
|
|
9
9
|
}
|
package/src/INSARouterProps.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { NamirasoftAccountServer, TokenManager } from "namirasoft-account";
|
|
2
|
-
import { ParsedNameValue } from "namirasoft-core";
|
|
3
|
-
import { INSRouterProps } from "namirasoft-site-react";
|
|
4
|
-
import { ParsedQuery } from "query-string";
|
|
5
|
-
|
|
6
|
-
export interface INSARouterProps extends INSRouterProps
|
|
7
|
-
{
|
|
8
|
-
account: {
|
|
9
|
-
token_manager: TokenManager
|
|
10
|
-
server: NamirasoftAccountServer;
|
|
11
|
-
},
|
|
12
|
-
url: {
|
|
13
|
-
getQueryStrings(): ParsedQuery;
|
|
14
|
-
getQuery(name: string): string;
|
|
15
|
-
getLink(sub: string, customQuery: { [name: string]: ParsedNameValue }): string;
|
|
16
|
-
redirect(sub: string, customQuery: { [name: string]: ParsedNameValue }): void;
|
|
17
|
-
}
|
|
1
|
+
import { NamirasoftAccountServer, TokenManager } from "namirasoft-account";
|
|
2
|
+
import { ParsedNameValue } from "namirasoft-core";
|
|
3
|
+
import { INSRouterProps } from "namirasoft-site-react";
|
|
4
|
+
import { ParsedQuery } from "query-string";
|
|
5
|
+
|
|
6
|
+
export interface INSARouterProps extends INSRouterProps
|
|
7
|
+
{
|
|
8
|
+
account: {
|
|
9
|
+
token_manager: TokenManager
|
|
10
|
+
server: NamirasoftAccountServer;
|
|
11
|
+
},
|
|
12
|
+
url: {
|
|
13
|
+
getQueryStrings(): ParsedQuery;
|
|
14
|
+
getQuery(name: string): string;
|
|
15
|
+
getLink(sub: string, customQuery: { [name: string]: ParsedNameValue }): string;
|
|
16
|
+
redirect(sub: string, customQuery: { [name: string]: ParsedNameValue }): void;
|
|
17
|
+
}
|
|
18
18
|
}
|
package/src/INSARouterState.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { INSRouterState } from "namirasoft-site-react";
|
|
2
|
-
|
|
3
|
-
export interface INSARouterState extends INSRouterState
|
|
4
|
-
{
|
|
5
|
-
inited?: boolean;
|
|
1
|
+
import { INSRouterState } from "namirasoft-site-react";
|
|
2
|
+
|
|
3
|
+
export interface INSARouterState extends INSRouterState
|
|
4
|
+
{
|
|
5
|
+
inited?: boolean;
|
|
6
6
|
}
|
package/src/Info.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { ParsedQuery } from 'query-string';
|
|
2
|
-
import DeviceUUID from "device-uuid";
|
|
3
|
-
|
|
4
|
-
export class Info
|
|
5
|
-
{
|
|
6
|
-
static getDeviceName(query: ParsedQuery)
|
|
7
|
-
{
|
|
8
|
-
var du = new DeviceUUID.DeviceUUID().parse();
|
|
9
|
-
return query.device ?? (du.platform + " " + du.version);
|
|
10
|
-
}
|
|
11
|
-
static getVersion()
|
|
12
|
-
{
|
|
13
|
-
var du = new DeviceUUID.DeviceUUID().parse();
|
|
14
|
-
return du.version;
|
|
15
|
-
}
|
|
16
|
-
static getOS(query: ParsedQuery)
|
|
17
|
-
{
|
|
18
|
-
var du = new DeviceUUID.DeviceUUID().parse();
|
|
19
|
-
return query.os ?? du.os;
|
|
20
|
-
}
|
|
1
|
+
import { ParsedQuery } from 'query-string';
|
|
2
|
+
import DeviceUUID from "device-uuid";
|
|
3
|
+
|
|
4
|
+
export class Info
|
|
5
|
+
{
|
|
6
|
+
static getDeviceName(query: ParsedQuery)
|
|
7
|
+
{
|
|
8
|
+
var du = new DeviceUUID.DeviceUUID().parse();
|
|
9
|
+
return query.device ?? (du.platform + " " + du.version);
|
|
10
|
+
}
|
|
11
|
+
static getVersion()
|
|
12
|
+
{
|
|
13
|
+
var du = new DeviceUUID.DeviceUUID().parse();
|
|
14
|
+
return du.version;
|
|
15
|
+
}
|
|
16
|
+
static getOS(query: ParsedQuery)
|
|
17
|
+
{
|
|
18
|
+
var du = new DeviceUUID.DeviceUUID().parse();
|
|
19
|
+
return query.os ?? du.os;
|
|
20
|
+
}
|
|
21
21
|
};
|
package/src/NSARouterMaker.tsx
CHANGED
|
@@ -1,139 +1,139 @@
|
|
|
1
|
-
import queryString, { ParsedQuery } from 'query-string';
|
|
2
|
-
import { IStorageCookie, ObjectService, ParsedNameValue, URLOperation } from "namirasoft-core";
|
|
3
|
-
import { NamirasoftAccountServer, TokenManager } from "namirasoft-account";
|
|
4
|
-
import { INSARouterProps } from "./INSARouterProps";
|
|
5
|
-
import { INSARouterMaker } from "./INSARouterMaker";
|
|
6
|
-
import { INSARouterState } from "./INSARouterState";
|
|
7
|
-
import { INSRouterProps, NSRouterMaker } from 'namirasoft-site-react';
|
|
8
|
-
import rrd from 'react-router-dom';
|
|
9
|
-
import axios from "axios";
|
|
10
|
-
|
|
11
|
-
export class NSARouterMaker
|
|
12
|
-
{
|
|
13
|
-
private ns_router_maker_props!: INSRouterProps;
|
|
14
|
-
private state: INSARouterState | undefined;
|
|
15
|
-
private setState: React.Dispatch<React.SetStateAction<INSARouterState | undefined>>;
|
|
16
|
-
private location: rrd.Location;
|
|
17
|
-
private navigate: rrd.NavigateFunction;
|
|
18
|
-
private component: INSARouterMaker;
|
|
19
|
-
constructor(state: INSARouterState | undefined, setState: React.Dispatch<React.SetStateAction<INSARouterState | undefined>>,
|
|
20
|
-
location: rrd.Location, navigate: rrd.NavigateFunction,
|
|
21
|
-
component: INSARouterMaker)
|
|
22
|
-
{
|
|
23
|
-
this.state = state;
|
|
24
|
-
this.setState = setState;
|
|
25
|
-
this.location = location;
|
|
26
|
-
this.navigate = navigate;
|
|
27
|
-
this.component = component;
|
|
28
|
-
this.init = this.init.bind(this);
|
|
29
|
-
this.getQueryStrings = this.getQueryStrings.bind(this);
|
|
30
|
-
this.getQuery = this.getQuery.bind(this);
|
|
31
|
-
this.getLink = this.getLink.bind(this);
|
|
32
|
-
this.redirect = this.redirect.bind(this);
|
|
33
|
-
this.onComponentDidMount = this.onComponentDidMount.bind(this);
|
|
34
|
-
this.onRender = this.onRender.bind(this);
|
|
35
|
-
}
|
|
36
|
-
private init(): { props: INSARouterProps, inited: boolean }
|
|
37
|
-
{
|
|
38
|
-
let qToken: string = this.getQuery("token");
|
|
39
|
-
let Cookies = process.env.REACT_APP_ACCOUNT_TOKEN;
|
|
40
|
-
let storage = new IStorageCookie({ domain: ".namirasoft.com", path: "/" }, Cookies);
|
|
41
|
-
let token_manager = new TokenManager(storage, () => this.setState({}));
|
|
42
|
-
if (qToken)
|
|
43
|
-
token_manager.setValue(qToken, true);
|
|
44
|
-
let server = new NamirasoftAccountServer(token_manager, (error: Error) =>
|
|
45
|
-
{
|
|
46
|
-
if (axios.isAxiosError(error))
|
|
47
|
-
if (error.response)
|
|
48
|
-
if (error.response?.status === 401)
|
|
49
|
-
{
|
|
50
|
-
token_manager.del();
|
|
51
|
-
this.component.on401();
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
this.ns_router_maker_props.notifier.onError(error);
|
|
55
|
-
});
|
|
56
|
-
let props: INSARouterProps = {
|
|
57
|
-
account: {
|
|
58
|
-
token_manager,
|
|
59
|
-
server,
|
|
60
|
-
},
|
|
61
|
-
url: {
|
|
62
|
-
getLink: this.getLink,
|
|
63
|
-
redirect: this.redirect,
|
|
64
|
-
getQueryStrings: this.getQueryStrings,
|
|
65
|
-
getQuery: this.getQuery,
|
|
66
|
-
},
|
|
67
|
-
...this.ns_router_maker_props
|
|
68
|
-
};
|
|
69
|
-
let inited = true;
|
|
70
|
-
if (qToken)
|
|
71
|
-
inited = this.state?.inited ?? false;
|
|
72
|
-
return { props, inited };
|
|
73
|
-
}
|
|
74
|
-
getQueryStrings(): ParsedQuery
|
|
75
|
-
{
|
|
76
|
-
return queryString.parse(this.location.search);
|
|
77
|
-
}
|
|
78
|
-
getQuery(name: string): string
|
|
79
|
-
{
|
|
80
|
-
let query = this.getQueryStrings();
|
|
81
|
-
let item = query[name];
|
|
82
|
-
return new ObjectService(item).getString();
|
|
83
|
-
}
|
|
84
|
-
getLink(sub: string, customQuery: { [name: string]: ParsedNameValue })
|
|
85
|
-
{
|
|
86
|
-
if (!customQuery)
|
|
87
|
-
customQuery = {};
|
|
88
|
-
return URLOperation.getLink("", sub, customQuery);
|
|
89
|
-
}
|
|
90
|
-
redirect(sub: string, customQuery: { [name: string]: ParsedNameValue }): void
|
|
91
|
-
{
|
|
92
|
-
let ans = this.getLink(sub, customQuery);
|
|
93
|
-
this.navigate(ans);
|
|
94
|
-
}
|
|
95
|
-
onComponentDidMount(): void
|
|
96
|
-
{
|
|
97
|
-
let { inited, props } = this.init();
|
|
98
|
-
this.setState({ notifications: [], inited });
|
|
99
|
-
let token = this.getQuery("token");
|
|
100
|
-
if (token)
|
|
101
|
-
{
|
|
102
|
-
if (!props.account.token_manager.getUserData(u => u.id, ""))
|
|
103
|
-
{
|
|
104
|
-
props.account.server.session.Current()
|
|
105
|
-
.then(response =>
|
|
106
|
-
{
|
|
107
|
-
props.account.token_manager.set(response, false);
|
|
108
|
-
this.setState({ inited: true });
|
|
109
|
-
})
|
|
110
|
-
.catch(() =>
|
|
111
|
-
{
|
|
112
|
-
this.setState({ inited: true });
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
onRender(): React.JSX.Element
|
|
118
|
-
{
|
|
119
|
-
let maker = new NSRouterMaker(this.state, this.setState, {
|
|
120
|
-
onRender: (ns_router_maker_props: INSRouterProps) =>
|
|
121
|
-
{
|
|
122
|
-
this.ns_router_maker_props = ns_router_maker_props;
|
|
123
|
-
let { inited, props } = this.init();
|
|
124
|
-
if (!inited)
|
|
125
|
-
return <></>;
|
|
126
|
-
let banned = false;
|
|
127
|
-
if (props.account.token_manager.exists())
|
|
128
|
-
{
|
|
129
|
-
banned = props.account.token_manager.getUserData(user => user.banned, false);
|
|
130
|
-
if (!banned)
|
|
131
|
-
return this.component.onRenderOnLogin(props);
|
|
132
|
-
}
|
|
133
|
-
return this.component.onRenderOnLogout(props, banned);
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
return maker.onRender();
|
|
138
|
-
}
|
|
1
|
+
import queryString, { ParsedQuery } from 'query-string';
|
|
2
|
+
import { IStorageCookie, ObjectService, ParsedNameValue, URLOperation } from "namirasoft-core";
|
|
3
|
+
import { NamirasoftAccountServer, TokenManager } from "namirasoft-account";
|
|
4
|
+
import { INSARouterProps } from "./INSARouterProps";
|
|
5
|
+
import { INSARouterMaker } from "./INSARouterMaker";
|
|
6
|
+
import { INSARouterState } from "./INSARouterState";
|
|
7
|
+
import { INSRouterProps, NSRouterMaker } from 'namirasoft-site-react';
|
|
8
|
+
import rrd from 'react-router-dom';
|
|
9
|
+
import axios from "axios";
|
|
10
|
+
|
|
11
|
+
export class NSARouterMaker
|
|
12
|
+
{
|
|
13
|
+
private ns_router_maker_props!: INSRouterProps;
|
|
14
|
+
private state: INSARouterState | undefined;
|
|
15
|
+
private setState: React.Dispatch<React.SetStateAction<INSARouterState | undefined>>;
|
|
16
|
+
private location: rrd.Location;
|
|
17
|
+
private navigate: rrd.NavigateFunction;
|
|
18
|
+
private component: INSARouterMaker;
|
|
19
|
+
constructor(state: INSARouterState | undefined, setState: React.Dispatch<React.SetStateAction<INSARouterState | undefined>>,
|
|
20
|
+
location: rrd.Location, navigate: rrd.NavigateFunction,
|
|
21
|
+
component: INSARouterMaker)
|
|
22
|
+
{
|
|
23
|
+
this.state = state;
|
|
24
|
+
this.setState = setState;
|
|
25
|
+
this.location = location;
|
|
26
|
+
this.navigate = navigate;
|
|
27
|
+
this.component = component;
|
|
28
|
+
this.init = this.init.bind(this);
|
|
29
|
+
this.getQueryStrings = this.getQueryStrings.bind(this);
|
|
30
|
+
this.getQuery = this.getQuery.bind(this);
|
|
31
|
+
this.getLink = this.getLink.bind(this);
|
|
32
|
+
this.redirect = this.redirect.bind(this);
|
|
33
|
+
this.onComponentDidMount = this.onComponentDidMount.bind(this);
|
|
34
|
+
this.onRender = this.onRender.bind(this);
|
|
35
|
+
}
|
|
36
|
+
private init(): { props: INSARouterProps, inited: boolean }
|
|
37
|
+
{
|
|
38
|
+
let qToken: string = this.getQuery("token");
|
|
39
|
+
let Cookies = process.env.REACT_APP_ACCOUNT_TOKEN;
|
|
40
|
+
let storage = new IStorageCookie({ domain: ".namirasoft.com", path: "/" }, Cookies);
|
|
41
|
+
let token_manager = new TokenManager(storage, () => this.setState({}));
|
|
42
|
+
if (qToken)
|
|
43
|
+
token_manager.setValue(qToken, true);
|
|
44
|
+
let server = new NamirasoftAccountServer(token_manager, (error: Error) =>
|
|
45
|
+
{
|
|
46
|
+
if (axios.isAxiosError(error))
|
|
47
|
+
if (error.response)
|
|
48
|
+
if (error.response?.status === 401)
|
|
49
|
+
{
|
|
50
|
+
token_manager.del();
|
|
51
|
+
this.component.on401();
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
this.ns_router_maker_props.notifier.onError(error);
|
|
55
|
+
});
|
|
56
|
+
let props: INSARouterProps = {
|
|
57
|
+
account: {
|
|
58
|
+
token_manager,
|
|
59
|
+
server,
|
|
60
|
+
},
|
|
61
|
+
url: {
|
|
62
|
+
getLink: this.getLink,
|
|
63
|
+
redirect: this.redirect,
|
|
64
|
+
getQueryStrings: this.getQueryStrings,
|
|
65
|
+
getQuery: this.getQuery,
|
|
66
|
+
},
|
|
67
|
+
...this.ns_router_maker_props
|
|
68
|
+
};
|
|
69
|
+
let inited = true;
|
|
70
|
+
if (qToken)
|
|
71
|
+
inited = this.state?.inited ?? false;
|
|
72
|
+
return { props, inited };
|
|
73
|
+
}
|
|
74
|
+
getQueryStrings(): ParsedQuery
|
|
75
|
+
{
|
|
76
|
+
return queryString.parse(this.location.search);
|
|
77
|
+
}
|
|
78
|
+
getQuery(name: string): string
|
|
79
|
+
{
|
|
80
|
+
let query = this.getQueryStrings();
|
|
81
|
+
let item = query[name];
|
|
82
|
+
return new ObjectService(item).getString();
|
|
83
|
+
}
|
|
84
|
+
getLink(sub: string, customQuery: { [name: string]: ParsedNameValue })
|
|
85
|
+
{
|
|
86
|
+
if (!customQuery)
|
|
87
|
+
customQuery = {};
|
|
88
|
+
return URLOperation.getLink("", sub, customQuery);
|
|
89
|
+
}
|
|
90
|
+
redirect(sub: string, customQuery: { [name: string]: ParsedNameValue }): void
|
|
91
|
+
{
|
|
92
|
+
let ans = this.getLink(sub, customQuery);
|
|
93
|
+
this.navigate(ans);
|
|
94
|
+
}
|
|
95
|
+
onComponentDidMount(): void
|
|
96
|
+
{
|
|
97
|
+
let { inited, props } = this.init();
|
|
98
|
+
this.setState({ notifications: [], inited });
|
|
99
|
+
let token = this.getQuery("token");
|
|
100
|
+
if (token)
|
|
101
|
+
{
|
|
102
|
+
if (!props.account.token_manager.getUserData(u => u.id, ""))
|
|
103
|
+
{
|
|
104
|
+
props.account.server.session.Current()
|
|
105
|
+
.then(response =>
|
|
106
|
+
{
|
|
107
|
+
props.account.token_manager.set(response, false);
|
|
108
|
+
this.setState({ inited: true });
|
|
109
|
+
})
|
|
110
|
+
.catch(() =>
|
|
111
|
+
{
|
|
112
|
+
this.setState({ inited: true });
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
onRender(): React.JSX.Element
|
|
118
|
+
{
|
|
119
|
+
let maker = new NSRouterMaker(this.state, this.setState, {
|
|
120
|
+
onRender: (ns_router_maker_props: INSRouterProps) =>
|
|
121
|
+
{
|
|
122
|
+
this.ns_router_maker_props = ns_router_maker_props;
|
|
123
|
+
let { inited, props } = this.init();
|
|
124
|
+
if (!inited)
|
|
125
|
+
return <></>;
|
|
126
|
+
let banned = false;
|
|
127
|
+
if (props.account.token_manager.exists())
|
|
128
|
+
{
|
|
129
|
+
banned = props.account.token_manager.getUserData(user => user.banned, false);
|
|
130
|
+
if (!banned)
|
|
131
|
+
return this.component.onRenderOnLogin(props);
|
|
132
|
+
}
|
|
133
|
+
return this.component.onRenderOnLogout(props, banned);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
return maker.onRender();
|
|
138
|
+
}
|
|
139
139
|
};
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
// import Styles from './NSALayoutAction.module.css';
|
|
2
|
-
import { NSModal } from 'namirasoft-site-react';
|
|
3
|
-
import { NSButtonGreen, NSButtonRed, NSSpace, NSSpaceSizeType } from "namirasoft-site-react";
|
|
4
|
-
|
|
5
|
-
export interface NSADeleteModalProps
|
|
6
|
-
{
|
|
7
|
-
title: string;
|
|
8
|
-
description: string;
|
|
9
|
-
show: boolean;
|
|
10
|
-
onYes: () => void;
|
|
11
|
-
onNo: () => void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function NSADeleteModal(props: NSADeleteModalProps)
|
|
15
|
-
{
|
|
16
|
-
return (
|
|
17
|
-
<NSModal title={props.title} description={props.description} show={props.show}
|
|
18
|
-
onClose={props.onNo} children={
|
|
19
|
-
<div>
|
|
20
|
-
<NSButtonGreen title="Yes" onClick={props.onYes} />
|
|
21
|
-
<NSSpace size={NSSpaceSizeType.MICRO}></NSSpace>
|
|
22
|
-
<NSButtonRed title="No" onClick={props.onNo} />
|
|
23
|
-
</div>} />
|
|
24
|
-
);
|
|
1
|
+
// import Styles from './NSALayoutAction.module.css';
|
|
2
|
+
import { NSModal } from 'namirasoft-site-react';
|
|
3
|
+
import { NSButtonGreen, NSButtonRed, NSSpace, NSSpaceSizeType } from "namirasoft-site-react";
|
|
4
|
+
|
|
5
|
+
export interface NSADeleteModalProps
|
|
6
|
+
{
|
|
7
|
+
title: string;
|
|
8
|
+
description: string;
|
|
9
|
+
show: boolean;
|
|
10
|
+
onYes: () => void;
|
|
11
|
+
onNo: () => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function NSADeleteModal(props: NSADeleteModalProps)
|
|
15
|
+
{
|
|
16
|
+
return (
|
|
17
|
+
<NSModal title={props.title} description={props.description} show={props.show}
|
|
18
|
+
onClose={props.onNo} children={
|
|
19
|
+
<div>
|
|
20
|
+
<NSButtonGreen title="Yes" onClick={props.onYes} />
|
|
21
|
+
<NSSpace size={NSSpaceSizeType.MICRO}></NSSpace>
|
|
22
|
+
<NSButtonRed title="No" onClick={props.onNo} />
|
|
23
|
+
</div>} />
|
|
24
|
+
);
|
|
25
25
|
}
|