Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 37 additions & 108 deletions app/assets/geode_objects.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
// oxlint-disable import/max-dependencies -- one icon import per geode object type
import type { GeodeObjectType } from "@geode/opengeodeweb-microservice/data_types";

import BRep from "@ogw_front/assets/img/geode_objects/BRep.svg";
import CrossSection from "@ogw_front/assets/img/geode_objects/CrossSection.svg";
import EdgedCurve2D from "@ogw_front/assets/img/geode_objects/EdgedCurve2D.svg";
import EdgedCurve3D from "@ogw_front/assets/img/geode_objects/EdgedCurve3D.svg";
import Graph from "@ogw_front/assets/img/geode_objects/Graph.svg";
import HorizonStack3D from "@ogw_front/assets/img/geode_objects/HorizonStack3D.svg";
import HybridSolid3D from "@ogw_front/assets/img/geode_objects/HybridSolid3D.svg";
import ImplicitCrossSection from "@ogw_front/assets/img/geode_objects/ImplicitCrossSection.svg";
import ImplicitStructuralModel from "@ogw_front/assets/img/geode_objects/ImplicitStructuralModel.svg";
Expand All @@ -13,7 +17,6 @@ import PointSet3D from "@ogw_front/assets/img/geode_objects/PointSet3D.svg";
import PolygonalSurface2D from "@ogw_front/assets/img/geode_objects/PolygonalSurface2D.svg";
import PolygonalSurface3D from "@ogw_front/assets/img/geode_objects/PolygonalSurface3D.svg";
import PolyhedralSolid3D from "@ogw_front/assets/img/geode_objects/PolyhedralSolid3D.svg";
// oxlint-disable-next-line import/max-dependencies -- one icon import per geode object.
import RasterImage2D from "@ogw_front/assets/img/geode_objects/RasterImage2D.svg";
import RasterImage3D from "@ogw_front/assets/img/geode_objects/RasterImage3D.svg";
import RegularGrid2D from "@ogw_front/assets/img/geode_objects/RegularGrid2D.svg";
Expand All @@ -25,112 +28,38 @@ import TriangulatedSurface2D from "@ogw_front/assets/img/geode_objects/Triangula
import TriangulatedSurface3D from "@ogw_front/assets/img/geode_objects/TriangulatedSurface3D.svg";
import VertexSet from "@ogw_front/assets/img/geode_objects/VertexSet.svg";

interface GeodeObject {
tooltip: string;
image: string;
}

