@nocobase/plugin-map 0.11.1-alpha.5 → 0.12.0-alpha.1

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.
Files changed (197) hide show
  1. package/client.d.ts +2 -3
  2. package/client.js +1 -1
  3. package/dist/client/index.js +3092 -0
  4. package/{lib → dist}/index.d.ts +1 -0
  5. package/dist/index.js +18 -0
  6. package/dist/locale/en-US.js +6 -0
  7. package/dist/locale/fr-FR.js +6 -0
  8. package/dist/locale/pt-BR.js +51 -0
  9. package/dist/locale/zh-CN.js +54 -0
  10. package/dist/server/actions/index.js +43 -0
  11. package/dist/server/collections/mapConfiguration.js +32 -0
  12. package/dist/server/constants.js +5 -0
  13. package/dist/server/fields/circle.js +47 -0
  14. package/dist/server/fields/index.js +33 -0
  15. package/dist/server/fields/lineString.js +54 -0
  16. package/dist/server/fields/point.js +57 -0
  17. package/dist/server/fields/polygon.js +53 -0
  18. package/dist/server/helpers/index.js +31 -0
  19. package/dist/server/index.js +11 -0
  20. package/dist/server/plugin.js +59 -0
  21. package/dist/server/value-parsers/index.js +53 -0
  22. package/docs/en-US/changelog.md +1 -0
  23. package/docs/en-US/index.md +1 -0
  24. package/docs/en-US/installation.md +1 -0
  25. package/docs/en-US/tabs.json +18 -0
  26. package/docs/en-US/usage.md +1 -0
  27. package/docs/zh-CN/changelog.md +1 -0
  28. package/docs/zh-CN/index.md +1 -0
  29. package/docs/zh-CN/installation.md +1 -0
  30. package/docs/zh-CN/tabs.json +18 -0
  31. package/docs/zh-CN/usage.md +1 -0
  32. package/package.json +19 -30
  33. package/server.d.ts +2 -3
  34. package/server.js +1 -1
  35. package/lib/client/block/MapActionInitializers.js +0 -93
  36. package/lib/client/block/MapBlock.js +0 -38
  37. package/lib/client/block/MapBlockDesigner.js +0 -196
  38. package/lib/client/block/MapBlockInitializer.js +0 -124
  39. package/lib/client/block/MapBlockProvider.js +0 -91
  40. package/lib/client/block/index.js +0 -58
  41. package/lib/client/block/utils.js +0 -102
  42. package/lib/client/components/AMap/Block.js +0 -350
  43. package/lib/client/components/AMap/Map.js +0 -458
  44. package/lib/client/components/AMap/Search.js +0 -121
  45. package/lib/client/components/AMap/index.js +0 -27
  46. package/lib/client/components/Configuration.js +0 -160
  47. package/lib/client/components/Designer.js +0 -167
  48. package/lib/client/components/GoogleMaps/Block.js +0 -370
  49. package/lib/client/components/GoogleMaps/Map.js +0 -466
  50. package/lib/client/components/GoogleMaps/Search.js +0 -128
  51. package/lib/client/components/GoogleMaps/index.js +0 -27
  52. package/lib/client/components/GoogleMaps/utils.js +0 -44
  53. package/lib/client/components/Map.js +0 -50
  54. package/lib/client/components/MapBlock.js +0 -40
  55. package/lib/client/components/MapComponent.js +0 -42
  56. package/lib/client/components/ReadPretty.js +0 -56
  57. package/lib/client/components/index.js +0 -71
  58. package/lib/client/constants.js +0 -19
  59. package/lib/client/fields/circle.js +0 -32
  60. package/lib/client/fields/index.js +0 -17
  61. package/lib/client/fields/lineString.js +0 -32
  62. package/lib/client/fields/point.js +0 -32
  63. package/lib/client/fields/polygon.js +0 -32
  64. package/lib/client/fields/schema.js +0 -64
  65. package/lib/client/hooks/index.js +0 -16
  66. package/lib/client/hooks/useMapConfiguration.js +0 -54
  67. package/lib/client/index.js +0 -73
  68. package/lib/client/initialize.js +0 -50
  69. package/lib/client/locale/index.js +0 -38
  70. package/lib/client/types.js +0 -5
  71. package/lib/client/utils.js +0 -1
  72. package/lib/index.js +0 -13
  73. package/lib/locale/en-US.js +0 -9
  74. package/lib/locale/fr-FR.js +0 -9
  75. package/lib/locale/pt-BR.js +0 -54
  76. package/lib/locale/zh-CN.js +0 -57
  77. package/lib/server/actions/index.js +0 -55
  78. package/lib/server/collections/mapConfiguration.js +0 -30
  79. package/lib/server/constants.js +0 -8
  80. package/lib/server/fields/circle.js +0 -58
  81. package/lib/server/fields/index.js +0 -49
  82. package/lib/server/fields/lineString.js +0 -65
  83. package/lib/server/fields/point.js +0 -68
  84. package/lib/server/fields/polygon.js +0 -64
  85. package/lib/server/helpers/index.js +0 -32
  86. package/lib/server/index.js +0 -13
  87. package/lib/server/plugin.js +0 -79
  88. package/lib/server/value-parsers/index.js +0 -75
  89. package/src/client/block/MapActionInitializers.tsx +0 -97
  90. package/src/client/block/MapBlock.tsx +0 -11
  91. package/src/client/block/MapBlockDesigner.tsx +0 -161
  92. package/src/client/block/MapBlockInitializer.tsx +0 -91
  93. package/src/client/block/MapBlockProvider.tsx +0 -55
  94. package/src/client/block/index.tsx +0 -35
  95. package/src/client/block/utils.ts +0 -81
  96. package/src/client/components/AMap/Block.tsx +0 -314
  97. package/src/client/components/AMap/Map.tsx +0 -461
  98. package/src/client/components/AMap/Search.tsx +0 -92
  99. package/src/client/components/AMap/index.ts +0 -2
  100. package/src/client/components/Configuration.tsx +0 -117
  101. package/src/client/components/Designer.tsx +0 -147
  102. package/src/client/components/GoogleMaps/Block.tsx +0 -341
  103. package/src/client/components/GoogleMaps/Map.tsx +0 -470
  104. package/src/client/components/GoogleMaps/Search.tsx +0 -107
  105. package/src/client/components/GoogleMaps/index.ts +0 -2
  106. package/src/client/components/GoogleMaps/utils.ts +0 -33
  107. package/src/client/components/Map.tsx +0 -33
  108. package/src/client/components/MapBlock.tsx +0 -24
  109. package/src/client/components/MapComponent.tsx +0 -23
  110. package/src/client/components/ReadPretty.tsx +0 -28
  111. package/src/client/components/index.ts +0 -6
  112. package/src/client/constants.ts +0 -11
  113. package/src/client/fields/circle.ts +0 -23
  114. package/src/client/fields/index.ts +0 -11
  115. package/src/client/fields/lineString.ts +0 -23
  116. package/src/client/fields/point.ts +0 -23
  117. package/src/client/fields/polygon.ts +0 -23
  118. package/src/client/fields/schema.ts +0 -54
  119. package/src/client/hooks/index.ts +0 -1
  120. package/src/client/hooks/useMapConfiguration.ts +0 -42
  121. package/src/client/index.tsx +0 -55
  122. package/src/client/initialize.tsx +0 -32
  123. package/src/client/locale/index.ts +0 -19
  124. package/src/client/types.ts +0 -1
  125. package/src/client/utils.ts +0 -0
  126. package/src/index.ts +0 -1
  127. package/src/locale/en-US.ts +0 -3
  128. package/src/locale/fr-FR.ts +0 -3
  129. package/src/locale/pt-BR.ts +0 -51
  130. package/src/locale/zh-CN.ts +0 -52
  131. package/src/server/__tests__/fields.test.ts +0 -157
  132. package/src/server/actions/index.ts +0 -44
  133. package/src/server/collections/mapConfiguration.ts +0 -29
  134. package/src/server/constants.ts +0 -1
  135. package/src/server/fields/.gitkeep +0 -0
  136. package/src/server/fields/circle.ts +0 -48
  137. package/src/server/fields/index.ts +0 -4
  138. package/src/server/fields/lineString.ts +0 -55
  139. package/src/server/fields/point.ts +0 -58
  140. package/src/server/fields/polygon.ts +0 -54
  141. package/src/server/helpers/index.ts +0 -25
  142. package/src/server/index.ts +0 -1
  143. package/src/server/plugin.ts +0 -57
  144. package/src/server/value-parsers/index.ts +0 -55
  145. /package/{lib → dist}/client/block/MapActionInitializers.d.ts +0 -0
  146. /package/{lib → dist}/client/block/MapBlock.d.ts +0 -0
  147. /package/{lib → dist}/client/block/MapBlockDesigner.d.ts +0 -0
  148. /package/{lib → dist}/client/block/MapBlockInitializer.d.ts +0 -0
  149. /package/{lib → dist}/client/block/MapBlockProvider.d.ts +0 -0
  150. /package/{lib → dist}/client/block/index.d.ts +0 -0
  151. /package/{lib → dist}/client/block/utils.d.ts +0 -0
  152. /package/{lib → dist}/client/components/AMap/Block.d.ts +0 -0
  153. /package/{lib → dist}/client/components/AMap/Map.d.ts +0 -0
  154. /package/{lib → dist}/client/components/AMap/Search.d.ts +0 -0
  155. /package/{lib → dist}/client/components/AMap/index.d.ts +0 -0
  156. /package/{lib → dist}/client/components/Configuration.d.ts +0 -0
  157. /package/{lib → dist}/client/components/Designer.d.ts +0 -0
  158. /package/{lib → dist}/client/components/GoogleMaps/Block.d.ts +0 -0
  159. /package/{lib → dist}/client/components/GoogleMaps/Map.d.ts +0 -0
  160. /package/{lib → dist}/client/components/GoogleMaps/Search.d.ts +0 -0
  161. /package/{lib → dist}/client/components/GoogleMaps/index.d.ts +0 -0
  162. /package/{lib → dist}/client/components/GoogleMaps/utils.d.ts +0 -0
  163. /package/{lib → dist}/client/components/Map.d.ts +0 -0
  164. /package/{lib → dist}/client/components/MapBlock.d.ts +0 -0
  165. /package/{lib → dist}/client/components/MapComponent.d.ts +0 -0
  166. /package/{lib → dist}/client/components/ReadPretty.d.ts +0 -0
  167. /package/{lib → dist}/client/components/index.d.ts +0 -0
  168. /package/{lib → dist}/client/constants.d.ts +0 -0
  169. /package/{lib → dist}/client/fields/circle.d.ts +0 -0
  170. /package/{lib → dist}/client/fields/index.d.ts +0 -0
  171. /package/{lib → dist}/client/fields/lineString.d.ts +0 -0
  172. /package/{lib → dist}/client/fields/point.d.ts +0 -0
  173. /package/{lib → dist}/client/fields/polygon.d.ts +0 -0
  174. /package/{lib → dist}/client/fields/schema.d.ts +0 -0
  175. /package/{lib → dist}/client/hooks/index.d.ts +0 -0
  176. /package/{lib → dist}/client/hooks/useMapConfiguration.d.ts +0 -0
  177. /package/{lib → dist}/client/index.d.ts +0 -0
  178. /package/{lib → dist}/client/initialize.d.ts +0 -0
  179. /package/{lib → dist}/client/locale/index.d.ts +0 -0
  180. /package/{lib → dist}/client/types.d.ts +0 -0
  181. /package/{lib → dist}/client/utils.d.ts +0 -0
  182. /package/{lib → dist}/locale/en-US.d.ts +0 -0
  183. /package/{lib → dist}/locale/fr-FR.d.ts +0 -0
  184. /package/{lib → dist}/locale/pt-BR.d.ts +0 -0
  185. /package/{lib → dist}/locale/zh-CN.d.ts +0 -0
  186. /package/{lib → dist}/server/actions/index.d.ts +0 -0
  187. /package/{lib → dist}/server/collections/mapConfiguration.d.ts +0 -0
  188. /package/{lib → dist}/server/constants.d.ts +0 -0
  189. /package/{lib → dist}/server/fields/circle.d.ts +0 -0
  190. /package/{lib → dist}/server/fields/index.d.ts +0 -0
  191. /package/{lib → dist}/server/fields/lineString.d.ts +0 -0
  192. /package/{lib → dist}/server/fields/point.d.ts +0 -0
  193. /package/{lib → dist}/server/fields/polygon.d.ts +0 -0
  194. /package/{lib → dist}/server/helpers/index.d.ts +0 -0
  195. /package/{lib → dist}/server/index.d.ts +0 -0
  196. /package/{lib → dist}/server/plugin.d.ts +0 -0
  197. /package/{lib → dist}/server/value-parsers/index.d.ts +0 -0
