mirror of
https://github.com/optim-enterprises-bv/OptimCloud-gw-ui.git
synced 2025-10-30 17:57:46 +00:00
Added firmware upgrade modal with no action
This commit is contained in:
@@ -1,17 +1,49 @@
|
|||||||
import React from 'react'
|
import React, { useState } from 'react'
|
||||||
import {
|
import {
|
||||||
CButton,
|
CButton,
|
||||||
CCard,
|
CCard,
|
||||||
CCardHeader,
|
CCardHeader,
|
||||||
CCardBody,
|
CCardBody,
|
||||||
CRow,
|
CRow,
|
||||||
CCol
|
CCol,
|
||||||
|
CModal,
|
||||||
|
CModalHeader,
|
||||||
|
CModalTitle,
|
||||||
|
CModalBody,
|
||||||
|
CModalFooter,
|
||||||
|
CForm,
|
||||||
|
CInput,
|
||||||
|
CInvalidFeedback
|
||||||
} from '@coreui/react'
|
} from '@coreui/react'
|
||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
|
|
||||||
const DeviceActions = () => {
|
const DeviceActions = () => {
|
||||||
|
const [showModal, setShowModal] = useState(false);
|
||||||
|
const [firmwareUri, setFirmwareUri] = useState('');
|
||||||
|
const [validField, setValidField] = useState(true);
|
||||||
|
|
||||||
let selectedDevice = useSelector(state => state.selectedDevice);
|
let selectedDevice = useSelector(state => state.selectedDevice);
|
||||||
console.log(selectedDevice);
|
|
||||||
|
const toggleModal = (e) => {
|
||||||
|
setShowModal(!showModal);
|
||||||
|
//e.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
const formChange = (fieldValue) => {
|
||||||
|
if(!validField){
|
||||||
|
setValidField(true);
|
||||||
|
}
|
||||||
|
setFirmwareUri(fieldValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
const formValidation = () => {
|
||||||
|
if (firmwareUri.trim() === ''){
|
||||||
|
setValidField(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CCard>
|
<CCard>
|
||||||
<CCardHeader>
|
<CCardHeader>
|
||||||
@@ -25,9 +57,35 @@ const DeviceActions = () => {
|
|||||||
<CCol>
|
<CCol>
|
||||||
<CButton block color="primary">Blink</CButton>
|
<CButton block color="primary">Blink</CButton>
|
||||||
</CCol>
|
</CCol>
|
||||||
|
</CRow>
|
||||||
|
<CRow style={{marginTop :'10px'}}>
|
||||||
|
<CCol>
|
||||||
|
<CButton onClick = { toggleModal } block color="primary">Firmware Upgrade</CButton>
|
||||||
|
</CCol>
|
||||||
</CRow>
|
</CRow>
|
||||||
</CCardBody>
|
</CCardBody>
|
||||||
|
<CModal
|
||||||
|
show={showModal}
|
||||||
|
onClose={toggleModal}
|
||||||
|
>
|
||||||
|
<CModalHeader closeButton>
|
||||||
|
<CModalTitle>Firmware Upgrade</CModalTitle>
|
||||||
|
</CModalHeader>
|
||||||
|
<CModalBody>
|
||||||
|
<p>Insert the link of the firmware version you would like to upgrade the device to.</p>
|
||||||
|
<CForm action="" method="post" encType="multipart/form-data" className="form-horizontal">
|
||||||
|
<CInput className={'form-control', {'is-invalid' : !validField}} type="text" id="uri" name="uri-input" placeholder="https://somelocation.com/file=newversion.bin" autoComplete="firmware-uri" onChange={event => formChange(event.target.value)}/>
|
||||||
|
<CInvalidFeedback>You need a url...</CInvalidFeedback>
|
||||||
|
</CForm>
|
||||||
|
</CModalBody>
|
||||||
|
<CModalFooter>
|
||||||
|
<CButton color="primary" onClick={event => formValidation()}>Upgrade</CButton>
|
||||||
|
<CButton
|
||||||
|
color="secondary"
|
||||||
|
onClick={toggleModal}
|
||||||
|
>Cancel</CButton>
|
||||||
|
</CModalFooter>
|
||||||
|
</CModal>
|
||||||
</CCard>
|
</CCard>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ const Login = () => {
|
|||||||
console.log(error.response);
|
console.log(error.response);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const formValidation = () => {
|
const formValidation = () => {
|
||||||
if (userId.trim() === '' || password.trim() === ''){
|
if (userId.trim() === '' || password.trim() === ''){
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user