Skip to content

Commit

Permalink
Merge branch 'main' of github.com:specklesystems/speckle-server
Browse files Browse the repository at this point in the history
  • Loading branch information
fabis94 committed Feb 12, 2024
2 parents d3ad2ea + d7402d8 commit 0e7b2a0
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/frontend-2/components/viewer/Controls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
: '-translate-x-[100%] opacity-0'
} ${isEmbedEnabled ? 'mt-1.5' : 'mt-[4rem]'}`"
>
<div v-show="activeControl.length !== 0 && activeControl === 'measurements'">
<div v-if="activeControl.length !== 0 && activeControl === 'measurements'">
<KeepAlive>
<div><ViewerMeasurementsOptions @close="toggleMeasurements" /></div>
</KeepAlive>
Expand Down
3 changes: 1 addition & 2 deletions packages/frontend-2/components/viewer/GlobalFilterReset.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<template>
<div
v-show="hasAnyFiltersApplied"
class="absolute left-0 w-screen p-2 bg-pink-300/0 flex justify-center pointer-events-none"
:class="isEmbedEnabled ? 'bottom-16 mb-2' : 'bottom-4'"
class="bg-pink-300/0 flex justify-center items-center pointer-events-none"
>
<Transition
enter-active-class="transform ease-out duration-300 transition"
Expand Down
13 changes: 11 additions & 2 deletions packages/frontend-2/components/viewer/PreSetupWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,17 @@
<ViewerSelectionSidebar class="z-20" />
</div>
</Transition>
<!-- Shows up when filters are applied for an easy return to normality -->
<ViewerGlobalFilterReset class="z-20" :embed="!!isEmbedEnabled" />
<div
class="absolute z-10 w-screen flex flex-col items-center justify-center gap-2"
:class="isEmbedEnabled ? 'bottom-16 mb-1' : 'bottom-6'"
>
<PortalTarget name="pocket-tip"></PortalTarget>
<div class="flex gap-3">
<PortalTarget name="pocket-actions"></PortalTarget>
<!-- Shows up when filters are applied for an easy return to normality -->
<ViewerGlobalFilterReset class="z-20" :embed="!!isEmbedEnabled" />
</div>
</div>
</ClientOnly>
</div>
</ViewerPostSetupWrapper>
Expand Down
20 changes: 20 additions & 0 deletions packages/frontend-2/components/viewer/Tip.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<template>
<div
class="group flex items-center select-none opacity-70 hover:opacity-90 transition"
>
<div
class="relative z-10 h-7 w-7 rounded-full bg-foundation-2 shadow-xl flex items-center justify-center"
>
<LightBulbIcon
class="h-5 w-5 text-foreground opacity-60 shrink-0 group-hover:text-warning group-hover:opacity-80 transition"
/>
</div>
<div class="text-xs bg-foundation-2 rounded-r-md p-[3px] pl-4 pr-2 -ml-3 shadow-xl">
<slot></slot>
</div>
</div>
</template>

<script setup lang="ts">
import { LightBulbIcon } from '@heroicons/vue/24/outline'
</script>
21 changes: 18 additions & 3 deletions packages/frontend-2/components/viewer/measurements/Options.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
v-for="option in measurementTypeOptions"
:key="option.value"
:label="option.title"
:description="option.description"
:value="option.value.toString()"
name="measurementType"
:icon="option.icon"
Expand Down Expand Up @@ -73,6 +74,17 @@
</div>
</div>
</div>
<Portal to="pocket-tip">
<ViewerTip>
<strong>Tip:</strong>
Right click to cancel measurement
</ViewerTip>
</Portal>
<Portal to="pocket-actions">
<FormButton size="sm" @click="() => clearMeasurements()">
Reset Measurements
</FormButton>
</Portal>
</ViewerLayoutPanel>
</template>
<script setup lang="ts">
Expand Down Expand Up @@ -101,7 +113,8 @@ const measurementParams = ref({
precision: measurementPrecision.value
})
const { setMeasurementOptions, removeMeasurement } = useMeasurementUtilities()
const { setMeasurementOptions, removeMeasurement, clearMeasurements } =
useMeasurementUtilities()
const updateMeasurementsType = (selectedOption: MeasurementTypeOption) => {
measurementParams.value.type = selectedOption.value
Expand Down Expand Up @@ -135,12 +148,14 @@ const measurementTypeOptions = [
{
title: 'Point to Point',
icon: IconPointToPoint,
value: MeasurementType.POINTTOPOINT
value: MeasurementType.POINTTOPOINT,
description: 'Choose two points for precise measurements'
},
{
title: 'Perpendicular',
icon: IconPerpendicular,
value: MeasurementType.PERPENDICULAR
value: MeasurementType.PERPENDICULAR,
description: 'Tip: Double-click to quick-measure'
}
]
</script>
7 changes: 7 additions & 0 deletions packages/frontend-2/lib/viewer/composables/setup/postSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { CameraController } from '@speckle/viewer'
import type { Reference } from '@apollo/client'
import type { Modifier } from '@apollo/client/cache'
import { useEmbed } from '~/lib/viewer/composables/setup/embed'
import { useMeasurementUtilities } from '~~/lib/viewer/composables/ui'

function useViewerIsBusyEventHandler() {
const state = useInjectedViewerState()
Expand Down Expand Up @@ -724,6 +725,12 @@ function useViewerMeasurementIntegration() {
viewer: { instance }
} = useInjectedViewerState()

const { clearMeasurements } = useMeasurementUtilities()

onBeforeUnmount(() => {
clearMeasurements()
})

watch(
() => measurement.enabled.value,
(newVal, oldVal) => {
Expand Down
9 changes: 7 additions & 2 deletions packages/frontend-2/lib/viewer/composables/ui.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SpeckleViewer, timeoutAt } from '@speckle/shared'
import type { TreeNode } from '@speckle/viewer'
import { CameraController } from '@speckle/viewer'
import { CameraController, MeasurementsExtension } from '@speckle/viewer'
import type { MeasurementOptions, PropertyInfo } from '@speckle/viewer'
import { until } from '@vueuse/shared'
import { difference, isString, uniq } from 'lodash-es'
Expand Down Expand Up @@ -357,10 +357,15 @@ export function useMeasurementUtilities() {
}
}

const clearMeasurements = () => {
state.viewer.instance.getExtension(MeasurementsExtension).clearMeasurements()
}

return {
enableMeasurements,
setMeasurementOptions,
removeMeasurement
removeMeasurement,
clearMeasurements
}
}

Expand Down
8 changes: 4 additions & 4 deletions packages/server/modules/core/services/ratelimiter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ export enum RateLimitAction {
'GET /objects/:streamId/:objectId' = 'GET /objects/:streamId/:objectId',
'GET /objects/:streamId/:objectId/single' = 'GET /objects/:streamId/:objectId/single',
'POST /graphql' = 'POST /graphql',
'GET /auth/local/login' = 'GET /auth/local/login',
'POST /auth/local/login' = 'POST /auth/local/login',
'GET /auth/azure' = 'GET /auth/azure',
'GET /auth/gh' = 'GET /auth/gh',
'GET /auth/goog' = 'GET /auth/goog',
'GET /auth/oidc' = 'GET /auth/oidc',
'GET /auth/azure/callback' = 'GET /auth/azure/callback',
'POST /auth/azure/callback' = 'POST /auth/azure/callback',
'GET /auth/gh/callback' = 'GET /auth/gh/callback',
'GET /auth/goog/callback' = 'GET /auth/goog/callback',
'GET /auth/oidc/callback' = 'GET /auth/oidc/callback'
Expand Down Expand Up @@ -179,7 +179,7 @@ export const LIMITS: RateLimiterOptions = {
duration: 1 * TIME.minute
}
},
'GET /auth/local/login': {
'POST /auth/local/login': {
regularOptions: {
limitCount: getIntFromEnv('RATELIMIT_GET_AUTH', '4'),
duration: 10 * TIME.minute
Expand Down Expand Up @@ -229,7 +229,7 @@ export const LIMITS: RateLimiterOptions = {
duration: 30 * TIME.minute
}
},
'GET /auth/azure/callback': {
'POST /auth/azure/callback': {
regularOptions: {
limitCount: getIntFromEnv('RATELIMIT_GET_AUTH', '4'),
duration: 10 * TIME.minute
Expand Down
3 changes: 2 additions & 1 deletion packages/ui-components/src/components/form/Radio.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ export const WithIcon: StoryObj<typeof defaultArgs> = {
args: {
name: 'withIcon',
label: 'Example radio with Icon',
icon: ArrowRightIcon
icon: ArrowRightIcon,
description: 'Example discription'
}
}

Expand Down
21 changes: 17 additions & 4 deletions packages/ui-components/src/components/form/Radio.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div
class="relative flex gap-2 mb-2 last:mb-0"
:class="description ? 'items-start' : 'items-center'"
:class="description && inlineDescription ? 'items-start' : 'items-center'"
>
<div class="flex h-6 items-center">
<!-- eslint-disable-next-line vuejs-accessibility/form-control-has-label -->
Expand Down Expand Up @@ -31,10 +31,23 @@
<div v-if="icon" class="text-sm">
<component :is="icon" class="h-8 sm:h-10 w-8 sm:w-10"></component>
</div>
<span>{{ title }}</span>
<div class="flex flex-col">
<span>{{ title }}</span>
<p
v-if="descriptionText && !inlineDescription"
:id="descriptionId"
:class="descriptionClasses"
>
{{ descriptionText }}
</p>
</div>
<span v-if="showRequired" class="text-danger ml-1">*</span>
</label>
<p v-if="descriptionText" :id="descriptionId" :class="descriptionClasses">
<p
v-if="descriptionText && inlineDescription"
:id="descriptionId"
:class="descriptionClasses"
>
{{ descriptionText }}
</p>
</div>
Expand Down Expand Up @@ -186,7 +199,7 @@ const computedClasses = computed((): string => {
const descriptionText = computed(() => props.description || errorMessage.value)
const descriptionId = computed(() => `${props.name}-description`)
const descriptionClasses = computed((): string => {
const classParts: string[] = []
const classParts: string[] = ['text-xs']
if (errorMessage.value) {
classParts.push('text-danger')
Expand Down

0 comments on commit 0e7b2a0

Please sign in to comment.