diff --git a/client/src/Utils/analytics.js b/client/src/Utils/analytics.js deleted file mode 100644 index ab461aa5..00000000 --- a/client/src/Utils/analytics.js +++ /dev/null @@ -1,61 +0,0 @@ -export const parseXML = xml => { - const parser = new DOMParser(); - const xmlData = { - blocks: {}, - categories: {} - }; - let xmlDoc = parser.parseFromString(xml, "text/xml"); - const xmlBlocks = xmlDoc.querySelectorAll('block'); - for (const block of xmlBlocks) { - const blockType = block.getAttribute('type'); - if(xmlData.blocks[blockType]) { - xmlData.blocks[blockType].count++; - } else { - xmlData.blocks[blockType] = { - count: 1, - deleted: 0 - }; - } - } - return xmlData; -} - -export const compareXML = ({blocks: currentBlocks}, {blocks: previousBlocks}) => { - const blocks = diffObjects(currentBlocks, previousBlocks); - return { - blocks - } -} - -const diffObjects = (currentObj, previousObj) => { - const currentKeys = Object.keys(currentObj) - const prevKeys = Object.keys(previousObj) - // deleted all of one type of block - if (prevKeys.length > currentKeys.length) { - for(let key of prevKeys) { - if(currentKeys.indexOf(key) === -1) { - console.log('deleted all of one block'); - currentObj[key] = { - count: 0, - deleted: previousObj[key].deleted + 1 - } - } - } - } - for (let key of currentKeys) { - if (key in previousObj) { - if (currentObj[key].count < previousObj[key].count) { - currentObj[key].deleted = previousObj[key].deleted + 1; - console.log('a block was deleted'); - } - if(currentObj[key].deleted < previousObj[key].deleted) { - console.log('a block was reintroduced'); - currentObj[key] = { - count: 1, - deleted: previousObj[key].deleted - } - } - } - } - return currentObj -} \ No newline at end of file diff --git a/client/src/components/DayPanels/Utils/consoleHelpers.js b/client/src/components/DayPanels/Utils/consoleHelpers.js index fe8a3018..285f5024 100644 --- a/client/src/components/DayPanels/Utils/consoleHelpers.js +++ b/client/src/components/DayPanels/Utils/consoleHelpers.js @@ -59,7 +59,6 @@ const readUntilClose = async ( .pipeThrough(new window.TransformStream(new LineBreakTransformer())) .getReader(); - console.log('reader opened'); let string = ''; plotData = []; @@ -70,7 +69,6 @@ const readUntilClose = async ( reader.releaseLock(); break; } - console.log(value); if (type === 'notNewLine') { string += value; document.getElementById('console-content').innerHTML = string; @@ -100,7 +98,6 @@ export const writeToPort = async (data) => { writer = port.writable.getWriter(); data += '\n'; await writer.write(textEncoder.encode(data)); - console.log(textEncoder.encode(data)); writer.releaseLock(); }; diff --git a/client/src/components/DayPanels/consoleHelpers.js b/client/src/components/DayPanels/consoleHelpers.js deleted file mode 100644 index 10081017..00000000 --- a/client/src/components/DayPanels/consoleHelpers.js +++ /dev/null @@ -1,123 +0,0 @@ -let port; -let reader; -let writer; -let readableStreamClosed; - -class LineBreakTransformer { - constructor() { - this.container = ''; - } - - transform(chunk, controller) { - this.container += chunk; - const lines = this.container.split('\r\n'); - this.container = lines.pop(); - lines.forEach((line) => controller.enqueue(line)); - } - - flush(controller) { - controller.enqueue(this.container); - } -} - -export const openConnection = async (baudRate_, newLine) => { - //requesting port on the pop up window. - port = window['port']; - - var options = { - baudRate: baudRate_, - parity: 'none', - dataBits: 8, - stopBits: 1, - bufferSize: 1024, - }; - - // connect to port on baudRate 9600. - await port.open(options); - console.log(`port opened at baud rate: ${baudRate_} `); - document.getElementById('console-content').innerHTML = ''; - readUntilClose(newLine); -}; - -const readUntilClose = async (newLine) => { - const textDecoder = new window.TextDecoderStream(); - readableStreamClosed = port.readable.pipeTo(textDecoder.writable); - // reader = textDecoder.readable.getReader(); - reader = textDecoder.readable - .pipeThrough(new window.TransformStream(new LineBreakTransformer())) - .getReader(); - - console.log('reader opened'); - let string = ''; - while (true) { - const { value, done } = await reader.read(); - if (done) { - // Allow the serial port to be closed later. - reader.releaseLock(); - break; - } - console.log(value); - if (!newLine) { - string += value; - document.getElementById('console-content').innerHTML = string; - } else { - let newP = document.createElement('p'); - newP.innerHTML = value; - newP.style.margin = 0; - document.getElementById('console-content').appendChild(newP); - newP.scrollIntoView(); - } - } -}; - -export const writeToPort = async (data) => { - const textEncoder = new window.TextEncoder(); - writer = port.writable.getWriter(); - data += '\n'; - await writer.write(textEncoder.encode(data)); - console.log(textEncoder.encode(data)); - writer.releaseLock(); -}; - -export const disconnect = async () => { - reader.cancel(); - await readableStreamClosed.catch(() => { - /* Ignore the error */ - }); - if (typeof writer !== 'undefined') { - const textEncoder = new window.TextEncoder(); - writer = port.writable.getWriter(); - await writer.write(textEncoder.encode('')); - await writer.close(); - } - await port.close(); -}; - -export const connectToPort = async () => { - const filters = [ - { usbVendorId: 0x2341, usbProductId: 0x0043 }, - { usbVendorId: 0x2341, usbProductId: 0x0001 }, - ]; - try { - port = await navigator.serial.requestPort({ filters }); - } catch (e) { - console.error(e); - return; - } - window['port'] = port; -}; - -export const handleOpenConnection = async (baudRate, newLine) => { - if (typeof window['port'] === 'undefined') { - await connectToPort(); - if (typeof window['port'] === 'undefined') { - return; - } - } - await openConnection(baudRate, newLine); -}; - -export const handleCloseConnection = async () => { - console.log('Close connection'); - disconnect(); -}; diff --git a/client/src/components/DayPanels/helpers.js b/client/src/components/DayPanels/helpers.js deleted file mode 100644 index 3bc83881..00000000 --- a/client/src/components/DayPanels/helpers.js +++ /dev/null @@ -1,197 +0,0 @@ -import { - createSubmission, - getSubmission, - saveWorkspace, - updateDayTemplate, -} from '../../Utils/requests'; -import { message } from 'antd'; - -const AvrboyArduino = window.AvrgirlArduino; - -export const setLocalSandbox = (workspaceRef) => { - let workspaceDom = window.Blockly.Xml.workspaceToDom(workspaceRef); - let workspaceText = window.Blockly.Xml.domToText(workspaceDom); - const localActivity = JSON.parse(localStorage.getItem('sandbox-day')); - - let lastActivity = { ...localActivity, template: workspaceText }; - localStorage.setItem('sandbox-day', JSON.stringify(lastActivity)); -}; - -// Generates xml from blockly canvas -export const getXml = (workspaceRef, shouldAlert = true) => { - const { Blockly } = window; - - let xml = Blockly.Xml.workspaceToDom(workspaceRef); - let xml_text = Blockly.Xml.domToText(xml); - if (shouldAlert) alert(xml_text); - return xml_text; -}; - -// Generates javascript code from blockly canvas -export const getJS = (workspaceRef) => { - window.Blockly.JavaScript.INFINITE_LOOP_TRAP = null; - let code = window.Blockly.JavaScript.workspaceToCode(workspaceRef); - alert(code); - return code; -}; - -// Generates Arduino code from blockly canvas -export const getArduino = (workspaceRef, shouldAlert = true) => { - window.Blockly.Arduino.INFINITE_LOOP_TRAP = null; - let code = window.Blockly.Arduino.workspaceToCode(workspaceRef); - if (shouldAlert) alert(code); - return code; -}; - -let intervalId; -const compileFail = (setSelectedCompile, setCompileError, msg) => { - setSelectedCompile(false); - message.error('Compile Fail', 3); - setCompileError(msg); -}; -// Sends compiled arduino code to server and returns hex to flash board with -export const compileArduinoCode = async ( - workspaceRef, - setSelectedCompile, - setCompileError, - day, - isStudent -) => { - setSelectedCompile(true); - const sketch = getArduino(workspaceRef, false); - let workspaceDom = window.Blockly.Xml.workspaceToDom(workspaceRef); - let workspaceText = window.Blockly.Xml.domToText(workspaceDom); - let path; - isStudent ? (path = '/submissions') : (path = '/sandbox/submission'); - let id = isStudent ? day.id : undefined; - - // create an initial submission - const initialSubmission = await createSubmission( - id, - workspaceText, - sketch, - path, - isStudent - ); - - // if we fail to create submission - if (!initialSubmission.data) { - compileFail( - setSelectedCompile, - setCompileError, - 'Oops. Something went wrong, please check your internet connection.' - ); - return; - } - // Get the submission Id and send a request to get the submission every - // 0.25 second until the submission status equal to COMPLETE. - intervalId = setInterval( - () => - getAndFlashSubmission( - initialSubmission.data.id, - path, - isStudent, - setSelectedCompile, - setCompileError - ), - 250 - ); - - // Set a timeout of 20 second. If the submission status fail to update to - // COMPLETE, show error. - setTimeout(() => { - if (intervalId) { - clearInterval(intervalId); - intervalId = undefined; - compileFail( - setSelectedCompile, - setCompileError, - 'Oops. Something went wrong, please try again.' - ); - } - }, 20000); -}; - -const getAndFlashSubmission = async ( - id, - path, - isStudent, - setSelectedCompile, - setCompileError -) => { - // get the submission - const response = await getSubmission(id, path, isStudent); - // If we fail to retrive submission - if (!response.data) { - if (intervalId) { - clearInterval(intervalId); - intervalId = undefined; - } - compileFail( - setSelectedCompile, - setCompileError, - 'Oops. Something went wrong, please check your internet connection.' - ); - return; - } - - // if the submission is not complete, try again later - if (response.data.status !== 'COMPLETED') { - return; - } - - // If the submission is ready - if (intervalId) { - clearInterval(intervalId); - intervalId = undefined; - } - // flash the board with the output - await flashArduino(response, setSelectedCompile, setCompileError); -}; - -const flashArduino = async (response, setSelectedCompile, setCompileError) => { - if (response.data) { - // if we get a success status from the submission, send it to arduino - if (response.data.success) { - // converting base 64 to hex - let Hex = atob(response.data.hex).toString(); - - const avrgirl = new AvrboyArduino({ - board: 'uno', - debug: true, - }); - - avrgirl.flash(Hex, (err) => { - if (err) { - console.log(err); - } else { - console.log('done correctly.'); - message.success('Compile Success', 3); - setSelectedCompile(false); - } - }); - } - // else if there is error on the Arduino code, show error - else if (response.data.stderr) { - message.error('Compile Fail', 3); - setSelectedCompile(false); - setCompileError(response.data.stderr); - } - } else { - message.error(response.err); - } -}; - -// save current workspace -export const handleSave = async (dayId, workspaceRef, replay) => { - let xml = window.Blockly.Xml.workspaceToDom(workspaceRef.current); - let xml_text = window.Blockly.Xml.domToText(xml); - return await saveWorkspace(dayId, xml_text, replay); -}; - -export const handleCreatorSaveDay = async (dayId, workspaceRef, blocksList) => { - let xml = window.Blockly.Xml.workspaceToDom(workspaceRef.current); - let xml_text = window.Blockly.Xml.domToText(xml); - - return await updateDayTemplate(dayId, xml_text, blocksList); -}; diff --git a/client/src/components/DropdownMenu/ReportDropdown.js b/client/src/components/DropdownMenu/ReportDropdown.js deleted file mode 100644 index e8b5b812..00000000 --- a/client/src/components/DropdownMenu/ReportDropdown.js +++ /dev/null @@ -1,29 +0,0 @@ -import React from 'react'; -import './ReportDropdown.less'; -import { Form, Select } from 'antd'; -const { Option } = Select; - - -function handleChange(value) { - console.log(`selected ${value}`); -} - -export default function ReportDropdown({label, menuName, menuItems}) { - const menus = Object.entries(menuItems).map((key) => { - return ( - - ) - }) - - return ( -
- - - -
- ) -} diff --git a/client/src/components/DropdownMenu/ReportDropdown.less b/client/src/components/DropdownMenu/ReportDropdown.less deleted file mode 100644 index 24c6d791..00000000 --- a/client/src/components/DropdownMenu/ReportDropdown.less +++ /dev/null @@ -1,67 +0,0 @@ -@import "../../assets/style.less"; - -// .report-menu-item { -// display: flex; -// justify-content: space-between; -// align-items: center; -// flex-wrap: nowrap; -// width: 100%; -// position: -webkit-sticky; -// position: fixed; -// top: 0; -// z-index: 2; -// height: 8vh; -// background-color: #colors[primary]; -// padding-right: 2vw; - -// -moz-box-shadow: 0 1px 5px -1px darken(#colors[primary], 90%); -// -webkit-box-shadow: 0 1px 5px -1px darken(#colors[primary], 90%); -// box-shadow: 0 1px 5px -1px darken(#colors[primary], 90%); - -// #link { -// #casmm-logo { -// position: relative; -// bottom: 0; -// height: 6vh; -// width: auto; -// } -// } -// } - -// #menu-link { -// background: none !important; -// border: none; -// padding: 0 !important; -// display: inline-block; - -// &:focus { -// outline: none; -// } - -// &:hover { -// cursor: pointer; -// } -// } - -.ant-select-selection-item { - color: black; - border: none; - // padding: 1rem !important; - font-size: 1rem; - font-weight: bold; - - &:focus { - outline: none; - } - - &:hover { - color: #colors[secondary]; - cursor: pointer; - } -} - -.ant-form-item-label > label { - color: black; - font-size: 1rem; - font-weight: bold; -} \ No newline at end of file diff --git a/client/src/components/Tabs/SavedWorkspaceTab.js b/client/src/components/Tabs/SavedWorkspaceTab.js index a83194b4..a0c9f535 100644 --- a/client/src/components/Tabs/SavedWorkspaceTab.js +++ b/client/src/components/Tabs/SavedWorkspaceTab.js @@ -28,7 +28,6 @@ export default function SavedWorkSpaceTab({searchParams, setSearchParams, classr } setWorkspaceList(wsResponse.data); - console.log(wsResponse.data); }; fetchData(); }, [classroomId]); diff --git a/client/src/views/ContentCreator/LearningStandardCreator/LearningStandardCreator.js b/client/src/views/ContentCreator/LearningStandardCreator/LearningStandardCreator.js index 0577318d..70849e5b 100644 --- a/client/src/views/ContentCreator/LearningStandardCreator/LearningStandardCreator.js +++ b/client/src/views/ContentCreator/LearningStandardCreator/LearningStandardCreator.js @@ -99,7 +99,6 @@ export default function LearningStandardCreator({ }; const checkURL = (n) => { - console.log(n); const regex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/g; if (n.search(regex) === -1) { diff --git a/client/src/views/ContentCreator/LearningStandardDayCreator/DayEditor.js b/client/src/views/ContentCreator/LearningStandardDayCreator/DayEditor.js index 5e79c6a5..2f17ffb2 100644 --- a/client/src/views/ContentCreator/LearningStandardDayCreator/DayEditor.js +++ b/client/src/views/ContentCreator/LearningStandardDayCreator/DayEditor.js @@ -39,7 +39,6 @@ export default function ContentCreator({ learningStandard }) { message.error(response.err); } setDay([...days, response.data]); - console.log(response); }; const removeBasicDay = async (currDay) => { diff --git a/client/src/views/ContentCreator/UnitCreator/UnitCreator.js b/client/src/views/ContentCreator/UnitCreator/UnitCreator.js index b6bc47da..c1d30d88 100644 --- a/client/src/views/ContentCreator/UnitCreator/UnitCreator.js +++ b/client/src/views/ContentCreator/UnitCreator/UnitCreator.js @@ -24,9 +24,7 @@ export default function UnitCreator({ gradeList }) { }; const handleSubmit = async (e) => { - console.log(e); const res = await createUnit(number, name, tek, description, grade); - console.log(res); if (res.err) { message.error('Fail to create a new unit'); } else { diff --git a/client/src/views/Dashboard/Dashboard.js b/client/src/views/Dashboard/Dashboard.js index 99ffbb21..91e3ca7d 100644 --- a/client/src/views/Dashboard/Dashboard.js +++ b/client/src/views/Dashboard/Dashboard.js @@ -17,7 +17,6 @@ export default function Dashboard() { let classroomIds = []; getMentor().then((res) => { if (res.data) { - console.log(res.data); res.data.classrooms.forEach((classroom) => { classroomIds.push(classroom.id); }); diff --git a/client/src/views/Mentor/Classroom/Home/Home.js b/client/src/views/Mentor/Classroom/Home/Home.js index 36a02a32..9665c953 100644 --- a/client/src/views/Mentor/Classroom/Home/Home.js +++ b/client/src/views/Mentor/Classroom/Home/Home.js @@ -44,7 +44,6 @@ export default function Home({ classroomId, viewing }) { else { message.error(daysRes.err); } - console.log(daysRes.data); } }); } else { diff --git a/client/src/views/Mentor/Classroom/Roster/CardView.js b/client/src/views/Mentor/Classroom/Roster/CardView.js index f99d19df..865b9f69 100644 --- a/client/src/views/Mentor/Classroom/Roster/CardView.js +++ b/client/src/views/Mentor/Classroom/Roster/CardView.js @@ -24,7 +24,7 @@ export default function CardView(props) {
- +