-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
all the stuff for updating day template codes with api
- Loading branch information
Showing
14 changed files
with
460 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import { message } from 'antd'; | ||
import React, { useState, useRef } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import NavBar from '../../components/NavBar/NavBar'; | ||
import { getArduinoXML } from '../../components/DayPanels/Utils/helpers'; | ||
import { getSession, getDay, updateDayArduino } from '../../Utils/requests'; | ||
import './dayz.less'; | ||
//import { findSuperAdmins } from '../../../../server/extensions/users-permissions/controllers/Auth'; | ||
|
||
|
||
const useFormInput = (initialValue) => { | ||
const [value, setValue] = useState(initialValue); | ||
|
||
const handleChange = (e) => { | ||
setValue(e.target.value); | ||
}; | ||
return { | ||
value, | ||
onChange: handleChange, | ||
}; | ||
}; | ||
|
||
export default function CodeDayz() { | ||
const rID = useFormInput(''); | ||
const [loading, setLoading] = useState(false); | ||
const navigate = useNavigate(); | ||
const workspaceRef = useRef(null); | ||
|
||
const handleLogin = () => { | ||
setLoading(true); | ||
//console.log(rID) | ||
getDay(parseInt(rID.value)) | ||
.then((response) => { | ||
//console.log(response) | ||
if (workspaceRef.current) { | ||
workspaceRef.current.dispose() | ||
} | ||
workspaceRef.current = window.Blockly.inject('blockly-box', { | ||
toolbox: document.getElementById('toolbox'), | ||
readOnly: true, | ||
}); | ||
|
||
|
||
|
||
if (response.data === '') { | ||
workspaceRef.current.dispose(); | ||
message.error('No workspace associated with ID'); | ||
setLoading(false); | ||
} | ||
else { | ||
setLoading(false); | ||
//console.log(response.data.template); | ||
workspaceRef.current.dispose(); | ||
//console.log(getArduinoXML(response.data.template, workspaceRef.current)); | ||
updateDayArduino(parseInt(rID.value), getArduinoXML(response.data.template, workspaceRef.current)) | ||
.catch(error => { | ||
console.log(error) | ||
}); | ||
} | ||
|
||
|
||
}) | ||
.catch((error) => { | ||
message.error('Please enter a valid workspace ID'); | ||
setLoading(false); | ||
workspaceRef.current.dispose(); | ||
|
||
}); | ||
}; | ||
|
||
return ( | ||
<div className='container nav-padding'> | ||
<NavBar /> | ||
<div id='content-wrapper'> | ||
<form | ||
id='box' | ||
onKeyPress={(e) => { | ||
if (e.key === 'Enter') handleLogin(); | ||
}} | ||
> | ||
<div id='box-title'>Update Day Record</div> | ||
<input | ||
type='email' | ||
{...rID} | ||
placeholder='Day ID' | ||
autoComplete='username' | ||
/> | ||
<input | ||
type='button' | ||
value={loading ? 'Loading...' : 'Update Day'} | ||
onClick={handleLogin} | ||
disabled={loading} | ||
/> | ||
|
||
|
||
|
||
</form> | ||
</div> | ||
<div id='blockly-box'></div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
@import '../../assets/style.less'; | ||
|
||
.container { | ||
background-color: #colors[primary]; | ||
height: 100%; | ||
min-height: 100vh; | ||
width: 100%; | ||
min-width: 100vw; | ||
text-align: center; | ||
} | ||
|
||
#content-wrapper { | ||
margin: 12vh auto 8vh auto; | ||
display: inline-block; | ||
} | ||
|
||
#box { | ||
width: 300px; | ||
padding: 40px 20px; | ||
background-color: #colors[tertiary]; | ||
text-align: center; | ||
border-radius: 15px; | ||
border: 4px solid; | ||
border-color: #colors[secondary]; | ||
} | ||
|
||
#box-title { | ||
background-color: #colors[secondary]; | ||
border-radius: 80px; | ||
width: 80%; | ||
min-height: 8%; | ||
color: #colors[text-secondary]; | ||
font-size: 1.5em; | ||
font-weight: bold; | ||
position: relative; | ||
top: -60px; | ||
left: -40px; | ||
line-height: 50px; | ||
text-align: center; | ||
} | ||
|
||
#box input[type='text'], | ||
#box input[type='email'], | ||
#box input[type='password'] { | ||
display: block; | ||
background: none; | ||
margin: 20px auto 0px; | ||
border: 2px solid; | ||
border-color: #colors[secondary]; | ||
padding: 14px 10px; | ||
width: 200px; | ||
outline: none; | ||
color: #colors[text-primary]; | ||
border-radius: 8px; | ||
transition: 0.25s; | ||
} | ||
|
||
#box input[type='text']:focus, | ||
#box input[type='email']:focus, | ||
#box input[type='password']:focus { | ||
width: 220px; | ||
} | ||
|
||
#box input[type='button'] { | ||
background: darken(#colors[tertiary], 30%); | ||
width: 80%; | ||
display: block; | ||
margin: 0 auto; | ||
border: 2px solid; | ||
border-color: #colors[secondary]; | ||
padding: 14px 40px; | ||
outline: none; | ||
color: #colors[text-primary]; | ||
background-color: #colors[quaternary]; | ||
font-size: 1.2em; | ||
font-weight: 500; | ||
border-radius: 30px; | ||
cursor: pointer; | ||
transition: 0.25s; | ||
position: relative; | ||
bottom: -65px; | ||
|
||
&:hover { | ||
background-color: #colors[quinary]; | ||
color: #colors[text-primary]; | ||
} | ||
} | ||
|
||
#box #forgot-password { | ||
margin-top: 10px; | ||
margin-bottom: 0px; | ||
float: none; | ||
|
||
|
||
&:hover { | ||
cursor: pointer; | ||
} | ||
} | ||
#box #create-account { | ||
margin-top: 15px; | ||
margin-bottom: 0px; | ||
float: none; | ||
|
||
|
||
&:hover { | ||
cursor: pointer; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.