Files
speckle-server/packages/frontend-2/lib/common/composables/serverInfo.ts
T
Iain Sproat ecab655719 chore(fe2): update graphql serverinfo to use new configuration object (#2741)
* feat(graphql/serverinfo): provide maximum object size in bytes

* Places config values in a ServerConfiguration object
- updates blobstorage to use ServerConfiguration, while retaining backwards compatibility

* chore(fe2): update graphql serverinfo to use new configuration object

* Update gqlgen and remaining changes
2024-10-15 13:52:43 +01:00

40 lines
1.1 KiB
TypeScript

import { useQuery } from '@vue/apollo-composable'
import { cloneDeep } from 'lodash-es'
import {
serverInfoAllScopesQuery,
serverInfoBlobSizeLimitQuery
} from '~~/lib/common/graphql/queries'
import { prettyFileSize } from '~~/lib/core/helpers/file'
import type { AllScopes } from '@speckle/shared'
export function useServerFileUploadLimit() {
const { result } = useQuery(serverInfoBlobSizeLimitQuery)
const maxSizeInBytes = computed(
() => result.value?.serverInfo.configuration.blobSizeLimitBytes || 0
)
const maxSizeDisplayString = computed(() => prettyFileSize(maxSizeInBytes.value))
return {
maxSizeInBytes,
maxSizeDisplayString
}
}
export const useServerInfoScopes = () => {
const { result } = useQuery(serverInfoAllScopesQuery)
const scopes = computed(() => {
const base = result.value?.serverInfo.scopes || []
const cloned = cloneDeep(base) // cause it might get directly plopped back into the cache by a dev
return cloned.map((scope) => ({
...scope,
name: scope.name as unknown as (typeof AllScopes)[number]
}))
})
return {
scopes
}
}