<template>
    <div class="card">
        <div class="card-header">PCB Table Settings</div>
        <div class="card-body">
            
            <div class="mb-3">
                <label class="form-label">PCB Table position</label>
                <div class="row mb-2">
                    <div class="col">
                        <div class="row">
                            <div class="col-auto pt-1">X:</div>
                            <div class="col"><input v-model="pcbtable.x" type="number" step="0.01" class="form-control form-control-sm"></div>
                        </div>
                    </div>
                    <div class="col">
                        <div class="row">
                            <div class="col-auto pt-1">Y:</div>
                            <div class="col"><input v-model="pcbtable.y" type="number" step="0.01" class="form-control form-control-sm"></div>
                        </div>
                    </div>
                    <div class="col">
                        <div class="row">
                            <div class="col-auto pt-1">Z:</div>
                            <div class="col"><input v-model="pcbtable.z" type="number" step="0.01" class="form-control form-control-sm"></div>
                        </div>
                    </div>
                    <div class="col-auto">
                        <button class="btn btn-sm btn-outline-secondary btn-danger me-1" @click="setPosition(n)" title="Set current position of nozzle">🞊</button>
                    </div>
                </div>
                <div class="form-text">Left bottom PCB table position</div>

            </div>

            <div class="row mt-2">
                <div class="col">
                    <button :disabled="loading" class="btn btn-sm btn-outline-secondary" @click="applaySettings()">Applay settings</button>
                </div>
            </div>

        </div>

    </div>
</template>

<script>
    import machineState from '../js/machine_state.js'

    export default {
        mixins: [machineState],
        props: {
            pcbtable: Object,
            machineState: Object,
            machinePos: Object,
            loading: Boolean
        },
        methods: {
            applaySettings() {
                this.$emit('applaySettings')
            },
            setPosition(number) {
                if (this.machineStateIsOK() == true) {
                    this.pcbtable.z = parseFloat(this.machinePos.z)
                }
            },
        }
    }
</script>

<style>

</style>