const geode_objects: Record<string, GeodeObject> = {
BRep: {
tooltip: "BRep",
image: BRep,
},
CrossSection: {
tooltip: "CrossSection",
image: CrossSection,
},
EdgedCurve2D: {
tooltip: "EdgedCurve2D",
image: EdgedCurve2D,
},
EdgedCurve3D: {
tooltip: "EdgedCurve3D",
image: EdgedCurve3D,
},
Graph: {
tooltip: "Graph",
image: Graph,
},
HybridSolid3D: {
tooltip: "HybridSolid3D",
image: HybridSolid3D,
},
ImplicitCrossSection: {
tooltip: "ImplicitCrossSection",
image: ImplicitCrossSection,
},
ImplicitStructuralModel: {
tooltip: "ImplicitStructuralModel",
image: ImplicitStructuralModel,
},
LightRegularGrid2D: {
tooltip: "LightRegularGrid2D",
image: LightRegularGrid2D,
},
LightRegularGrid3D: {
tooltip: "LightRegularGrid3D",
image: LightRegularGrid3D,
},
PointSet2D: {
tooltip: "PointSet2D",
image: PointSet2D,
},
PointSet3D: {
tooltip: "PointSet3D",
image: PointSet3D,
},
PolygonalSurface2D: {
tooltip: "PolygonalSurface2D",
image: PolygonalSurface2D,
},
PolygonalSurface3D: {
tooltip: "PolygonalSurface3D",
image: PolygonalSurface3D,
},
PolyhedralSolid3D: {
tooltip: "PolyhedralSolid3D",
image: PolyhedralSolid3D,
},
RasterImage2D: {
tooltip: "RasterImage2D",
image: RasterImage2D,
},
RasterImage3D: {
tooltip: "RasterImage3D",
image: RasterImage3D,
},
RegularGrid2D: {
tooltip: "RegularGrid2D",
image: RegularGrid2D,
},
RegularGrid3D: {
tooltip: "RegularGrid3D",
image: RegularGrid3D,
},
Section: {
tooltip: "Section",
image: Section,
},
StructuralModel: {
tooltip: "StructuralModel",
image: StructuralModel,
},
TetrahedralSolid3D: {
tooltip: "TetrahedralSolid3D",
image: TetrahedralSolid3D,
},
TriangulatedSurface2D: {
tooltip: "TriangulatedSurface2D",
image: TriangulatedSurface2D,
},
TriangulatedSurface3D: {
tooltip: "TriangulatedSurface3D",
image: TriangulatedSurface3D,
},
VertexSet: {
tooltip: "VertexSet",
image: VertexSet,
},
// Icon of each geode object type: every type of data_types.py must have one
const geodeObjectImages: Record<GeodeObjectType, string> = {
BRep,
CrossSection,
EdgedCurve2D,
EdgedCurve3D,
Graph,
HorizonStack3D,
HybridSolid3D,
ImplicitCrossSection,
ImplicitStructuralModel,
LightRegularGrid2D,
LightRegularGrid3D,
PointSet2D,
PointSet3D,
PolygonalSurface2D,
PolygonalSurface3D,
PolyhedralSolid3D,
RasterImage2D,
RasterImage3D,
RegularGrid2D,
RegularGrid3D,
Section,
StructuralModel,
TetrahedralSolid3D,
TriangulatedSurface2D,
TriangulatedSurface3D,
VertexSet,
};

export { geode_objects };
function geodeObjectImage(geodeObjectType: GeodeObjectType): string {
return geodeObjectImages[geodeObjectType];
}

export { geodeObjectImage };
10 changes: 10 additions & 0 deletions app/assets/img/geode_objects/HorizonStack3D.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions app/components/CrsSelector.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import type { CRSList } from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
import type { GeodeObjectType } from "@ogw_front/types/identifiers";
import type { CRS } from "@geode/opengeodeweb-back/schema_types";
import type { GeodeObjectType } from "@geode/opengeodeweb-microservice/data_types";
import { useCrsStore } from "@ogw_front/stores/crs";

interface Props {
Expand All @@ -10,23 +10,23 @@ interface Props {
}

const { geodeObjectType, compact = false } = defineProps<Props>();
const selectedCrs = defineModel<CRSList | undefined>();
const selectedCrs = defineModel<CRS | undefined>();

const search = ref<string>("");
const data_table_loading = ref<boolean>(false);
// Thousands of rows that are never mutated: no deep reactivity
const crs_list = shallowRef<CRSList[]>([]);
const crs_list = shallowRef<CRS[]>([]);
// Keys of the selected rows: the item-value of the table, "AUTHORITY:CODE"
const selected_crs = ref<string[]>([]);
const toggle_loading = useToggle(data_table_loading);
const crsStore = useCrsStore();

// Codes are only unique within an authority (e.g. EPSG:4812 and ESRI:4812)
function crs_key(crs: CRSList): string {
function crs_key(crs: CRS): string {
return `${crs.authority}:${crs.code}`;
}

function get_selected_crs(key: string | undefined): CRSList | undefined {
function get_selected_crs(key: string | undefined): CRS | undefined {
return crs_list.value.find((crs) => crs_key(crs) === key);
}

Expand Down
35 changes: 21 additions & 14 deletions app/components/ExtensionSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import schemas from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";

import FetchingData from "@ogw_front/components/FetchingData.vue";
import type { GeodeObjectType } from "@ogw_front/types/identifiers";
import type { GeodeObjectType } from "@geode/opengeodeweb-microservice/data_types";
import { useBackStore } from "@ogw_front/stores/back";

const schema = schemas.opengeodeweb_back.geode_objects_and_output_extensions;
Expand All @@ -20,7 +20,9 @@ interface Props {
const { geodeObjectType, filenames } = defineProps<Props>();
type OutputExtensions = Record<string, { is_saveable: boolean }>;

const geode_objects_and_output_extensions = ref<Record<GeodeObjectType, OutputExtensions>>({});
const geode_objects_and_output_extensions = ref<Partial<Record<GeodeObjectType, OutputExtensions>>>(
{},
);
const loading = ref<boolean>(false);

const toggle_loading = useToggle(loading);
Expand All @@ -29,25 +31,28 @@ async function get_output_file_extensions(): Promise<void> {
toggle_loading();
geode_objects_and_output_extensions.value = {};
const backStore = useBackStore();
const values: Record<GeodeObjectType, Record<string, boolean>>[] = await Promise.all(
filenames.map(async (filename): Promise<Record<GeodeObjectType, Record<string, boolean>>> => {
const params = { geode_object_type: geodeObjectType, filename };
const response = await backStore.request({ schema, params });
return response.geode_objects_and_output_extensions;
}),
const values: Partial<Record<GeodeObjectType, Record<string, boolean>>>[] = await Promise.all(
filenames.map(
async (filename): Promise<Partial<Record<GeodeObjectType, Record<string, boolean>>>> => {
const params = { geode_object_type: geodeObjectType, filename };
const response = await backStore.request({ schema, params });
return response.geode_objects_and_output_extensions;
},
),
);
const all_keys = [...new Set(values.flatMap((value) => Object.keys(value)))];
const all_keys = [...new Set(values.flatMap((value) => Object.keys(value) as GeodeObjectType[]))];
const common_keys = all_keys.filter((i) => !values.some((j) => !Object.keys(j).includes(i)));
const final_object: Record<GeodeObjectType, OutputExtensions> = {};
const final_object: Partial<Record<GeodeObjectType, OutputExtensions>> = {};
for (const key of common_keys) {
final_object[key] = {};
const output_extensions: OutputExtensions = {};
final_object[key] = output_extensions;
for (const value of values) {
const extensions = value[key];
if (!extensions) {
continue;
}
for (const [extension, is_saveable] of Object.entries(extensions)) {
final_object[key][extension] = { is_saveable };
output_extensions[extension] = { is_saveable };
}
}
}
Expand All @@ -56,7 +61,7 @@ async function get_output_file_extensions(): Promise<void> {
}

function update_values(output_geode_object: GeodeObjectType, output_extension: string): void {
if (output_geode_object !== "" && output_extension !== "") {
if (output_extension !== "") {
emit("update_values", {
output_geode_object,
output_extension,
Expand Down Expand Up @@ -100,7 +105,9 @@ await get_output_file_extensions();
class="card ma-2"
:color="extension.is_saveable ? 'primary' : 'grey'"
hover
@click="update_values(output_geode_object, output_extension)"
@click="
update_values(output_geode_object as GeodeObjectType, output_extension)
"
:disabled="!extension.is_saveable"
>
<v-card-title align="center">
Expand Down
2 changes: 1 addition & 1 deletion app/components/MissingFilesSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { matchExpectedFiles, uploadPath } from "@ogw_front/utils/upload_path";
import DragAndDrop from "@ogw_front/components/DragAndDrop.vue";
import FetchingData from "@ogw_front/components/FetchingData.vue";
import FileUploader from "@ogw_front/components/FileUploader.vue";
import type { GeodeObjectType } from "@ogw_front/types/identifiers";
import type { GeodeObjectType } from "@geode/opengeodeweb-microservice/data_types";
import { useBackStore } from "@ogw_front/stores/back";
import { useFeedbackStore } from "@ogw_front/stores/feedback";

Expand Down
21 changes: 7 additions & 14 deletions app/components/ObjectSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
resolveAllowedObjectsPerFile,
} from "@ogw_shared/utils/response_handlers/load.js";
import FetchingData from "@ogw_front/components/FetchingData.vue";
import type { GeodeObjectType } from "@ogw_front/types/identifiers";
import { geode_objects } from "@ogw_front/assets/geode_objects";
import type { GeodeObjectType } from "@geode/opengeodeweb-microservice/data_types";
import { geodeObjectImage } from "@ogw_front/assets/geode_objects";
import schemas from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
import { useBackStore } from "@ogw_front/stores/back";

Expand Down Expand Up @@ -94,15 +94,8 @@ function groupPendingFiles(pending: readonly FileAllowedObjects[]): PendingGroup
return [...groups.values()];
}

// The geode_objects lookup is fixed and keyed by known object type names; a missing entry only happens if the backend reports a type this table doesn't know about.
function geodeObjectTooltip(key: string, isLoadable: boolean): string {
return isLoadable
? (geode_objects[key]?.tooltip ?? key)
: `Data not loadable with this class (${key})`;
}

function geodeObjectImage(key: string): string | undefined {
return geode_objects[key]?.image;
return isLoadable ? key : `Data not loadable with this class (${key})`;
}

function showCommonGeodeObjects(
Expand Down Expand Up @@ -229,7 +222,7 @@ await getAllowedGeodeObjects();
Choose the data type for: {{ pendingFilenames.join(", ") }}
</v-col>
<v-col v-for="(value, key) in allowedGeodeObjects" :key="key" cols="3" md="4">
<v-tooltip :text="geodeObjectTooltip(key, Boolean(value['is_loadable']))" location="bottom">
<v-tooltip :text="geodeObjectTooltip(key, Boolean(value?.is_loadable))" location="bottom">
<template v-slot:activator="{ props }">
<span v-bind="props">
<v-card
Expand All @@ -238,13 +231,13 @@ await getAllowedGeodeObjects();
hover
rounded
@click="setGeodeObject(key)"
:disabled="!value['is_loadable']"
:elevation="value['is_loadable'] ? 5 : 3"
:disabled="!value?.is_loadable"
:elevation="value?.is_loadable ? 5 : 3"
>
<v-img
:src="geodeObjectImage(key)"
cover
:class="!value['is_loadable'] ? 'disabled' : undefined"
:class="!value?.is_loadable ? 'disabled' : undefined"
/>
</v-card>
</span>
Expand Down
2 changes: 1 addition & 1 deletion app/components/ThresholdFilter.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import type { Threshold, ThresholdAttribute } from "@ogw_internal/stores/hybrid_viewer/filters";
import type { AttributeSource } from "@ogw_front/utils/threshold";
import type { DataId } from "@ogw_front/types/identifiers";
import type { DataId } from "@geode/opengeodeweb-microservice/schema_types";
import ThresholdCard from "@ogw_front/components/ThresholdCard.vue";
import ToolPanel from "@ogw_front/components/ToolPanel.vue";
import { fetchSources } from "@ogw_front/utils/threshold_sources";
Expand Down
7 changes: 2 additions & 5 deletions app/components/TimeSeriesTargetSelector.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
<script setup lang="ts">
import schemas from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";

import type {
DataIdentified,
GeodeObjectType,
GeodeObjectTyped,
} from "@ogw_front/types/identifiers";
import type { DataIdentified, GeodeObjectTyped } from "@ogw_front/types/identifiers";
import FetchingData from "@ogw_front/components/FetchingData.vue";
import type { GeodeObjectType } from "@geode/opengeodeweb-microservice/data_types";
import { useBackStore } from "@ogw_front/stores/back";
import { useDataStore } from "@ogw_front/stores/data";

Expand Down
2 changes: 1 addition & 1 deletion app/components/Viewer/ContextMenu/ContextMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ useEventListener(globalThis, "mouseup", (event: MouseEvent) => {

const menu_items = shallowRef<Component[]>([]);
watch(
() => [meta_data.value.viewer_object_type, meta_data.value.geode_object_type],
() => [meta_data.value.viewer_object_type, meta_data.value.geode_object_type] as const,
([viewer_object_type, geode_object_type]) => {
menu_items.value = menuStore.getMenuItems(viewer_object_type, geode_object_type);
},
Expand Down
Loading
Loading