@antcde/component-library 0.1.32-rc.1 → 0.1.33-rc.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.
@@ -1,36 +1,12 @@
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';
5
3
  import { default as BaseClickableIcon } from './components/BaseClickableIcon.vue';
6
4
  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';
14
5
  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';
20
6
  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';
24
7
  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';
31
8
  import { default as AntActionMenu } from './components/form/AntActionMenu.vue';
32
9
  import { default as AntCheckboxCards } from './components/form/AntCheckboxCards.vue';
33
- import { default as AntColumnMapRow } from './components/form/AntColumnMapRow.vue';
34
10
  import { default as AntDialogShell } from './components/form/AntDialogShell.vue';
35
11
  import { default as AntField } from './components/form/AntField.vue';
36
12
  import { default as AntFilterChips } from './components/form/AntFilterChips.vue';
@@ -43,15 +19,12 @@ import { default as AntNumberField } from './components/form/AntNumberField.vue'
43
19
  import { default as AntOptionPicker } from './components/form/AntOptionPicker.vue';
44
20
  import { default as AntPanelSection } from './components/form/AntPanelSection.vue';
45
21
  import { default as AntRadioCards } from './components/form/AntRadioCards.vue';
46
- import { default as AntResourceTile } from './components/form/AntResourceTile.vue';
47
22
  import { default as AntSaveBar } from './components/form/AntSaveBar.vue';
48
- import { default as AntScopePanel } from './components/form/AntScopePanel.vue';
49
23
  import { default as AntSearchField } from './components/form/AntSearchField.vue';
50
24
  import { default as AntSectionCard } from './components/form/AntSectionCard.vue';
51
25
  import { default as AntSelect } from './components/form/AntSelect.vue';
52
26
  import { default as AntStatusPill } from './components/form/AntStatusPill.vue';
53
27
  import { default as AntToggle } from './components/form/AntToggle.vue';
54
- export type { AppLike } from './components/BaseAppCard/index.vue';
55
28
  export type { ActionMenuItem } from './components/form/AntActionMenu.vue';
56
29
  export type { CheckboxCardOption } from './components/form/AntCheckboxCards.vue';
57
30
  export type { FilterChipOption } from './components/form/AntFilterChips.types';
@@ -61,24 +34,8 @@ export type { RadioCardOption } from './components/form/AntRadioCards.vue';
61
34
  export type { SelectOption } from './components/form/AntSelect.vue';
62
35
  export type { PillTone } from './components/form/AntStatusPill.vue';
63
36
  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';
78
37
  export { formatBytes } from './components/Usage/formatBytes';
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';
38
+ export * from './deprecated';
82
39
  export * from '@antcde/vue-utils';
83
40
  /** @deprecated Unused on the platform; removed in the next minor. Use the `Ant*` components instead. */
84
41
  export declare const BaseAntButton: import('vue').DefineComponent<{
@@ -358,7 +315,7 @@ export declare const BaseResizePanel: {
358
315
  default?: (props: {}) => any;
359
316
  };
360
317
  });
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, };
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, };
362
319
  /**
363
320
  * ⚠️ `BaseAntInput` and `BaseAntDatePicker` are the SUPERSEDED field idiom: Vuetify-field
364
321
  * wrappers whose border weight and floating notched label make forms read as "raw Vuetify".
@@ -0,0 +1,26 @@
1
+ /*
2
+ * ANT platform font: Inter, self-hosted from @fontsource-variable (OFL-1.1).
3
+ * Vuetify reads `--v-font-body` everywhere (heading falls back to it), so this
4
+ * one variable sets the font for every app; override it, never `font-family`.
5
+ */
6
+ @import '@fontsource-variable/inter/wght.css';
7
+ @import '@fontsource-variable/inter/wght-italic.css';
8
+
9
+ /* Arial resized to Inter's metrics (fontaine), so the swap doesn't shift layout. */
10
+ @font-face {
11
+ font-family: 'Inter Fallback';
12
+ src: local('Arial');
13
+ size-adjust: 107.1194%;
14
+ ascent-override: 90.4365%;
15
+ descent-override: 22.518%;
16
+ line-gap-override: 0%;
17
+ }
18
+
19
+ :root {
20
+ --v-font-body: 'Inter Variable', 'Inter Fallback', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
21
+ }
22
+
23
+ html {
24
+ -webkit-font-smoothing: antialiased;
25
+ -moz-osx-font-smoothing: grayscale;
26
+ }
package/lib/build/uno.ts CHANGED
@@ -145,6 +145,8 @@ export function createAntUnoConfig(overrides: Partial<UserConfig> = {}): UserCon
145
145
  colors: { ...antColors, ...(overrideTheme?.colors ?? {}) },
146
146
  breakpoints: { ...vuetifyBreakpoints, ...(overrideTheme?.breakpoints ?? {}) },
147
147
  radius: { sm: '2px', xl: '24px', ...(overrideTheme?.radius ?? {}) },
148
+ // Follows Vuetify's font variable (set in fonts.css), so `font-sans` stays Inter.
149
+ font: { sans: 'var(--v-font-body)', ...(overrideTheme?.font ?? {}) },
148
150
  },
