step 19 : form rs232 desktop

This commit is contained in:
sindhu
2025-03-13 13:18:58 +07:00
parent 3cae1230c4
commit 4fa3f65355
2 changed files with 336 additions and 31 deletions

View File

@@ -11,6 +11,16 @@ document.addEventListener('alpine:init', () => {
namaInstrument: '',
// idJenis 2 ketambahan server
server: '',
// idJenis 3
idSerial: -1,
namaSerial: '',
speed: '',
idParity: -1,
namaParity: '',
idDataBit: -1,
namaDataBit: '',
idStopBit: -1,
namaStopBit: ''
},
dataSetting: [
{
@@ -104,12 +114,76 @@ document.addEventListener('alpine:init', () => {
namaInstrument: 'Cobas C311',
},
],
selectedSerial: {
idSerial: -1,
namaSerial: 'Serial'
},
openSerial: false,
dataSerial: [
{
idSerial: 1,
namaSerial: 'ttyS0'
},
{
idSerial: 2,
namaSerial: 'psx3'
},
],
selectedParity: {
idParity: -1,
namaParity: 'Parity'
},
openParity: false,
dataParity: [
{
idParity: 1,
namaParity: 'None'
},
{
idParity: 2,
namaParity: 'All'
},
],
selectedDataBit: {
idDataBit: -1,
namaDataBit: 'DataBit'
},
openDataBit: false,
dataDataBit: [
{
idDataBit: 1,
namaDataBit: '1'
},
{
idDataBit: 2,
namaDataBit: '6'
},
],
selectedStopBit: {
idStopBit: -1,
namaStopBit: 'StopBit'
},
openStopBit: false,
dataStopBit: [
{
idStopBit: 1,
namaStopBit: '0'
},
{
idStopBit: 2,
namaStopBit: '1'
},
],
// 1. Inisialisasi End
// 2. Fungsi Start
closeDialog() {
this.openJenis = false;
this.openInterface = false;
this.openInstrument = false;
this.openSerial = false;
this.openParity = false;
this.openDataBit = false;
this.openStopBit = false;
this.selectedJenis = {
idJenis: -1,
namaJenis: 'Jenis'
@@ -122,11 +196,28 @@ document.addEventListener('alpine:init', () => {
idInstrument: -1,
namaInstrument: 'Instrument'
}
this.selectedSerial = {
idSerial: -1,
namaSerial: 'Serial'
},
this.selectedParity = {
idParity: -1,
namaParity: 'Parity'
},
this.selectedDataBit = {
idDataBit: -1,
namaDataBit: 'DataBit'
},
this.selectedStopBit = {
idStopBit: -1,
namaStopBit: 'StopBit'
},
this.showDialogAdd = false
},
onChangeJenis(item) {
this.openJenis = false;
this.selectedJenis = item;
// clear form
this.objAddForm = {
port: '',
@@ -135,6 +226,15 @@ document.addEventListener('alpine:init', () => {
idInstrument: -1,
namaInstrument: '',
server: '',
idSerial: -1,
namaSerial: '',
speed: '',
idParity: -1,
namaParity: '',
idDataBit: -1,
namaDataBit: '',
idStopBit: -1,
namaStopBit: ''
};
},
onChangeInterface(item) {
@@ -145,6 +245,22 @@ document.addEventListener('alpine:init', () => {
this.openInstrument = false;
this.selectedInstrument = item;
},
onChangeSerial(item) {
this.openSerial = false;
this.selectedSerial = item;
},
onChangeParity(item) {
this.openParity = false;
this.selectedParity = item;
},
onChangeDataBit(item) {
this.openDataBit = false;
this.selectedDataBit = item;
},
onChangeStopBit(item) {
this.openStopBit = false;
this.selectedStopBit = item;
},
// 2. Fungsi End
}))
})

View File

@@ -232,12 +232,11 @@
<button @click="openInterface = !openInterface" type="button"
class="w-full flex items-center justify-between bg-transparent text-gray-900 py-0.5 focus:outline-none">
<span x-text="selectedInterface.namaInterface" class="text-left"></span>
<svg xmlns="http://www.w3.org/2000/svg"
class="h-5 w-5 transition-transform"
:class="{ 'rotate-180': openInterface }" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round"
stroke-width="2" d="M19 9l-7 7-7-7" />
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 transition-transform"
:class="{ 'rotate-180': openInterface }" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M19 9l-7 7-7-7" />
</svg>
</button>
</fieldset>
@@ -262,14 +261,12 @@
</span>
<button @click="openInstrument = !openInstrument" type="button"
class="w-full flex items-center justify-between bg-transparent text-gray-900 py-0.5 focus:outline-none">
<span x-text="selectedInstrument.namaInstrument"
class="text-left"></span>
<svg xmlns="http://www.w3.org/2000/svg"
class="h-5 w-5 transition-transform"
<span x-text="selectedInstrument.namaInstrument" class="text-left"></span>
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 transition-transform"
:class="{ 'rotate-180': openInstrument }" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round"
stroke-width="2" d="M19 9l-7 7-7-7" />
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M19 9l-7 7-7-7" />
</svg>
</button>
</fieldset>
@@ -328,12 +325,11 @@
<button @click="openInterface = !openInterface" type="button"
class="w-full flex items-center justify-between bg-transparent text-gray-900 py-0.5 focus:outline-none">
<span x-text="selectedInterface.namaInterface" class="text-left"></span>
<svg xmlns="http://www.w3.org/2000/svg"
class="h-5 w-5 transition-transform"
:class="{ 'rotate-180': openInterface }" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round"
stroke-width="2" d="M19 9l-7 7-7-7" />
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 transition-transform"
:class="{ 'rotate-180': openInterface }" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M19 9l-7 7-7-7" />
</svg>
</button>
</fieldset>
@@ -358,14 +354,12 @@
</span>
<button @click="openInstrument = !openInstrument" type="button"
class="w-full flex items-center justify-between bg-transparent text-gray-900 py-0.5 focus:outline-none">
<span x-text="selectedInstrument.namaInstrument"
class="text-left"></span>
<svg xmlns="http://www.w3.org/2000/svg"
class="h-5 w-5 transition-transform"
<span x-text="selectedInstrument.namaInstrument" class="text-left"></span>
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 transition-transform"
:class="{ 'rotate-180': openInstrument }" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round"
stroke-width="2" d="M19 9l-7 7-7-7" />
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M19 9l-7 7-7-7" />
</svg>
</button>
</fieldset>
@@ -385,20 +379,215 @@
</template>
<!-- namaJenis TCP Client -->
<!-- -->
<!-- namaJenis RS232 -->
<template x-if="selectedJenis.idJenis === 3">
<div>
<!-- serial -->
<fieldset @click.outside="openSerial = false"
class="relative border border-gray-400 rounded-md focus-within:border-blue-500 focus-within:ring-1 focus-within:ring-blue-500 px-3 pt-2 pb-2">
<span
x-text="selectedSerial.idSerial != -1 ? 'Serial' : selectedSerial.namaSerial"
class="pointer-events-none absolute start-2.5 top-0 -translate-y-1/2 bg-white p-0.5 text-xs text-gray-700 transition-all peer-placeholder-shown:top-1/2 peer-placeholder-shown:text-sm peer-focus:top-0 peer-focus:text-xs">
</span>
<button @click="openSerial = !openSerial" type="button"
class="w-full flex items-center justify-between bg-transparent text-gray-900 py-0.5 focus:outline-none">
<span x-text="selectedSerial.namaSerial" class="text-left"></span>
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 transition-transform"
:class="{ 'rotate-180': openSerial }" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M19 9l-7 7-7-7" />
</svg>
</button>
</fieldset>
<div x-show="openSerial"
class="absolute bg-white w-full border border-gray-300 rounded-md shadow-lg z-10 max-h-[200px] overflow-y-auto">
<ul>
<template x-for="item in dataSerial" :key="item.idSerial">
<li :id="item.idSerial" @click="onChangeSerial(item)"
class="py-2 px-3 hover:bg-blue-100 cursor-pointer text-gray-700">
<button x-text="item.namaSerial"></button>
</li>
</template>
</ul>
</div>
<div class="mb-5"></div>
<!-- speed -->
<label for="Speed"
class="relative block rounded-md border border-gray-400 focus-within:border-blue-600 focus-within:ring-1 focus-within:ring-blue-600">
<input type="text" id="Speed"
class="peer pl-2 border-none py-3 bg-transparent placeholder-transparent focus:border-transparent focus:ring-0 focus:outline-hidden"
placeholder="Speed" />
<span
class="pointer-events-none absolute start-2.5 top-0 -translate-y-1/2 bg-white p-0.5 text-xs text-gray-700 transition-all peer-placeholder-shown:top-1/2 peer-placeholder-shown:text-sm peer-focus:top-0 peer-focus:text-xs">
Speed
</span>
</label>
<div class="mb-5"></div>
<!-- parity -->
<fieldset @click.outside="openParity = false"
class="relative border border-gray-400 rounded-md focus-within:border-blue-500 focus-within:ring-1 focus-within:ring-blue-500 px-3 pt-2 pb-2">
<span
x-text="selectedParity.idParity != -1 ? 'DataBit' : selectedParity.namaParity"
class="pointer-events-none absolute start-2.5 top-0 -translate-y-1/2 bg-white p-0.5 text-xs text-gray-700 transition-all peer-placeholder-shown:top-1/2 peer-placeholder-shown:text-sm peer-focus:top-0 peer-focus:text-xs">
</span>
<button @click="openParity = !openParity" type="button"
class="w-full flex items-center justify-between bg-transparent text-gray-900 py-0.5 focus:outline-none">
<span x-text="selectedParity.namaParity" class="text-left"></span>
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 transition-transform"
:class="{ 'rotate-180': openParity }" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M19 9l-7 7-7-7" />
</svg>
</button>
</fieldset>
<div x-show="openParity"
class="absolute bg-white w-full border border-gray-300 rounded-md shadow-lg z-10 max-h-[200px] overflow-y-auto">
<ul>
<template x-for="item in dataParity" :key="item.idParity">
<li :id="item.idParity" @click="onChangeParity(item)"
class="py-2 px-3 hover:bg-blue-100 cursor-pointer text-gray-700">
<button x-text="item.namaParity"></button>
</li>
</template>
</ul>
</div>
<div class="mb-5"></div>
<!-- data bits -->
<fieldset @click.outside="openDataBit = false"
class="relative border border-gray-400 rounded-md focus-within:border-blue-500 focus-within:ring-1 focus-within:ring-blue-500 px-3 pt-2 pb-2">
<span
x-text="selectedDataBit.idDataBit != -1 ? 'DataBit' : selectedDataBit.namaDataBit"
class="pointer-events-none absolute start-2.5 top-0 -translate-y-1/2 bg-white p-0.5 text-xs text-gray-700 transition-all peer-placeholder-shown:top-1/2 peer-placeholder-shown:text-sm peer-focus:top-0 peer-focus:text-xs">
</span>
<button @click="openDataBit = !openDataBit" type="button"
class="w-full flex items-center justify-between bg-transparent text-gray-900 py-0.5 focus:outline-none">
<span x-text="selectedDataBit.namaDataBit" class="text-left"></span>
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 transition-transform"
:class="{ 'rotate-180': openDataBit }" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M19 9l-7 7-7-7" />
</svg>
</button>
</fieldset>
<div x-show="openDataBit"
class="absolute bg-white w-full border border-gray-300 rounded-md shadow-lg z-10 max-h-[200px] overflow-y-auto">
<ul>
<template x-for="item in dataDataBit" :key="item.idDataBit">
<li :id="item.idDataBit" @click="onChangeDataBit(item)"
class="py-2 px-3 hover:bg-blue-100 cursor-pointer text-gray-700">
<button x-text="item.namaDataBit"></button>
</li>
</template>
</ul>
</div>
<div class="mb-5"></div>
<!-- stop bit -->
<fieldset @click.outside="openStopBit = false"
class="relative border border-gray-400 rounded-md focus-within:border-blue-500 focus-within:ring-1 focus-within:ring-blue-500 px-3 pt-2 pb-2">
<span
x-text="selectedStopBit.idStopBit != -1 ? 'StopBit' : selectedStopBit.namaStopBit"
class="pointer-events-none absolute start-2.5 top-0 -translate-y-1/2 bg-white p-0.5 text-xs text-gray-700 transition-all peer-placeholder-shown:top-1/2 peer-placeholder-shown:text-sm peer-focus:top-0 peer-focus:text-xs">
</span>
<button @click="openStopBit = !openStopBit" type="button"
class="w-full flex items-center justify-between bg-transparent text-gray-900 py-0.5 focus:outline-none">
<span x-text="selectedStopBit.namaStopBit" class="text-left"></span>
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 transition-transform"
:class="{ 'rotate-180': openStopBit }" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M19 9l-7 7-7-7" />
</svg>
</button>
</fieldset>
<div x-show="openStopBit"
class="absolute bg-white w-full border border-gray-300 rounded-md shadow-lg z-10 max-h-[200px] overflow-y-auto">
<ul>
<template x-for="item in dataStopBit" :key="item.idStopBit">
<li :id="item.idStopBit" @click="onChangeStopBit(item)"
class="py-2 px-3 hover:bg-blue-100 cursor-pointer text-gray-700">
<button x-text="item.namaStopBit"></button>
</li>
</template>
</ul>
</div>
<div class="mb-5"></div>
<!-- interface -->
<fieldset @click.outside="openInterface = false"
class="relative border border-gray-400 rounded-md focus-within:border-blue-500 focus-within:ring-1 focus-within:ring-blue-500 px-3 pt-2 pb-2">
<span
x-text="selectedInterface.idInterface != -1 ? 'Interface' : selectedInterface.namaInterface"
class="pointer-events-none absolute start-2.5 top-0 -translate-y-1/2 bg-white p-0.5 text-xs text-gray-700 transition-all peer-placeholder-shown:top-1/2 peer-placeholder-shown:text-sm peer-focus:top-0 peer-focus:text-xs">
</span>
<button @click="openInterface = !openInterface" type="button"
class="w-full flex items-center justify-between bg-transparent text-gray-900 py-0.5 focus:outline-none">
<span x-text="selectedInterface.namaInterface" class="text-left"></span>
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 transition-transform"
:class="{ 'rotate-180': openInterface }" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M19 9l-7 7-7-7" />
</svg>
</button>
</fieldset>
<div x-show="openInterface"
class="absolute bg-white w-full border border-gray-300 rounded-md shadow-lg z-10 max-h-[200px] overflow-y-auto">
<ul>
<template x-for="item in dataInterface" :key="item.idInterface">
<li :id="item.idInterface" @click="onChangeInterface(item)"
class="py-2 px-3 hover:bg-blue-100 cursor-pointer text-gray-700">
<button x-text="item.namaInterface"></button>
</li>
</template>
</ul>
</div>
<div class="mb-5"></div>
<!-- instrument -->
<fieldset @click.outside="openInstrument = false"
class="relative border border-gray-400 rounded-md focus-within:border-blue-500 focus-within:ring-1 focus-within:ring-blue-500 px-3 pt-2 pb-2">
<span
x-text="selectedInstrument.idInstrument != -1 ? 'Instrument' : selectedInstrument.namaInstrument"
class="pointer-events-none absolute start-2.5 top-0 -translate-y-1/2 bg-white p-0.5 text-xs text-gray-700 transition-all peer-placeholder-shown:top-1/2 peer-placeholder-shown:text-sm peer-focus:top-0 peer-focus:text-xs">
</span>
<button @click="openInstrument = !openInstrument" type="button"
class="w-full flex items-center justify-between bg-transparent text-gray-900 py-0.5 focus:outline-none">
<span x-text="selectedInstrument.namaInstrument" class="text-left"></span>
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 transition-transform"
:class="{ 'rotate-180': openInstrument }" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M19 9l-7 7-7-7" />
</svg>
</button>
</fieldset>
<div x-show="openInstrument"
class="absolute bg-white w-full border border-gray-300 rounded-md shadow-lg z-10 max-h-[200px] overflow-y-auto">
<ul>
<template x-for="item in dataInstrument" :key="item.idInstrument">
<li :id="item.idInstrument" @click="onChangeInstrument(item)"
class="py-2 px-3 hover:bg-blue-100 cursor-pointer text-gray-700">
<button x-text="item.namaInstrument"></button>
</li>
</template>
</ul>
</div>
<div class="mb-5"></div>
</div>
</template>
<!-- namaJenis RS232 -->
</div>
</div>
<!-- footer -->
<div class="h-10 px-4 py-2 mb-5">
<div class="flex items-end justify-end">
<button
@click="closeDialog()"
class="mr-3 text-[#FF5252] hover:text-white font-bold text-sm uppercase transition duration-200
<button @click="closeDialog()" class="mr-3 text-[#FF5252] hover:text-white font-bold text-sm uppercase transition duration-200
hover:bg-[#FF5252] px-4 py-2 rounded-md">
Cancel
</button>
<button
class="text-[#1976D2] font-bold text-sm uppercase px-4 py-2 rounded-md transition duration-200
<button class="text-[#1976D2] font-bold text-sm uppercase px-4 py-2 rounded-md transition duration-200
hover:bg-[#1976D2] hover:text-white">
Save
</button>