@nocobase/plugin-map 0.11.1-alpha.5 → 0.12.0-alpha.2
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/client.d.ts +2 -3
- package/client.js +1 -1
- package/dist/client/index.js +3092 -0
- package/{lib → dist}/index.d.ts +1 -0
- package/dist/index.js +18 -0
- package/dist/locale/en-US.js +6 -0
- package/dist/locale/fr-FR.js +6 -0
- package/dist/locale/pt-BR.js +51 -0
- package/dist/locale/zh-CN.js +54 -0
- package/dist/server/actions/index.js +43 -0
- package/dist/server/collections/mapConfiguration.js +32 -0
- package/dist/server/constants.js +5 -0
- package/dist/server/fields/circle.js +47 -0
- package/dist/server/fields/index.js +33 -0
- package/dist/server/fields/lineString.js +54 -0
- package/dist/server/fields/point.js +57 -0
- package/dist/server/fields/polygon.js +53 -0
- package/dist/server/helpers/index.js +31 -0
- package/dist/server/index.js +11 -0
- package/dist/server/plugin.js +59 -0
- package/dist/server/value-parsers/index.js +53 -0
- package/docs/en-US/changelog.md +1 -0
- package/docs/en-US/index.md +1 -0
- package/docs/en-US/installation.md +1 -0
- package/docs/en-US/tabs.json +18 -0
- package/docs/en-US/usage.md +1 -0
- package/docs/zh-CN/changelog.md +1 -0
- package/docs/zh-CN/index.md +1 -0
- package/docs/zh-CN/installation.md +1 -0
- package/docs/zh-CN/tabs.json +18 -0
- package/docs/zh-CN/usage.md +1 -0
- package/package.json +19 -30
- package/server.d.ts +2 -3
- package/server.js +1 -1
- package/lib/client/block/MapActionInitializers.js +0 -93
- package/lib/client/block/MapBlock.js +0 -38
- package/lib/client/block/MapBlockDesigner.js +0 -196
- package/lib/client/block/MapBlockInitializer.js +0 -124
- package/lib/client/block/MapBlockProvider.js +0 -91
- package/lib/client/block/index.js +0 -58
- package/lib/client/block/utils.js +0 -102
- package/lib/client/components/AMap/Block.js +0 -350
- package/lib/client/components/AMap/Map.js +0 -458
- package/lib/client/components/AMap/Search.js +0 -121
- package/lib/client/components/AMap/index.js +0 -27
- package/lib/client/components/Configuration.js +0 -160
- package/lib/client/components/Designer.js +0 -167
- package/lib/client/components/GoogleMaps/Block.js +0 -370
- package/lib/client/components/GoogleMaps/Map.js +0 -466
- package/lib/client/components/GoogleMaps/Search.js +0 -128
- package/lib/client/components/GoogleMaps/index.js +0 -27
- package/lib/client/components/GoogleMaps/utils.js +0 -44
- package/lib/client/components/Map.js +0 -50
- package/lib/client/components/MapBlock.js +0 -40
- package/lib/client/components/MapComponent.js +0 -42
- package/lib/client/components/ReadPretty.js +0 -56
- package/lib/client/components/index.js +0 -71
- package/lib/client/constants.js +0 -19
- package/lib/client/fields/circle.js +0 -32
- package/lib/client/fields/index.js +0 -17
- package/lib/client/fields/lineString.js +0 -32
- package/lib/client/fields/point.js +0 -32
- package/lib/client/fields/polygon.js +0 -32
- package/lib/client/fields/schema.js +0 -64
- package/lib/client/hooks/index.js +0 -16
- package/lib/client/hooks/useMapConfiguration.js +0 -54
- package/lib/client/index.js +0 -73
- package/lib/client/initialize.js +0 -50
- package/lib/client/locale/index.js +0 -38
- package/lib/client/types.js +0 -5
- package/lib/client/utils.js +0 -1
- package/lib/index.js +0 -13
- package/lib/locale/en-US.js +0 -9
- package/lib/locale/fr-FR.js +0 -9
- package/lib/locale/pt-BR.js +0 -54
- package/lib/locale/zh-CN.js +0 -57
- package/lib/server/actions/index.js +0 -55
- package/lib/server/collections/mapConfiguration.js +0 -30
- package/lib/server/constants.js +0 -8
- package/lib/server/fields/circle.js +0 -58
- package/lib/server/fields/index.js +0 -49
- package/lib/server/fields/lineString.js +0 -65
- package/lib/server/fields/point.js +0 -68
- package/lib/server/fields/polygon.js +0 -64
- package/lib/server/helpers/index.js +0 -32
- package/lib/server/index.js +0 -13
- package/lib/server/plugin.js +0 -79
- package/lib/server/value-parsers/index.js +0 -75
- package/src/client/block/MapActionInitializers.tsx +0 -97
- package/src/client/block/MapBlock.tsx +0 -11
- package/src/client/block/MapBlockDesigner.tsx +0 -161
- package/src/client/block/MapBlockInitializer.tsx +0 -91
- package/src/client/block/MapBlockProvider.tsx +0 -55
- package/src/client/block/index.tsx +0 -35
- package/src/client/block/utils.ts +0 -81
- package/src/client/components/AMap/Block.tsx +0 -314
- package/src/client/components/AMap/Map.tsx +0 -461
- package/src/client/components/AMap/Search.tsx +0 -92
- package/src/client/components/AMap/index.ts +0 -2
- package/src/client/components/Configuration.tsx +0 -117
- package/src/client/components/Designer.tsx +0 -147
- package/src/client/components/GoogleMaps/Block.tsx +0 -341
- package/src/client/components/GoogleMaps/Map.tsx +0 -470
- package/src/client/components/GoogleMaps/Search.tsx +0 -107
- package/src/client/components/GoogleMaps/index.ts +0 -2
- package/src/client/components/GoogleMaps/utils.ts +0 -33
- package/src/client/components/Map.tsx +0 -33
- package/src/client/components/MapBlock.tsx +0 -24
- package/src/client/components/MapComponent.tsx +0 -23
- package/src/client/components/ReadPretty.tsx +0 -28
- package/src/client/components/index.ts +0 -6
- package/src/client/constants.ts +0 -11
- package/src/client/fields/circle.ts +0 -23
- package/src/client/fields/index.ts +0 -11
- package/src/client/fields/lineString.ts +0 -23
- package/src/client/fields/point.ts +0 -23
- package/src/client/fields/polygon.ts +0 -23
- package/src/client/fields/schema.ts +0 -54
- package/src/client/hooks/index.ts +0 -1
- package/src/client/hooks/useMapConfiguration.ts +0 -42
- package/src/client/index.tsx +0 -55
- package/src/client/initialize.tsx +0 -32
- package/src/client/locale/index.ts +0 -19
- package/src/client/types.ts +0 -1
- package/src/client/utils.ts +0 -0
- package/src/index.ts +0 -1
- package/src/locale/en-US.ts +0 -3
- package/src/locale/fr-FR.ts +0 -3
- package/src/locale/pt-BR.ts +0 -51
- package/src/locale/zh-CN.ts +0 -52
- package/src/server/__tests__/fields.test.ts +0 -157
- package/src/server/actions/index.ts +0 -44
- package/src/server/collections/mapConfiguration.ts +0 -29
- package/src/server/constants.ts +0 -1
- package/src/server/fields/.gitkeep +0 -0
- package/src/server/fields/circle.ts +0 -48
- package/src/server/fields/index.ts +0 -4
- package/src/server/fields/lineString.ts +0 -55
- package/src/server/fields/point.ts +0 -58
- package/src/server/fields/polygon.ts +0 -54
- package/src/server/helpers/index.ts +0 -25
- package/src/server/index.ts +0 -1
- package/src/server/plugin.ts +0 -57
- package/src/server/value-parsers/index.ts +0 -55
- /package/{lib → dist}/client/block/MapActionInitializers.d.ts +0 -0
- /package/{lib → dist}/client/block/MapBlock.d.ts +0 -0
- /package/{lib → dist}/client/block/MapBlockDesigner.d.ts +0 -0
- /package/{lib → dist}/client/block/MapBlockInitializer.d.ts +0 -0
- /package/{lib → dist}/client/block/MapBlockProvider.d.ts +0 -0
- /package/{lib → dist}/client/block/index.d.ts +0 -0
- /package/{lib → dist}/client/block/utils.d.ts +0 -0
- /package/{lib → dist}/client/components/AMap/Block.d.ts +0 -0
- /package/{lib → dist}/client/components/AMap/Map.d.ts +0 -0
- /package/{lib → dist}/client/components/AMap/Search.d.ts +0 -0
- /package/{lib → dist}/client/components/AMap/index.d.ts +0 -0
- /package/{lib → dist}/client/components/Configuration.d.ts +0 -0
- /package/{lib → dist}/client/components/Designer.d.ts +0 -0
- /package/{lib → dist}/client/components/GoogleMaps/Block.d.ts +0 -0
- /package/{lib → dist}/client/components/GoogleMaps/Map.d.ts +0 -0
- /package/{lib → dist}/client/components/GoogleMaps/Search.d.ts +0 -0
- /package/{lib → dist}/client/components/GoogleMaps/index.d.ts +0 -0
- /package/{lib → dist}/client/components/GoogleMaps/utils.d.ts +0 -0
- /package/{lib → dist}/client/components/Map.d.ts +0 -0
- /package/{lib → dist}/client/components/MapBlock.d.ts +0 -0
- /package/{lib → dist}/client/components/MapComponent.d.ts +0 -0
- /package/{lib → dist}/client/components/ReadPretty.d.ts +0 -0
- /package/{lib → dist}/client/components/index.d.ts +0 -0
- /package/{lib → dist}/client/constants.d.ts +0 -0
- /package/{lib → dist}/client/fields/circle.d.ts +0 -0
- /package/{lib → dist}/client/fields/index.d.ts +0 -0
- /package/{lib → dist}/client/fields/lineString.d.ts +0 -0
- /package/{lib → dist}/client/fields/point.d.ts +0 -0
- /package/{lib → dist}/client/fields/polygon.d.ts +0 -0
- /package/{lib → dist}/client/fields/schema.d.ts +0 -0
- /package/{lib → dist}/client/hooks/index.d.ts +0 -0
- /package/{lib → dist}/client/hooks/useMapConfiguration.d.ts +0 -0
- /package/{lib → dist}/client/index.d.ts +0 -0
- /package/{lib → dist}/client/initialize.d.ts +0 -0
- /package/{lib → dist}/client/locale/index.d.ts +0 -0
- /package/{lib → dist}/client/types.d.ts +0 -0
- /package/{lib → dist}/client/utils.d.ts +0 -0
- /package/{lib → dist}/locale/en-US.d.ts +0 -0
- /package/{lib → dist}/locale/fr-FR.d.ts +0 -0
- /package/{lib → dist}/locale/pt-BR.d.ts +0 -0
- /package/{lib → dist}/locale/zh-CN.d.ts +0 -0
- /package/{lib → dist}/server/actions/index.d.ts +0 -0
- /package/{lib → dist}/server/collections/mapConfiguration.d.ts +0 -0
- /package/{lib → dist}/server/constants.d.ts +0 -0
- /package/{lib → dist}/server/fields/circle.d.ts +0 -0
- /package/{lib → dist}/server/fields/index.d.ts +0 -0
- /package/{lib → dist}/server/fields/lineString.d.ts +0 -0
- /package/{lib → dist}/server/fields/point.d.ts +0 -0
- /package/{lib → dist}/server/fields/polygon.d.ts +0 -0
- /package/{lib → dist}/server/helpers/index.d.ts +0 -0
- /package/{lib → dist}/server/index.d.ts +0 -0
- /package/{lib → dist}/server/plugin.d.ts +0 -0
- /package/{lib → dist}/server/value-parsers/index.d.ts +0 -0
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Context } from '@nocobase/actions';
|
|
2
|
-
import { MapConfigurationCollectionName } from '../constants';
|
|
3
|
-
|
|
4
|
-
export const getConfiguration = async (ctx: Context, next) => {
|
|
5
|
-
const {
|
|
6
|
-
params: { type },
|
|
7
|
-
} = ctx.action;
|
|
8
|
-
|
|
9
|
-
const repo = ctx.db.getRepository(MapConfigurationCollectionName);
|
|
10
|
-
const record = await repo.findOne({
|
|
11
|
-
filter: {
|
|
12
|
-
type,
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
ctx.body = record;
|
|
17
|
-
return next();
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const setConfiguration = async (ctx: Context, next) => {
|
|
21
|
-
const { params: values } = ctx.action;
|
|
22
|
-
const repo = ctx.db.getRepository(MapConfigurationCollectionName);
|
|
23
|
-
const record = await repo.findOne({
|
|
24
|
-
filter: {
|
|
25
|
-
type: values.type,
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
if (record) {
|
|
30
|
-
await repo.update({
|
|
31
|
-
values,
|
|
32
|
-
filter: {
|
|
33
|
-
type: values.type,
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
} else {
|
|
37
|
-
await repo.create({
|
|
38
|
-
values,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
ctx.body = 'ok';
|
|
43
|
-
return next();
|
|
44
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { CollectionOptions } from '@nocobase/client';
|
|
2
|
-
import { MapConfigurationCollectionName } from '../constants';
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
namespace: 'map.mapConfiguration',
|
|
6
|
-
duplicator: 'optional',
|
|
7
|
-
name: MapConfigurationCollectionName,
|
|
8
|
-
title: '{{t("Map Manager")}}',
|
|
9
|
-
fields: [
|
|
10
|
-
{
|
|
11
|
-
title: 'Access key',
|
|
12
|
-
comment: '访问密钥',
|
|
13
|
-
name: 'accessKey',
|
|
14
|
-
type: 'string',
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
title: 'securityJsCode',
|
|
18
|
-
comment: 'securityJsCode or serviceHOST',
|
|
19
|
-
name: 'securityJsCode',
|
|
20
|
-
type: 'string',
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
title: 'Map type',
|
|
24
|
-
comment: '地图类型',
|
|
25
|
-
name: 'type',
|
|
26
|
-
type: 'string',
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
} as CollectionOptions;
|
package/src/server/constants.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const MapConfigurationCollectionName = 'mapConfiguration';
|
|
File without changes
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { BaseColumnFieldOptions, DataTypes, Field, FieldContext } from '@nocobase/database';
|
|
2
|
-
import { isPg, toValue } from '../helpers';
|
|
3
|
-
|
|
4
|
-
class Circle extends DataTypes.ABSTRACT {
|
|
5
|
-
key = 'Circle';
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export class CircleField extends Field {
|
|
9
|
-
constructor(options?: any, context?: FieldContext) {
|
|
10
|
-
const { name } = options;
|
|
11
|
-
super(
|
|
12
|
-
{
|
|
13
|
-
get() {
|
|
14
|
-
const value = this.getDataValue(name);
|
|
15
|
-
if (isPg(context)) {
|
|
16
|
-
if (typeof value === 'string') {
|
|
17
|
-
return toValue(`(${value})`);
|
|
18
|
-
}
|
|
19
|
-
return value ? [value.x, value.y, value.radius] : null;
|
|
20
|
-
} else {
|
|
21
|
-
return value;
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
set(value) {
|
|
25
|
-
if (!value?.length) value = null;
|
|
26
|
-
else if (isPg(context)) {
|
|
27
|
-
value = value.join(',');
|
|
28
|
-
}
|
|
29
|
-
this.setDataValue(name, value);
|
|
30
|
-
},
|
|
31
|
-
...options,
|
|
32
|
-
},
|
|
33
|
-
context,
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
get dataType() {
|
|
38
|
-
if (isPg(this.context)) {
|
|
39
|
-
return Circle;
|
|
40
|
-
} else {
|
|
41
|
-
return DataTypes.JSON;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface CircleFieldOptions extends BaseColumnFieldOptions {
|
|
47
|
-
type: 'circle';
|
|
48
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { BaseColumnFieldOptions, DataTypes, Field, FieldContext } from '@nocobase/database';
|
|
2
|
-
import { isMysql, isPg, joinComma, toValue } from '../helpers';
|
|
3
|
-
|
|
4
|
-
class LineString extends DataTypes.ABSTRACT {
|
|
5
|
-
key = 'Path';
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export class LineStringField extends Field {
|
|
9
|
-
constructor(options?: any, context?: FieldContext) {
|
|
10
|
-
const { name } = options;
|
|
11
|
-
super(
|
|
12
|
-
{
|
|
13
|
-
get() {
|
|
14
|
-
const value = this.getDataValue(name);
|
|
15
|
-
if (isPg(context)) {
|
|
16
|
-
return toValue(value);
|
|
17
|
-
} else if (isMysql(context)) {
|
|
18
|
-
return value?.coordinates || null;
|
|
19
|
-
} else {
|
|
20
|
-
return value;
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
set(value) {
|
|
24
|
-
if (!value?.length) value = null;
|
|
25
|
-
else if (isPg(context)) {
|
|
26
|
-
value = joinComma(value.map(joinComma));
|
|
27
|
-
} else if (isMysql(context)) {
|
|
28
|
-
value = {
|
|
29
|
-
type: 'LineString',
|
|
30
|
-
coordinates: value,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
this.setDataValue(name, value);
|
|
34
|
-
},
|
|
35
|
-
...options,
|
|
36
|
-
},
|
|
37
|
-
context,
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
get dataType() {
|
|
42
|
-
if (isPg(this.context)) {
|
|
43
|
-
return LineString;
|
|
44
|
-
}
|
|
45
|
-
if (isMysql(this.context)) {
|
|
46
|
-
return DataTypes.GEOMETRY('LINESTRING');
|
|
47
|
-
} else {
|
|
48
|
-
return DataTypes.JSON;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface LineStringOptions extends BaseColumnFieldOptions {
|
|
54
|
-
type: 'lineString';
|
|
55
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { BaseColumnFieldOptions, DataTypes, Field, FieldContext } from '@nocobase/database';
|
|
2
|
-
import { isMysql, isPg, joinComma, toValue } from '../helpers';
|
|
3
|
-
|
|
4
|
-
class Point extends DataTypes.ABSTRACT {
|
|
5
|
-
key = 'Point';
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export class PointField extends Field {
|
|
9
|
-
constructor(options?: any, context?: FieldContext) {
|
|
10
|
-
const { name } = options;
|
|
11
|
-
super(
|
|
12
|
-
{
|
|
13
|
-
get() {
|
|
14
|
-
const value = this.getDataValue(name);
|
|
15
|
-
if (isPg(context)) {
|
|
16
|
-
if (typeof value === 'string') {
|
|
17
|
-
return toValue(value);
|
|
18
|
-
}
|
|
19
|
-
return value ? [value.x, value.y] : null;
|
|
20
|
-
} else if (isMysql(context)) {
|
|
21
|
-
return value?.coordinates || null;
|
|
22
|
-
} else {
|
|
23
|
-
return value;
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
set(value) {
|
|
27
|
-
if (!value?.length) value = null;
|
|
28
|
-
else if (isPg(context)) {
|
|
29
|
-
value = joinComma(value);
|
|
30
|
-
} else if (isMysql(context)) {
|
|
31
|
-
value = {
|
|
32
|
-
type: 'Point',
|
|
33
|
-
coordinates: value,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
this.setDataValue(name, value);
|
|
37
|
-
},
|
|
38
|
-
...options,
|
|
39
|
-
},
|
|
40
|
-
context,
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
get dataType() {
|
|
45
|
-
if (isPg(this.context)) {
|
|
46
|
-
return Point;
|
|
47
|
-
}
|
|
48
|
-
if (isMysql(this.context)) {
|
|
49
|
-
return DataTypes.GEOMETRY('POINT');
|
|
50
|
-
} else {
|
|
51
|
-
return DataTypes.JSON;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface PointFieldOptions extends BaseColumnFieldOptions {
|
|
57
|
-
type: 'point';
|
|
58
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { BaseColumnFieldOptions, DataTypes, Field, FieldContext } from '@nocobase/database';
|
|
2
|
-
import { isMysql, isPg, joinComma, toValue } from '../helpers';
|
|
3
|
-
|
|
4
|
-
class Polygon extends DataTypes.ABSTRACT {
|
|
5
|
-
key = 'Polygon';
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export class PolygonField extends Field {
|
|
9
|
-
constructor(options?: any, context?: FieldContext) {
|
|
10
|
-
const { name } = options;
|
|
11
|
-
super(
|
|
12
|
-
{
|
|
13
|
-
get() {
|
|
14
|
-
const value = this.getDataValue(name);
|
|
15
|
-
if (isPg(context)) {
|
|
16
|
-
return toValue(value);
|
|
17
|
-
} else if (isMysql(context)) {
|
|
18
|
-
return value?.coordinates[0].slice(0, -1) || null;
|
|
19
|
-
} else {
|
|
20
|
-
return value;
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
set(value) {
|
|
24
|
-
if (!value?.length) value = null;
|
|
25
|
-
else if (isPg(context)) {
|
|
26
|
-
value = joinComma(value.map((item: any) => joinComma(item)));
|
|
27
|
-
} else if (isMysql(context)) {
|
|
28
|
-
value = {
|
|
29
|
-
type: 'Polygon',
|
|
30
|
-
coordinates: [value.concat([value[0]])],
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
this.setDataValue(name, value);
|
|
34
|
-
},
|
|
35
|
-
...options,
|
|
36
|
-
},
|
|
37
|
-
context,
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
get dataType() {
|
|
42
|
-
if (isPg(this.context)) {
|
|
43
|
-
return Polygon;
|
|
44
|
-
} else if (isMysql(this.context)) {
|
|
45
|
-
return DataTypes.GEOMETRY('POLYGON');
|
|
46
|
-
} else {
|
|
47
|
-
return DataTypes.JSON;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface PolygonFieldOptions extends BaseColumnFieldOptions {
|
|
53
|
-
type: 'polygon';
|
|
54
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export const joinComma = (value: any[]) => {
|
|
2
|
-
if (!value) return null;
|
|
3
|
-
return `(${value.join(',')})`;
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
export const toValue = (value?: string) => {
|
|
7
|
-
if (!value) return null;
|
|
8
|
-
return JSON.parse(value.replace(/\(/g, '[').replace(/\)/g, ']'));
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const getDialect = (ctx) => {
|
|
12
|
-
return (ctx.db || ctx.database).sequelize.getDialect();
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const isPg = (ctx) => {
|
|
16
|
-
return getDialect(ctx) === 'postgres';
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export const isSqlite = (ctx) => {
|
|
20
|
-
return getDialect(ctx) === 'sqlite';
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const isMysql = (ctx) => {
|
|
24
|
-
return getDialect(ctx) === 'mysql';
|
|
25
|
-
};
|
package/src/server/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './plugin';
|
package/src/server/plugin.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { InstallOptions, Plugin } from '@nocobase/server';
|
|
2
|
-
import { resolve } from 'path';
|
|
3
|
-
import { getConfiguration, setConfiguration } from './actions';
|
|
4
|
-
import { CircleField, LineStringField, PointField, PolygonField } from './fields';
|
|
5
|
-
import { CircleValueParser, LineStringValueParser, PointValueParser, PolygonValueParser } from './value-parsers';
|
|
6
|
-
|
|
7
|
-
export class MapPlugin extends Plugin {
|
|
8
|
-
afterAdd() {}
|
|
9
|
-
|
|
10
|
-
beforeLoad() {
|
|
11
|
-
const fields = {
|
|
12
|
-
point: PointField,
|
|
13
|
-
polygon: PolygonField,
|
|
14
|
-
lineString: LineStringField,
|
|
15
|
-
circle: CircleField,
|
|
16
|
-
};
|
|
17
|
-
this.db.registerFieldTypes(fields);
|
|
18
|
-
this.db.registerFieldValueParsers({
|
|
19
|
-
point: PointValueParser,
|
|
20
|
-
polygon: PolygonValueParser,
|
|
21
|
-
lineString: LineStringValueParser,
|
|
22
|
-
circle: CircleValueParser,
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async load() {
|
|
27
|
-
await this.db.import({
|
|
28
|
-
directory: resolve(__dirname, 'collections'),
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
this.app.resource({
|
|
32
|
-
name: 'map-configuration',
|
|
33
|
-
actions: {
|
|
34
|
-
get: getConfiguration,
|
|
35
|
-
set: setConfiguration,
|
|
36
|
-
},
|
|
37
|
-
only: ['get', 'set'],
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
this.app.acl.registerSnippet({
|
|
41
|
-
name: `pm.${this.name}.configuration`,
|
|
42
|
-
actions: ['map-configuration:set'],
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
this.app.acl.allow('map-configuration', 'get', 'loggedIn');
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async install(options?: InstallOptions) {}
|
|
49
|
-
|
|
50
|
-
async afterEnable() {}
|
|
51
|
-
|
|
52
|
-
async afterDisable() {}
|
|
53
|
-
|
|
54
|
-
async remove() {}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export default MapPlugin;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { BaseValueParser } from '@nocobase/database';
|
|
2
|
-
|
|
3
|
-
export class PointValueParser extends BaseValueParser {
|
|
4
|
-
async setValue(value) {
|
|
5
|
-
if (Array.isArray(value)) {
|
|
6
|
-
this.value = value;
|
|
7
|
-
} else if (typeof value === 'string') {
|
|
8
|
-
this.value = value.split(',');
|
|
9
|
-
} else {
|
|
10
|
-
this.errors.push('Value invalid');
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export class PolygonValueParser extends BaseValueParser {
|
|
16
|
-
async setValue(value) {
|
|
17
|
-
if (Array.isArray(value)) {
|
|
18
|
-
this.value = value;
|
|
19
|
-
} else if (typeof value === 'string') {
|
|
20
|
-
this.value = value
|
|
21
|
-
.substring(1, value.length - 1)
|
|
22
|
-
.split('),(')
|
|
23
|
-
.map((v) => v.split(','));
|
|
24
|
-
} else {
|
|
25
|
-
this.errors.push('Value invalid');
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export class LineStringValueParser extends BaseValueParser {
|
|
31
|
-
async setValue(value) {
|
|
32
|
-
if (Array.isArray(value)) {
|
|
33
|
-
this.value = value;
|
|
34
|
-
} else if (typeof value === 'string') {
|
|
35
|
-
this.value = value
|
|
36
|
-
.substring(1, value.length - 1)
|
|
37
|
-
.split('),(')
|
|
38
|
-
.map((v) => v.split(','));
|
|
39
|
-
} else {
|
|
40
|
-
this.errors.push('Value invalid');
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export class CircleValueParser extends BaseValueParser {
|
|
46
|
-
async setValue(value) {
|
|
47
|
-
if (Array.isArray(value)) {
|
|
48
|
-
this.value = value;
|
|
49
|
-
} else if (typeof value === 'string') {
|
|
50
|
-
this.value = value.split(',');
|
|
51
|
-
} else {
|
|
52
|
-
this.errors.push('Value invalid');
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|