namirasoft-site-react 1.4.306 → 1.4.307
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 +11 -1
- package/dist/components/NSID.js +66 -49
- package/dist/components/NSID.js.map +1 -1
- package/package.json +3 -2
- package/src/components/NSID.tsx +90 -59
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { IBaseComponentProps } from '../main';
|
|
2
3
|
import { IStorage } from 'namirasoft-core';
|
|
3
4
|
import { Globe } from 'namirasoft-site-map';
|
|
@@ -10,4 +11,13 @@ export interface NSIDState {
|
|
|
10
11
|
tried: boolean;
|
|
11
12
|
text?: string;
|
|
12
13
|
}
|
|
13
|
-
export declare
|
|
14
|
+
export declare class NSID extends React.Component<NSIDProps, NSIDState> {
|
|
15
|
+
private static mutex;
|
|
16
|
+
private static mutexes;
|
|
17
|
+
private globe;
|
|
18
|
+
private info;
|
|
19
|
+
constructor(props: NSIDProps);
|
|
20
|
+
componentDidMount(): void;
|
|
21
|
+
reload(): Promise<void>;
|
|
22
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
}
|
package/dist/components/NSID.js
CHANGED
|
@@ -8,59 +8,76 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
-
import
|
|
11
|
+
import React from 'react';
|
|
12
12
|
import { BaseURLImageFormatter, NSCopy } from '../main';
|
|
13
13
|
import { BaseUUID, CacheService } from 'namirasoft-core';
|
|
14
14
|
import { Globe } from 'namirasoft-site-map';
|
|
15
15
|
import Styles from './NSID.module.css';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
16
|
+
import { Mutex } from 'async-mutex';
|
|
17
|
+
export class NSID extends React.Component {
|
|
18
|
+
constructor(props) {
|
|
19
|
+
var _a;
|
|
20
|
+
super(props);
|
|
21
|
+
this.state = { tried: false };
|
|
22
|
+
let short = BaseUUID.getShort(this.props.id);
|
|
23
|
+
this.globe = (_a = this.props.globe) !== null && _a !== void 0 ? _a : new Globe();
|
|
24
|
+
this.info = this.globe.getByShortName(short);
|
|
25
|
+
}
|
|
26
|
+
componentDidMount() {
|
|
27
|
+
this.reload();
|
|
28
|
+
}
|
|
29
|
+
reload() {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
let cache = null;
|
|
32
|
+
if (this.props.storage) {
|
|
33
|
+
cache = new CacheService(this.info.product.id + ":" + this.info.table.name + ":" + this.props.id, this.props.storage, 30, () => __awaiter(this, void 0, void 0, function* () { return "0.0.0"; }), () => __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
if (this.info.table.back_end.get) {
|
|
36
|
+
try {
|
|
37
|
+
let columns = [];
|
|
38
|
+
this.info.table.forEachColumn(column => {
|
|
39
|
+
if (column.name.includes("name"))
|
|
40
|
+
columns.push(column.name);
|
|
41
|
+
});
|
|
42
|
+
let row = yield this.info.table.back_end.get(this.props.id);
|
|
43
|
+
let values = columns.map(column => row[column]).filter(x => x);
|
|
44
|
+
if (values.length > 0)
|
|
45
|
+
return values.join(" ");
|
|
46
|
+
return (_b = (_a = row.name) !== null && _a !== void 0 ? _a : row.description) !== null && _b !== void 0 ? _b : "";
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
console.error(error);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return "";
|
|
53
|
+
}));
|
|
54
|
+
cache.runGetOn = yield NSID.mutex.runExclusive(() => __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
if (!NSID.mutexes[this.info.product.id])
|
|
56
|
+
NSID.mutexes[this.info.product.id] = new Mutex();
|
|
57
|
+
return NSID.mutexes[this.info.product.id];
|
|
58
|
+
}));
|
|
44
59
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
setState({ tried: true
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
if (cache)
|
|
61
|
+
cache.get().then(text => {
|
|
62
|
+
this.setState({ tried: true, text });
|
|
63
|
+
});
|
|
64
|
+
else
|
|
65
|
+
this.setState({ tried: true });
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
render() {
|
|
69
|
+
let text = this.state.text;
|
|
70
|
+
if (!text)
|
|
71
|
+
text = this.props.id;
|
|
72
|
+
let formatter = new BaseURLImageFormatter();
|
|
73
|
+
return (_jsxs(NSCopy, { value: this.props.id, children: [!this.state.tried &&
|
|
74
|
+
_jsx("div", { className: Styles.ns_loader }), formatter.format({
|
|
75
|
+
text,
|
|
76
|
+
href: this.info.table.front_end.getViewLink(this.props.id + ""),
|
|
77
|
+
image: { url: this.info.product.logo, alt: this.info.product.logo }
|
|
78
|
+
})] }));
|
|
79
|
+
}
|
|
65
80
|
}
|
|
81
|
+
NSID.mutex = new Mutex();
|
|
82
|
+
NSID.mutexes = {};
|
|
66
83
|
//# sourceMappingURL=NSID.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NSID.js","sourceRoot":"","sources":["../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AAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;iBACnE,CAAC,IAEK,CACT,CAAC;IACH,CAAC;;AAhGc,UAAK,GAAU,IAAI,KAAK,EAAE,CAAC;AAC3B,YAAO,GAAoC,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"framework": "npm",
|
|
9
9
|
"application": "package",
|
|
10
10
|
"private": false,
|
|
11
|
-
"version": "1.4.
|
|
11
|
+
"version": "1.4.307",
|
|
12
12
|
"author": "Amir Abolhasani",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"main": "./dist/main.js",
|
|
@@ -28,13 +28,14 @@
|
|
|
28
28
|
"@types/react-bootstrap": "^0.32.37",
|
|
29
29
|
"@types/react-dom": "^18.3.1",
|
|
30
30
|
"antd": "^5.24.3",
|
|
31
|
+
"async-mutex": "^0.5.0",
|
|
31
32
|
"bootstrap": "^5.3.3",
|
|
32
33
|
"chart.js": "^4.4.8",
|
|
33
34
|
"copyfiles": "^2.4.1",
|
|
34
35
|
"link-react": "^3.0.0",
|
|
35
36
|
"namirasoft-api-link": "^1.4.13",
|
|
36
37
|
"namirasoft-api-product": "^1.4.19",
|
|
37
|
-
"namirasoft-core": "^1.4.
|
|
38
|
+
"namirasoft-core": "^1.4.54",
|
|
38
39
|
"namirasoft-schema": "^1.4.25",
|
|
39
40
|
"namirasoft-site": "^1.4.24",
|
|
40
41
|
"namirasoft-site-map": "^1.4.15",
|
package/src/components/NSID.tsx
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { BaseURLImageFormatter, IBaseComponentProps, NSCopy } from '../main';
|
|
3
3
|
import { BaseUUID, CacheService, IStorage } from 'namirasoft-core';
|
|
4
4
|
import { Globe } from 'namirasoft-site-map';
|
|
5
5
|
import Styles from './NSID.module.css';
|
|
6
|
+
import { NSBaseMetaTable, NSBaseServer } from 'namirasoft-site';
|
|
7
|
+
import { Mutex } from 'async-mutex';
|
|
6
8
|
|
|
7
9
|
export interface NSIDProps extends IBaseComponentProps
|
|
8
10
|
{
|
|
@@ -17,74 +19,103 @@ export interface NSIDState
|
|
|
17
19
|
text?: string;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
|
-
export
|
|
22
|
+
export class NSID extends React.Component<NSIDProps, NSIDState>
|
|
21
23
|
{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
private static mutex: Mutex = new Mutex();
|
|
25
|
+
private static mutexes: { [product_id: string]: Mutex } = {};
|
|
26
|
+
private globe: Globe;
|
|
27
|
+
private info: {
|
|
28
|
+
product: {
|
|
29
|
+
id: string;
|
|
30
|
+
name: string;
|
|
31
|
+
headline: string;
|
|
32
|
+
description: string;
|
|
33
|
+
logo: string;
|
|
34
|
+
link: string;
|
|
35
|
+
};
|
|
36
|
+
table: NSBaseMetaTable<NSBaseServer, any>;
|
|
37
|
+
};
|
|
38
|
+
constructor(props: NSIDProps)
|
|
39
|
+
{
|
|
40
|
+
super(props);
|
|
41
|
+
this.state = { tried: false };
|
|
42
|
+
let short = BaseUUID.getShort(this.props.id);
|
|
43
|
+
this.globe = this.props.globe ?? new Globe();
|
|
44
|
+
this.info = this.globe.getByShortName(short);
|
|
45
|
+
}
|
|
46
|
+
override componentDidMount(): void
|
|
47
|
+
{
|
|
48
|
+
this.reload();
|
|
49
|
+
}
|
|
50
|
+
async reload()
|
|
51
|
+
{
|
|
52
|
+
let cache = null;
|
|
53
|
+
if (this.props.storage)
|
|
32
54
|
{
|
|
33
|
-
|
|
55
|
+
cache = new CacheService<string>(this.info.product.id + ":" + this.info.table.name + ":" + this.props.id, this.props.storage, 30, async () => "0.0.0", async () =>
|
|
34
56
|
{
|
|
35
|
-
|
|
57
|
+
if (this.info.table.back_end.get)
|
|
36
58
|
{
|
|
37
|
-
|
|
38
|
-
info.table.forEachColumn(column =>
|
|
59
|
+
try
|
|
39
60
|
{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
61
|
+
let columns: string[] = [];
|
|
62
|
+
this.info.table.forEachColumn(column =>
|
|
63
|
+
{
|
|
64
|
+
if (column.name.includes("name"))
|
|
65
|
+
columns.push(column.name);
|
|
66
|
+
});
|
|
67
|
+
let row = await this.info.table.back_end.get(this.props.id);
|
|
68
|
+
let values = columns.map(column => row[column]).filter(x => x);
|
|
69
|
+
if (values.length > 0)
|
|
70
|
+
return values.join(" ");
|
|
71
|
+
return row.name ?? row.description ?? "";
|
|
72
|
+
} catch (error)
|
|
73
|
+
{
|
|
74
|
+
console.error(error);
|
|
75
|
+
}
|
|
51
76
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
77
|
+
return "";
|
|
78
|
+
});
|
|
79
|
+
cache.runGetOn = await NSID.mutex.runExclusive(async () =>
|
|
80
|
+
{
|
|
81
|
+
if (!NSID.mutexes[this.info.product.id])
|
|
82
|
+
NSID.mutexes[this.info.product.id] = new Mutex();
|
|
83
|
+
return NSID.mutexes[this.info.product.id];
|
|
84
|
+
});
|
|
85
|
+
}
|
|
58
86
|
if (cache)
|
|
59
87
|
cache.get().then(text =>
|
|
60
88
|
{
|
|
61
|
-
setState({ tried: true, text });
|
|
89
|
+
this.setState({ tried: true, text });
|
|
62
90
|
});
|
|
63
91
|
else
|
|
64
|
-
setState({ tried: true });
|
|
65
|
-
}
|
|
92
|
+
this.setState({ tried: true });
|
|
93
|
+
}
|
|
66
94
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
text =
|
|
95
|
+
override render()
|
|
96
|
+
{
|
|
97
|
+
let text = this.state.text;
|
|
98
|
+
if (!text)
|
|
99
|
+
text = this.props.id;
|
|
70
100
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
101
|
+
let formatter = new BaseURLImageFormatter();
|
|
102
|
+
return (
|
|
103
|
+
<NSCopy
|
|
104
|
+
value={this.props.id}
|
|
105
|
+
>
|
|
106
|
+
{
|
|
107
|
+
!this.state.tried &&
|
|
108
|
+
<div className={Styles.ns_loader}>
|
|
109
|
+
</div>
|
|
110
|
+
}
|
|
111
|
+
{
|
|
112
|
+
formatter.format({
|
|
113
|
+
text,
|
|
114
|
+
href: this.info.table.front_end.getViewLink(this.props.id + ""),
|
|
115
|
+
image: { url: this.info.product.logo, alt: this.info.product.logo }
|
|
116
|
+
})
|
|
117
|
+
}
|
|
118
|
+
</NSCopy>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
}
|