instrument box component & stories
This commit is contained in:
@@ -8,13 +8,15 @@ import {
|
|||||||
import { Rs232PropertyView } from './Rs232PropertyView';
|
import { Rs232PropertyView } from './Rs232PropertyView';
|
||||||
import { IpClientPropertyView } from './IpClientPropertyView';
|
import { IpClientPropertyView } from './IpClientPropertyView';
|
||||||
import { IpServerPropertyView } from './IpServerPropertyView';
|
import { IpServerPropertyView } from './IpServerPropertyView';
|
||||||
import { RowIndicatorv1 } from './Rowindicatorv1';
|
import { RowIndicatorv1 } from './RowIndicatorv1';
|
||||||
|
import { IpClientType, IpServerType, Rs232Type, UdpClientType, UdpServerType, } from '../models/InstrumentModel';
|
||||||
|
|
||||||
interface CardProps {
|
interface CardProps {
|
||||||
titleAlat?: string,
|
titleAlat?: string,
|
||||||
type?: string,
|
type?: string,
|
||||||
lampu?: boolean,
|
lampu?: boolean,
|
||||||
online?: boolean,
|
online?: boolean,
|
||||||
|
typeDetail: Rs232Type | IpClientType | IpServerType | UdpClientType | UdpServerType
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,9 +26,10 @@ interface CardProps {
|
|||||||
export const CardInstrument = ({
|
export const CardInstrument = ({
|
||||||
...props
|
...props
|
||||||
}: CardProps) => {
|
}: CardProps) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Card className="w-234 mx-auto rounded-lg overflow-hidden border-black border-solid">
|
<Card className="w-60 mx-auto rounded-lg overflow-hidden border-black border-solid">
|
||||||
<CardHeader className='bg-orange-500'>
|
<CardHeader className='bg-orange-500'>
|
||||||
<CardTitle>
|
<CardTitle>
|
||||||
<div className='flex justify-between'>
|
<div className='flex justify-between'>
|
||||||
@@ -50,6 +53,7 @@ export const CardInstrument = ({
|
|||||||
lampu={props.lampu}
|
lampu={props.lampu}
|
||||||
type={props.type}
|
type={props.type}
|
||||||
online={props.online}
|
online={props.online}
|
||||||
|
blink={false}
|
||||||
/>
|
/>
|
||||||
{/* ROW 1 & 2 END */}
|
{/* ROW 1 & 2 END */}
|
||||||
|
|
||||||
@@ -57,22 +61,27 @@ export const CardInstrument = ({
|
|||||||
{
|
{
|
||||||
props.type == 'rs232' ? (<Rs232PropertyView
|
props.type == 'rs232' ? (<Rs232PropertyView
|
||||||
type={props.type}
|
type={props.type}
|
||||||
|
valueSpeed={(props.typeDetail as Rs232Type).speedValue}
|
||||||
|
valueBaud='8'
|
||||||
|
valueDataBit={(props.typeDetail as Rs232Type).dataBitValue}
|
||||||
|
valueStopBit={(props.typeDetail as Rs232Type).stopBitValue}
|
||||||
/>) : ''
|
/>) : ''
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
props.type == 'ipclient' ? (<IpClientPropertyView
|
props.type == 'ipclient' ? (<IpClientPropertyView
|
||||||
type={props.type}
|
type={props.type}
|
||||||
|
valueHost={(props.typeDetail as IpClientType).hostValue}
|
||||||
|
valuePort={(props.typeDetail as IpClientType).portValue}
|
||||||
/>) : ''
|
/>) : ''
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
props.type == 'ipserver' ? (<IpServerPropertyView
|
props.type == 'ipserver' ? (<IpServerPropertyView
|
||||||
type={props.type}
|
type={props.type}
|
||||||
|
valueListeningPort={(props.typeDetail as IpServerType).listeningPortValue}
|
||||||
/>) : ''
|
/>) : ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import { RowLabelValue } from './RowLabelValue';
|
|||||||
|
|
||||||
interface IpClientPropertyViewProps {
|
interface IpClientPropertyViewProps {
|
||||||
type?: string,
|
type?: string,
|
||||||
|
valueHost:string,
|
||||||
|
valuePort:string,
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14,11 +16,11 @@ export const IpClientPropertyView = ({
|
|||||||
{/* IpClient START */}
|
{/* IpClient START */}
|
||||||
<RowLabelValue
|
<RowLabelValue
|
||||||
label='Host'
|
label='Host'
|
||||||
value='192.168.10.10'
|
value={props.valueHost}
|
||||||
/>
|
/>
|
||||||
<RowLabelValue
|
<RowLabelValue
|
||||||
label='Port'
|
label='Port'
|
||||||
value='5001'
|
value={props.valuePort}
|
||||||
/>
|
/>
|
||||||
{/* IpClient END */}
|
{/* IpClient END */}
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { RowLabelValue } from './RowLabelValue';
|
|||||||
|
|
||||||
interface IpServerPropertyViewProps {
|
interface IpServerPropertyViewProps {
|
||||||
type?: string,
|
type?: string,
|
||||||
|
valueListeningPort:string,
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14,7 +15,7 @@ export const IpServerPropertyView = ({
|
|||||||
{/* IpServer START */}
|
{/* IpServer START */}
|
||||||
<RowLabelValue
|
<RowLabelValue
|
||||||
label='Listening Port'
|
label='Listening Port'
|
||||||
value='8001'
|
value={props.valueListeningPort}
|
||||||
/>
|
/>
|
||||||
{/* IpServer END */}
|
{/* IpServer END */}
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import '../../../../app/global.css'
|
import '../../../../app/global.css'
|
||||||
import { StatusTransferv1 } from './StatusTransferv1';
|
import { StatusTransferv1 } from './StatusTransferv1';
|
||||||
import { StatusOnlinev1 } from './Statusonlinev1';
|
import { StatusOnlinev1 } from './StatusOnlinev1';
|
||||||
import { TypeCardv1 } from './Typecardv1';
|
import { TypeCardv1 } from './TypeCardv1';
|
||||||
|
|
||||||
interface RowIndicatorv1Props {
|
interface RowIndicatorv1Props {
|
||||||
lampu?: boolean,
|
lampu?: boolean,
|
||||||
type?: string;
|
type?: string;
|
||||||
online?: boolean;
|
online?: boolean;
|
||||||
|
blink?:boolean;
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,10 @@ import { RowLabelValue } from './RowLabelValue';
|
|||||||
|
|
||||||
interface Rs232PropertyViewProps {
|
interface Rs232PropertyViewProps {
|
||||||
type?: string,
|
type?: string,
|
||||||
|
valueSpeed:string,
|
||||||
|
valueBaud:string,
|
||||||
|
valueDataBit:string,
|
||||||
|
valueStopBit:string
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14,24 +18,24 @@ export const Rs232PropertyView = ({
|
|||||||
{/* RS232 START */}
|
{/* RS232 START */}
|
||||||
<RowLabelValue
|
<RowLabelValue
|
||||||
label='Speed'
|
label='Speed'
|
||||||
value='800'
|
value={props.valueSpeed}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<RowLabelValue
|
<RowLabelValue
|
||||||
label='Baud'
|
label='Baud'
|
||||||
value='8'
|
value={props.valueBaud}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
||||||
<RowLabelValue
|
<RowLabelValue
|
||||||
label='Data Bit'
|
label='Data Bit'
|
||||||
value='N'
|
value={props.valueDataBit}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
||||||
<RowLabelValue
|
<RowLabelValue
|
||||||
label='Stop Bit'
|
label='Stop Bit'
|
||||||
value='1'
|
value={props.valueStopBit}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* RS232 END */}
|
{/* RS232 END */}
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"idInstrument":"1",
|
||||||
|
"namaInstrument":"Mindray BC800",
|
||||||
|
"type":"rs232",
|
||||||
|
"instrumentTypeDetail":[
|
||||||
|
{
|
||||||
|
"label":"speed",
|
||||||
|
"value":"800"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label":"baudRate",
|
||||||
|
"value":"8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label":"dataBit",
|
||||||
|
"value":"N"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label":"stopBit",
|
||||||
|
"value":"1"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idInstrument":"2",
|
||||||
|
"namaInstrument":"Mindray BC240",
|
||||||
|
"type":"rs232",
|
||||||
|
"instrumentTypeDetail":[
|
||||||
|
{
|
||||||
|
"label":"speed",
|
||||||
|
"value":"800"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label":"baudRate",
|
||||||
|
"value":"8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label":"dataBit",
|
||||||
|
"value":"N"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label":"stopBit",
|
||||||
|
"value":"1"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idInstrument":"3",
|
||||||
|
"namaInstrument":"Mindray BC800",
|
||||||
|
"type":"ipclient",
|
||||||
|
"instrumentTypeDetail":[
|
||||||
|
{
|
||||||
|
"label":"host",
|
||||||
|
"value":"192.168.10.10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label":"port",
|
||||||
|
"value":"5001"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idInstrument":"4",
|
||||||
|
"namaInstrument":"Mindray BC240",
|
||||||
|
"type":"ipserver",
|
||||||
|
"instrumentTypeDetail":[
|
||||||
|
{
|
||||||
|
"label":"listeningPort",
|
||||||
|
"value":"8001"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import '../../../../app/global.css'
|
||||||
|
import { CardInstrument } from '../cardInstrument/CardInstrument';
|
||||||
|
import { InstrumentType } from '../models/InstrumentModel';
|
||||||
|
|
||||||
|
interface InstrumentBoxProps {
|
||||||
|
totalCard?: number;
|
||||||
|
dataInstrumentType: InstrumentType[];
|
||||||
|
onClick?: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Primary UI component for user interaction
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const InstrumentBox = ({
|
||||||
|
...props
|
||||||
|
}: InstrumentBoxProps) => {
|
||||||
|
|
||||||
|
let col = 2;
|
||||||
|
|
||||||
|
let showData = [];
|
||||||
|
|
||||||
|
if (props.totalCard != undefined && props.totalCard > 0) {
|
||||||
|
for (let index = 0; index < props.totalCard; index++) {
|
||||||
|
showData.push([
|
||||||
|
<CardInstrument
|
||||||
|
lampu={true}
|
||||||
|
online={true}
|
||||||
|
titleAlat={props.dataInstrumentType[index].title}
|
||||||
|
type={props.dataInstrumentType[index].type}
|
||||||
|
typeDetail={props.dataInstrumentType[index].data}
|
||||||
|
/>
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className={`grid grid-cols-${col} gap-10`}>
|
||||||
|
{ showData }
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
// export type InstrumentTypeDetail = {
|
||||||
|
// label: string;
|
||||||
|
// value: string;
|
||||||
|
// };
|
||||||
|
|
||||||
|
// export type InstrumentModel = {
|
||||||
|
// idInstrument: string;
|
||||||
|
// namaInstrument: string;
|
||||||
|
// type:string;
|
||||||
|
// instrumentTypeDetail: InstrumentTypeDetail[]
|
||||||
|
// };
|
||||||
|
|
||||||
|
export type Rs232Type = {
|
||||||
|
speedValue: string,
|
||||||
|
dataBitValue: string,
|
||||||
|
parityValue: string,
|
||||||
|
stopBitValue: string,
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IpClientType = {
|
||||||
|
hostValue: string,
|
||||||
|
portValue: string,
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IpServerType = {
|
||||||
|
listeningPortValue: string,
|
||||||
|
};
|
||||||
|
|
||||||
|
export type UdpClientType = {
|
||||||
|
hostValue: string,
|
||||||
|
portValue: string,
|
||||||
|
};
|
||||||
|
|
||||||
|
export type UdpServerType = {
|
||||||
|
listeningPortValue: string,
|
||||||
|
};
|
||||||
|
|
||||||
|
export type InstrumentType = {
|
||||||
|
engine: string,
|
||||||
|
type: string,
|
||||||
|
title: string,
|
||||||
|
data: Rs232Type | IpClientType | IpServerType | UdpClientType | UdpServerType
|
||||||
|
};
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { StatusCardv1 } from '@/components/main/cardInstrument/Statuscardv1';
|
import { StatusCardv1 } from '@/components/main/cardInstrument/StatusCardv1';
|
||||||
import type { Meta, StoryObj } from '@storybook/react';
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
|
||||||
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { StatusOnlinev1 } from '@/components/main/cardInstrument/Statusonlinev1';
|
import { StatusOnlinev1 } from '@/components/main/cardInstrument/StatusOnlinev1';
|
||||||
import type { Meta, StoryObj } from '@storybook/react';
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
|
||||||
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
|
import { TypeCardv1 } from '@/components/main/cardInstrument/TypeCardv1';
|
||||||
import { TypeCardv1 } from '@/components/main/cardInstrument/Typecardv1';
|
|
||||||
import type { Meta, StoryObj } from '@storybook/react';
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
|
||||||
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
||||||
|
|||||||
@@ -0,0 +1,162 @@
|
|||||||
|
import { InstrumentBox } from '@/components/main/instrumentBox/InstrumentBox';
|
||||||
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
|
||||||
|
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
||||||
|
const meta = {
|
||||||
|
title: 'Component/Main/Instrument Box',
|
||||||
|
component: InstrumentBox,
|
||||||
|
parameters: {
|
||||||
|
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/react/configure/story-layout
|
||||||
|
layout: 'centered',
|
||||||
|
},
|
||||||
|
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
|
||||||
|
tags: ['autodocs'],
|
||||||
|
// More on argTypes: https://storybook.js.org/docs/react/api/argtypes
|
||||||
|
argTypes: {
|
||||||
|
// backgroundColor: { control: 'color' },
|
||||||
|
},
|
||||||
|
} satisfies Meta<typeof InstrumentBox>;
|
||||||
|
|
||||||
|
export default meta;
|
||||||
|
type Story = StoryObj<typeof meta>;
|
||||||
|
|
||||||
|
// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
|
||||||
|
|
||||||
|
// Instrument 1 Alat
|
||||||
|
export const Instrument1Alat: Story = {
|
||||||
|
args: {
|
||||||
|
totalCard:1,
|
||||||
|
dataInstrumentType:[
|
||||||
|
{
|
||||||
|
engine:'astm',
|
||||||
|
title:'Cobas800',
|
||||||
|
type:'rs232',
|
||||||
|
data:{
|
||||||
|
speedValue: '800',
|
||||||
|
dataBitValue: 'N',
|
||||||
|
parityValue: '',
|
||||||
|
stopBitValue: 'N'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// Instrument 2 Alat
|
||||||
|
export const Instrument2Alat: Story = {
|
||||||
|
args: {
|
||||||
|
totalCard:2,
|
||||||
|
dataInstrumentType:[
|
||||||
|
{
|
||||||
|
engine:'astm',
|
||||||
|
title:'Cobas800',
|
||||||
|
type:'rs232',
|
||||||
|
data:{
|
||||||
|
speedValue: '800',
|
||||||
|
dataBitValue: 'N',
|
||||||
|
parityValue: '',
|
||||||
|
stopBitValue: 'N'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
engine:'astm',
|
||||||
|
title:'Axsym 100',
|
||||||
|
type:'rs232',
|
||||||
|
data:{
|
||||||
|
speedValue: '800',
|
||||||
|
dataBitValue: 'N',
|
||||||
|
parityValue: '',
|
||||||
|
stopBitValue: 'N'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// Instrument 3 Alat
|
||||||
|
export const Instrument3Alat: Story = {
|
||||||
|
args: {
|
||||||
|
totalCard:3,
|
||||||
|
dataInstrumentType:[
|
||||||
|
{
|
||||||
|
engine:'astm',
|
||||||
|
title:'Cobas800',
|
||||||
|
type:'rs232',
|
||||||
|
data:{
|
||||||
|
speedValue: '800',
|
||||||
|
dataBitValue: 'N',
|
||||||
|
parityValue: '',
|
||||||
|
stopBitValue: 'N'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
engine:'astm',
|
||||||
|
title:'Axsym 100',
|
||||||
|
type:'rs232',
|
||||||
|
data:{
|
||||||
|
speedValue: '800',
|
||||||
|
dataBitValue: 'N',
|
||||||
|
parityValue: '',
|
||||||
|
stopBitValue: 'N'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
engine:'mindray',
|
||||||
|
title:'Mindray BC800',
|
||||||
|
type:'ipclient',
|
||||||
|
data:{
|
||||||
|
hostValue:"192.168.10.10",
|
||||||
|
portValue:"5001"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// Instrument 4 Alat
|
||||||
|
export const Instrument4Alat: Story = {
|
||||||
|
args: {
|
||||||
|
totalCard:4,
|
||||||
|
dataInstrumentType:[
|
||||||
|
{
|
||||||
|
engine:'astm',
|
||||||
|
title:'Cobas800',
|
||||||
|
type:'rs232',
|
||||||
|
data:{
|
||||||
|
speedValue: '800',
|
||||||
|
dataBitValue: 'N',
|
||||||
|
parityValue: '',
|
||||||
|
stopBitValue: 'N'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
engine:'astm',
|
||||||
|
title:'Axsym 100',
|
||||||
|
type:'rs232',
|
||||||
|
data:{
|
||||||
|
speedValue: '800',
|
||||||
|
dataBitValue: 'N',
|
||||||
|
parityValue: '',
|
||||||
|
stopBitValue: 'N'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
engine:'mindray',
|
||||||
|
title:'Mindray BC800',
|
||||||
|
type:'ipclient',
|
||||||
|
data:{
|
||||||
|
hostValue:"192.168.10.10",
|
||||||
|
portValue:"5001"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
engine:'mindray',
|
||||||
|
title:'Mindray BC240',
|
||||||
|
type:'ipserver',
|
||||||
|
data:{
|
||||||
|
listeningPortValue:"8001"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user