namirasoft-site-react 1.4.390 → 1.4.391
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/components/NSID.d.ts +29 -3
- package/dist/components/NSID.js +45 -28
- package/dist/components/NSID.js.map +1 -1
- package/dist/formatter/IDFormatter.js +1 -1
- package/dist/formatter/IDFormatter.js.map +1 -1
- package/package.json +1 -1
- package/src/components/NSID.tsx +67 -42
- package/src/formatter/IDFormatter.tsx +1 -1
|
@@ -1,19 +1,45 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { IBaseComponentProps } from '../main';
|
|
3
|
-
import { IStorage } from 'namirasoft-core';
|
|
3
|
+
import { CacheService, IStorage } from 'namirasoft-core';
|
|
4
4
|
import { NamirasoftMap } from 'namirasoft-site-map';
|
|
5
|
+
import { NSBaseMetaTable, NSBaseServer } from 'namirasoft-site';
|
|
5
6
|
export interface NSIDProps extends IBaseComponentProps {
|
|
6
7
|
id: string;
|
|
7
|
-
|
|
8
|
+
map: NamirasoftMap | null;
|
|
8
9
|
storage: IStorage | null;
|
|
9
10
|
}
|
|
10
11
|
export interface NSIDState {
|
|
11
12
|
text?: string;
|
|
12
13
|
}
|
|
14
|
+
export interface NSIDInfo {
|
|
15
|
+
product: {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
headline: string;
|
|
19
|
+
description: string;
|
|
20
|
+
logo: string;
|
|
21
|
+
link: string;
|
|
22
|
+
};
|
|
23
|
+
table: NSBaseMetaTable<NSBaseServer, any>;
|
|
24
|
+
}
|
|
13
25
|
export declare class NSID extends React.Component<NSIDProps, NSIDState> {
|
|
14
26
|
private static mutex;
|
|
15
27
|
private static mutexes;
|
|
16
|
-
private info
|
|
28
|
+
private info;
|
|
29
|
+
static getKey(info: NSIDInfo, id: string): string;
|
|
30
|
+
static getInfo(id: string, map?: NamirasoftMap | null): {
|
|
31
|
+
product: {
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
headline: string;
|
|
35
|
+
description: string;
|
|
36
|
+
logo: string;
|
|
37
|
+
link: string;
|
|
38
|
+
};
|
|
39
|
+
table: NSBaseMetaTable<NSBaseServer, any>;
|
|
40
|
+
} | null;
|
|
41
|
+
static getCache(info: NSIDInfo, storage: IStorage, id: string): CacheService<string>;
|
|
42
|
+
static clearID(storage: IStorage, id: string, map?: NamirasoftMap | null): void;
|
|
17
43
|
constructor(props: NSIDProps);
|
|
18
44
|
componentDidMount(): void;
|
|
19
45
|
reload(): Promise<void>;
|
package/dist/components/NSID.js
CHANGED
|
@@ -14,17 +14,54 @@ import { BaseUUID, CacheService } from 'namirasoft-core';
|
|
|
14
14
|
import { NamirasoftMap } from 'namirasoft-site-map';
|
|
15
15
|
import { Mutex } from 'async-mutex';
|
|
16
16
|
export class NSID extends React.Component {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
static getKey(info, id) {
|
|
18
|
+
return `${info.product.id}:${info.table.name}:${id}`;
|
|
19
|
+
}
|
|
20
|
+
static getInfo(id, map) {
|
|
21
21
|
try {
|
|
22
|
-
let short = BaseUUID.getShort(
|
|
23
|
-
let namriasoft =
|
|
24
|
-
|
|
22
|
+
let short = BaseUUID.getShort(id);
|
|
23
|
+
let namriasoft = map !== null && map !== void 0 ? map : new NamirasoftMap();
|
|
24
|
+
return namriasoft.getByShortName(short);
|
|
25
25
|
}
|
|
26
26
|
catch (error) {
|
|
27
27
|
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
static getCache(info, storage, id) {
|
|
31
|
+
let key = NSID.getKey(info, id);
|
|
32
|
+
return new CacheService(key, storage, 60, () => __awaiter(this, void 0, void 0, function* () { return "0.0.0"; }), () => __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
if (info.table.back_end.get) {
|
|
35
|
+
try {
|
|
36
|
+
let columns = [];
|
|
37
|
+
info.table.forEachColumn(column => {
|
|
38
|
+
if (column.name.includes("name"))
|
|
39
|
+
columns.push(column.name);
|
|
40
|
+
});
|
|
41
|
+
let row = yield info.table.back_end.get(id);
|
|
42
|
+
let values = columns.map(column => row[column]).filter(x => x);
|
|
43
|
+
if (values.length > 0)
|
|
44
|
+
return values.join(" ");
|
|
45
|
+
return (_b = (_a = row.name) !== null && _a !== void 0 ? _a : row.description) !== null && _b !== void 0 ? _b : "";
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
console.error(error);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return "";
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
static clearID(storage, id, map) {
|
|
55
|
+
let info = NSID.getInfo(id, map);
|
|
56
|
+
if (info) {
|
|
57
|
+
let cache = NSID.getCache(info, storage, id);
|
|
58
|
+
cache.del();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
constructor(props) {
|
|
62
|
+
super(props);
|
|
63
|
+
this.state = {};
|
|
64
|
+
this.info = NSID.getInfo(this.props.id, this.props.map);
|
|
28
65
|
}
|
|
29
66
|
componentDidMount() {
|
|
30
67
|
this.reload();
|
|
@@ -38,27 +75,7 @@ export class NSID extends React.Component {
|
|
|
38
75
|
let info = this.info;
|
|
39
76
|
let cache = null;
|
|
40
77
|
if (this.props.storage) {
|
|
41
|
-
cache =
|
|
42
|
-
var _a, _b;
|
|
43
|
-
if (info.table.back_end.get) {
|
|
44
|
-
try {
|
|
45
|
-
let columns = [];
|
|
46
|
-
info.table.forEachColumn(column => {
|
|
47
|
-
if (column.name.includes("name"))
|
|
48
|
-
columns.push(column.name);
|
|
49
|
-
});
|
|
50
|
-
let row = yield info.table.back_end.get(this.props.id);
|
|
51
|
-
let values = columns.map(column => row[column]).filter(x => x);
|
|
52
|
-
if (values.length > 0)
|
|
53
|
-
return values.join(" ");
|
|
54
|
-
return (_b = (_a = row.name) !== null && _a !== void 0 ? _a : row.description) !== null && _b !== void 0 ? _b : "";
|
|
55
|
-
}
|
|
56
|
-
catch (error) {
|
|
57
|
-
console.error(error);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return "";
|
|
61
|
-
}));
|
|
78
|
+
cache = NSID.getCache(info, this.props.storage, this.props.id);
|
|
62
79
|
cache.runGetOn = yield NSID.mutex.runExclusive(() => __awaiter(this, void 0, void 0, function* () {
|
|
63
80
|
if (!NSID.mutexes[info.product.id])
|
|
64
81
|
NSID.mutexes[info.product.id] = new Mutex();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NSID.js","sourceRoot":"","sources":["../../src/components/NSID.tsx"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAuB,MAAM,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAY,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"NSID.js","sourceRoot":"","sources":["../../src/components/NSID.tsx"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAuB,MAAM,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAY,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AA0BpC,MAAM,OAAO,IAAK,SAAQ,KAAK,CAAC,SAA+B;IAKvD,MAAM,CAAC,MAAM,CAAC,IAAc,EAAE,EAAU;QAE9C,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,IAA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EAAE,CAAC,CAAC;QAClE,CAAC;QAAC,OAAO,KAAK,EACd,CAAC;QACD,CAAC;QACD,IAAI,SAAS,GAAG,IAAI,qBAAqB,EAAE,CAAC;QAC5C,OAAO,CACN,KAAC,MAAM,IACN,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,EACpB,SAAS,EAAE,CAAC,uBAAuB,CAAC,YAGnC,SAAS,CAAC,MAAM,CAAC;gBAChB,IAAI;gBACJ,IAAI;gBACJ,KAAK,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,MAAA,IAAI,CAAC,IAAI,0CAAE,OAAO,CAAC,IAAI,EAAE;aACpE,CAAC,GAEK,CACT,CAAC;IACH,CAAC;;AA5Hc,UAAK,GAAU,IAAI,KAAK,EAAE,CAAC;AAC3B,YAAO,GAAoC,EAAE,CAAC"}
|
|
@@ -12,7 +12,7 @@ export class IDFormatter extends BaseColumnFormatter {
|
|
|
12
12
|
format(value, _, __, printable) {
|
|
13
13
|
try {
|
|
14
14
|
if (!printable)
|
|
15
|
-
return _jsx(NSID, { id: value,
|
|
15
|
+
return _jsx(NSID, { id: value, map: this.namirasoft, storage: this.storage });
|
|
16
16
|
}
|
|
17
17
|
catch (error) {
|
|
18
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IDFormatter.js","sourceRoot":"","sources":["../../src/formatter/IDFormatter.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG1C,MAAM,OAAO,WAAY,SAAQ,mBAAmB;IAKhD,YAAY,KAA2B,EAAE,OAAwB,EAAE,QAAgB,OAAO;QAEtF,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;QAC9B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IACQ,MAAM,CAAC,KAAU,EAAE,CAAkB,EAAE,EAAqB,EAAE,SAAkB;QAErF,IACA,CAAC;YACG,IAAI,CAAC,SAAS;gBACV,OAAO,KAAC,IAAI,IAAC,EAAE,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"IDFormatter.js","sourceRoot":"","sources":["../../src/formatter/IDFormatter.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG1C,MAAM,OAAO,WAAY,SAAQ,mBAAmB;IAKhD,YAAY,KAA2B,EAAE,OAAwB,EAAE,QAAgB,OAAO;QAEtF,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;QAC9B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IACQ,MAAM,CAAC,KAAU,EAAE,CAAkB,EAAE,EAAqB,EAAE,SAAkB;QAErF,IACA,CAAC;YACG,IAAI,CAAC,SAAS;gBACV,OAAO,KAAC,IAAI,IAAC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,GAAS,CAAC;QACrF,CAAC;QAAC,OAAO,KAAK,EACd,CAAC;QACD,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ"}
|
package/package.json
CHANGED
package/src/components/NSID.tsx
CHANGED
|
@@ -8,7 +8,7 @@ import { Mutex } from 'async-mutex';
|
|
|
8
8
|
export interface NSIDProps extends IBaseComponentProps
|
|
9
9
|
{
|
|
10
10
|
id: string;
|
|
11
|
-
|
|
11
|
+
map: NamirasoftMap | null;
|
|
12
12
|
storage: IStorage | null;
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -16,34 +16,82 @@ export interface NSIDState
|
|
|
16
16
|
{
|
|
17
17
|
text?: string;
|
|
18
18
|
}
|
|
19
|
+
export interface NSIDInfo
|
|
20
|
+
{
|
|
21
|
+
product: {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
headline: string;
|
|
25
|
+
description: string;
|
|
26
|
+
logo: string;
|
|
27
|
+
link: string;
|
|
28
|
+
};
|
|
29
|
+
table: NSBaseMetaTable<NSBaseServer, any>;
|
|
30
|
+
}
|
|
19
31
|
|
|
20
32
|
export class NSID extends React.Component<NSIDProps, NSIDState>
|
|
21
33
|
{
|
|
22
34
|
private static mutex: Mutex = new Mutex();
|
|
23
35
|
private static mutexes: { [product_id: string]: Mutex } = {};
|
|
24
|
-
private info
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
logo: string;
|
|
31
|
-
link: string;
|
|
32
|
-
};
|
|
33
|
-
table: NSBaseMetaTable<NSBaseServer, any>;
|
|
34
|
-
};
|
|
35
|
-
constructor(props: NSIDProps)
|
|
36
|
+
private info: NSIDInfo | null;
|
|
37
|
+
public static getKey(info: NSIDInfo, id: string)
|
|
38
|
+
{
|
|
39
|
+
return `${info.product.id}:${info.table.name}:${id}`
|
|
40
|
+
}
|
|
41
|
+
public static getInfo(id: string, map?: NamirasoftMap | null)
|
|
36
42
|
{
|
|
37
|
-
super(props);
|
|
38
|
-
this.state = {};
|
|
39
43
|
try
|
|
40
44
|
{
|
|
41
|
-
let short = BaseUUID.getShort(
|
|
42
|
-
let namriasoft =
|
|
43
|
-
|
|
45
|
+
let short = BaseUUID.getShort(id);
|
|
46
|
+
let namriasoft = map ?? new NamirasoftMap();
|
|
47
|
+
return namriasoft.getByShortName(short);
|
|
44
48
|
} catch (error)
|
|
45
49
|
{
|
|
46
50
|
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
public static getCache(info: NSIDInfo, storage: IStorage, id: string)
|
|
54
|
+
{
|
|
55
|
+
let key = NSID.getKey(info, id);
|
|
56
|
+
return new CacheService<string>(key, storage, 60, async () => "0.0.0", async () =>
|
|
57
|
+
{
|
|
58
|
+
if (info.table.back_end.get)
|
|
59
|
+
{
|
|
60
|
+
try
|
|
61
|
+
{
|
|
62
|
+
let columns: string[] = [];
|
|
63
|
+
info.table.forEachColumn(column =>
|
|
64
|
+
{
|
|
65
|
+
if (column.name.includes("name"))
|
|
66
|
+
columns.push(column.name);
|
|
67
|
+
});
|
|
68
|
+
let row = await info.table.back_end.get(id);
|
|
69
|
+
let values = columns.map(column => row[column]).filter(x => x);
|
|
70
|
+
if (values.length > 0)
|
|
71
|
+
return values.join(" ");
|
|
72
|
+
return row.name ?? row.description ?? "";
|
|
73
|
+
} catch (error)
|
|
74
|
+
{
|
|
75
|
+
console.error(error);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return "";
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
public static clearID(storage: IStorage, id: string, map?: NamirasoftMap | null)
|
|
82
|
+
{
|
|
83
|
+
let info = NSID.getInfo(id, map);
|
|
84
|
+
if (info)
|
|
85
|
+
{
|
|
86
|
+
let cache = NSID.getCache(info, storage, id);
|
|
87
|
+
cache.del();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
constructor(props: NSIDProps)
|
|
91
|
+
{
|
|
92
|
+
super(props);
|
|
93
|
+
this.state = {};
|
|
94
|
+
this.info = NSID.getInfo(this.props.id, this.props.map);
|
|
47
95
|
}
|
|
48
96
|
override componentDidMount(): void
|
|
49
97
|
{
|
|
@@ -59,30 +107,7 @@ export class NSID extends React.Component<NSIDProps, NSIDState>
|
|
|
59
107
|
let cache = null;
|
|
60
108
|
if (this.props.storage)
|
|
61
109
|
{
|
|
62
|
-
cache =
|
|
63
|
-
{
|
|
64
|
-
if (info.table.back_end.get)
|
|
65
|
-
{
|
|
66
|
-
try
|
|
67
|
-
{
|
|
68
|
-
let columns: string[] = [];
|
|
69
|
-
info.table.forEachColumn(column =>
|
|
70
|
-
{
|
|
71
|
-
if (column.name.includes("name"))
|
|
72
|
-
columns.push(column.name);
|
|
73
|
-
});
|
|
74
|
-
let row = await info.table.back_end.get(this.props.id);
|
|
75
|
-
let values = columns.map(column => row[column]).filter(x => x);
|
|
76
|
-
if (values.length > 0)
|
|
77
|
-
return values.join(" ");
|
|
78
|
-
return row.name ?? row.description ?? "";
|
|
79
|
-
} catch (error)
|
|
80
|
-
{
|
|
81
|
-
console.error(error);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return "";
|
|
85
|
-
});
|
|
110
|
+
cache = NSID.getCache(info, this.props.storage, this.props.id);
|
|
86
111
|
cache.runGetOn = await NSID.mutex.runExclusive(async () =>
|
|
87
112
|
{
|
|
88
113
|
if (!NSID.mutexes[info.product.id])
|
|
@@ -22,7 +22,7 @@ export class IDFormatter extends BaseColumnFormatter
|
|
|
22
22
|
try
|
|
23
23
|
{
|
|
24
24
|
if (!printable)
|
|
25
|
-
return <NSID id={value}
|
|
25
|
+
return <NSID id={value} map={this.namirasoft} storage={this.storage}></NSID>;
|
|
26
26
|
} catch (error)
|
|
27
27
|
{
|
|
28
28
|
}
|