Skip to content

Commit

Permalink
wraping react icons
Browse files Browse the repository at this point in the history
  • Loading branch information
salimkanoun committed Oct 7, 2024
1 parent e9bbe20 commit eb42b99
Show file tree
Hide file tree
Showing 15 changed files with 140 additions and 22 deletions.
26 changes: 13 additions & 13 deletions src/admin/general/OrthancCard.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { useMemo, useState } from 'react';
import { VscDebugRestart as RestartIcon } from "react-icons/vsc";
import { IoClose } from "react-icons/io5";
import { BsQuestionLg } from "react-icons/bs";

import { Table, Button, ToggleEye, Input, Modal, CardFooter, SelectInput } from '../../ui/';
import { Colors } from '../../utils/enums';
import { useCustomMutation, useCustomQuery } from '../../utils/reactQuery';
import { getOrthancSystem, getVerbosity, orthancReset, orthancShutdown, updateVerbosity } from '../../services/orthanc';
import { useConfirm } from '../../services';
import { Close, Question, Restart } from '../../icons';

type OrthancData = {
username: string;
Expand All @@ -27,7 +25,7 @@ const selectOptions = [
];

const OrthancSettingsCard = ({ orthancData }: OrthancCardProps) => {
const {confirm} = useConfirm()
const { confirm } = useConfirm()

const [showModal, setShowModal] = useState(false);

Expand Down Expand Up @@ -59,7 +57,7 @@ const OrthancSettingsCard = ({ orthancData }: OrthancCardProps) => {
[['log-level']],
);

const currentVerbosityOption = useMemo(()=>{
const currentVerbosityOption = useMemo(() => {
return selectOptions.find(option => option.value === orthancVerbosity)?.value ?? null
}, [orthancVerbosity])

Expand Down Expand Up @@ -104,9 +102,9 @@ const OrthancSettingsCard = ({ orthancData }: OrthancCardProps) => {
};

const handleOrthancShutdown = async () => {
if(await confirm({ content: "Are you sure to shutdown Orthanc ?" })) {
if (await confirm({ content: "Are you sure to shutdown Orthanc ?" })) {
shutdownOrthanc({});
}
}
}


Expand All @@ -127,20 +125,22 @@ const OrthancSettingsCard = ({ orthancData }: OrthancCardProps) => {
<Button
color={Colors.warning}
onClick={reset}>
<RestartIcon
<Restart
size="20px"
title="Restart" />
title="Restart"
/>
</Button>
<Button
color={Colors.danger}
onClick={handleOrthancShutdown}
>
<IoClose
>
<Close
size="20px"
title="Shutdown" />
title="Shutdown"
/>
</Button>
<Button color={Colors.primary} onClick={orthancInfoHandler}>
<BsQuestionLg size="20px" title="Info" />
<Question size="20px" title="Info" />
</Button>
<div className="w-1/4">
<SelectInput
Expand Down
2 changes: 1 addition & 1 deletion src/admin/jobs/JobTable.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BsInfoCircle as Info } from "react-icons/bs";
import { Info } from "../../icons";
import { Table, Badge, Popover } from "../../ui";

import { Colors } from "../../utils/enums";
Expand Down
4 changes: 2 additions & 2 deletions src/admin/users/oauth/OauthForm.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ChangeEvent, useEffect, useState } from "react";
import { BsPersonCheckFill as SubmitUser } from "react-icons/bs";

import { Colors, Oauth2Config } from "../../../utils";
import { Button, Input } from "../../../ui";
import { SubmitUser } from "../../../icons";

type OauthFormProps = {
onSubmit: (payload: Oauth2Config) => void;
Expand Down Expand Up @@ -83,7 +83,7 @@ const OauthForm = ({ onSubmit, initialData, buttonText }: OauthFormProps) => {
className="h-12 gap-3 justify-self-center w-36 md:justify-center"
type="submit"
>
<SubmitUser size={"1.3rem"} />
<SubmitUser size="1.3rem" />
<div className="">{buttonText}</div>
</Button>
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/admin/users/roles/RoleForm.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ChangeEvent, useState, useEffect } from "react";
import { BsPersonCheckFill as SubmitUser } from "react-icons/bs";
import { ChangeEvent, useState } from "react";

import { Role } from "../../../utils/types";
import { Colors } from "../../../utils";

import { Button, Input,Toggle } from "../../../ui";
import { SubmitUser } from "../../../icons";

type RoleFormProps = {
onSubmit: (payload: Role) => void;
Expand Down Expand Up @@ -150,7 +150,7 @@ const RoleForm = ({ onSubmit, initialData, buttonText }: RoleFormProps) => {
</div>
<div className="flex justify-center">
<Button color={Colors.success} className="h-12 gap-3 justify-self-center w-36 md:justify-center" type="submit">
<SubmitUser size={'1.3rem'} />
<SubmitUser size='1.3rem' />
<div>{buttonText}</div>
</Button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/admin/users/user/CreateUserForm.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ChangeEvent, useState, FormEvent } from 'react';
import { BsPersonCheckFill as SubmitUser } from 'react-icons/bs';
import { getRoles, postUsers } from '../../../services';
import {
useCustomMutation,
Expand All @@ -18,6 +17,7 @@ import {
} from '../../../ui';
import { getErrorMessage } from '../../../utils/error';
import InputPassword from '../../../ui/InputPassword';
import { SubmitUser } from '../../../icons';

type UserFormProps = {
onClose : () => void;
Expand Down
2 changes: 1 addition & 1 deletion src/admin/users/user/EditUserForm.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ChangeEvent, useEffect, useState } from "react";
import { BsPersonCheckFill as SubmitUser } from "react-icons/bs";
import { useCustomToast, Colors, useCustomMutation, useCustomQuery, UserUpdatePayload, User, Role, Option } from "../../../utils";
import { getRoles, updateUser } from "../../../services";
import { Button, Card, CardBody, CardHeader, CloseButton, Input, Label, SelectInput } from "../../../ui";
import { SubmitUser } from "../../../icons";

type UserFormProps = {
title: string;
Expand Down
5 changes: 4 additions & 1 deletion src/export/ExportRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { storeToModality } from "../services/modalities";
import ProgressJobs from "../query/ProgressJobs";
import { sendResourcesToPeer } from "../services/peers";
import { exportCsv } from "../utils/export";
import SelectTransferSyntax from "./SelectTransferSyntax";

const ExportRoot = () => {
const { toastSuccess, updateExistingToast, toastWarning } = useCustomToast();
Expand All @@ -25,6 +26,7 @@ const ExportRoot = () => {
const [currentStudyId, setCurrentStudyId] = useState(null);
const [storeJobId, setStoreJobId] = useState(null);
const [sendPeerJobId, setsendPeerJobId] = useState(null);
const [transferSyntax, setTrasferSyntax] = useState('None')

const series = useMemo(() => {
if (!currentStudyId) return [];
Expand Down Expand Up @@ -77,7 +79,7 @@ const ExportRoot = () => {
(mb) => updateExistingToast(id, "Downloaded " + mb + " mb"),
undefined,
hierarchical,
undefined
transferSyntax != "None" ? transferSyntax : undefined
);
};

Expand Down Expand Up @@ -163,6 +165,7 @@ const ExportRoot = () => {
<CardFooter color={Colors.light} className="flex justify-center flex-grow gap-3">
<div className="flex justify-center w-4/5 gap-3">
<DropdownButton row={null} buttonText="Download" options={downloadOptions} />
<SelectTransferSyntax value={transferSyntax} onChange={(value)=>setTrasferSyntax(value)} />
<DropdownButton row={null} buttonText="Send To Modality" options={modalitiesOptions} />
{storeJobId && <ProgressJobs size={50} jobId={storeJobId} />}
<DropdownButton row={null} buttonText="Send To Peer" options={peersOptions} />
Expand Down
46 changes: 46 additions & 0 deletions src/export/SelectTransferSyntax.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Gear } from "../icons";
import { Button, Popover, SelectInput } from "../ui";
import { Colors } from "../utils";

type SelectTransferSyntaxProps = {
value: string;
onChange: (value: string) => void
}


const TRANSCODING_OPTIONS = [
{ value: 'None', label: 'None (use Original TS)' },
{ value: '1.2.840.10008.1.2', label: 'Implicit VR Endian' },
{ value: '1.2.840.10008.1.2.1', label: 'Explicit VR Little Endian' },
{ value: '1.2.840.10008.1.2.1.99', label: 'Deflated Explicit VR Little Endian' },
{ value: '1.2.840.10008.1.2.2', label: 'Explicit VR Big Endian' },
{ value: '1.2.840.10008.1.2.4.50', label: 'JPEG 8-bit' },
{ value: '1.2.840.10008.1.2.4.51', label: 'JPEG 12-bit' },
{ value: '1.2.840.10008.1.2.4.57', label: 'JPEG Lossless' },
{ value: '1.2.840.10008.1.2.4.70', label: 'JPEG Lossless' },
{ value: '1.2.840.10008.1.2.4.80', label: 'JPEG-LS Lossless' },
{ value: '1.2.840.10008.1.2.4.81', label: 'JPEG-LS Lossy' },
{ value: '1.2.840.10008.1.2.4.90', label: 'JPEG 2000 (90)' },
{ value: '1.2.840.10008.1.2.4.91', label: 'JPEG 2000 (91)' },
{ value: '1.2.840.10008.1.2.4.92', label: 'JPEG 2000 (92)' },
{ value: '1.2.840.10008.1.2.4.93', label: 'JPEG 2000 (93)' }
]

const SelectTransferSyntax = ({ value, onChange }: SelectTransferSyntaxProps) => {

return (
<Popover
withOnClick
className="w-64"
popover={
<SelectInput options={TRANSCODING_OPTIONS} value={value} onChange={(option) => onChange(option?.value)} />}
>
<div className="flex justify-center items-center w-5 h-full">
<Gear className='text-warning w-full h-full' />
</div>
</Popover>
)

}

export default SelectTransferSyntax
9 changes: 9 additions & 0 deletions src/icons/Close.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { IoClose } from "react-icons/io5";

const Close = (props) => {
return (
<IoClose {...props} />
)
}

export default Close
9 changes: 9 additions & 0 deletions src/icons/Gear.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { FaGear } from "react-icons/fa6";

const Gear = (props) => {
return (
<FaGear {...props} />
)
}

export default Gear
9 changes: 9 additions & 0 deletions src/icons/Info.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { BsInfoCircle } from "react-icons/bs";

const Info = (props) => {
return (
<BsInfoCircle {...props} />
)
}

export default Info
9 changes: 9 additions & 0 deletions src/icons/Question.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { BsQuestionLg } from "react-icons/bs";

const Question = (props) => {
return (
<BsQuestionLg {...props} />
)
}

export default Question
9 changes: 9 additions & 0 deletions src/icons/Restart.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { VscDebugRestart } from "react-icons/vsc";

const Restart = (props) => {
return (
<VscDebugRestart {...props} />
)
}

export default Restart
9 changes: 9 additions & 0 deletions src/icons/SubmitUser.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { BsPersonCheckFill } from "react-icons/bs";

const SubmitUser = (props) => {
return (
<BsPersonCheckFill {...props} />
)
}

export default SubmitUser
15 changes: 15 additions & 0 deletions src/icons/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Close from './Close'
import Gear from './Gear'
import Info from './Info'
import Question from './Question'
import Restart from './Restart'
import SubmitUser from './SubmitUser'

export {
Close,
Gear,
Info,
Question,
Restart,
SubmitUser
}

0 comments on commit eb42b99

Please sign in to comment.