namirasoft-site-react 1.4.306 → 1.4.309

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.
@@ -1,13 +1,22 @@
1
+ import React from 'react';
1
2
  import { IBaseComponentProps } from '../main';
2
3
  import { IStorage } from 'namirasoft-core';
3
- import { Globe } from 'namirasoft-site-map';
4
+ import { NamirasoftMap } from 'namirasoft-site-map';
4
5
  export interface NSIDProps extends IBaseComponentProps {
5
6
  id: string;
6
- globe: Globe | null;
7
+ globe: NamirasoftMap | null;
7
8
  storage: IStorage | null;
8
9
  }
9
10
  export interface NSIDState {
10
- tried: boolean;
11
11
  text?: string;
12
12
  }
13
- export declare function NSID(props: NSIDProps): import("react/jsx-runtime").JSX.Element;
13
+ export declare class NSID extends React.Component<NSIDProps, NSIDState> {
14
+ private static mutex;
15
+ private static mutexes;
16
+ private namriasoft;
17
+ private info;
18
+ constructor(props: NSIDProps);
19
+ componentDidMount(): void;
20
+ reload(): Promise<void>;
21
+ render(): import("react/jsx-runtime").JSX.Element;
22
+ }
@@ -7,60 +7,73 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
- import { useEffect, useState } from 'react';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import React from 'react';
12
12
  import { BaseURLImageFormatter, NSCopy } from '../main';
13
13
  import { BaseUUID, CacheService } from 'namirasoft-core';
14
- import { Globe } from 'namirasoft-site-map';
15
- import Styles from './NSID.module.css';
16
- export function NSID(props) {
17
- var _a;
18
- const [state, setState] = useState({
19
- tried: false,
20
- });
21
- let short = BaseUUID.getShort(props.id);
22
- let namirasoft = (_a = props.globe) !== null && _a !== void 0 ? _a : new Globe();
23
- let info = namirasoft.getByShortName(short);
24
- let cache = null;
25
- if (props.storage)
26
- cache = new CacheService(info.product.id + "-" + info.table.name, props.storage, 30, () => __awaiter(this, void 0, void 0, function* () { return "0.0.0"; }), () => __awaiter(this, void 0, void 0, function* () {
27
- var _a, _b;
28
- if (info.table.back_end.get) {
29
- try {
30
- let columns = [];
31
- info.table.forEachColumn(column => {
32
- if (column.name.includes("name"))
33
- columns.push(column.name);
34
- });
35
- let row = yield info.table.back_end.get(props.id);
36
- let values = columns.map(column => row[column]).filter(x => x);
37
- if (values.length > 0)
38
- return values.join(" ");
39
- return (_b = (_a = row.name) !== null && _a !== void 0 ? _a : row.description) !== null && _b !== void 0 ? _b : "";
40
- }
41
- catch (error) {
42
- console.error(error);
43
- }
14
+ import { NamirasoftMap } from 'namirasoft-site-map';
15
+ import { Mutex } from 'async-mutex';
16
+ export class NSID extends React.Component {
17
+ constructor(props) {
18
+ var _a;
19
+ super(props);
20
+ this.state = {};
21
+ let short = BaseUUID.getShort(this.props.id);
22
+ this.namriasoft = (_a = this.props.globe) !== null && _a !== void 0 ? _a : new NamirasoftMap();
23
+ this.info = this.namriasoft.getByShortName(short);
24
+ }
25
+ componentDidMount() {
26
+ this.reload();
27
+ }
28
+ reload() {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ let cache = null;
31
+ if (this.props.storage) {
32
+ cache = new CacheService(this.info.product.id + ":" + this.info.table.name + ":" + this.props.id, this.props.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 (this.info.table.back_end.get) {
35
+ try {
36
+ let columns = [];
37
+ this.info.table.forEachColumn(column => {
38
+ if (column.name.includes("name"))
39
+ columns.push(column.name);
40
+ });
41
+ let row = yield this.info.table.back_end.get(this.props.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
+ cache.runGetOn = yield NSID.mutex.runExclusive(() => __awaiter(this, void 0, void 0, function* () {
54
+ if (!NSID.mutexes[this.info.product.id])
55
+ NSID.mutexes[this.info.product.id] = new Mutex();
56
+ return NSID.mutexes[this.info.product.id];
57
+ }));
44
58
  }
45
- return "";
46
- }));
47
- useEffect(() => {
48
- if (cache)
49
- cache.get().then(text => {
50
- setState({ tried: true, text });
51
- });
52
- else
53
- setState({ tried: true });
54
- }, [props.id]);
55
- let text = state.text;
56
- if (!text)
57
- text = props.id;
58
- let formatter = new BaseURLImageFormatter();
59
- return (_jsxs(NSCopy, { value: props.id, children: [!state.tried &&
60
- _jsx("div", { className: Styles.ns_loader }), formatter.format({
59
+ if (cache)
60
+ cache.get().then(text => {
61
+ this.setState({ text });
62
+ });
63
+ });
64
+ }
65
+ render() {
66
+ let text = this.state.text;
67
+ if (!text)
68
+ text = this.props.id;
69
+ let formatter = new BaseURLImageFormatter();
70
+ return (_jsx(NSCopy, { value: this.props.id, children: formatter.format({
61
71
  text,
62
- href: info.table.front_end.getViewLink(props.id + ""),
63
- image: { url: info.product.logo, alt: info.product.logo }
64
- })] }));
72
+ href: this.info.table.front_end.getViewLink(this.props.id + ""),
73
+ image: { url: this.info.product.logo, alt: this.info.product.logo }
74
+ }) }));
75
+ }
65
76
  }
77
+ NSID.mutex = new Mutex();
78
+ NSID.mutexes = {};
66
79
  //# sourceMappingURL=NSID.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NSID.js","sourceRoot":"","sources":["../../src/components/NSID.tsx"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAuB,MAAM,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAY,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM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ACH,CAAC;;AAzFc,UAAK,GAAU,IAAI,KAAK,EAAE,CAAC;AAC3B,YAAO,GAAoC,EAAE,CAAC"}
@@ -1,10 +1,10 @@
1
1
  import { IStorage } from "namirasoft-core";
2
2
  import { BaseColumnFormatter } from "./BaseColumnFormatter";
3
3
  import { TableColumnInfo, TableRowInfo } from "../components/NSTable";
4
- import { Globe } from "namirasoft-site-map";
4
+ import { NamirasoftMap } from "namirasoft-site-map";
5
5
  export declare class IDFormatter extends BaseColumnFormatter {
6
- private globe;
6
+ private namirasoft;
7
7
  private storage;
8
- constructor(globe: Globe | null, storage: IStorage | null, width?: string);
8
+ constructor(globe: NamirasoftMap | null, storage: IStorage | null, width?: string);
9
9
  format(value: any, _: TableColumnInfo, __: TableRowInfo<any>, printable: boolean): any;
10
10
  }
@@ -4,7 +4,7 @@ import { NSID } from "../components/NSID";
4
4
  export class IDFormatter extends BaseColumnFormatter {
5
5
  constructor(globe, storage, width = "224px") {
6
6
  super();
7
- this.globe = globe;
7
+ this.namirasoft = globe;
8
8
  this.storage = storage;
9
9
  this.onclick_overrided = true;
10
10
  this.width = width;
@@ -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, globe: this.globe, storage: this.storage });
15
+ return _jsx(NSID, { id: value, globe: 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,KAAmB,EAAE,OAAwB,EAAE,QAAgB,OAAO;QAE9E,KAAK,EAAE,CAAC;QACR,IAAI,CA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C;QAAC,OAAO,KAAK,EACd,CAAC;QACD,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ"}
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "framework": "npm",
9
9
  "application": "package",
10
10
  "private": false,
11
- "version": "1.4.306",
11
+ "version": "1.4.309",
12
12
  "author": "Amir Abolhasani",
13
13
  "license": "MIT",
14
14
  "main": "./dist/main.js",
@@ -28,16 +28,17 @@
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.53",
38
+ "namirasoft-core": "^1.4.54",
38
39
  "namirasoft-schema": "^1.4.25",
39
40
  "namirasoft-site": "^1.4.24",
40
- "namirasoft-site-map": "^1.4.15",
41
+ "namirasoft-site-map": "^1.4.16",
41
42
  "os-browserify": "^0.3.0",
42
43
  "path-browserify": "^1.0.1",
43
44
  "react": "^18.3.1",
@@ -760,7 +760,7 @@ export class NSBoxBuilder extends BaseTypeBuilder<React.JSX.Element | null>
760
760
 
761
761
  getItems={async () =>
762
762
  {
763
- // let product = Globe.namirasoft.getByProductID(schema.product);
763
+ // let product = NamirasoftMap.namirasoft.getByProductID(schema.product);
764
764
  // product.meta.tables[schema.table];
765
765
  // product.server.List;
766
766
  // todo
@@ -1,90 +1,112 @@
1
- import { useEffect, useState } from 'react';
1
+ import React from 'react';
2
2
  import { BaseURLImageFormatter, IBaseComponentProps, NSCopy } from '../main';
3
3
  import { BaseUUID, CacheService, IStorage } from 'namirasoft-core';
4
- import { Globe } from 'namirasoft-site-map';
5
- import Styles from './NSID.module.css';
4
+ import { NamirasoftMap } from 'namirasoft-site-map';
5
+ import { NSBaseMetaTable, NSBaseServer } from 'namirasoft-site';
6
+ import { Mutex } from 'async-mutex';
6
7
 
7
8
  export interface NSIDProps extends IBaseComponentProps
8
9
  {
9
10
  id: string;
10
- globe: Globe | null;
11
+ globe: NamirasoftMap | null;
11
12
  storage: IStorage | null;
12
13
  }
13
14
 
14
15
  export interface NSIDState
15
16
  {
16
- tried: boolean;
17
17
  text?: string;
18
18
  }
19
19
 
20
- export function NSID(props: NSIDProps)
20
+ export class NSID extends React.Component<NSIDProps, NSIDState>
21
21
  {
22
- const [state, setState] = useState<NSIDState>({
23
- tried: false,
24
- });
25
-
26
- let short = BaseUUID.getShort(props.id);
27
- let namirasoft = props.globe ?? new Globe();
28
- let info = namirasoft.getByShortName(short);
29
- let cache = null;
30
- if (props.storage)
31
- cache = new CacheService<string>(info.product.id + "-" + info.table.name, props.storage, 30, async () => "0.0.0", async () =>
22
+ private static mutex: Mutex = new Mutex();
23
+ private static mutexes: { [product_id: string]: Mutex } = {};
24
+ private namriasoft: NamirasoftMap;
25
+ private info: {
26
+ product: {
27
+ id: string;
28
+ name: string;
29
+ headline: string;
30
+ description: string;
31
+ logo: string;
32
+ link: string;
33
+ };
34
+ table: NSBaseMetaTable<NSBaseServer, any>;
35
+ };
36
+ constructor(props: NSIDProps)
37
+ {
38
+ super(props);
39
+ this.state = {};
40
+ let short = BaseUUID.getShort(this.props.id);
41
+ this.namriasoft = this.props.globe ?? new NamirasoftMap();
42
+ this.info = this.namriasoft.getByShortName(short);
43
+ }
44
+ override componentDidMount(): void
45
+ {
46
+ this.reload();
47
+ }
48
+ async reload()
49
+ {
50
+ let cache = null;
51
+ if (this.props.storage)
32
52
  {
33
- if (info.table.back_end.get)
53
+ cache = new CacheService<string>(this.info.product.id + ":" + this.info.table.name + ":" + this.props.id, this.props.storage, 60, async () => "0.0.0", async () =>
34
54
  {
35
- try
55
+ if (this.info.table.back_end.get)
36
56
  {
37
- let columns: string[] = [];
38
- info.table.forEachColumn(column =>
57
+ try
39
58
  {
40
- if (column.name.includes("name"))
41
- columns.push(column.name);
42
- });
43
- let row = await info.table.back_end.get(props.id);
44
- let values = columns.map(column => row[column]).filter(x => x);
45
- if (values.length > 0)
46
- return values.join(" ");
47
- return row.name ?? row.description ?? "";
48
- } catch (error)
49
- {
50
- console.error(error);
59
+ let columns: string[] = [];
60
+ this.info.table.forEachColumn(column =>
61
+ {
62
+ if (column.name.includes("name"))
63
+ columns.push(column.name);
64
+ });
65
+ let row = await this.info.table.back_end.get(this.props.id);
66
+ let values = columns.map(column => row[column]).filter(x => x);
67
+ if (values.length > 0)
68
+ return values.join(" ");
69
+ return row.name ?? row.description ?? "";
70
+ } catch (error)
71
+ {
72
+ console.error(error);
73
+ }
51
74
  }
52
- }
53
- return "";
54
- });
55
-
56
- useEffect(() =>
57
- {
75
+ return "";
76
+ });
77
+ cache.runGetOn = await NSID.mutex.runExclusive(async () =>
78
+ {
79
+ if (!NSID.mutexes[this.info.product.id])
80
+ NSID.mutexes[this.info.product.id] = new Mutex();
81
+ return NSID.mutexes[this.info.product.id];
82
+ });
83
+ }
58
84
  if (cache)
59
85
  cache.get().then(text =>
60
86
  {
61
- setState({ tried: true, text });
87
+ this.setState({ text });
62
88
  });
63
- else
64
- setState({ tried: true });
65
- }, [props.id]);
89
+ }
66
90
 
67
- let text = state.text;
68
- if (!text)
69
- text = props.id;
91
+ override render()
92
+ {
93
+ let text = this.state.text;
94
+ if (!text)
95
+ text = this.props.id;
70
96
 
71
- let formatter = new BaseURLImageFormatter();
72
- return (
73
- <NSCopy
74
- value={props.id}
75
- >
76
- {
77
- !state.tried &&
78
- <div className={Styles.ns_loader}>
79
- </div>
80
- }
81
- {
82
- formatter.format({
83
- text,
84
- href: info.table.front_end.getViewLink(props.id + ""),
85
- image: { url: info.product.logo, alt: info.product.logo }
86
- })
87
- }
88
- </NSCopy>
89
- );
97
+ let formatter = new BaseURLImageFormatter();
98
+ return (
99
+ <NSCopy
100
+ value={this.props.id}
101
+ >
102
+ {
103
+ formatter.format({
104
+ text,
105
+ href: this.info.table.front_end.getViewLink(this.props.id + ""),
106
+ image: { url: this.info.product.logo, alt: this.info.product.logo }
107
+ })
108
+ }
109
+ </NSCopy>
110
+ );
111
+ }
90
112
  }
@@ -2,17 +2,17 @@ import { IStorage } from "namirasoft-core";
2
2
  import { BaseColumnFormatter } from "./BaseColumnFormatter";
3
3
  import { TableColumnInfo, TableRowInfo } from "../components/NSTable";
4
4
  import { NSID } from "../components/NSID";
5
- import { Globe } from "namirasoft-site-map";
5
+ import { NamirasoftMap } from "namirasoft-site-map";
6
6
 
7
7
  export class IDFormatter extends BaseColumnFormatter
8
8
  {
9
- private globe: Globe | null;
9
+ private namirasoft: NamirasoftMap | null;
10
10
  private storage: IStorage | null;
11
11
 
12
- constructor(globe: Globe | null, storage: IStorage | null, width: string = "224px")
12
+ constructor(globe: NamirasoftMap | null, storage: IStorage | null, width: string = "224px")
13
13
  {
14
14
  super();
15
- this.globe = globe;
15
+ this.namirasoft = globe;
16
16
  this.storage = storage;
17
17
  this.onclick_overrided = true;
18
18
  this.width = width;
@@ -22,7 +22,7 @@ export class IDFormatter extends BaseColumnFormatter
22
22
  try
23
23
  {
24
24
  if (!printable)
25
- return <NSID id={value} globe={this.globe} storage={this.storage}></NSID>;
25
+ return <NSID id={value} globe={this.namirasoft} storage={this.storage}></NSID>;
26
26
  } catch (error)
27
27
  {
28
28
  }
@@ -1,18 +0,0 @@
1
- .ns_id_loader {
2
- margin: 0;
3
- width: 24px;
4
- height: 24px;
5
- border-radius: 50%;
6
- background: conic-gradient(#0000 10%, #001664) content-box;
7
- -webkit-mask:
8
- repeating-conic-gradient(#0000 0deg, #000 1deg 20deg, #0000 21deg 36deg),
9
- radial-gradient(farthest-side, #0000 calc(100% - 9px), #000 calc(100% - 8px));
10
- -webkit-mask-composite: destination-in;
11
- animation: rotate 1s infinite steps(10);
12
- }
13
-
14
- @keyframes rotate {
15
- to {
16
- transform: rotate(1turn)
17
- }
18
- }
@@ -1,18 +0,0 @@
1
- .ns_id_loader {
2
- margin: 0;
3
- width: 24px;
4
- height: 24px;
5
- border-radius: 50%;
6
- background: conic-gradient(#0000 10%, #001664) content-box;
7
- -webkit-mask:
8
- repeating-conic-gradient(#0000 0deg, #000 1deg 20deg, #0000 21deg 36deg),
9
- radial-gradient(farthest-side, #0000 calc(100% - 9px), #000 calc(100% - 8px));
10
- -webkit-mask-composite: destination-in;
11
- animation: rotate 1s infinite steps(10);
12
- }
13
-
14
- @keyframes rotate {
15
- to {
16
- transform: rotate(1turn)
17
- }
18
- }