@antcde/component-library 0.1.33-rc.1 → 0.1.33
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/dist/build/uno.js +0 -2
- package/dist/index.js +28341 -28346
- package/dist/types/components/AntTourZone/index.vue.d.ts +1 -1
- package/dist/types/components/BaseAppCardSkeleton.vue.d.ts +1 -1
- package/dist/types/components/BaseLimitedButton.vue.d.ts +1 -1
- package/dist/types/components/FilePreviewContent/usePreviewDetails.d.ts +1 -1
- package/dist/types/components/ScriptTrigger/context.d.ts +2 -2
- package/dist/types/components/StackedLabels/index.vue.d.ts +1 -1
- package/dist/types/components/TasksFlow/composables/useFlowEdgeConditionState.d.ts +1 -1
- package/dist/types/components/TasksFlow/composables/useTaskFlow.d.ts +1 -1
- package/dist/types/index.d.ts +45 -2
- package/lib/ForgeViewer/ForgeViewer.vue +43 -0
- package/lib/ForgeViewer/index.ts +4 -0
- package/lib/ForgeViewer/lang/translations/de.json +6 -0
- package/lib/ForgeViewer/lang/translations/en.json +6 -0
- package/lib/ForgeViewer/lang/translations/nl.json +6 -0
- package/lib/ForgeViewer/useForgeViewer.ts +401 -0
- package/lib/GisViewer/GisViewer.vue +67 -0
- package/lib/GisViewer/GisViewerAppBar.vue +34 -0
- package/lib/GisViewer/index.ts +3 -0
- package/lib/GisViewer/useGisViewer.ts +415 -0
- package/lib/build/uno.ts +0 -2
- package/lib/build/vuetify.ts +0 -2
- package/package.json +17 -6
- package/dist/types/deprecated.d.ts +0 -974
- package/lib/build/fonts.css +0 -26
|
@@ -26,10 +26,10 @@ type __VLS_Slots = {} & {
|
|
|
26
26
|
default?: (props: typeof __VLS_1) => any;
|
|
27
27
|
};
|
|
28
28
|
declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
29
|
+
enabled: boolean;
|
|
29
30
|
placement: "top" | "bottom" | "left" | "right";
|
|
30
31
|
radius: string;
|
|
31
32
|
z: number;
|
|
32
|
-
enabled: boolean;
|
|
33
33
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
34
34
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
35
35
|
declare const _default: typeof __VLS_export;
|
|
@@ -7,8 +7,8 @@ type __VLS_Props = {
|
|
|
7
7
|
};
|
|
8
8
|
declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
9
9
|
small: boolean;
|
|
10
|
-
index: number;
|
|
11
10
|
fluid: boolean;
|
|
11
|
+
index: number;
|
|
12
12
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
13
13
|
declare const _default: typeof __VLS_export;
|
|
14
14
|
export default _default;
|
|
@@ -26,10 +26,10 @@ declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {},
|
|
|
26
26
|
size: "x-small" | "small" | "default" | "large" | "x-large";
|
|
27
27
|
color: string;
|
|
28
28
|
prependIcon: string;
|
|
29
|
-
variant: "flat" | "text" | "elevated" | "tonal" | "outlined" | "plain";
|
|
30
29
|
limited: boolean;
|
|
31
30
|
tooltip: string;
|
|
32
31
|
tooltipMaxWidth: number | string;
|
|
32
|
+
variant: "flat" | "text" | "elevated" | "tonal" | "outlined" | "plain";
|
|
33
33
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
34
34
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
35
35
|
declare const _default: typeof __VLS_export;
|
|
@@ -13,7 +13,7 @@ export declare function usePreviewDetails(tab: () => PreviewTabData, antConnect:
|
|
|
13
13
|
createdAt: string | undefined;
|
|
14
14
|
updatedAt: string | undefined;
|
|
15
15
|
}>;
|
|
16
|
-
fileScope: import('vue').ComputedRef<"
|
|
16
|
+
fileScope: import('vue').ComputedRef<"project" | "license">;
|
|
17
17
|
breadcrumbs: import('vue').ComputedRef<{
|
|
18
18
|
name: string;
|
|
19
19
|
is_folder: boolean;
|
|
@@ -6,12 +6,12 @@ export interface ScriptTriggerContext {
|
|
|
6
6
|
licenseId: string | null;
|
|
7
7
|
projectId: string | null;
|
|
8
8
|
sbsCode?: string | null;
|
|
9
|
-
/** Column types a dataset may publish, from `
|
|
9
|
+
/** Column types a dataset may publish, from `webhookConfig.fetchConfig`. */
|
|
10
10
|
publishableColumnTypes: string[];
|
|
11
11
|
}
|
|
12
12
|
export declare function provideScriptTriggerContext(context: MaybeRefOrGetter<ScriptTriggerContext>): ComputedRef<ScriptTriggerContext>;
|
|
13
13
|
export declare function injectScriptTriggerContext(): ComputedRef<ScriptTriggerContext>;
|
|
14
|
-
export declare function useScriptTriggerI18n(): import('vue-i18n').Composer<{
|
|
14
|
+
export declare function useScriptTriggerI18n(): import('../../../vue-i18n/dist/vue-i18n.runtime.esm-bundler.js').Composer<{
|
|
15
15
|
en: {
|
|
16
16
|
common: {
|
|
17
17
|
loading: string;
|
|
@@ -18,8 +18,8 @@ type __VLS_Props = {
|
|
|
18
18
|
};
|
|
19
19
|
declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
20
20
|
size: number;
|
|
21
|
-
maxVisible: number;
|
|
22
21
|
display: "stacked" | "inline";
|
|
22
|
+
maxVisible: number;
|
|
23
23
|
menuEnabled: boolean;
|
|
24
24
|
showIcon: boolean;
|
|
25
25
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
@@ -14,7 +14,7 @@ interface Options {
|
|
|
14
14
|
* reads as 'pending' and is never rendered.
|
|
15
15
|
*/
|
|
16
16
|
export declare function useFlowEdgeConditionState({ isConditional, conditions, sourceNode, targetNode }: Options): {
|
|
17
|
-
conditionStateIcon: ComputedRef<"mdi-
|
|
17
|
+
conditionStateIcon: ComputedRef<"mdi-alert-circle-outline" | "mdi-check-circle" | "mdi-debug-step-over" | "mdi-clock-outline">;
|
|
18
18
|
conditionStateColor: ComputedRef<"warning" | "success" | undefined>;
|
|
19
19
|
canReevaluate: ComputedRef<boolean>;
|
|
20
20
|
};
|
|
@@ -362,7 +362,7 @@ export declare function useTaskFlow(antConnect: AntConnect, notepad: Notepad, ch
|
|
|
362
362
|
flowEdges: Ref<TaskFlowEdge[], TaskFlowEdge[]>;
|
|
363
363
|
highlightedNodeId: Ref<string | null, string | null>;
|
|
364
364
|
hoveredNodeId: Ref<string | null, string | null>;
|
|
365
|
-
layoutDirection: Ref<"
|
|
365
|
+
layoutDirection: Ref<"TB" | "LR", "TB" | "LR">;
|
|
366
366
|
viewMode: Ref<"free" | "swimlane", "free" | "swimlane">;
|
|
367
367
|
editingConditionsEdgeId: Ref<string | null, string | null>;
|
|
368
368
|
openConditionsEditor: (edgeId: string) => void;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,12 +1,36 @@
|
|
|
1
1
|
import { App } from 'vue';
|
|
2
2
|
import { default as BaseAntInput } from './components/BaseAntInput.vue';
|
|
3
|
+
import { default as BaseAppCard } from './components/BaseAppCard/index.vue';
|
|
4
|
+
import { default as BaseAppCardSkeleton } from './components/BaseAppCardSkeleton.vue';
|
|
3
5
|
import { default as BaseClickableIcon } from './components/BaseClickableIcon.vue';
|
|
4
6
|
import { default as BaseDeleteDialog } from './components/BaseDeleteDialog.vue';
|
|
7
|
+
import { default as BaseLimitedButton } from './components/BaseLimitedButton.vue';
|
|
8
|
+
import { default as BulkLabelsMenu } from './components/BulkLabelsMenu.vue';
|
|
9
|
+
import { default as DmsFilePicker } from './components/DmsFilePicker/index.vue';
|
|
10
|
+
import { default as GlobalLabelBadge } from './components/GlobalLabelBadge.vue';
|
|
11
|
+
import { default as PermissionCard } from './components/RBAC/Permissions/PermissionCard.vue';
|
|
12
|
+
import { default as StackedLabels } from './components/StackedLabels/index.vue';
|
|
13
|
+
import { default as LabelsMenuCard } from './components/StackedLabels/_LabelsMenuCard.vue';
|
|
5
14
|
import { default as RichTextEditor } from './components/RichTextEditor/index.vue';
|
|
15
|
+
import { default as FilePreviewContent } from './components/FilePreviewContent/index.vue';
|
|
16
|
+
import { default as FlowWindowContent } from './components/FlowWindowContent/index.vue';
|
|
17
|
+
import { default as UnifiedWindow } from './components/UnifiedWindow/index.vue';
|
|
18
|
+
import { default as TaskFlow } from './components/TasksFlow/index.vue';
|
|
19
|
+
import { default as VersionPublishDialog } from './components/VersionPublishDialog.vue';
|
|
6
20
|
import { default as AntTourZone } from './components/AntTourZone/index.vue';
|
|
21
|
+
import { default as ResourceTrash } from './components/Usage/ResourceTrash.vue';
|
|
22
|
+
import { default as UsageActions } from './components/Usage/UsageActions.vue';
|
|
23
|
+
import { default as UsagePanel } from './components/Usage/UsagePanel.vue';
|
|
7
24
|
import { default as AntNoticeAlert } from './components/AntNoticeAlert.vue';
|
|
25
|
+
import { default as AntDatasetFileSource } from './components/ScriptTrigger/AntDatasetFileSource.vue';
|
|
26
|
+
import { default as AntDatasetTableSource } from './components/ScriptTrigger/AntDatasetTableSource.vue';
|
|
27
|
+
import { default as AntPayloadFieldsEditor } from './components/ScriptTrigger/AntPayloadFieldsEditor.vue';
|
|
28
|
+
import { default as AntRunScriptFields } from './components/ScriptTrigger/AntRunScriptFields.vue';
|
|
29
|
+
import { default as AntTransformScriptFields } from './components/ScriptTrigger/AntTransformScriptFields.vue';
|
|
30
|
+
import { default as AntTriggerExecutionUser } from './components/ScriptTrigger/AntTriggerExecutionUser.vue';
|
|
8
31
|
import { default as AntActionMenu } from './components/form/AntActionMenu.vue';
|
|
9
32
|
import { default as AntCheckboxCards } from './components/form/AntCheckboxCards.vue';
|
|
33
|
+
import { default as AntColumnMapRow } from './components/form/AntColumnMapRow.vue';
|
|
10
34
|
import { default as AntDialogShell } from './components/form/AntDialogShell.vue';
|
|
11
35
|
import { default as AntField } from './components/form/AntField.vue';
|
|
12
36
|
import { default as AntFilterChips } from './components/form/AntFilterChips.vue';
|
|
@@ -19,12 +43,15 @@ import { default as AntNumberField } from './components/form/AntNumberField.vue'
|
|
|
19
43
|
import { default as AntOptionPicker } from './components/form/AntOptionPicker.vue';
|
|
20
44
|
import { default as AntPanelSection } from './components/form/AntPanelSection.vue';
|
|
21
45
|
import { default as AntRadioCards } from './components/form/AntRadioCards.vue';
|
|
46
|
+
import { default as AntResourceTile } from './components/form/AntResourceTile.vue';
|
|
22
47
|
import { default as AntSaveBar } from './components/form/AntSaveBar.vue';
|
|
48
|
+
import { default as AntScopePanel } from './components/form/AntScopePanel.vue';
|
|
23
49
|
import { default as AntSearchField } from './components/form/AntSearchField.vue';
|
|
24
50
|
import { default as AntSectionCard } from './components/form/AntSectionCard.vue';
|
|
25
51
|
import { default as AntSelect } from './components/form/AntSelect.vue';
|
|
26
52
|
import { default as AntStatusPill } from './components/form/AntStatusPill.vue';
|
|
27
53
|
import { default as AntToggle } from './components/form/AntToggle.vue';
|
|
54
|
+
export type { AppLike } from './components/BaseAppCard/index.vue';
|
|
28
55
|
export type { ActionMenuItem } from './components/form/AntActionMenu.vue';
|
|
29
56
|
export type { CheckboxCardOption } from './components/form/AntCheckboxCards.vue';
|
|
30
57
|
export type { FilterChipOption } from './components/form/AntFilterChips.types';
|
|
@@ -34,8 +61,24 @@ export type { RadioCardOption } from './components/form/AntRadioCards.vue';
|
|
|
34
61
|
export type { SelectOption } from './components/form/AntSelect.vue';
|
|
35
62
|
export type { PillTone } from './components/form/AntStatusPill.vue';
|
|
36
63
|
export type { MentionItem } from './components/RichTextEditor/index.vue';
|
|
64
|
+
export type { FieldIssue, FieldIssues } from './components/ScriptTrigger/composables/useFieldIssue';
|
|
65
|
+
export { FIELD_ISSUES_KEY, useFieldIssue } from './components/ScriptTrigger/composables/useFieldIssue';
|
|
66
|
+
export { useScriptSelection, WORKING_COPY } from './components/ScriptTrigger/composables/useScriptSelection';
|
|
67
|
+
export type { DatasetColumnChoice } from './components/ScriptTrigger/composables/useTableColumns';
|
|
68
|
+
export { useTableColumns } from './components/ScriptTrigger/composables/useTableColumns';
|
|
69
|
+
export { useTableSelection } from './components/ScriptTrigger/composables/useTableSelection';
|
|
70
|
+
export type { ScriptTriggerContext } from './components/ScriptTrigger/context';
|
|
71
|
+
export { provideScriptTriggerContext } from './components/ScriptTrigger/context';
|
|
72
|
+
export type { PayloadField } from './components/ScriptTrigger/utils/payloadFields';
|
|
73
|
+
export { convertPayloadFieldsToJson, initializePayloadFields } from './components/ScriptTrigger/utils/payloadFields';
|
|
74
|
+
export { withSavedOption } from './components/ScriptTrigger/utils/withSavedOption';
|
|
75
|
+
export type { StackedLabel } from './components/StackedLabels/index.vue';
|
|
76
|
+
export type { FlowChannelSubscriber } from './components/TasksFlow/composables/useTaskFlow';
|
|
77
|
+
export type { WindowSizePreset, WindowTab } from './components/UnifiedWindow/types';
|
|
37
78
|
export { formatBytes } from './components/Usage/formatBytes';
|
|
38
|
-
export
|
|
79
|
+
export { type UseResourceTrash, useResourceTrash } from './components/Usage/useResourceTrash';
|
|
80
|
+
export { type UseResourceUsage, useResourceUsage, type UseResourceUsageOptions } from './components/Usage/useResourceUsage';
|
|
81
|
+
export { useShowUsageSizes } from './components/Usage/useShowUsageSizes';
|
|
39
82
|
export * from '@antcde/vue-utils';
|
|
40
83
|
/** @deprecated Unused on the platform; removed in the next minor. Use the `Ant*` components instead. */
|
|
41
84
|
export declare const BaseAntButton: import('vue').DefineComponent<{
|
|
@@ -315,7 +358,7 @@ export declare const BaseResizePanel: {
|
|
|
315
358
|
default?: (props: {}) => any;
|
|
316
359
|
};
|
|
317
360
|
});
|
|
318
|
-
export { AntActionMenu, AntCheckboxCards, AntDialogShell, AntField, AntFilterChips, AntFilterSelect, AntHintBanner, AntHintTip, AntInput, AntMultiSelect, AntNoticeAlert, AntNumberField, AntOptionPicker, AntPanelSection, AntRadioCards, AntSaveBar, AntSearchField, AntSectionCard, AntSelect, AntStatusPill, AntToggle, AntTourZone, BaseAntInput, BaseClickableIcon, BaseDeleteDialog, RichTextEditor, };
|
|
361
|
+
export { AntActionMenu, AntCheckboxCards, AntColumnMapRow, AntDatasetFileSource, AntDatasetTableSource, AntDialogShell, AntField, AntFilterChips, AntFilterSelect, AntHintBanner, AntHintTip, AntInput, AntMultiSelect, AntNoticeAlert, AntNumberField, AntOptionPicker, AntPanelSection, AntPayloadFieldsEditor, AntRadioCards, AntResourceTile, AntRunScriptFields, AntSaveBar, AntScopePanel, AntSearchField, AntSectionCard, AntSelect, AntStatusPill, AntToggle, AntTourZone, AntTransformScriptFields, AntTriggerExecutionUser, BaseAntInput, BaseAppCard, BaseAppCardSkeleton, BaseClickableIcon, BaseDeleteDialog, BaseLimitedButton, BulkLabelsMenu, DmsFilePicker, FilePreviewContent, FlowWindowContent, GlobalLabelBadge, LabelsMenuCard, PermissionCard, ResourceTrash, RichTextEditor, StackedLabels, TaskFlow, UnifiedWindow, UsageActions, UsagePanel, VersionPublishDialog, };
|
|
319
362
|
/**
|
|
320
363
|
* ⚠️ `BaseAntInput` and `BaseAntDatePicker` are the SUPERSEDED field idiom: Vuetify-field
|
|
321
364
|
* wrappers whose border weight and floating notched label make forms read as "raw Vuetify".
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import type { ApplicationProps } from './useForgeViewer'
|
|
3
|
+
import { useAntI18n } from '@antcde/vue-utils'
|
|
4
|
+
import { computed, onMounted, onUnmounted } from 'vue'
|
|
5
|
+
|
|
6
|
+
const { viewer, client } = defineProps<ApplicationProps>()
|
|
7
|
+
const { t } = useAntI18n(client)
|
|
8
|
+
const showErrorDialog = computed(() => viewer.isLoading.value === null)
|
|
9
|
+
|
|
10
|
+
// handle resize evnet using resize observer
|
|
11
|
+
const resizeObserver = new ResizeObserver(() => viewer.resize())
|
|
12
|
+
|
|
13
|
+
onMounted(() => {
|
|
14
|
+
if (viewer.container.value) {
|
|
15
|
+
resizeObserver.observe(viewer.container.value)
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
onUnmounted(() => {
|
|
20
|
+
if (viewer.container.value) {
|
|
21
|
+
resizeObserver.unobserve(viewer.container.value)
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<template>
|
|
27
|
+
<div class="relative w-full h-full">
|
|
28
|
+
<div
|
|
29
|
+
:ref="viewer.container"
|
|
30
|
+
class="relative w-full h-full"
|
|
31
|
+
:class="{ 'opacity-30 transition-opacity duration-700': viewer.isLoading.value }"
|
|
32
|
+
/>
|
|
33
|
+
<div v-if="viewer.isLoading.value === true" class="absolute items-center justify-center inset-0 flex z-1">
|
|
34
|
+
<div class="w-10 h-10 rounded-full border-4 border-black/10 border-l-black animate-spin" />
|
|
35
|
+
</div>
|
|
36
|
+
<v-dialog v-model="showErrorDialog" persistent width="500">
|
|
37
|
+
<v-card
|
|
38
|
+
:title="t('forgeViewer.errorTitle')"
|
|
39
|
+
:text="t('forgeViewer.errorDescription')"
|
|
40
|
+
/>
|
|
41
|
+
</v-dialog>
|
|
42
|
+
</div>
|
|
43
|
+
</template>
|
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
import type { UseCommsClient } from '@antcde/vue-utils'
|
|
2
|
+
import { onMounted, onUnmounted, ref, type Ref, watch } from 'vue'
|
|
3
|
+
|
|
4
|
+
export interface ApplicationProps {
|
|
5
|
+
client: UseCommsClient
|
|
6
|
+
viewer: ReturnType<typeof useForgeViewer>
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface SbsRecord {
|
|
10
|
+
code: string
|
|
11
|
+
color: string | null
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface AntModelProperties {
|
|
15
|
+
objectid: number
|
|
16
|
+
name: string
|
|
17
|
+
externalId: string
|
|
18
|
+
properties: any[]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface AntModel {
|
|
22
|
+
id: string
|
|
23
|
+
urn: string
|
|
24
|
+
name: string
|
|
25
|
+
enabled: boolean
|
|
26
|
+
sbscode: string
|
|
27
|
+
sbs_parameter: string
|
|
28
|
+
version: string
|
|
29
|
+
properties: AntModelProperties[]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface Box {
|
|
33
|
+
view?: Autodesk.Viewing.AggregatedView
|
|
34
|
+
viewer?: Record<any, any>
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function useForgeViewer(client: UseCommsClient) {
|
|
38
|
+
const { context, connect } = client
|
|
39
|
+
const container = ref<HTMLDivElement | null>(null)
|
|
40
|
+
const antModels = ref<AntModel[]>([])
|
|
41
|
+
const performanceMode = ref<boolean>(true)
|
|
42
|
+
const viewType = ref<number>(1)
|
|
43
|
+
const ghostingMode = ref<boolean>(true)
|
|
44
|
+
const accessToken = ref<string>()
|
|
45
|
+
const autodeskScript = Object.assign(document.createElement('script'), {
|
|
46
|
+
src: 'https://developer.api.autodesk.com/modelderivative/v2/viewers/7.*/viewer3D.min.js',
|
|
47
|
+
})
|
|
48
|
+
const autodeskCss = Object.assign(document.createElement('link'), {
|
|
49
|
+
href: 'https://developer.api.autodesk.com/modelderivative/v2/viewers/7.*/style.min.css',
|
|
50
|
+
rel: 'stylesheet',
|
|
51
|
+
})
|
|
52
|
+
const box: Box = {
|
|
53
|
+
viewer: undefined,
|
|
54
|
+
view: undefined,
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
onMounted(() => document.head.append(autodeskScript, autodeskCss))
|
|
58
|
+
|
|
59
|
+
onUnmounted(() => {
|
|
60
|
+
document.head
|
|
61
|
+
.querySelectorAll('script[src*="developer.api.autodesk.com"]')
|
|
62
|
+
.forEach(script => script.remove())
|
|
63
|
+
autodeskCss.remove()
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
const isLoadingViewer = ref<boolean | null>(false)
|
|
67
|
+
|
|
68
|
+
const loadViewer = async (projectId: string, sbsCode?: string) => {
|
|
69
|
+
isLoadingViewer.value = true
|
|
70
|
+
return Promise.resolve(projectId)
|
|
71
|
+
.then(createTableQueryPayload)
|
|
72
|
+
.then(q => connect.tables.queryTables<AntModel>(q))
|
|
73
|
+
.then(
|
|
74
|
+
async ({
|
|
75
|
+
client: {
|
|
76
|
+
records: [client],
|
|
77
|
+
},
|
|
78
|
+
models: { records: models },
|
|
79
|
+
}) => {
|
|
80
|
+
if (!accessToken.value) {
|
|
81
|
+
const { access_token } = await fetchAccessToken(client.client_id, client.secret)
|
|
82
|
+
accessToken.value = access_token
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (accessToken.value) {
|
|
86
|
+
models.forEach((model) => {
|
|
87
|
+
getUrnMetadata(model.urn, accessToken.value!)
|
|
88
|
+
.then((res: any) => res.data.metadata[0].guid)
|
|
89
|
+
.then((guid) => {
|
|
90
|
+
getGuidProperties(model.urn, guid, accessToken.value!)
|
|
91
|
+
.then((prop: any) => prop.data.collection)
|
|
92
|
+
.then(properties => (model.properties = properties))
|
|
93
|
+
})
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
antModels.value = models
|
|
98
|
+
initializeViewer(box, accessToken.value, antModels.value, container, sbsCode)
|
|
99
|
+
},
|
|
100
|
+
)
|
|
101
|
+
.then(
|
|
102
|
+
() => (isLoadingViewer.value = false),
|
|
103
|
+
() => (isLoadingViewer.value = null),
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
watch(
|
|
108
|
+
() => context.value.project?.id,
|
|
109
|
+
(id, previousId) => id && id !== previousId && loadViewer(id),
|
|
110
|
+
{ immediate: true },
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
watch(
|
|
114
|
+
() => context.value.sbs?.code,
|
|
115
|
+
code => filterModelsOnSbs(box, antModels, { code }),
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
const loadAntModels = async (item: AntModel) => {
|
|
119
|
+
const { project, sbs } = context.value
|
|
120
|
+
const antModel = antModels.value.find(model => model.id === item.id)
|
|
121
|
+
|
|
122
|
+
if (antModel && project) {
|
|
123
|
+
antModel.enabled = !antModel.enabled
|
|
124
|
+
antModels.value = [...antModels.value]
|
|
125
|
+
await loadViewer(project.id, sbs?.code)
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
setPerformanceMode: () =>
|
|
131
|
+
setPerformanceMode(box, (performanceMode.value = !performanceMode.value)),
|
|
132
|
+
setViewType: () => setViewType(box, (viewType.value = viewType.value === 1 ? 2 : 1)),
|
|
133
|
+
setGhosting: () => setGhosting(box, (ghostingMode.value = !ghostingMode.value)),
|
|
134
|
+
clearIsolation: () => clearIsolation(box),
|
|
135
|
+
clearSearch: () => clearSearch(box),
|
|
136
|
+
onSbsSearch: (code?: string) => code && filterModelsOnSbs(box, antModels, { code }),
|
|
137
|
+
drawSbs: (sbsRecords: SbsRecord[]) => drawModelsBySbs(box, antModels, sbsRecords),
|
|
138
|
+
resize: () => box.viewer?.resize(),
|
|
139
|
+
loadAntModels,
|
|
140
|
+
performanceMode,
|
|
141
|
+
ghostingMode,
|
|
142
|
+
viewType,
|
|
143
|
+
container,
|
|
144
|
+
antModels,
|
|
145
|
+
isLoading: isLoadingViewer,
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function createTableQueryPayload(project: string) {
|
|
150
|
+
return {
|
|
151
|
+
tables: [
|
|
152
|
+
{
|
|
153
|
+
name: 'CFFA_FORGE_MODELS',
|
|
154
|
+
project,
|
|
155
|
+
as: 'models',
|
|
156
|
+
columns: ['urn', 'name', 'enabled', 'sbscode', 'sbs_parameter', 'version'].map(field => ({
|
|
157
|
+
name: field,
|
|
158
|
+
})),
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: 'CFFA_FORGE_CLIENT',
|
|
162
|
+
project,
|
|
163
|
+
as: 'client',
|
|
164
|
+
columns: ['client_id', 'secret'].map(field => ({ name: field })),
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function fetchAccessToken(client_id: string, secret: string): Promise<{ access_token: string }> {
|
|
171
|
+
const params = new URLSearchParams({
|
|
172
|
+
grant_type: 'client_credentials',
|
|
173
|
+
redirect_uri: 'https://app.alpha.antcde.io/acc-callback',
|
|
174
|
+
scope: 'data:read',
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
const config = {
|
|
178
|
+
method: 'POST',
|
|
179
|
+
body: params,
|
|
180
|
+
headers: {
|
|
181
|
+
'Accept': 'application/json',
|
|
182
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
183
|
+
'Authorization': `Basic ${btoa(`${client_id}:${secret}`)}`,
|
|
184
|
+
},
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return fetch(`https://developer.api.autodesk.com/authentication/v2/token`, config).then(
|
|
188
|
+
response => response.json(),
|
|
189
|
+
)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function getUrnMetadata(urn: string, token: string, region = 'US') {
|
|
193
|
+
const url
|
|
194
|
+
= region === 'EMEA'
|
|
195
|
+
? `https://developer.api.autodesk.com/modelderivative/v2/regions/eu/designdata/${urn}/metadata`
|
|
196
|
+
: `https://developer.api.autodesk.com/modelderivative/v2/designdata/${urn}/metadata`
|
|
197
|
+
const config = {
|
|
198
|
+
method: 'GET',
|
|
199
|
+
headers: {
|
|
200
|
+
'Accept': 'application/json',
|
|
201
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
202
|
+
'Authorization': `Bearer ${token}`,
|
|
203
|
+
},
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return fetch(`${url}?forceget=true`, config).then(response => response.json())
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function getGuidProperties(urn: string, modelGuid: string, token: string, region = 'US') {
|
|
210
|
+
const url
|
|
211
|
+
= region === 'EMEA'
|
|
212
|
+
? `https://developer.api.autodesk.com/modelderivative/v2/regions/eu/designdata/${urn}/metadata/${modelGuid}/properties`
|
|
213
|
+
: `https://developer.api.autodesk.com/modelderivative/v2/designdata/${urn}/metadata/${modelGuid}/properties`
|
|
214
|
+
const config = {
|
|
215
|
+
method: 'GET',
|
|
216
|
+
headers: {
|
|
217
|
+
'Accept': 'application/json',
|
|
218
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
219
|
+
'Authorization': `Bearer ${token}`,
|
|
220
|
+
},
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return fetch(`${url}?forceget=true`, config).then(response => response.json())
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function loadManifest(urn: string) {
|
|
227
|
+
return new Promise((resolve, reject) => {
|
|
228
|
+
Autodesk.Viewing.Document.load(
|
|
229
|
+
`urn:${urn}`,
|
|
230
|
+
doc => doc.downloadAecModelData(() => resolve(doc)),
|
|
231
|
+
reject,
|
|
232
|
+
)
|
|
233
|
+
})
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function initializeViewer(
|
|
237
|
+
box: Box,
|
|
238
|
+
accessToken: string,
|
|
239
|
+
models: AntModel[],
|
|
240
|
+
container: Ref<HTMLDivElement | null>,
|
|
241
|
+
sbscode?: string,
|
|
242
|
+
) {
|
|
243
|
+
if (!models.length)
|
|
244
|
+
return console.error('Empty urn records input')
|
|
245
|
+
|
|
246
|
+
const options = {
|
|
247
|
+
env: 'AutodeskProduction',
|
|
248
|
+
api: 'derivativeV2',
|
|
249
|
+
getAccessToken: (onTokenReady: (token: string, timeInSeconds: number) => void) =>
|
|
250
|
+
onTokenReady(accessToken, 3600),
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const options3d = { viewerConfig: { disableBimWalkInfoIcon: true } }
|
|
254
|
+
|
|
255
|
+
Autodesk.Viewing.Initializer(options, async () => {
|
|
256
|
+
box.view = new Autodesk.Viewing.AggregatedView()
|
|
257
|
+
box.view.init(container.value!, options3d) // TODO first make sure it is not null!
|
|
258
|
+
box.viewer = box.view.viewer
|
|
259
|
+
|
|
260
|
+
const bubbles = await Promise.all(
|
|
261
|
+
models.filter(md => md.enabled).map(md => loadManifest(md.urn)),
|
|
262
|
+
).then((docs: any[]) =>
|
|
263
|
+
docs.map((doc: any) => doc.getRoot().search({ type: 'geometry', role: '3d' })[0] || null),
|
|
264
|
+
)
|
|
265
|
+
|
|
266
|
+
box.view.setNodes(bubbles, null)
|
|
267
|
+
box.viewer.addEventListener(Autodesk.Viewing.GEOMETRY_LOADED_EVENT, () => {
|
|
268
|
+
box.viewer?.fitToView()
|
|
269
|
+
if (sbscode)
|
|
270
|
+
searchWithSbsCode(box, sbscode)
|
|
271
|
+
})
|
|
272
|
+
})
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function getAutodeskModels(box: Box): Autodesk.Viewing.Model[] {
|
|
276
|
+
return box.viewer?.impl.modelQueue().getModels() ?? []
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function setPerformanceMode(box: Box, value: boolean) {
|
|
280
|
+
if (box.viewer) {
|
|
281
|
+
box.viewer.setGroundShadow(!value)
|
|
282
|
+
box.viewer.setGhosting(!value)
|
|
283
|
+
box.viewer.setQualityLevel(!value, !value)
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function setViewType(box: Box, value: number) {
|
|
288
|
+
;(box.viewer as any).setViewType?.(value)
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function setGhosting(box: Box, value: boolean) {
|
|
292
|
+
box.viewer?.setGhosting(value)
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function clearIsolation(box: Box) {
|
|
296
|
+
box.viewer?.fitToView()
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function clearSearch(box: Box) {
|
|
300
|
+
if (box.viewer) {
|
|
301
|
+
box.viewer.showAll()
|
|
302
|
+
box.viewer.fitToView()
|
|
303
|
+
box.viewer.clearThemingColors(box.viewer.model)
|
|
304
|
+
box.viewer.clearSelection()
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function searchWithSbsCode(box: Box, search: string) {
|
|
309
|
+
if (box.viewer) {
|
|
310
|
+
box.viewer.clearSelection()
|
|
311
|
+
box.viewer.search(search, showIsolated, searchErrorCallback, [])
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function showIsolated(box: Box, ids: number[], model?: Autodesk.Viewing.Model) {
|
|
316
|
+
box.viewer?.isolate(ids, model)
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function searchErrorCallback(string: string) {
|
|
320
|
+
return `${string} not found!`
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function getObjectsWithMappingLevel(objects: AntModelProperties[], levels: string[]) {
|
|
324
|
+
const hasNestedProperty = (objs: AntModelProperties[], propertyPath: string[]) => {
|
|
325
|
+
return propertyPath.reduce((acc, key) => acc && (acc as any)[key], objs) !== undefined
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
const filteredObjects = objects.filter((obj: AntModelProperties) => {
|
|
329
|
+
return hasNestedProperty(obj.properties, levels)
|
|
330
|
+
})
|
|
331
|
+
|
|
332
|
+
return filteredObjects
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function getValueFromProperties(properties: any[], keys: any[]) {
|
|
336
|
+
return keys.reduce((acc, key) => acc && acc[key], properties)
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function filterModelsOnSbs(box: Box, antModels: Ref<AntModel[]>, sbs: { code?: string }) {
|
|
340
|
+
const autodeskModels: Autodesk.Viewing.Model[] = getAutodeskModels(box)
|
|
341
|
+
|
|
342
|
+
autodeskModels.forEach((autodeskModel: Autodesk.Viewing.Model) => {
|
|
343
|
+
showIsolated(box, [-1], autodeskModel)
|
|
344
|
+
})
|
|
345
|
+
|
|
346
|
+
antModels.value.forEach((antModel: AntModel) => {
|
|
347
|
+
const sbsLevel = antModel.sbs_parameter.split('.')
|
|
348
|
+
const objects = getObjectsWithMappingLevel(antModel.properties, sbsLevel)
|
|
349
|
+
const selectedAutodeskModel = autodeskModels.find(
|
|
350
|
+
(autodeskModel: Autodesk.Viewing.Model) => antModel.urn === autodeskModel.getData().urn,
|
|
351
|
+
)
|
|
352
|
+
|
|
353
|
+
objects.forEach((object: AntModelProperties) => {
|
|
354
|
+
const value = getValueFromProperties(object.properties, sbsLevel)
|
|
355
|
+
if (value === sbs.code) {
|
|
356
|
+
showIsolated(box, [object.objectid], selectedAutodeskModel)
|
|
357
|
+
}
|
|
358
|
+
})
|
|
359
|
+
})
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
function drawModelsBySbs(box: Box, antModels: Ref<AntModel[]>, sbsRecords: SbsRecord[]) {
|
|
363
|
+
const autodeskModels: Autodesk.Viewing.Model[] = getAutodeskModels(box)
|
|
364
|
+
|
|
365
|
+
antModels.value.forEach((antModel: AntModel) => {
|
|
366
|
+
const sbsLevel = antModel.sbs_parameter.split('.')
|
|
367
|
+
const objects = getObjectsWithMappingLevel(antModel.properties, sbsLevel)
|
|
368
|
+
const selectedAutodeskModel = autodeskModels.find(
|
|
369
|
+
(autodeskModel: Autodesk.Viewing.Model) => antModel.urn === autodeskModel.getData().urn,
|
|
370
|
+
)
|
|
371
|
+
|
|
372
|
+
selectedAutodeskModel?.clearThemingColors()
|
|
373
|
+
|
|
374
|
+
objects.forEach((object: AntModelProperties) => {
|
|
375
|
+
const value = getValueFromProperties(object.properties, sbsLevel)
|
|
376
|
+
if (!value) {
|
|
377
|
+
box.viewer?.show(object.objectid, selectedAutodeskModel)
|
|
378
|
+
return
|
|
379
|
+
}
|
|
380
|
+
const record = sbsRecords.find(record => record.code === value)
|
|
381
|
+
if (record) {
|
|
382
|
+
box.viewer?.show(object.objectid, selectedAutodeskModel)
|
|
383
|
+
if (record.color) {
|
|
384
|
+
selectedAutodeskModel?.setThemingColor(
|
|
385
|
+
object.objectid,
|
|
386
|
+
new THREE.Vector4(
|
|
387
|
+
Number.parseInt(record.color.slice(1, 3), 16) / 255,
|
|
388
|
+
Number.parseInt(record.color.slice(3, 5), 16) / 255,
|
|
389
|
+
Number.parseInt(record.color.slice(5, 7), 16) / 255,
|
|
390
|
+
1,
|
|
391
|
+
),
|
|
392
|
+
true,
|
|
393
|
+
)
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
box.viewer?.hide(object.objectid, selectedAutodeskModel)
|
|
398
|
+
}
|
|
399
|
+
})
|
|
400
|
+
})
|
|
401
|
+
}
|