generated from ZanzyTHEbar/SolidJSTauri
-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add dismissible readme panel before flashing
Steps to follow before uploading the software
- Loading branch information
Showing
11 changed files
with
249 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Component } from 'solid-js' | ||
import Checkbox from '@components/Checkbox/Index' | ||
|
||
export interface IProps { | ||
onClick: () => void | ||
checked: boolean | ||
label: string | ||
} | ||
|
||
const CheckboxButton: Component<IProps> = (props) => { | ||
return ( | ||
<div | ||
class="flex flex-row justify-center items-center gap-[6px] cursor-pointer" | ||
onClick={() => { | ||
props.onClick() | ||
}}> | ||
<Checkbox checked={props.checked} /> | ||
<p class="text-left text-[14px] text-[#9793FD] font-normal leading-[26px] not-italic"> | ||
Don’t show this again | ||
</p> | ||
</div> | ||
) | ||
} | ||
|
||
export default CheckboxButton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Component } from 'solid-js' | ||
|
||
export interface IProps { | ||
checked: boolean | ||
} | ||
|
||
const Checkbox: Component<IProps> = (props) => { | ||
return ( | ||
<div | ||
classList={{ | ||
'bg-[#9793FD]': props.checked, | ||
}} | ||
class="w-[14px] h-[14px] border border-solid border-[#9793FD] rounded-[4px] " | ||
/> | ||
) | ||
} | ||
|
||
export default Checkbox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { appWindow } from '@tauri-apps/api/window' | ||
import { createMemo } from 'solid-js' | ||
import { ENotificationType, MODAL_TYPE, TITLEBAR_ACTION } from '@interfaces/enums' | ||
import BeforeFlashingModal from '@pages/Modals/BeforeFlashingModal' | ||
import { usb } from '@src/static' | ||
import { useAppAPIContext } from '@store/context/api' | ||
import { useAppNotificationsContext } from '@store/context/notifications' | ||
import { useAppUIContext } from '@store/context/ui' | ||
import { installOpenIris } from '@store/terminal/actions' | ||
import { isActiveProcess } from '@store/terminal/selectors' | ||
import { | ||
restartFirmwareState, | ||
setAbortController, | ||
setProcessStatus, | ||
} from '@store/terminal/terminal' | ||
|
||
const BeforeFlashingContainer = () => { | ||
const { downloadAsset, getFirmwareType, activeBoard, manifestPath } = useAppAPIContext() | ||
const { modal, setOpenModal, hideModal, setHideModal } = useAppUIContext() | ||
const { addNotification } = useAppNotificationsContext() | ||
|
||
const isUSBBoard = createMemo(() => { | ||
return activeBoard().includes(usb) | ||
}) | ||
|
||
return ( | ||
<BeforeFlashingModal | ||
checked={hideModal()} | ||
isActive={modal().type === MODAL_TYPE.BEFORE_FLASHING} | ||
onClickHeader={(action: TITLEBAR_ACTION) => { | ||
switch (action) { | ||
case TITLEBAR_ACTION.MINIMIZE: | ||
appWindow.minimize() | ||
break | ||
case TITLEBAR_ACTION.MAXIMIZE: | ||
appWindow.toggleMaximize() | ||
break | ||
case TITLEBAR_ACTION.CLOSE: | ||
appWindow.close() | ||
break | ||
default: | ||
return | ||
} | ||
}} | ||
onClickClose={() => { | ||
setOpenModal({ open: false, type: MODAL_TYPE.NONE }) | ||
}} | ||
onClickCheckbox={() => { | ||
setHideModal() | ||
}} | ||
onClickInstallOpeniris={() => { | ||
setOpenModal({ open: false, type: MODAL_TYPE.NONE }) | ||
if (isActiveProcess()) { | ||
addNotification({ | ||
title: 'There is an active installation. Please wait.', | ||
message: 'There is an active installation. Please wait.', | ||
type: ENotificationType.INFO, | ||
}) | ||
return true | ||
} | ||
setAbortController('openiris') | ||
setProcessStatus(true) | ||
restartFirmwareState() | ||
installOpenIris( | ||
isUSBBoard(), | ||
manifestPath(), | ||
async () => { | ||
await downloadAsset(getFirmwareType()) | ||
}, | ||
() => { | ||
setOpenModal({ open: true, type: MODAL_TYPE.UPDATE_NETWORK }) | ||
}, | ||
).catch(() => ({})) | ||
}} | ||
/> | ||
) | ||
} | ||
|
||
export default BeforeFlashingContainer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { Component } from 'solid-js' | ||
import CheckboxButton from '@components/Buttons/CheckboxButton/Index' | ||
import { Button } from '@components/Buttons/DefaultButton' | ||
import { Modal } from '@components/Modal/Index' | ||
import ModalHeader from '@components/ModalHeader/Index' | ||
import { TITLEBAR_ACTION } from '@interfaces/enums' | ||
import { beforeFlashingModalID } from '@src/static' | ||
|
||
export interface IProps { | ||
onClickHeader: (action: TITLEBAR_ACTION) => void | ||
onClickClose: () => void | ||
onClickInstallOpeniris: () => void | ||
onClickCheckbox: () => void | ||
isActive: boolean | ||
checked: boolean | ||
} | ||
|
||
const BeforeFlashingModal: Component<IProps> = (props) => { | ||
return ( | ||
<Modal | ||
id={beforeFlashingModalID} | ||
isActive={props.isActive} | ||
onClickCloseModal={props.onClickClose} | ||
onClickHeader={props.onClickHeader}> | ||
<div class="flex flex-col gap-[14px]"> | ||
<ModalHeader label="Reminder!" onClick={props.onClickClose} /> | ||
<div class="flex flex-col gap-[14px]"> | ||
<div> | ||
<p class="text-left text-[18px] text-[#9793FD] font-medium leading-[20px] not-italic"> | ||
Before flashing | ||
</p> | ||
</div> | ||
<div> | ||
<p class="text-left text-[14px] text-white font-normal leading-[26px] not-italic"> | ||
Make sure to follow the steps below 👇 | ||
</p> | ||
</div> | ||
<div> | ||
<p class="text-left text-[14px] text-white font-normal leading-[26px] not-italic"> | ||
• hold B button while plugging the board in | ||
</p> | ||
<p class="text-left text-[14px] text-white font-normal leading-[26px] not-italic py-[10px]"> | ||
• Make sure you have the antenna and camera plugged into the | ||
board if you plan on using them wirelessly | ||
</p> | ||
<p class="text-left text-[14px] text-white font-normal leading-[26px] not-italic"> | ||
• Make sure your password and ssid do not have special characters | ||
</p> | ||
<p class="text-left text-[14px] text-white font-normal leading-[26px] not-italic"> | ||
• Make sure you have a stable internet connection | ||
</p> | ||
</div> | ||
</div> | ||
<div class="flex gap-[10px] justify-between"> | ||
<CheckboxButton | ||
onClick={props.onClickCheckbox} | ||
checked={props.checked} | ||
label="Don’t show this again" | ||
/> | ||
<Button | ||
type={'button'} | ||
isActive={true} | ||
label="Install Openiris" | ||
onClick={props.onClickInstallOpeniris} | ||
/> | ||
</div> | ||
</div> | ||
</Modal> | ||
) | ||
} | ||
|
||
export default BeforeFlashingModal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters