Files
speckle-server/packages/frontend-2/lib/common/composables/serverInfo.ts
T
Kristaps Fabians Geikins 83d8035dc2 chore: upgrade to eslint 9 (#2348)
* root + server

* frontend

* frontend-2

* dui3

* dui3

* tailwind theme

* ui-components

* preview service

* viewer

* viewer-sandbox

* fileimport-service

* webhook service

* objectloader

* shared

* ui-components-nuxt

* WIP full config

* WIP full linter

* eslint projectwide util

* minor fix

* removing redundant ci

* clean up test errors

* fixed prettier formatting

* CI improvements

* TSC lint fix

* 'buildBatch' needs to be async since some batch types (like Text) require it. Removed a disabled liniting rule from ObjLoader

* removed unnecessary void

---------

Co-authored-by: AlexandruPopovici <alexandrupopoviciioan@gmail.com>
2024-06-12 14:38:02 +03: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.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
}
}