@geode/opengeodeweb-front 10.7.0 → 10.8.0-rc.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.
Files changed (89) hide show
  1. package/app/components/ObjectSelector.vue +0 -2
  2. package/app/components/Viewer/BreadCrumb.vue +6 -1
  3. package/app/components/Viewer/TreeComponent.vue +8 -9
  4. package/app/stores/app.js +1 -0
  5. package/app/stores/data.js +16 -3
  6. package/app/stores/data_style.js +28 -25
  7. package/app/stores/hybrid_viewer.js +0 -1
  8. package/app/utils/extension.js +1 -1
  9. package/app/utils/file_import_workflow.js +1 -0
  10. package/app/utils/local/cleanup.js +5 -1
  11. package/app/utils/local/microservices.js +1 -13
  12. package/app/utils/local/path.js +20 -1
  13. package/internal/database/base_database.js +22 -0
  14. package/internal/database/database.js +5 -20
  15. package/internal/database/extended_database.js +3 -10
  16. package/internal/database/tables/data_style.js +4 -0
  17. package/internal/database/tables/model_component_datastyle.js +4 -0
  18. package/internal/stores/data_style/mesh/cells/cell.js +12 -39
  19. package/internal/stores/data_style/mesh/cells/color.js +4 -4
  20. package/internal/stores/data_style/mesh/cells/common.js +19 -3
  21. package/internal/stores/data_style/mesh/cells/index.js +16 -10
  22. package/internal/stores/data_style/mesh/cells/textures.js +4 -4
  23. package/internal/stores/data_style/mesh/cells/vertex.js +35 -42
  24. package/internal/stores/data_style/mesh/cells/visibility.js +1 -4
  25. package/internal/stores/data_style/mesh/edges/color.js +4 -4
  26. package/internal/stores/data_style/mesh/edges/common.js +12 -3
  27. package/internal/stores/data_style/mesh/edges/edge.js +40 -40
  28. package/internal/stores/data_style/mesh/edges/index.js +18 -19
  29. package/internal/stores/data_style/mesh/edges/vertex.js +37 -44
  30. package/internal/stores/data_style/mesh/edges/visibility.js +1 -5
  31. package/internal/stores/data_style/mesh/edges/width.js +1 -5
  32. package/internal/stores/data_style/mesh/index.js +32 -5
  33. package/internal/stores/data_style/mesh/points/color.js +4 -4
  34. package/internal/stores/data_style/mesh/points/common.js +12 -3
  35. package/internal/stores/data_style/mesh/points/index.js +34 -32
  36. package/internal/stores/data_style/mesh/points/size.js +1 -4
  37. package/internal/stores/data_style/mesh/points/vertex.js +79 -65
  38. package/internal/stores/data_style/mesh/points/visibility.js +1 -4
  39. package/internal/stores/data_style/mesh/polygons/color.js +4 -4
  40. package/internal/stores/data_style/mesh/polygons/common.js +12 -3
  41. package/internal/stores/data_style/mesh/polygons/index.js +35 -24
  42. package/internal/stores/data_style/mesh/polygons/polygon.js +40 -34
  43. package/internal/stores/data_style/mesh/polygons/textures.js +4 -4
  44. package/internal/stores/data_style/mesh/polygons/vertex.js +35 -42
  45. package/internal/stores/data_style/mesh/polygons/visibility.js +4 -4
  46. package/internal/stores/data_style/mesh/polyhedra/color.js +4 -4
  47. package/internal/stores/data_style/mesh/polyhedra/common.js +12 -3
  48. package/internal/stores/data_style/mesh/polyhedra/index.js +21 -11
  49. package/internal/stores/data_style/mesh/polyhedra/polyhedron.js +80 -60
  50. package/internal/stores/data_style/mesh/polyhedra/vertex.js +79 -65
  51. package/internal/stores/data_style/mesh/polyhedra/visibility.js +4 -4
  52. package/internal/stores/data_style/model/blocks/color.js +17 -29
  53. package/internal/stores/data_style/model/blocks/common.js +14 -4
  54. package/internal/stores/data_style/model/blocks/index.js +38 -8
  55. package/internal/stores/data_style/model/blocks/visibility.js +19 -30
  56. package/internal/stores/data_style/model/corners/color.js +16 -29
  57. package/internal/stores/data_style/model/corners/common.js +14 -4
  58. package/internal/stores/data_style/model/corners/index.js +42 -8
  59. package/internal/stores/data_style/model/corners/visibility.js +16 -29
  60. package/internal/stores/data_style/model/edges/common.js +8 -1
  61. package/internal/stores/data_style/model/edges/index.js +2 -5
  62. package/internal/stores/data_style/model/edges/visibility.js +7 -5
  63. package/internal/stores/data_style/model/index.js +102 -133
  64. package/internal/stores/data_style/model/lines/color.js +20 -29
  65. package/internal/stores/data_style/model/lines/common.js +14 -4
  66. package/internal/stores/data_style/model/lines/index.js +35 -6
  67. package/internal/stores/data_style/model/lines/visibility.js +19 -29
  68. package/internal/stores/data_style/model/points/common.js +7 -0
  69. package/internal/stores/data_style/model/points/size.js +1 -4
  70. package/internal/stores/data_style/model/points/visibility.js +4 -4
  71. package/internal/stores/data_style/model/surfaces/color.js +16 -29
  72. package/internal/stores/data_style/model/surfaces/common.js +14 -4
  73. package/internal/stores/data_style/model/surfaces/index.js +37 -6
  74. package/internal/stores/data_style/model/surfaces/visibility.js +17 -29
  75. package/internal/stores/data_style/state.js +126 -5
  76. package/internal/utils/viewer_call.js +1 -1
  77. package/package.json +3 -3
  78. package/server/api/extensions/run.post.js +8 -1
  79. package/tests/integration/microservices/back/requirements.txt +7 -0
  80. package/tests/integration/microservices/viewer/requirements.txt +7 -0
  81. package/tests/integration/stores/data_style/mesh/cells.nuxt.test.js +3 -1
  82. package/tests/integration/stores/data_style/model/blocks.nuxt.test.js +10 -0
  83. package/tests/integration/stores/data_style/model/corners.nuxt.test.js +10 -0
  84. package/tests/integration/stores/data_style/model/edges.nuxt.test.js +9 -0
  85. package/tests/integration/stores/data_style/model/index.nuxt.test.js +9 -0
  86. package/tests/integration/stores/data_style/model/lines.nuxt.test.js +10 -0
  87. package/tests/integration/stores/data_style/model/points.nuxt.test.js +10 -0
  88. package/tests/integration/stores/data_style/model/surfaces.nuxt.test.js +10 -0
  89. package/tests/unit/plugins/project_load.nuxt.test.js +13 -6