@@ -1 +1,2 @@
1
+ export * from './server';
1
2
  export { default } from './server';
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var server = require('./server');
6
+
7
+
8
+
9
+ Object.defineProperty(exports, 'default', {
10
+ enumerable: true,
11
+ get: function () { return server__namespace.default; }
12
+ });
13
+ Object.keys(server).forEach(function (k) {
14
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
15
+ enumerable: true,
16
+ get: function () { return server[k]; }
17
+ });
18
+ });
@@ -0,0 +1,6 @@
1
+ 'use strict';
2
+
3
+ const locale = {};
4
+ var en_US_default = locale;
5
+
6
+ module.exports = en_US_default;
@@ -0,0 +1,6 @@
1
+ 'use strict';
2
+
3
+ const locale = {};
4
+ var fr_FR_default = locale;
5
+
6
+ module.exports = fr_FR_default;
@@ -0,0 +1,51 @@
1
+ 'use strict';
2
+
3
+ const locale = {
4
+ "Map-based geometry": "Geometria baseada em mapa",
5
+ "Map type": "Tipo de mapa",
6
+ Point: "Ponto",
7
+ Line: "Linha",
8
+ Circle: "C\xEDrculo",
9
+ Polygon: "Pol\xEDgono",
10
+ "Access key": "Chave de acesso",
11
+ "securityJsCode or serviceHost": "securityJsCode ou serviceHost",
12
+ AMap: "AMap",
13
+ "Google Maps": "Google Maps",
14
+ Clear: "Limpar",
15
+ "Click to select the starting point and double-click to end the drawing": "Clique para selecionar o ponto de partida e d\xEA um duplo clique para terminar a cria\xE7\xE3o",
16
+ "Clear the canvas": "Limpar a tela",
17
+ "Are you sure to clear the canvas?": "Tem certeza de que deseja limpar a tela?",
18
+ Confirm: "Confirmar",
19
+ Cancel: "Cancelar",
20
+ "Enter keywords to search": "Digite palavras-chave para buscar",
21
+ "The AccessKey is incorrect, please check it": "A chave de acesso est\xE1 incorreta, por favor verifique",
22
+ "Please configure the AMap securityCode or serviceHost correctly": "Por favor, configure o securityCode ou serviceHost do AMap corretamente",
23
+ "Map Manager": "Gerenciador de Mapa",
24
+ Configuration: "Configura\xE7\xE3o",
25
+ "Saved successfully": "Salvo com sucesso",
26
+ "Saved failed": "Falha ao salvar",
27
+ Edit: "Editar",
28
+ Save: "Salvar",
29
+ "Please configure the AccessKey and SecurityJsCode first": "Por favor, configure a AccessKey e o SecurityJsCode primeiro",
30
+ "Go to the configuration page": "Ir para a p\xE1gina de configura\xE7\xE3o",
31
+ Zoom: "Zoom",
32
+ "Set default zoom level": "Definir n\xEDvel de zoom padr\xE3o",
33
+ "The default zoom level of the map": "O n\xEDvel de zoom padr\xE3o do mapa",
34
+ // Designer
35
+ "Edit field title": "Editar t\xEDtulo do campo",
36
+ "Field title": "T\xEDtulo do campo",
37
+ "Edit tooltip": "Editar dica de ferramenta",
38
+ "Delete field": "Excluir campo",
39
+ Required: "Obrigat\xF3rio",
40
+ Pattern: "Padr\xE3o",
41
+ Operator: "Operador",
42
+ Editable: "Edit\xE1vel",
43
+ Readonly: "Somente leitura",
44
+ "Easy-reading": "Apenas leitura (Modo de Leitura)",
45
+ "Edit description": "Editar descri\xE7\xE3o",
46
+ "Map field": "Campo de mapa",
47
+ "Marker field": "Campo de marcador"
48
+ };
49
+ var pt_BR_default = locale;
50
+
51
+ module.exports = pt_BR_default;
@@ -0,0 +1,54 @@
1
+ 'use strict';
2
+
3
+ const locale = {
4
+ Map: "\u5730\u56FE",
5
+ "Map-based geometry": "\u57FA\u4E8E\u5730\u56FE\u7684\u51E0\u4F55\u56FE\u5F62",
6
+ "Map type": "\u5730\u56FE\u7C7B\u578B",
7
+ Point: "\u70B9",
8
+ Line: "\u7EBF",
9
+ Circle: "\u5706",
10
+ Polygon: "\u591A\u8FB9\u5F62",
11
+ "Access key": "\u8BBF\u95EE\u5BC6\u94A5",
12
+ "securityJsCode or serviceHost": "securityJsCode \u6216 serviceHost",
13
+ AMap: "\u9AD8\u5FB7\u5730\u56FE",
14
+ "Google Maps": "\u8C37\u6B4C\u5730\u56FE",
15
+ Clear: "\u6E05\u7A7A",
16
+ "Click to select the starting point and double-click to end the drawing": "\u70B9\u51FB\u9009\u62E9\u8D77\u70B9\uFF0C\u53CC\u51FB\u7ED3\u675F\u7ED8\u5236",
17
+ "Clear the canvas": "\u6E05\u7A7A\u753B\u5E03",
18
+ "Are you sure to clear the canvas?": "\u60A8\u786E\u5B9A\u8981\u6E05\u7A7A\u753B\u5E03\u5417\uFF1F",
19
+ Confirm: "\u786E\u5B9A",
20
+ Cancel: "\u53D6\u6D88",
21
+ "Enter keywords to search": "\u8F93\u5165\u5730\u65B9\u540D\u5173\u952E\u5B57\u641C\u7D22\uFF08\u5FC5\u987B\u5305\u542B\u7701/\u5E02\uFF09",
22
+ "The AccessKey is incorrect, please check it": "\u8BBF\u95EE\u5BC6\u94A5\u4E0D\u6B63\u786E\uFF0C\u8BF7\u68C0\u67E5",
23
+ "Please configure the AMap securityCode or serviceHost correctly": "\u8BF7\u6B63\u786E\u914D\u7F6E\u9AD8\u5FB7\u5730\u56FE securityCode \u6216 serviceHost",
24
+ "Map Manager": "\u5730\u56FE\u7BA1\u7406",
25
+ Configuration: "\u914D\u7F6E",
26
+ "Saved successfully": "\u4FDD\u5B58\u6210\u529F",
27
+ "Saved failed": "\u4FDD\u5B58\u5931\u8D25",
28
+ Edit: "\u7F16\u8F91",
29
+ Save: "\u4FDD\u5B58",
30
+ "Please configure the AccessKey and SecurityJsCode first": "\u8BF7\u5148\u914D\u7F6E AccessKey \u548C SecurityJsCode",
31
+ "Go to the configuration page": "\u524D\u5F80\u914D\u7F6E\u9875\u9762",
32
+ Zoom: "\u7F29\u653E",
33
+ "Set default zoom level": "\u8BBE\u7F6E\u9ED8\u8BA4\u7F29\u653E\u7EA7\u522B",
34
+ "The default zoom level of the map": "\u5730\u56FE\u9ED8\u8BA4\u7F29\u653E\u7EA7\u522B",
35
+ // Designer
36
+ "Edit field title": "\u7F16\u8F91\u5B57\u6BB5\u6807\u9898",
37
+ "Field title": "\u5B57\u6BB5\u6807\u9898",
38
+ "Edit tooltip": "\u7F16\u8F91\u63D0\u793A\u4FE1\u606F",
39
+ "Delete field": "\u5220\u9664\u5B57\u6BB5",
40
+ Required: "\u5FC5\u586B",
41
+ Pattern: "\u6A21\u5F0F",
42
+ Operator: "\u8FD0\u7B97\u7B26",
43
+ Editable: "\u53EF\u7F16\u8F91",
44
+ Readonly: "\u53EA\u8BFB\uFF08\u7981\u6B62\u7F16\u8F91\uFF09",
45
+ "Easy-reading": "\u53EA\u8BFB\uFF08\u9605\u8BFB\u6A21\u5F0F\uFF09",
46
+ "Edit description": "\u7F16\u8F91\u63CF\u8FF0",
47
+ "Map field": "\u5730\u56FE\u5B57\u6BB5",
48
+ "Marker field": "\u6807\u8BB0\u5B57\u6BB5",
49
+ "Load google maps failed, Please check the Api key and refresh the page": "\u52A0\u8F7D\u8C37\u6B4C\u5730\u56FE\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5 Api key \u5E76\u5237\u65B0\u9875\u9762",
50
+ "Create map block": "\u521B\u5EFA\u5730\u56FE\u533A\u5757"
51
+ };
52
+ var zh_CN_default = locale;
53
+
54
+ module.exports = zh_CN_default;
@@ -0,0 +1,43 @@
1
+ 'use strict';
2
+
3
+ var constants = require('../constants');
4
+
5
+ const getConfiguration = async (ctx, next) => {
6
+ const {
7
+ params: { type }
8
+ } = ctx.action;
9
+ const repo = ctx.db.getRepository(constants.MapConfigurationCollectionName);
10
+ const record = await repo.findOne({
11
+ filter: {
12
+ type
13
+ }
14
+ });
15
+ ctx.body = record;
16
+ return next();
17
+ };
18
+ const setConfiguration = async (ctx, next) => {
19
+ const { params: values } = ctx.action;
20
+ const repo = ctx.db.getRepository(constants.MapConfigurationCollectionName);
21
+ const record = await repo.findOne({
22
+ filter: {
23
+ type: values.type
24
+ }
25
+ });
26
+ if (record) {
27
+ await repo.update({
28
+ values,
29
+ filter: {
30
+ type: values.type
31
+ }
32
+ });
33
+ } else {
34
+ await repo.create({
35
+ values
36
+ });
37
+ }
38
+ ctx.body = "ok";
39
+ return next();
40
+ };
41
+
42
+ exports.getConfiguration = getConfiguration;
43
+ exports.setConfiguration = setConfiguration;
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ var constants = require('../constants');
4
+
5
+ var mapConfiguration_default = {
6
+ namespace: "map.mapConfiguration",
7
+ duplicator: "optional",
8
+ name: constants.MapConfigurationCollectionName,
9
+ title: '{{t("Map Manager")}}',
10
+ fields: [
11
+ {
12
+ title: "Access key",
13
+ comment: "\u8BBF\u95EE\u5BC6\u94A5",
14
+ name: "accessKey",
15
+ type: "string"
16
+ },
17
+ {
18
+ title: "securityJsCode",
19
+ comment: "securityJsCode or serviceHOST",
20
+ name: "securityJsCode",
21
+ type: "string"
22
+ },
23
+ {
24
+ title: "Map type",
25
+ comment: "\u5730\u56FE\u7C7B\u578B",
26
+ name: "type",
27
+ type: "string"
28
+ }
29
+ ]
30
+ };
31
+
32
+ module.exports = mapConfiguration_default;
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ const MapConfigurationCollectionName = "mapConfiguration";
4
+
5
+ exports.MapConfigurationCollectionName = MapConfigurationCollectionName;
@@ -0,0 +1,47 @@
1
+ 'use strict';
2
+
3
+ var database = require('@nocobase/database');
4
+ var helpers = require('../helpers');
5
+
6
+ class Circle extends database.DataTypes.ABSTRACT {
7
+ key = "Circle";
8
+ }
9
+ class CircleField extends database.Field {
10
+ constructor(options, context) {
11
+ const { name } = options;
12
+ super(
13
+ {
14
+ get() {
15
+ const value = this.getDataValue(name);
16
+ if (helpers.isPg(context)) {
17
+ if (typeof value === "string") {
18
+ return helpers.toValue(`(${value})`);
19
+ }
20
+ return value ? [value.x, value.y, value.radius] : null;
21
+ } else {
22
+ return value;
23
+ }
24
+ },
25
+ set(value) {
26
+ if (!(value == null ? void 0 : value.length))
27
+ value = null;
28
+ else if (helpers.isPg(context)) {
29
+ value = value.join(",");
30
+ }
31
+ this.setDataValue(name, value);
32
+ },
33
+ ...options
34
+ },
35
+ context
36
+ );
37
+ }
38
+ get dataType() {
39
+ if (helpers.isPg(this.context)) {
40
+ return Circle;
41
+ } else {
42
+ return database.DataTypes.JSON;
43
+ }
44
+ }
45
+ }
46
+
47
+ exports.CircleField = CircleField;
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ var point = require('./point');
4
+ var lineString = require('./lineString');
5
+ var polygon = require('./polygon');
6
+ var circle = require('./circle');
7
+
8
+
9
+
10
+ Object.keys(point).forEach(function (k) {
11
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
12
+ enumerable: true,
13
+ get: function () { return point[k]; }
14
+ });
15
+ });
16
+ Object.keys(lineString).forEach(function (k) {
17
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
18
+ enumerable: true,
19
+ get: function () { return lineString[k]; }
20
+ });
21
+ });
22
+ Object.keys(polygon).forEach(function (k) {
23
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
24
+ enumerable: true,
25
+ get: function () { return polygon[k]; }
26
+ });
27
+ });
28
+ Object.keys(circle).forEach(function (k) {
29
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
30
+ enumerable: true,
31
+ get: function () { return circle[k]; }
32
+ });
33
+ });
@@ -0,0 +1,54 @@
1
+ 'use strict';
2
+
3
+ var database = require('@nocobase/database');
4
+ var helpers = require('../helpers');
5
+
6
+ class LineString extends database.DataTypes.ABSTRACT {
7
+ key = "Path";
8
+ }
9
+ class LineStringField extends database.Field {
10
+ constructor(options, context) {
11
+ const { name } = options;
12
+ super(
13
+ {
14
+ get() {
15
+ const value = this.getDataValue(name);
16
+ if (helpers.isPg(context)) {
17
+ return helpers.toValue(value);
18
+ } else if (helpers.isMysql(context)) {
19
+ return (value == null ? void 0 : value.coordinates) || null;
20
+ } else {
21
+ return value;
22
+ }
23
+ },
24
+ set(value) {
25
+ if (!(value == null ? void 0 : value.length))
26
+ value = null;
27
+ else if (helpers.isPg(context)) {
28
+ value = helpers.joinComma(value.map(helpers.joinComma));
29
+ } else if (helpers.isMysql(context)) {
30
+ value = {
31
+ type: "LineString",
32
+ coordinates: value
33
+ };
34
+ }
35
+ this.setDataValue(name, value);
36
+ },
37
+ ...options
38
+ },
39
+ context
40
+ );
41
+ }
42
+ get dataType() {
43
+ if (helpers.isPg(this.context)) {
44
+ return LineString;
45
+ }
46
+ if (helpers.isMysql(this.context)) {
47
+ return database.DataTypes.GEOMETRY("LINESTRING");
48
+ } else {
49
+ return database.DataTypes.JSON;
50
+ }
51
+ }
52
+ }
53
+
54
+ exports.LineStringField = LineStringField;
@@ -0,0 +1,57 @@
1
+ 'use strict';
2
+
3
+ var database = require('@nocobase/database');
4
+ var helpers = require('../helpers');
5
+
6
+ class Point extends database.DataTypes.ABSTRACT {
7
+ key = "Point";
8
+ }
9
+ class PointField extends database.Field {
10
+ constructor(options, context) {
11
+ const { name } = options;
12
+ super(
13
+ {
14
+ get() {
15
+ const value = this.getDataValue(name);
16
+ if (helpers.isPg(context)) {
17
+ if (typeof value === "string") {
18
+ return helpers.toValue(value);
19
+ }
20
+ return value ? [value.x, value.y] : null;
21
+ } else if (helpers.isMysql(context)) {
22
+ return (value == null ? void 0 : value.coordinates) || null;
23
+ } else {
24
+ return value;
25
+ }
26
+ },
27
+ set(value) {
28
+ if (!(value == null ? void 0 : value.length))
29
+ value = null;
30
+ else if (helpers.isPg(context)) {
31
+ value = helpers.joinComma(value);
32
+ } else if (helpers.isMysql(context)) {
33
+ value = {
34
+ type: "Point",
35
+ coordinates: value
36
+ };
37
+ }
38
+ this.setDataValue(name, value);
39
+ },
40
+ ...options
41
+ },
42
+ context
43
+ );
44
+ }
45
+ get dataType() {
46
+ if (helpers.isPg(this.context)) {
47
+ return Point;
48
+ }
49
+ if (helpers.isMysql(this.context)) {
50
+ return database.DataTypes.GEOMETRY("POINT");
51
+ } else {
52
+ return database.DataTypes.JSON;
53
+ }
54
+ }
55
+ }
56
+
57
+ exports.PointField = PointField;
@@ -0,0 +1,53 @@
1
+ 'use strict';
2
+
3
+ var database = require('@nocobase/database');
4
+ var helpers = require('../helpers');
5
+
6
+ class Polygon extends database.DataTypes.ABSTRACT {
7
+ key = "Polygon";
8
+ }
9
+ class PolygonField extends database.Field {
10
+ constructor(options, context) {
11
+ const { name } = options;
12
+ super(
13
+ {
14
+ get() {
15
+ const value = this.getDataValue(name);
16
+ if (helpers.isPg(context)) {
17
+ return helpers.toValue(value);
18
+ } else if (helpers.isMysql(context)) {
19
+ return (value == null ? void 0 : value.coordinates[0].slice(0, -1)) || null;
20
+ } else {
21
+ return value;
22
+ }
23
+ },
24
+ set(value) {
25
+ if (!(value == null ? void 0 : value.length))
26
+ value = null;
27
+ else if (helpers.isPg(context)) {
28
+ value = helpers.joinComma(value.map((item) => helpers.joinComma(item)));
29
+ } else if (helpers.isMysql(context)) {
30
+ value = {
31
+ type: "Polygon",
32
+ coordinates: [value.concat([value[0]])]
33
+ };
34
+ }
35
+ this.setDataValue(name, value);
36
+ },
37
+ ...options
38
+ },
39
+ context
40
+ );
41
+ }
42
+ get dataType() {
43
+ if (helpers.isPg(this.context)) {
44
+ return Polygon;
45
+ } else if (helpers.isMysql(this.context)) {
46
+ return database.DataTypes.GEOMETRY("POLYGON");
47
+ } else {
48
+ return database.DataTypes.JSON;
49
+ }
50
+ }
51
+ }
52
+
53
+ exports.PolygonField = PolygonField;
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ const joinComma = (value) => {
4
+ if (!value)
5
+ return null;
6
+ return `(${value.join(",")})`;
7
+ };
8
+ const toValue = (value) => {
9
+ if (!value)
10
+ return null;
11
+ return JSON.parse(value.replace(/\(/g, "[").replace(/\)/g, "]"));
12
+ };
13
+ const getDialect = (ctx) => {
14
+ return (ctx.db || ctx.database).sequelize.getDialect();
15
+ };
16
+ const isPg = (ctx) => {
17
+ return getDialect(ctx) === "postgres";
18
+ };
19
+ const isSqlite = (ctx) => {
20
+ return getDialect(ctx) === "sqlite";
21
+ };
22
+ const isMysql = (ctx) => {
23
+ return getDialect(ctx) === "mysql";
24
+ };
25
+
26
+ exports.getDialect = getDialect;
27
+ exports.isMysql = isMysql;
28
+ exports.isPg = isPg;
29
+ exports.isSqlite = isSqlite;
30
+ exports.joinComma = joinComma;
31
+ exports.toValue = toValue;
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ var plugin = require('./plugin');
4
+
5
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
+
7
+ var plugin__default = /*#__PURE__*/_interopDefault(plugin);
8
+
9
+
10
+
11
+ module.exports = plugin__default.default;
@@ -0,0 +1,59 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var server = require('@nocobase/server');
6
+ var path = require('path');
7
+ var actions = require('./actions');
8
+ var fields = require('./fields');
9
+ var valueParsers = require('./value-parsers');
10
+
11
+ class MapPlugin extends server.Plugin {
12
+ afterAdd() {
13
+ }
14
+ beforeLoad() {
15
+ const fields$1 = {
16
+ point: fields.PointField,
17
+ polygon: fields.PolygonField,
18
+ lineString: fields.LineStringField,
19
+ circle: fields.CircleField
20
+ };
21
+ this.db.registerFieldTypes(fields$1);
22
+ this.db.registerFieldValueParsers({
23
+ point: valueParsers.PointValueParser,
24
+ polygon: valueParsers.PolygonValueParser,
25
+ lineString: valueParsers.LineStringValueParser,
26
+ circle: valueParsers.CircleValueParser
27
+ });
28
+ }
29
+ async load() {
30
+ await this.db.import({
31
+ directory: path.resolve(__dirname, "collections")
32
+ });
33
+ this.app.resource({
34
+ name: "map-configuration",
35
+ actions: {
36
+ get: actions.getConfiguration,
37
+ set: actions.setConfiguration
38
+ },
39
+ only: ["get", "set"]
40
+ });
41
+ this.app.acl.registerSnippet({
42
+ name: `pm.${this.name}.configuration`,
43
+ actions: ["map-configuration:set"]
44
+ });
45
+ this.app.acl.allow("map-configuration", "get", "loggedIn");
46
+ }
47
+ async install(options) {
48
+ }
49
+ async afterEnable() {
50
+ }
51
+ async afterDisable() {
52
+ }
53
+ async remove() {
54
+ }
55
+ }
56
+ var plugin_default = MapPlugin;
57
+
58
+ exports.MapPlugin = MapPlugin;
59
+ exports.default = plugin_default;
@@ -0,0 +1,53 @@
1
+ 'use strict';
2
+
3
+ var database = require('@nocobase/database');
4
+
5
+ class PointValueParser extends database.BaseValueParser {
6
+ async setValue(value) {
7
+ if (Array.isArray(value)) {
8
+ this.value = value;
9
+ } else if (typeof value === "string") {
10
+ this.value = value.split(",");
11
+ } else {
12
+ this.errors.push("Value invalid");
13
+ }
14
+ }
15
+ }
16
+ class PolygonValueParser extends database.BaseValueParser {
17
+ async setValue(value) {
18
+ if (Array.isArray(value)) {
19
+ this.value = value;
20
+ } else if (typeof value === "string") {
21
+ this.value = value.substring(1, value.length - 1).split("),(").map((v) => v.split(","));
22
+ } else {
23
+ this.errors.push("Value invalid");
24
+ }
25
+ }
26
+ }
27
+ class LineStringValueParser extends database.BaseValueParser {
28
+ async setValue(value) {
29
+ if (Array.isArray(value)) {
30
+ this.value = value;
31
+ } else if (typeof value === "string") {
32
+ this.value = value.substring(1, value.length - 1).split("),(").map((v) => v.split(","));
33
+ } else {
34
+ this.errors.push("Value invalid");
35
+ }
36
+ }
37
+ }
38
+ class CircleValueParser extends database.BaseValueParser {
39
+ async setValue(value) {
40
+ if (Array.isArray(value)) {
41
+ this.value = value;
42
+ } else if (typeof value === "string") {
43
+ this.value = value.split(",");
44
+ } else {
45
+ this.errors.push("Value invalid");
46
+ }
47
+ }
48
+ }
49
+
50
+ exports.CircleValueParser = CircleValueParser;
51
+ exports.LineStringValueParser = LineStringValueParser;
52
+ exports.PointValueParser = PointValueParser;
53
+ exports.PolygonValueParser = PolygonValueParser;
@@ -0,0 +1 @@
1
+ # Map Changelog
@@ -0,0 +1 @@
1
+ # Map overview
@@ -0,0 +1 @@
1
+ # Map Installation
@@ -0,0 +1,18 @@
1
+ [
2
+ {
3
+ "title": "Introduction",
4
+ "path": "index"
5
+ },
6
+ {
7
+ "title": "Installation",
8
+ "path": "installation"
9
+ },
10
+ {
11
+ "title": "Usage",
12
+ "path": "usage"
13
+ },
14
+ {
15
+ "title": "Changelog",
16
+ "path": "changelog"
17
+ }
18
+ ]
@@ -0,0 +1 @@
1
+ # Map Usage
@@ -0,0 +1 @@
1
+ # 地图更新日志
@@ -0,0 +1 @@
1
+ # 地图
@@ -0,0 +1 @@
1
+ # 地图安装方法