diff --git a/admin/app/services/map_service.ts b/admin/app/services/map_service.ts index 491d4cb..aa96541 100644 --- a/admin/app/services/map_service.ts +++ b/admin/app/services/map_service.ts @@ -125,13 +125,15 @@ export class MapService { throw new Error('Base styles file not found in storage/maps') } - const localUrl = env.get('URL') const rawStyles = JSON.parse(baseStyle.toString()) as BaseStylesFile const regions = (await this.listRegions()).files const sources = this.generateSourcesArray(regions) - const baseUrl = urlJoin(localUrl, this.mapStoragePath, this.basemapsAssetsDir) + const localUrl = env.get('URL') + const withProtocol = localUrl.startsWith('http') ? localUrl : `http://${localUrl}` + const baseUrlPath = urlJoin(this.mapStoragePath, this.basemapsAssetsDir) + const baseUrl = new URL(baseUrlPath, withProtocol).toString() const styles = await this.generateStylesFile( rawStyles, @@ -173,10 +175,15 @@ export class MapService { if (region.type === 'file' && region.name.endsWith('.pmtiles')) { const regionName = region.name.replace('.pmtiles', '') const source: BaseStylesFile['sources'] = {} + const sourceUrl = new URL( + urlJoin(this.mapStoragePath, 'pmtiles', region.name), + localUrl.startsWith('http') ? localUrl : `http://${localUrl}` + ).toString() + source[regionName] = { type: 'vector', attribution: PMTILES_ATTRIBUTION, - url: `pmtiles://http://${urlJoin(localUrl, this.mapStoragePath, 'pmtiles', region.name)}`, + url: `pmtiles://${sourceUrl}`, } sources.push(source) } diff --git a/admin/inertia/components/Alert.tsx b/admin/inertia/components/Alert.tsx index 2da737d..0d41772 100644 --- a/admin/inertia/components/Alert.tsx +++ b/admin/inertia/components/Alert.tsx @@ -1,62 +1,200 @@ -import { ExclamationTriangleIcon, XCircleIcon } from '@heroicons/react/24/solid' -import { IconCircleCheck } from '@tabler/icons-react' +import * as Icons from '@heroicons/react/24/solid' import classNames from '~/lib/classNames' export type AlertProps = React.HTMLAttributes & { title: string message?: string - type: 'warning' | 'error' | 'success' + type: 'warning' | 'error' | 'success' | 'info' children?: React.ReactNode + dismissible?: boolean + onDismiss?: () => void + icon?: keyof typeof Icons + variant?: 'standard' | 'bordered' | 'solid' } -export default function Alert({ title, message, type, children, ...props }: AlertProps) { - const getIcon = () => { - const Icon = - type === 'warning' - ? ExclamationTriangleIcon - : type === 'error' - ? XCircleIcon - : IconCircleCheck - const color = - type === 'warning' ? 'text-yellow-400' : type === 'error' ? 'text-red-400' : 'text-green-400' - - return