@@ -7,7 +7,6 @@ import { useGeodeStore } from "@ogw_front/stores/geode";
7
7
  const schema = schemas.opengeodeweb_back.allowed_objects;
8
8
 
9
9
  const emit = defineEmits(["update_values", "increment_step"]);
10
- console.log("ObjectSelector");
11
10
 
12
11
  const { filenames } = defineProps({
13
12
  filenames: { type: Array, required: true },
@@ -78,7 +77,6 @@ async function get_allowed_objects() {
78
77
  }
79
78
 
80
79
  function set_geode_object(geode_object_type) {
81
- console.log("set_geode_object", { geode_object_type });
82
80
  if (geode_object_type) {
83
81
  emit("update_values", { geode_object_type });
84
82
  emit("increment_step");
@@ -13,7 +13,12 @@ function goBackToFileTree() {
13
13
 
14
14
  const model_id = computed(() => treeviewStore.model_id);
15
15
 
16
- const metaDatas = dataStore.refItem(model_id.value);
16
+ const metaDatas = computed(() => {
17
+ if (!model_id.value) {
18
+ return {};
19
+ }
20
+ return dataStore.refItem(model_id.value).value || {};
21
+ });
17
22
  </script>
18
23
 
19
24
  <template>
@@ -1,24 +1,18 @@
1
1
  <script setup>
2
+ import { compareSelections } from "@ogw_front/utils/treeview";
2
3
  import { useDataStore } from "@ogw_front/stores/data";
3
4
  import { useDataStyleStore } from "@ogw_front/stores/data_style";
4
5
  import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
5
6
 
6
- import { compareSelections } from "@ogw_front/utils/treeview";
7
-
8
7
  const dataStyleStore = useDataStyleStore();
9
8
  const dataStore = useDataStore();
10
9
  const hybridViewerStore = useHybridViewerStore();
11
10
 
12
11
  const { id } = defineProps({ id: { type: String, required: true } });
13
-
14
12
  const emit = defineEmits(["show-menu"]);
15
13
 
16
- const items = ref([]);
17
- const mesh_components_selection = dataStyleStore.visibleMeshComponents(id);
18
-
19
- watchEffect(async () => {
20
- items.value = await dataStore.formatedMeshComponents(id);
21
- });
14
+ const items = dataStore.refFormatedMeshComponents(id);
15
+ const mesh_components_selection = computed(() => dataStyleStore.visibleMeshComponents(id));
22
16
 
23
17
  watch(
24
18
  mesh_components_selection,
@@ -28,6 +22,11 @@ watch(
28
22
  }
29
23
 
30
24
  const { added, removed } = compareSelections(current, previous);
25
+ console.log("TreeComponent selection change:", {
26
+ id: props.id,
27
+ added,
28
+ removed,
29
+ });
31
30
 
32
31
  if (added.length > 0) {
33
32
  await dataStyleStore.setModelMeshComponentsVisibility(id, added, true);
package/app/stores/app.js CHANGED
@@ -1,3 +1,4 @@
1
+ // Local imports
1
2
  import { api_fetch } from "@ogw_internal/utils/api_fetch.js";
2
3
  import { upload_file } from "@ogw_internal/utils/upload_file.js";
3
4
 
@@ -12,8 +12,12 @@ const viewer_generic_schemas = viewer_schemas.opengeodeweb_viewer.generic;
12
12
  export const useDataStore = defineStore("data", () => {
13
13
  const viewerStore = useViewerStore();
14
14
 
15
- function item(id) {
16
- return database.data.get(id);
15
+ async function item(id) {
16
+ const data_item = await database.data.get(id);
17
+ if (!data_item) {
18
+ throw new Error(`Item not found: ${id}`);
19
+ }
20
+ return data_item;
17
21
  }
18
22
 
19
23
  function refItem(id) {
@@ -62,6 +66,13 @@ export const useDataStore = defineStore("data", () => {
62
66
  }));
63
67
  }
64
68
 
69
+ function refFormatedMeshComponents(id) {
70
+ return useObservable(
71
+ liveQuery(() => formatedMeshComponents(id)),
72
+ { initialValue: [] },
73
+ );
74
+ }
75
+
65
76
  async function meshComponentType(modelId, geode_id) {
66
77
  const component = await database.model_components.where({ id: modelId, geode_id }).first();
67
78
  return component?.type;
@@ -176,7 +187,7 @@ export const useDataStore = defineStore("data", () => {
176
187
  .where("[id+geode_id]")
177
188
  .anyOf(meshComponentGeodeIds.map((geode_id) => [modelId, geode_id]))
178
189
  .toArray();
179
- return components.map((component) => component.viewer_id);
190
+ return components.map((component) => Number.parseInt(component.viewer_id, 10));
180
191
  }
181
192
 
182
193
  async function exportStores() {
@@ -198,6 +209,7 @@ export const useDataStore = defineStore("data", () => {
198
209
  refItem,
199
210
  meshComponentType,
200
211
  formatedMeshComponents,
212
+ refFormatedMeshComponents,
201
213
  registerObject,
202
214
  deregisterObject,
203
215
  addItem,
@@ -210,6 +222,7 @@ export const useDataStore = defineStore("data", () => {
210
222
  getSurfacesGeodeIds,
211
223
  getBlocksGeodeIds,
212
224
  getMeshComponentsViewerIds,
225
+
213
226
  exportStores,
214
227
  importStores,
215
228
  clear,
@@ -1,3 +1,4 @@
1
+ import { database } from "@ogw_internal/database/database.js";
1
2
  import { getDefaultStyle } from "@ogw_front/utils/default_styles";
2
3
  import { useDataStore } from "@ogw_front/stores/data";
3
4
  import { useDataStyleStateStore } from "@ogw_internal/stores/data_style/state";
@@ -10,16 +11,13 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
10
11
  const modelStyleStore = useModelStyle();
11
12
  const dataStore = useDataStore();
12
13
 
13
- function addDataStyle(id, geode_object) {
14
- dataStyleState.styles[id] = getDefaultStyle(geode_object);
14
+ async function addDataStyle(id, geode_object) {
15
+ await database.data_style.put(structuredClone({ id, ...getDefaultStyle(geode_object) }));
15
16
  }
16
17
 
17
18
  async function setVisibility(id, visibility) {
18
19
  const item = await dataStore.item(id);
19
- const viewer_type = item?.viewer_type;
20
- if (!viewer_type) {
21
- throw new Error(`Item not found or not loaded: ${id}`);
22
- }
20
+ const { viewer_type } = item;
23
21
 
24
22
  if (viewer_type === "mesh") {
25
23
  return meshStyleStore.setMeshVisibility(id, visibility);
@@ -32,10 +30,8 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
32
30
 
33
31
  async function applyDefaultStyle(id) {
34
32
  const item = await dataStore.item(id);
35
- const viewer_type = item?.viewer_type;
36
- if (!viewer_type) {
37
- throw new Error(`Item not found or not loaded: ${id}`);
38
- }
33
+ const { viewer_type } = item;
34
+
39
35
  if (viewer_type === "mesh") {
40
36
  return meshStyleStore.applyMeshStyle(id);
41
37
  }
@@ -46,29 +42,36 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
46
42
  }
47
43
 
48
44
  function exportStores() {
49
- return { styles: dataStyleState.styles };
45
+ return {
46
+ styles: dataStyleState.styles,
47
+ componentStyles: dataStyleState.componentStyles,
48
+ };
50
49
  }
51
50
 
52
- function importStores(snapshot) {
53
- const stylesSnapshot = snapshot.styles || {};
54
- for (const id of Object.keys(dataStyleState.styles)) {
55
- delete dataStyleState.styles[id];
56
- }
57
- for (const [id, style] of Object.entries(stylesSnapshot)) {
58
- dataStyleState.styles[id] = style;
59
- }
51
+ async function importStores(snapshot) {
52
+ const stylesSnapshot = snapshot.styles;
53
+ const componentStylesSnapshot = snapshot.componentStyles;
54
+
55
+ await dataStyleState.clear();
56
+
57
+ const style_promises = Object.entries(stylesSnapshot).map(([id, style]) =>
58
+ database.data_style.put(structuredClone({ id, ...style })),
59
+ );
60
+ const component_style_promises = Object.values(componentStylesSnapshot).map((style) =>
61
+ database.model_component_datastyle.put(structuredClone(style)),
62
+ );
63
+
64
+ await Promise.all([...style_promises, ...component_style_promises]);
60
65
  }
61
66
 
62
67
  function applyAllStylesFromState() {
63
- const ids = Object.keys(dataStyleState.styles || {});
68
+ const ids = Object.keys(dataStyleState.styles);
64
69
  const promises = ids.map(async (id) => {
65
70
  const meta = await dataStore.item(id);
66
- const viewerType = meta?.viewer_type;
67
- const style = dataStyleState.styles[id];
68
- if (style && viewerType === "mesh") {
71
+ const viewerType = meta.viewer_type;
72
+ if (viewerType === "mesh") {
69
73
  return meshStyleStore.applyMeshStyle(id);
70
- }
71
- if (style && viewerType === "model") {
74
+ } else if (viewerType === "model") {
72
75
  return modelStyleStore.applyModelStyle(id);
73
76
  }
74
77
  });
@@ -70,7 +70,6 @@ export const useHybridViewerStore = defineStore("hybridViewer", () => {
70
70
  return;
71
71
  }
72
72
  const value = await dataStore.item(id);
73
- console.log("hybridViewerStore.addItem", { value });
74
73
  const reader = vtkXMLPolyDataReader();
75
74
  const textEncoder = new TextEncoder();
76
75
  await reader.parseAsArrayBuffer(textEncoder.encode(value.binary_light_viewable));
@@ -19,7 +19,7 @@ async function registerRunningExtensions() {
19
19
 
20
20
  return Promise.all(
21
21
  extensionsArray.map(async (extension) => {
22
- const { name, version, frontendContent, port } = extension;
22
+ const { id, name, version, frontendContent, port } = extension;
23
23
  const blob = new Blob([frontendContent], {
24
24
  type: "application/javascript",
25
25
  });
@@ -30,6 +30,7 @@ async function importWorkflow(files) {
30
30
  function buildImportItemFromPayloadApi(value, geode_object_type) {
31
31
  console.log("buildImportItemFromPayloadApi", { value, geode_object_type });
32
32
  return {
33
+ geode_object_type,
33
34
  ...value,
34
35
  };
35
36
  }
@@ -133,6 +133,10 @@ function projectMicroservices(projectFolderPath) {
133
133
  }
134
134
 
135
135
  async function cleanupBackend(projectFolderPath) {
136
+ if (!fs.existsSync(projectFolderPath)) {
137
+ console.log(`Folder ${projectFolderPath} does not exist. Skipping cleanup.`);
138
+ return;
139
+ }
136
140
  const microservices = projectMicroservices(projectFolderPath);
137
141
  await killMicroservices(microservices);
138
142
  await deleteFolderRecursive(projectFolderPath);
@@ -142,4 +146,4 @@ function microservicesMetadatasPath(projectFolderPath) {
142
146
  return path.join(projectFolderPath, "microservices.json");
143
147
  }
144
148
 
145
- export { cleanupBackend, microservicesMetadatasPath };
149
+ export { cleanupBackend, microservicesMetadatasPath, projectMicroservices };
@@ -11,7 +11,7 @@ import pTimeout from "p-timeout";
11
11
  // Local imports
12
12
  import { commandExistsSync, waitForReady } from "./scripts.js";
13
13
  import { executableName, executablePath } from "./path.js";
14
- import { microservicesMetadatasPath } from "./cleanup.js";
14
+ import { microservicesMetadatasPath, projectMicroservices } from "./cleanup.js";
15
15
 
16
16
  const DEFAULT_TIMEOUT_SECONDS = 30;
17
17
  const MILLISECONDS_PER_SECOND = 1000;
@@ -112,18 +112,6 @@ async function runViewer(execName, execPath, args = {}) {
112
112
  return port;
113
113
  }
114
114
 
115
- function projectMicroservices(projectFolderPath) {
116
- console.log("projectMicroservices", { projectFolderPath });
117
- const filePath = microservicesMetadatasPath(projectFolderPath);
118
-
119
- if (!fs.existsSync(filePath)) {
120
- const microservicesMetadatas = { microservices: [] };
121
- fs.writeFileSync(filePath, JSON.stringify(microservicesMetadatas, undefined, 2), "utf8");
122
- }
123
- const content = JSON.parse(fs.readFileSync(filePath, "utf8"));
124
- return content.microservices;
125
- }
126
-
127
115
  function addMicroserviceMetadatas(projectFolderPath, serviceObj) {
128
116
  const microservices = projectMicroservices(projectFolderPath);
129
117
  if (serviceObj.type === "back") {
@@ -36,4 +36,23 @@ function generateProjectFolderPath(projectName) {
36
36
  return path.join(os.tmpdir(), projectName.replaceAll("/", "_"), uuidv4());
37
37
  }
38
38
 
39
- export { createPath, executablePath, executableName, generateProjectFolderPath };
39
+ function extensionFrontendPath(unzippedExtensionPath, frontendFile, rootPath, extensionId) {
40
+ if (process.env.NODE_ENV === "production") {
41
+ return path.join(unzippedExtensionPath, frontendFile);
42
+ }
43
+ const extentionRepoName = extensionId
44
+ .split("-")
45
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
46
+ .join("-");
47
+ const localExtensionPath = path.join(rootPath, "..", extentionRepoName, "dist", frontendFile);
48
+ console.log("runExtensions", { localExtensionPath });
49
+ return localExtensionPath;
50
+ }
51
+
52
+ export {
53
+ createPath,
54
+ extensionFrontendPath,
55
+ executablePath,
56
+ executableName,
57
+ generateProjectFolderPath,
58
+ };
@@ -0,0 +1,22 @@
1
+ import { Dexie } from "dexie";
2
+ import { dataStyleTable } from "./tables/data_style";
3
+ import { dataTable } from "./tables/data";
4
+ import { modelComponentDataStyleTable } from "./tables/model_component_datastyle";
5
+ import { modelComponentsRelationTable } from "./tables/model_components_relation";
6
+ import { modelComponentsTable } from "./tables/model_components";
7
+
8
+ export class BaseDatabase extends Dexie {
9
+ static get initialStores() {
10
+ return {
11
+ [dataTable.name]: dataTable.schema,
12
+ [modelComponentsTable.name]: modelComponentsTable.schema,
13
+ [dataStyleTable.name]: dataStyleTable.schema,
14
+ [modelComponentDataStyleTable.name]: modelComponentDataStyleTable.schema,
15
+ [modelComponentsRelationTable.name]: modelComponentsRelationTable.schema,
16
+ };
17
+ }
18
+
19
+ clear() {
20
+ return Promise.all(this.tables.map((table) => table.clear()));
21
+ }
22
+ }
@@ -1,18 +1,11 @@
1
- import { Dexie } from "dexie";
1
+ import { BaseDatabase } from "./base_database";
2
2
  import { ExtendedDatabase } from "./extended_database";
3
- import { dataTable } from "./tables/data";
4
- import { modelComponentsRelationTable } from "./tables/model_components_relation";
5
- import { modelComponentsTable } from "./tables/model_components";
6
3
 
7
- class Database extends Dexie {
4
+ class Database extends BaseDatabase {
8
5
  constructor() {
9
6
  super("Database");
10
7
 
11
- this.version(1).stores({
12
- [dataTable.name]: dataTable.schema,
13
- [modelComponentsTable.name]: modelComponentsTable.schema,
14
- [modelComponentsRelationTable.name]: modelComponentsRelationTable.schema,
15
- });
8
+ this.version(1).stores(BaseDatabase.initialStores);
16
9
  }
17
10
 
18
11
  static async addTable(tableName, schemaDefinition) {
@@ -24,11 +17,7 @@ class Database extends Dexie {
24
17
  await tempDb.open();
25
18
 
26
19
  const currentVersion = tempDb.verno;
27
- const currentStores = {
28
- [dataTable.name]: dataTable.schema,
29
- [modelComponentsTable.name]: modelComponentsTable.schema,
30
- [modelComponentsRelationTable.name]: modelComponentsRelationTable.schema,
31
- };
20
+ const currentStores = { ...BaseDatabase.initialStores };
32
21
 
33
22
  for (const table of tempDb.tables) {
34
23
  const keyPath = table.schema.primKey.src;
@@ -47,11 +36,7 @@ class Database extends Dexie {
47
36
  const existingDb = new Dexie("Database");
48
37
  for (let version = 1; version <= currentVersion; version += 1) {
49
38
  if (version === 1) {
50
- existingDb.version(1).stores({
51
- [dataTable.name]: dataTable.schema,
52
- [modelComponentsTable.name]: modelComponentsTable.schema,
53
- [modelComponentsRelationTable.name]: modelComponentsRelationTable.schema,
54
- });
39
+ existingDb.version(1).stores(BaseDatabase.initialStores);
55
40
  } else {
56
41
  existingDb.version(version).stores(currentStores);
57
42
  }
@@ -1,19 +1,12 @@
1
- import { Dexie } from "dexie";
2
- import { dataTable } from "./tables/data";
3
- import { modelComponentsRelationTable } from "./tables/model_components_relation";
4
- import { modelComponentsTable } from "./tables/model_components";
1
+ import { BaseDatabase } from "./base_database";
5
2
 
6
- export class ExtendedDatabase extends Dexie {
3
+ export class ExtendedDatabase extends BaseDatabase {
7
4
  constructor(currentVersion, currentStores, newTables) {
8
5
  super("Database");
9
6
 
10
7
  for (let version = 1; version <= currentVersion; version += 1) {
11
8
  if (version === 1) {
12
- this.version(1).stores({
13
- [dataTable.name]: dataTable.schema,
14
- [modelComponentsTable.name]: modelComponentsTable.schema,
15
- [modelComponentsRelationTable.name]: modelComponentsRelationTable.schema,
16
- });
9
+ this.version(1).stores(BaseDatabase.initialStores);
17
10
  } else {
18
11
  this.version(version).stores(currentStores);
19
12
  }
@@ -0,0 +1,4 @@
1
+ export const dataStyleTable = {
2
+ name: "data_style",
3
+ schema: "id",
4
+ };
@@ -0,0 +1,4 @@
1
+ export const modelComponentDataStyleTable = {
2
+ name: "model_component_datastyle",
3
+ schema: "[id_model+id_component], id_model",
4
+ };
@@ -29,28 +29,24 @@ export function useMeshCellsCellAttributeStyle() {
29
29
  });
30
30
  }
31
31
 
32
- function setMeshCellsCellAttributeStoredConfig(id, name, { minimum, maximum, colorMap }) {
33
- const { storedConfigs } = meshCellsCellAttribute(id);
34
- storedConfigs[name] = { minimum, maximum, colorMap };
35
- return storedConfigs[name];
32
+ function setMeshCellsCellAttributeStoredConfig(id, name, config) {
33
+ return meshCellsCommonStyle.mutateMeshCellsCellStyle(id, {
34
+ storedConfigs: {
35
+ [name]: config,
36
+ },
37
+ });
36
38
  }
37
39
 
38
40
  function meshCellsCellAttributeName(id) {
39
- console.log(meshCellsCellAttributeName.name, { id }, meshCellsCellAttribute(id));
40
41
  return meshCellsCellAttribute(id).name;
41
42
  }
43
+
42
44
  function setMeshCellsCellAttributeName(id, name) {
43
- console.log(setMeshCellsCellAttributeName.name, { id, name });
44
45
  return viewerStore.request(
45
46
  meshCellsCellAttributeSchemas.name,
46
47
  { id, name },
47
48
  {
48
- response_function: async () => {
49
- meshCellsCellAttribute(id).name = name;
50
- const { minimum, maximum } = meshCellsCellAttributeStoredConfig(id, name);
51
- await setMeshCellsCellAttributeRange(id, minimum, maximum);
52
- console.log(setMeshCellsCellAttributeName.name, { id }, meshCellsCellAttributeName(id));
53
- },
49
+ response_function: () => meshCellsCommonStyle.mutateMeshCellsCellStyle(id, { name }),
54
50
  },
55
51
  );
56
52
  }
@@ -61,12 +57,10 @@ export function useMeshCellsCellAttributeStyle() {
61
57
  const { minimum, maximum } = storedConfig;
62
58
  return [minimum, maximum];
63
59
  }
60
+
64
61
  function setMeshCellsCellAttributeRange(id, minimum, maximum) {
65
62
  const name = meshCellsCellAttributeName(id);
66
- const storedConfig = meshCellsCellAttributeStoredConfig(id, name);
67
- storedConfig.minimum = minimum;
68
- storedConfig.maximum = maximum;
69
- return setMeshCellsCellAttributeColorMap(id, storedConfig.colorMap);
63
+ return setMeshCellsCellAttributeStoredConfig(id, name, { minimum, maximum });
70
64
  }
71
65
 
72
66
  function meshCellsCellAttributeColorMap(id) {
@@ -75,38 +69,17 @@ export function useMeshCellsCellAttributeStyle() {
75
69
  const { colorMap } = storedConfig;
76
70
  return colorMap;
77
71
  }
72
+
78
73
  function setMeshCellsCellAttributeColorMap(id, colorMap) {
79
74
  const name = meshCellsCellAttributeName(id);
80
75
  const storedConfig = meshCellsCellAttributeStoredConfig(id, name);
81
- if (
82
- storedConfig.minimum === undefined ||
83
- storedConfig.maximum === undefined ||
84
- colorMap === undefined
85
- ) {
86
- storedConfig.colorMap = colorMap;
87
- return;
88
- }
89
76
  const points = getRGBPointsFromPreset(colorMap);
90
77
  const { minimum, maximum } = storedConfig;
91
-
92
- console.log(setMeshCellsCellAttributeColorMap.name, {
93
- id,
94
- minimum,
95
- maximum,
96
- colorMap,
97
- });
98
78
  return viewerStore.request(
99
79
  meshCellsCellAttributeSchemas.color_map,
100
80
  { id, points, minimum, maximum },
101
81
  {
102
- response_function: () => {
103
- storedConfig.colorMap = colorMap;
104
- console.log(
105
- setMeshCellsCellAttributeColorMap.name,
106
- { id },
107
- meshCellsCellAttributeColorMap(id),
108
- );
109
- },
82
+ response_function: () => setMeshCellsCellAttributeStoredConfig(id, name, { colorMap }),
110
83
  },
111
84
  );
112
85
  }
@@ -20,10 +20,10 @@ export function useMeshCellsColorStyle() {
20
20
  meshCellsColorSchemas,
21
21
  { id, color },
22
22
  {
23
- response_function: () => {
24
- meshCellsCommonStyle.meshCellsColoring(id).color = color;
25
- console.log(setMeshCellsColor.name, { id }, JSON.stringify(meshCellsColor(id)));
26
- },
23
+ response_function: () =>
24
+ meshCellsCommonStyle.mutateMeshCellsColoring(id, {
25
+ color,
26
+ }),
27
27
  },
28
28
  );
29
29
  }
@@ -3,6 +3,12 @@ import { useDataStyleStateStore } from "@ogw_internal/stores/data_style/state";
3
3
  export function useMeshCellsCommonStyle() {
4
4
  const dataStyleStateStore = useDataStyleStateStore();
5
5
 
6
+ function mutateMeshCellsStyle(id, values) {
7
+ return dataStyleStateStore.mutateStyle(id, {
8
+ cells: values,
9
+ });
10
+ }
11
+
6
12
  function meshCellsStyle(id) {
7
13
  return dataStyleStateStore.getStyle(id).cells;
8
14
  }
@@ -11,13 +17,23 @@ export function useMeshCellsCommonStyle() {
11
17
  return meshCellsStyle(id).coloring;
12
18
  }
13
19
 
14
- function meshCellsActiveColoring(id) {
15
- return meshCellsColoring(id).active;
20
+ function mutateMeshCellsColoring(id, values) {
21
+ return mutateMeshCellsStyle(id, {
22
+ coloring: values,
23
+ });
24
+ }
25
+
26
+ function mutateMeshCellsCellStyle(id, values) {
27
+ return mutateMeshCellsColoring(id, {
28
+ cell: values,
29
+ });
16
30
  }
17
31
 
18
32
  return {
19
33
  meshCellsStyle,
20
34
  meshCellsColoring,
21
- meshCellsActiveColoring,
35
+ mutateMeshCellsStyle,
36
+ mutateMeshCellsColoring,
37
+ mutateMeshCellsCellStyle,
22
38
  };
23
39
  }
@@ -15,17 +15,22 @@ export function useMeshCellsStyle() {
15
15
  const meshCellsVisibility = useMeshCellsVisibilityStyle();
16
16
  const meshCellsColorStyle = useMeshCellsColorStyle();
17
17
  const meshCellsTexturesStore = useMeshCellsTexturesStyle();
18
+
19
+ function meshCellsColoring(id) {
20
+ return meshCellsCommonStyle.meshCellsColoring(id);
21
+ }
18
22
  const meshCellsVertexAttributeStyle = useMeshCellsVertexAttributeStyle();
19
23
  const meshCellsCellAttributeStyle = useMeshCellsCellAttributeStyle();
20
24
 
25
+ function meshCellsActiveColoring(id) {
26
+ return meshCellsColoring(id).active;
27
+ }
28
+
21
29
  async function setMeshCellsActiveColoring(id, type) {
22
- const coloring = meshCellsCommonStyle.meshCellsColoring(id);
23
- coloring.active = type;
24
- console.log(
25
- setMeshCellsActiveColoring.name,
26
- { id },
27
- meshCellsCommonStyle.meshCellsActiveColoring(id),
28
- );
30
+ await meshCellsCommonStyle.mutateMeshCellsStyle(id, {
31
+ coloring: { active: type },
32
+ });
33
+ console.log(setMeshCellsActiveColoring.name, { id }, type);
29
34
  if (type === "color") {
30
35
  return meshCellsColorStyle.setMeshCellsColor(id, meshCellsColorStyle.meshCellsColor(id));
31
36
  }
@@ -48,8 +53,7 @@ export function useMeshCellsStyle() {
48
53
  if (name === undefined) {
49
54
  return;
50
55
  }
51
- await meshCellsCellAttributeStyle.setMeshCellsCellAttributeName(id, name);
52
- return;
56
+ return meshCellsCellAttributeStyle.setMeshCellsCellAttributeName(id, name);
53
57
  }
54
58
  throw new Error(`Unknown mesh cells coloring type: ${type}`);
55
59
  }
@@ -57,12 +61,14 @@ export function useMeshCellsStyle() {
57
61
  function applyMeshCellsStyle(id) {
58
62
  return Promise.all([
59
63
  meshCellsVisibility.setMeshCellsVisibility(id, meshCellsVisibility.meshCellsVisibility(id)),
60
- setMeshCellsActiveColoring(id, meshCellsCommonStyle.meshCellsActiveColoring(id)),
64
+ setMeshCellsActiveColoring(id, meshCellsActiveColoring(id)),
61
65
  ]);
62
66
  }
63
67
 
64
68
  return {
65
69
  ...meshCellsCommonStyle,
70
+ meshCellsColoring,
71
+ meshCellsActiveColoring,
66
72
  setMeshCellsActiveColoring,
67
73
  applyMeshCellsStyle,
68
74
  ...meshCellsVisibility,
@@ -20,10 +20,10 @@ export function useMeshCellsTexturesStyle() {
20
20
  meshCellsTexturesSchemas,
21
21
  { id, textures },
22
22
  {
23
- response_function: () => {
24
- meshCellsCommonStyle.meshCellsColoring(id).textures = textures;
25
- console.log(setMeshCellsTextures.name, { id }, meshCellsTextures(id));
26
- },
23
+ response_function: () =>
24
+ meshCellsCommonStyle.mutateMeshCellsStyle(id, {
25
+ coloring: { textures },
26
+ }),
27
27
  },
28
28
  );
29
29
  }