mirror of
				https://github.com/optim-enterprises-bv/OptimCloud-gw-ui.git
				synced 2025-10-31 02:07:45 +00:00 
			
		
		
		
	Reboot now button does the action
This commit is contained in:
		| @@ -24,6 +24,7 @@ const ActionModalWidget = ({ show, toggleModal, title, directions, action, extra | |||||||
|   const [waiting, setWaiting] = useState(false); |   const [waiting, setWaiting] = useState(false); | ||||||
|   const [validDate, setValidDate] = useState(true); |   const [validDate, setValidDate] = useState(true); | ||||||
|   const [chosenDate, setChosenDate] = useState(new Date().toString()); |   const [chosenDate, setChosenDate] = useState(new Date().toString()); | ||||||
|  |   const [doingNow, setDoingNow] = useState(false); | ||||||
|   const [responseBody, setResponseBody] = useState(''); |   const [responseBody, setResponseBody] = useState(''); | ||||||
|   const [checkingIfSure, setCheckingIfSure] = useState(false); |   const [checkingIfSure, setCheckingIfSure] = useState(false); | ||||||
|   const selectedDeviceId = useSelector((state) => state.selectedDeviceId); |   const selectedDeviceId = useSelector((state) => state.selectedDeviceId); | ||||||
| @@ -36,11 +37,6 @@ const ActionModalWidget = ({ show, toggleModal, title, directions, action, extra | |||||||
|     return true; |     return true; | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|   const setDateToNow = () => { |  | ||||||
|     const now = new Date().toString(); |  | ||||||
|     setChosenDate(now); |  | ||||||
|   }; |  | ||||||
|  |  | ||||||
|   const setDateToLate = () => { |   const setDateToLate = () => { | ||||||
|     const date = convertDateToUtc(new Date()); |     const date = convertDateToUtc(new Date()); | ||||||
|     if (date.getHours() >= 3) { |     if (date.getHours() >= 3) { | ||||||
| @@ -72,7 +68,8 @@ const ActionModalWidget = ({ show, toggleModal, title, directions, action, extra | |||||||
|     setCheckingIfSure(false); |     setCheckingIfSure(false); | ||||||
|   }, [show]); |   }, [show]); | ||||||
|  |  | ||||||
|   const doAction = () => { |   const doAction = (isNow) => { | ||||||
|  |     setDoingNow(isNow); | ||||||
|     setHadFailure(false); |     setHadFailure(false); | ||||||
|     setHadSuccess(false); |     setHadSuccess(false); | ||||||
|     setWaiting(true); |     setWaiting(true); | ||||||
| @@ -84,7 +81,7 @@ const ActionModalWidget = ({ show, toggleModal, title, directions, action, extra | |||||||
|     const parameters = { |     const parameters = { | ||||||
|       ...{ |       ...{ | ||||||
|         serialNumber: selectedDeviceId, |         serialNumber: selectedDeviceId, | ||||||
|         when: utcDateString, |         when: isNow ? 0 : utcDateString, | ||||||
|       }, |       }, | ||||||
|       ...extraParameters, |       ...extraParameters, | ||||||
|     }; |     }; | ||||||
| @@ -119,8 +116,14 @@ const ActionModalWidget = ({ show, toggleModal, title, directions, action, extra | |||||||
|         <h6>{directions}</h6> |         <h6>{directions}</h6> | ||||||
|         <CRow style={{ marginTop: '20px' }}> |         <CRow style={{ marginTop: '20px' }}> | ||||||
|           <CCol> |           <CCol> | ||||||
|             <CButton disabled={waiting} block color="primary" onClick={() => setDateToNow()}> |               <CButton  | ||||||
|               Now |                 onClick={() => doAction(true)}  | ||||||
|  |                 disabled={waiting}  | ||||||
|  |                 block  | ||||||
|  |                 color="primary" | ||||||
|  |               > | ||||||
|  |                 {waiting && doingNow ? 'Loading...' : 'Do Now!'} | ||||||
|  |                 <CSpinner hidden={!waiting || !doingNow} component="span" size="sm" /> | ||||||
|               </CButton> |               </CButton> | ||||||
|           </CCol> |           </CCol> | ||||||
|           <CCol> |           <CCol> | ||||||
| @@ -159,6 +162,7 @@ const ActionModalWidget = ({ show, toggleModal, title, directions, action, extra | |||||||
|         <div hidden={!checkingIfSure}>Are you sure?</div> |         <div hidden={!checkingIfSure}>Are you sure?</div> | ||||||
|         <CButton |         <CButton | ||||||
|           hidden={checkingIfSure} |           hidden={checkingIfSure} | ||||||
|  |           disabled={waiting} | ||||||
|           color="primary" |           color="primary" | ||||||
|           onClick={() => (formValidation() ? confirmingIfSure() : null)} |           onClick={() => (formValidation() ? confirmingIfSure() : null)} | ||||||
|         > |         > | ||||||
| @@ -168,10 +172,10 @@ const ActionModalWidget = ({ show, toggleModal, title, directions, action, extra | |||||||
|           hidden={!checkingIfSure} |           hidden={!checkingIfSure} | ||||||
|           disabled={waiting} |           disabled={waiting} | ||||||
|           color="primary" |           color="primary" | ||||||
|           onClick={() => (formValidation() ? doAction() : null)} |           onClick={() => (formValidation() ? doAction(false) : null)} | ||||||
|         > |         > | ||||||
|           {waiting ? 'Loading...' : 'Yes'} {'   '} |           {waiting && !doingNow ? 'Loading...' : 'Yes'} {'   '} | ||||||
|           <CSpinner hidden={!waiting} component="span" size="sm" /> |           <CSpinner hidden={!waiting || doingNow} component="span" size="sm" /> | ||||||
|         </CButton> |         </CButton> | ||||||
|         <CButton color="secondary" onClick={toggleModal}> |         <CButton color="secondary" onClick={toggleModal}> | ||||||
|           Cancel |           Cancel | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 bourquecharles
					bourquecharles