Project NOMAD is an offline-first knowledge and education server. Wikipedia, thousands of books, courses, maps, and optional local AI, all running on hardware you own with no internet required.
TypeScript
feat: easy setup wizard
Jake Turner4b74118fd9b5
diff --git a/admin/inertia/components/InstallActivityFeed.tsx b/admin/inertia/components/InstallActivityFeed.tsxindex ab7a9daa..d686e64b 100644--- a/admin/inertia/components/InstallActivityFeed.tsx+++ b/admin/inertia/components/InstallActivityFeed.tsx@@ -27,7 +27,7 @@ const InstallActivityFeed: React.FC<InstallActivityFeedProps> = ({ activity, clareturn (<div className={classNames('bg-white shadow-sm rounded-lg p-6', className)}>{withHeader && <h2 className="text-lg font-semibold text-gray-900">Installation Activity</h2>}- <ul role="list" className="mt-6 space-y-6 text-desert-green">+ <ul role="list" className={classNames("space-y-6 text-desert-green", withHeader ? 'mt-6' : '')}>{activity.map((activityItem, activityItemIdx) => (<li key={activityItem.timestamp} className="relative flex gap-x-4"><divdiff --git a/admin/inertia/hooks/useInternetStatus.ts b/admin/inertia/hooks/useInternetStatus.tsindex cd119e30..5b670861 100644--- a/admin/inertia/hooks/useInternetStatus.ts+++ b/admin/inertia/hooks/useInternetStatus.ts@@ -4,7 +4,7 @@ import { useEffect, useState } from 'react';import api from '~/lib/api';const useInternetStatus = () => {- const [isOnline, setIsOnline] = useState<boolean>(false);+ const [isOnline, setIsOnline] = useState<boolean>(true); // Initialize true to avoid "offline" flicker on loadconst { data } = useQuery<boolean>({queryKey: ['internetStatus'],queryFn: async () => (await api.getInternetStatus()) ?? false,diff --git a/admin/inertia/pages/easy-setup/index.tsx b/admin/inertia/pages/easy-setup/index.tsxindex f420b76f..d6f1ce0d 100644--- a/admin/inertia/pages/easy-setup/index.tsx+++ b/admin/inertia/pages/easy-setup/index.tsx@@ -1,6 +1,6 @@import { Head, router } from '@inertiajs/react'import { useQuery } from '@tanstack/react-query'-import { useState, useMemo } from 'react'+import { useState } from 'react'import AppLayout from '~/layouts/AppLayout'import StyledButton from '~/components/StyledButton'import api from '~/lib/api'@@ -42,9 +42,9 @@ export default function EasySetupWizard(props: { system: { services: ServiceSlimrefetchOnWindowFocus: false,})- const availableServices = useMemo(() => {- return props.system.services.filter((service) => !service.installed)- }, [props.system.services])+ const availableServices = props.system.services.filter(+ (service) => !service.installed && service.installation_status !== 'installing'+ )const toggleServiceSelection = (serviceName: string) => {setSelectedServices((prev) =>@@ -97,26 +97,23 @@ export default function EasySetupWizard(props: { system: { services: ServiceSlimtry {// All of these ops don't actually wait for completion, they just kick off the process, so we can run them in parallel without awaiting each one sequentially- // const installPromises = selectedServices.map((serviceName) => api.installService(serviceName))+ const installPromises = selectedServices.map((serviceName) => api.installService(serviceName))- // await Promise.all(installPromises)+ await Promise.all(installPromises)- // const downloadPromises = [- // ...selectedMapCollections.map((slug) => api.downloadMapCollection(slug)),- // ...selectedZimCollections.map((slug) => api.downloadZimCollection(slug)),- // ]+ const downloadPromises = [+ ...selectedMapCollections.map((slug) => api.downloadMapCollection(slug)),+ ...selectedZimCollections.map((slug) => api.downloadZimCollection(slug)),+ ]- // await Promise.all(downloadPromises)+ await Promise.all(downloadPromises)addNotification({type: 'success',message: 'Setup wizard completed! Your selections are being processed.',})- // Wait a moment then redirect to completion page to show progress- setTimeout(() => {- router.visit('/easy-setup/complete')- }, 2000)+ router.visit('/easy-setup/complete')} catch (error) {console.error('Error during setup:', error)addNotification({@@ -226,26 +223,17 @@ export default function EasySetupWizard(props: { system: { services: ServiceSlim) : (<div className="grid grid-cols-1 md:grid-cols-2 gap-4">{availableServices.map((service) => {- const selectedOrInstalled =- selectedServices.includes(service.service_name) ||- service.installed ||- service.installation_status === 'installing'-- const installedOrInstalling =- service.installed || service.installation_status === 'installing'+ const selected = selectedServices.includes(service.service_name)return (<divkey={service.id}- onClick={() =>- !installedOrInstalling && toggleServiceSelection(service.service_name)- }+ onClick={() => toggleServiceSelection(service.service_name)}className={classNames('p-6 rounded-lg border-2 cursor-pointer transition-all',- selectedOrInstalled+ selected? 'border-desert-green bg-desert-green bg-opacity-10 shadow-md text-white'- : 'border-desert-stone-light bg-white hover:border-desert-green hover:shadow-sm',- installedOrInstalling ? 'opacity-50 cursor-not-allowed' : ''+ : 'border-desert-stone-light bg-white hover:border-desert-green hover:shadow-sm')}><div className="flex items-start justify-between">@@ -256,7 +244,7 @@ export default function EasySetupWizard(props: { system: { services: ServiceSlim<pclassName={classNames('text-sm mt-1',- selectedOrInstalled ? 'text-white' : 'text-gray-600'+ selected ? 'text-white' : 'text-gray-600')}>{service.description}@@ -265,12 +253,10 @@ export default function EasySetupWizard(props: { system: { services: ServiceSlim<divclassName={classNames('ml-4 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all',- selectedOrInstalled- ? 'border-desert-green bg-desert-green'- : 'border-desert-stone'+ selected ? 'border-desert-green bg-desert-green' : 'border-desert-stone')}>- {selectedOrInstalled ? (+ {selected ? (<IconCheck size={20} className="text-white" />) : (<div className="w-5 h-5 rounded-full bg-transparent" />diff --git a/admin/inertia/pages/settings/zim/remote-explorer.tsx b/admin/inertia/pages/settings/zim/remote-explorer.tsxindex 20cd1d47..5c66b6ce 100644--- a/admin/inertia/pages/settings/zim/remote-explorer.tsx+++ b/admin/inertia/pages/settings/zim/remote-explorer.tsx@@ -230,6 +230,7 @@ export default function ZimRemoteExplorer() {key={collection.slug}collection={collection}onClick={(collection) => confirmDownload(collection)}+ size='large'/>))}</div>