149
151
  presets: presets ?? [
150
152
  presetRemToPx,
@@ -8,6 +8,8 @@ import 'vuetify/styles'
8
8
  import 'virtual:uno.css'
9
9
  // CSS patches for Vuetify quirks not expressible via theme/defaults.
10
10
  import './vuetify-overrides.css'
11
+ // Inter + `--v-font-body`, so every app gets the platform font.
12
+ import './fonts.css'
11
13
 
12
14
  /** ANT platform light theme colors — exported for apps that need to reference them in `themes` overrides (e.g. when adding a dark theme). */
13
15
  export const ANT_COLORS = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@antcde/component-library",
3
3
  "type": "module",
4
- "version": "0.1.32-rc.1",
4
+ "version": "0.1.33-rc.1",
5
5
  "description": "Helper to use ant components in Vue 3",
6
6
  "author": "CollaborAll",
7
7
  "exports": {
@@ -27,6 +27,7 @@
27
27
  "import": "./lib/build/vuetify.ts"
28
28
  },
29
29
  "./build/layer-order.css": "./lib/build/layer-order.css",
30
+ "./build/fonts.css": "./lib/build/fonts.css",
30
31
  "./test": {
31
32
  "import": "./lib/test/index.ts"
32
33
  },
@@ -53,24 +54,12 @@
53
54
  "./test/createTestRouter": {
54
55
  "import": "./lib/test/createTestRouter.ts"
55
56
  },
56
- "./lib/ForgeViewer": {
57
- "import": "./lib/ForgeViewer/index.ts"
58
- },
59
- "./lib/ForgeViewer/*": {
60
- "import": "./lib/ForgeViewer/*"
61
- },
62
57
  "./lib/PdfViewer": {
63
58
  "import": "./lib/PdfViewer/index.ts"
64
59
  },
65
60
  "./lib/PdfViewer/*": {
66
61
  "import": "./lib/PdfViewer/*"
67
62
  },
68
- "./lib/GisViewer": {
69
- "import": "./lib/GisViewer/index.ts"
70
- },
71
- "./lib/GisViewer/*": {
72
- "import": "./lib/GisViewer/*"
73
- },
74
63
  "./lib/TableViewer": {
75
64
  "import": "./lib/TableViewer/index.ts"
76
65
  },
@@ -110,7 +99,7 @@
110
99
  "build:safelist": "vite-node lib/build/genSafelist.mjs"
111
100
  },
112
101
  "peerDependencies": {
113
- "@antcde/connect-ts": ">=0.4.0",
102
+ "@antcde/connect-ts": ">=0.6.0",
114
103
  "@antcde/vue-utils": ">=0.2.0",
115
104
  "@iconify/vue": ">=5.0.0",
116
105
  "@intlify/unplugin-vue-i18n": ">=11.0.0",
@@ -190,7 +179,7 @@
190
179
  }
191
180
  },
192
181
  "dependencies": {
193
- "@arcgis/core": "^4.34.8",
182
+ "@fontsource-variable/inter": "^5.3.0",
194
183
  "@mdi/font": "^7.4.47",
195
184
  "@tiptap/extension-link": "^3.31.3",
196
185
  "@tiptap/extension-mention": "^3.31.3",
@@ -208,8 +197,8 @@
208
197
  "vue-i18n": "^11.4.12"
209
198
  },
210
199
  "devDependencies": {
211
- "@antcde/connect-ts": "0.4.34-rc.1",
212
- "@antcde/vue-utils": "0.2.29-rc.1",
200
+ "@antcde/connect-ts": "0.4.35-rc.1",
201
+ "@antcde/vue-utils": "0.2.30-rc.1",
213
202
  "@iconify-json/mdi": "^1.2.3",
214
203
  "@iconify/vue": "^5.0.3",
215
204
  "@intlify/unplugin-vue-i18n": "^11.2.5",
@@ -1,43 +0,0 @@
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>
@@ -1,4 +0,0 @@
1
- import ForgeViewer from './ForgeViewer.vue'
2
- import { useForgeViewer } from './useForgeViewer'
3
-
4
- export { ForgeViewer, useForgeViewer }
@@ -1,6 +0,0 @@
1
- {
2
- "forgeViewer": {
3
- "errorTitle": "Fehler beim Laden des Viewers",
4
- "errorDescription": "Beim Laden des Viewers ist etwas schief gelaufen. Bitte wählen Sie ein anderes Projekt aus"
5
- }
6
- }
@@ -1,6 +0,0 @@
1
- {
2
- "forgeViewer": {
3
- "errorTitle": "Error Loading Viewer",
4
- "errorDescription": "Something went wrong while loading the viewer. Please select another project"
5
- }
6
- }
@@ -1,6 +0,0 @@
1
- {
2
- "forgeViewer": {
3
- "errorTitle": "Fout bij Laden van Viewer",
4
- "errorDescription": "Er is iets misgegaan bij het laden van de viewer. Selecteer alstublieft een ander project"
5
- }
6
- }
@@ -1,401 +0,0 @@
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
- }