Skip to content

Commit d8c6a6c

Browse files
committed
semantic
1 parent 8c9c1f7 commit d8c6a6c

File tree

1 file changed

+69
-41
lines changed

1 file changed

+69
-41
lines changed

pages/index.tsx

+69-41
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,18 @@ const InstallerView = React.memo(function InstallerView({}: {}) {
167167
<ListIcon as={installer?.['@deep-foundation/deepmemo-links']?.length ? CheckCircleIcon : WarningIcon} color={installer?.['@deep-foundation/deepmemo-links']?.length ? 'green.500' : 'red.500'} />
168168
@deep-foundation/deepmemo-links
169169
</ListItem>
170+
<ListItem>
171+
<ListIcon as={installer?.['@deep-foundation/semantic']?.length ? CheckCircleIcon : WarningIcon} color={installer?.['@deep-foundation/semantic']?.length ? 'green.500' : 'red.500'} />
172+
@deep-foundation/semantic
173+
</ListItem>
170174
<ListItem>
171175
<ListIcon as={installer?.installed ? CheckCircleIcon : WarningIcon} color={installer?.installed ? 'green.500' : 'red.500'} />
172176
installed
173177
</ListItem>
178+
<ListItem>
179+
<ListIcon as={installer?.['semantic']?.length ? CheckCircleIcon : WarningIcon} color={installer?.['semantic']?.length ? 'green.500' : 'red.500'} />
180+
semantic
181+
</ListItem>
174182
<ListItem>
175183
<ListIcon as={installer?.['ApiKey']?.length ? CheckCircleIcon : WarningIcon} color={installer?.['ApiKey']?.length ? 'green.500' : 'red.500'} />
176184
ApiKey ({installer?.['ApiKey']?.[0]?.value?.value || ''})
@@ -574,6 +582,22 @@ export function Syncing({ title, value, setValue }) {
574582
</FormControl>;
575583
}
576584

585+
export function OnlyConnectedAndAdmin({ children }: { children: any }) {
586+
const deep = useDeep();
587+
const installer = useInstaller();
588+
return <>
589+
{deep?.linkId && installer?.isAdmin ? children : <Heading size="md">Deep.Memory Installer unavailable, you are not admin.</Heading>}
590+
</>
591+
}
592+
593+
export function OnlyInstalled({ children }: { children: any }) {
594+
const deep = useDeep();
595+
const installer = useInstaller();
596+
return <>
597+
{deep?.linkId && installer?.status ? children : <Heading size="md">Deep.Memo unavailable, {!deep?.linkId ? 'deep not connected' : 'not installed'}.</Heading>}
598+
</>
599+
}
600+
577601
export default function Page() {
578602
const deep = useDeep();
579603
const toast = useToast();
@@ -601,47 +625,51 @@ export default function Page() {
601625
<InstallerProvider>
602626
<Box p={4}>
603627
Version: {version}
604-
<InstallerView/>
605-
<Syncing title={'Enable syncing with deep backend?'} value={saver} setValue={setSaver}/>
606-
<FormControl display='flex' alignItems='center'>
607-
<FormLabel htmlFor='syncing' mb='0'>
608-
ContainerId
609-
</FormLabel>
610-
<Input
611-
placeholder={`${deep?.linkId}`}
612-
value={containerId} onChange={(e) => setContainerId(e.target.value)}
613-
w={'10em'}
614-
/>
615-
</FormControl>
616-
<SaverProvider onSave={({ Type, id, object, mode, promise }) => {
617-
toast.promise(promise, {
618-
success: { title: `Saved ${mode} #${id || '?'} of type (#${Type}) to deep`, isClosable: true },
619-
error: (e) => ({ title: `Error with saving ${mode} #${id || '?'} of type (#${Type}) to deep`, description: e.toString(), isClosable: true }),
620-
loading: { title: `Saving ${mode} #${id || '?'} of type (#${Type}) to deep`, isClosable: true },
621-
})
622-
}}>
623-
<DeviceProvider saver={saver && deviceSaver} containerId={containerId} interval={deviceInterval}>
624-
<GeolocationProvider saver={saver && geolocationSaver} interval={geolocationInterval} manual={geolocationManual}>
625-
<BackgroundGeolocationProvider saver={saver && backgroundgeolocationSaver} manual={backgroundGeolocationManual}>
626-
<VoiceProvider saver={saver}>
627-
{NEXT_PUBLIC_BUILD}
628-
<TemplatesView/>
629-
<VoiceView/>
630-
<Interval value={deviceInterval} onChange={setDeviceInterval}/>
631-
<Syncing title={'Enable voice syncing with deep backend?'} value={deviceSaver} setValue={setDeviceSaver}/>
632-
<DeviceView interval={deviceInterval}/>
633-
<Interval value={geolocationInterval} onChange={setGeolocationInterval}/>
634-
<Syncing title={'Enable geolocation syncing with deep backend?'} value={geolocationSaver} setValue={setGeolocationSaver}/>
635-
<Syncing title={'Enable auto request foregraund geolocation?'} value={!geolocationManual} setValue={(v) => setGeolocationManual(!v)}/>
636-
<GeolocationView interval={geolocationInterval}/>
637-
<Syncing title={'Enable background geolocation syncing with deep backend?'} value={backgroundgeolocationSaver} setValue={setBackgroundGeolocationSaver}/>
638-
<Syncing title={'Enable auto request background geolocation?'} value={!backgroundGeolocationManual} setValue={(v) => setBackgroundGeolocationManual(!v)}/>
639-
<BackgroundGeolocationView/>
640-
</VoiceProvider>
641-
</BackgroundGeolocationProvider>
642-
</GeolocationProvider>
643-
</DeviceProvider>
644-
</SaverProvider>
628+
<OnlyConnectedAndAdmin>
629+
<InstallerView/>
630+
</OnlyConnectedAndAdmin>
631+
<OnlyInstalled>
632+
<Syncing title={'Enable syncing with deep backend?'} value={saver} setValue={setSaver}/>
633+
<FormControl display='flex' alignItems='center'>
634+
<FormLabel htmlFor='syncing' mb='0'>
635+
ContainerId
636+
</FormLabel>
637+
<Input
638+
placeholder={`${deep?.linkId}`}
639+
value={containerId} onChange={(e) => setContainerId(e.target.value)}
640+
w={'10em'}
641+
/>
642+
</FormControl>
643+
<SaverProvider onSave={({ Type, id, object, mode, promise }) => {
644+
toast.promise(promise, {
645+
success: { title: `Saved ${mode} #${id || '?'} of type (#${Type}) to deep`, isClosable: true },
646+
error: (e) => ({ title: `Error with saving ${mode} #${id || '?'} of type (#${Type}) to deep`, description: e.toString(), isClosable: true }),
647+
loading: { title: `Saving ${mode} #${id || '?'} of type (#${Type}) to deep`, isClosable: true },
648+
})
649+
}}>
650+
<DeviceProvider saver={saver && deviceSaver} containerId={containerId} interval={deviceInterval}>
651+
<GeolocationProvider saver={saver && geolocationSaver} interval={geolocationInterval} manual={geolocationManual}>
652+
<BackgroundGeolocationProvider saver={saver && backgroundgeolocationSaver} manual={backgroundGeolocationManual}>
653+
<VoiceProvider saver={saver}>
654+
{NEXT_PUBLIC_BUILD}
655+
<TemplatesView/>
656+
<VoiceView/>
657+
<Interval value={deviceInterval} onChange={setDeviceInterval}/>
658+
<Syncing title={'Enable voice syncing with deep backend?'} value={deviceSaver} setValue={setDeviceSaver}/>
659+
<DeviceView interval={deviceInterval}/>
660+
<Interval value={geolocationInterval} onChange={setGeolocationInterval}/>
661+
<Syncing title={'Enable geolocation syncing with deep backend?'} value={geolocationSaver} setValue={setGeolocationSaver}/>
662+
<Syncing title={'Enable auto request foregraund geolocation?'} value={!geolocationManual} setValue={(v) => setGeolocationManual(!v)}/>
663+
<GeolocationView interval={geolocationInterval}/>
664+
<Syncing title={'Enable background geolocation syncing with deep backend?'} value={backgroundgeolocationSaver} setValue={setBackgroundGeolocationSaver}/>
665+
<Syncing title={'Enable auto request background geolocation?'} value={!backgroundGeolocationManual} setValue={(v) => setBackgroundGeolocationManual(!v)}/>
666+
<BackgroundGeolocationView/>
667+
</VoiceProvider>
668+
</BackgroundGeolocationProvider>
669+
</GeolocationProvider>
670+
</DeviceProvider>
671+
</SaverProvider>
672+
</OnlyInstalled>
645673
</Box>
646674
</InstallerProvider>
647675
</>);

0 commit comments

Comments
 (0)