Skip to content

Commit

Permalink
Merge pull request #529 from Sienci-Labs/typescript-conversion
Browse files Browse the repository at this point in the history
Typescript Conversion
  • Loading branch information
walidkayhan authored Aug 12, 2024
2 parents 2e0bf47 + 5d99363 commit 4b27fde
Show file tree
Hide file tree
Showing 80 changed files with 10,925 additions and 156 deletions.
523 changes: 406 additions & 117 deletions package.json

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions src/app/.tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"target": "es2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "CommonJS",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"noUncheckedIndexedAccess": true,
"noImplicitAny": true
}

}
6 changes: 6 additions & 0 deletions src/app/declarations.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare module 'universal-logger';
declare module 'universal-logger-browser';
declare module 'gcode-parser';
declare module 'memoize-one';
declare module 'gamepad.js';
declare module 'gcode-interpreter';
1 change: 1 addition & 0 deletions src/app/i18n/en/gcode.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
160 changes: 160 additions & 0 deletions src/app/i18n/en/resource.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
{
"Command succeeded": "Command succeeded",
"Command failed ({{err}})": "Command failed ({{err}})",
"Fork Widget": "Fork Widget",
"Are you sure you want to fork this widget?": "Are you sure you want to fork this widget?",
"Cancel": "Cancel",
"OK": "OK",
"Remove Widget": "Remove Widget",
"Are you sure you want to remove this widget?": "Are you sure you want to remove this widget?",
"Add New Task": "Add New Task",
"Task Name": "Task Name",
"Add Task": "Add Task",
"Edit Task": "Edit Task",
"Delete Task": "Delete Task",
"Save Changes": "Save Changes",
"Workflow Controls": "Workflow Controls",
"Resume": "Resume",
"Run": "Run",
"Pause": "Pause",
"Pause Job": "Pause Job",
"Stop": "Stop",
"Stop Job": "Stop Job",
"Click \"Resume\" to continue execution.": "Click \"Resume\" to continue execution.",
"Waiting for the planner to empty...": "Waiting for the planner to empty...",
"The following maintenance tasks are due:": "The following maintenance tasks are due:",
"Click 'Reset Timers' to reset the timers on ALL listed tasks. Click 'Close' to close the popup and do nothing.": "Click 'Reset Timers' to reset the timers on ALL listed tasks. Click 'Close' to close the popup and do nothing.",
"Reset Timers": "Reset Timers",
"Close": "Close",
"Please turn your device to landscape for the best experience, or click to continue.": "Please turn your device to landscape for the best experience, or click to continue.",
"On": "On",
"Off": "Off",
"Visualizer Widget": "Visualizer Widget",
"This widget visualizes a G-code file and simulates the tool path.": "This widget visualizes a G-code file and simulates the tool path.",
"Connection Widget": "Connection Widget",
"This widget lets you establish a connection to a serial port.": "This widget lets you establish a connection to a serial port.",
"Console Widget": "Console Widget",
"This widget lets you read and write data to the CNC controller connected to a serial port.": "This widget lets you read and write data to the CNC controller connected to a serial port.",
"Location Widget": "Location Widget",
"This widget displays machine and work coordinates for all axes.": "This widget displays machine and work coordinates for all axes.",
"Grbl Widget": "Grbl Widget",
"This widget shows the Grbl state and provides Grbl specific features.": "This widget shows the Grbl state and provides Grbl specific features.",
"Job Status Widget": "Job Status Widget",
"This widget displays the job progression and feed and spindle overrides.": "This widget displays the job progression and feed and spindle overrides.",
"Marlin Widget": "Marlin Widget",
"This widget shows the Marlin state and provides Marlin specific features.": "This widget shows the Marlin state and provides Marlin specific features.",
"Smoothie Widget": "Smoothie Widget",
"This widget shows the Smoothie state and provides Smoothie specific features.": "This widget shows the Smoothie state and provides Smoothie specific features.",
"TinyG Widget": "TinyG Widget",
"This widget shows the TinyG state and provides TinyG specific features.": "This widget shows the TinyG state and provides TinyG specific features.",
"JogControl Widget": "JogControl Widget",
"This widget shows the XYZ position. It includes jog controls, homing, and axis zeroing.": "This widget shows the XYZ position. It includes jog controls, homing, and axis zeroing.",
"This widget displays machine and work coordinates for all axes": "This widget displays machine and work coordinates for all axes",
"G-code Widget": "G-code Widget",
"This widget shows the current status of G-code commands.": "This widget shows the current status of G-code commands.",
"Laser Widget": "Laser Widget",
"This widget allows you control laser intensity and turn the laser on/off.": "This widget allows you control laser intensity and turn the laser on/off.",
"Macro Widget": "Macro Widget",
"This widget can use macros to automate routine tasks.": "This widget can use macros to automate routine tasks.",
"Probe Widget": "Probe Widget",
"This widget helps you use a touch plate to set your Z zero offset.": "This widget helps you use a touch plate to set your Z zero offset.",
"Spindle Widget": "Spindle Widget",
"This widget provides the spindle control.": "This widget provides the spindle control.",
"Custom Widget": "Custom Widget",
"This widget gives you a communication interface for creating your own widget.": "This widget gives you a communication interface for creating your own widget.",
"Webcam Widget": "Webcam Widget",
"This widget lets you monitor a webcam.": "This widget lets you monitor a webcam.",
"Widgets": "Widgets",
"Error": "Error",
"M0 Program Pause": "M0 Program Pause",
"M1 Program Pause": "M1 Program Pause",
"M2 Program End": "M2 Program End",
"M30 Program End": "M30 Program End",
"M6 Tool Change": "M6 Tool Change",
"M109 Set Extruder Temperature": "M109 Set Extruder Temperature",
"M190 Set Heated Bed Temperature": "M190 Set Heated Bed Temperature",
"Drop G-code file here": "Drop G-code file here",
"Corrupted workspace settings": "Corrupted workspace settings",
"The workspace settings have become corrupted or invalid. Click Restore Defaults to restore default settings and continue.": "The workspace settings have become corrupted or invalid. Click Restore Defaults to restore default settings and continue.",
"Download workspace settings": "Download workspace settings",
"Restore Defaults": "Restore Defaults",
"This field is required.": "This field is required.",
"Passwords should be equal.": "Passwords should be equal.",
"Not connected to a device": "Not connected to a device",
"Connected to {{-port}} with a baud rate of {{baudrate}}": "Connected to {{-port}} with a baud rate of {{baudrate}}",
"Console": "Console",
"Jog Control": "Jog Control",
"mm": "mm",
"Location": "Location",
"Axes": "Axes",
"X-axis": "X-axis",
"Y-axis": "Y-axis",
"Z-axis": "Z-axis",
"A-axis": "A-axis",
"B-axis": "B-axis",
"C-axis": "C-axis",
"Custom Jog Distance (mm)": "Custom Jog Distance (mm)",
"Add": "Add",
"Custom Jog Distance (inches)": "Custom Jog Distance (inches)",
"JogControl Settings": "JogControl Settings",
"General": "General",
"Custom Commands": "Custom Commands",
"ShuttleXpress": "ShuttleXpress",
"New": "New",
"Name": "Name",
"Command": "Command",
"Button Width": "Button Width",
"An unexpected error has occurred.": "An unexpected error has occurred.",
"Loading...": "Loading...",
"No data to display": "No data to display",
"Order": "Order",
"Move Up": "Move Up",
"Move Down": "Move Down",
"and more...": "and more...",
"Action": "Action",
"Update": "Update",
"Remove": "Remove",
"Feed Rate Range: {{min}} - {{max}} mm/min": "Feed Rate Range: {{min}} - {{max}} mm/min",
"Repeat Rate: {{hertz}}Hz": "Repeat Rate: {{hertz}}Hz",
"60 Times per Second": "60 Times per Second",
"45 Times per Second": "45 Times per Second",
"30 Times per Second": "30 Times per Second",
"15 Times per Second": "15 Times per Second",
"10 Times per Second": "10 Times per Second",
"5 Times per Second": "5 Times per Second",
"2 Times per Second": "2 Times per Second",
"Once Every Second": "Once Every Second",
"Distance Overshoot: {{overshoot}}x": "Distance Overshoot: {{overshoot}}x",
"Macro Name": "Macro Name",
"Macro Commands": "Macro Commands",
"Macro Variables": "Macro Variables",
"Add New Macro": "Add New Macro",
"Delete": "Delete",
"Macro": "Macro",
"New Macro": "New Macro",
"Expand": "Expand",
"Collapse": "Collapse",
"More": "More",
"Enter Full Screen": "Enter Full Screen",
"Exit Full Screen": "Exit Full Screen",
"Run Macro": "Run Macro",
"Error opening port '{{- port}}'": "Error opening port '{{- port}}'",
"Probe": "Probe",
"Top": "Top",
"Right": "Right",
"Front": "Front",
"3D": "3D",
"Left": "Left",
"File folder": "File folder",
"{{extname}} File": "{{extname}} File",
"File": "File",
"Rendering": "Rendering",
"Watch Directory": "Watch Directory",
"Date modified": "Date modified",
"Type": "Type",
"Size": "Size",
"Load G-code": "Load G-code",
"Load File": "Load File",
"Outline": "Outline",
"Verify Job": "Verify Job"
}
63 changes: 51 additions & 12 deletions src/app/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
*/

import axios, { InternalAxiosRequestConfig, AxiosResponse } from "axios";
import { MachineProfile } from "../definitions/interfaces/general";
import { USER_DATA_COLLECTION_T } from "../definitions/types";

// import store from "../store";

Expand Down Expand Up @@ -106,7 +108,7 @@ const getShouldInstallUpdates = (): Promise<AxiosResponse> => {
//
// State
//
const getState = (options: StateOptions): Promise<AxiosResponse> => {
const getState = (options?: StateOptions): Promise<AxiosResponse> => {
const { key } = { ...options };
return authrequest.get("/api/state", { params: { key } });
};
Expand All @@ -129,7 +131,7 @@ const loadGCode = (options: GCodeOptions): Promise<AxiosResponse> => {
return authrequest.post("/api/gcode", { port, name, gcode, context });
};

const fetchGCode = (options: GCodeOptions): Promise<AxiosResponse> => {
const fetchGCode = (options?: GCodeOptions): Promise<AxiosResponse> => {
const { port = "" } = { ...options };
return authrequest.get("/api/gcode", { params: { port } });
};
Expand Down Expand Up @@ -187,7 +189,7 @@ const watch = {
// Users
//
const users = {
fetch: (options: FetchOptions): Promise<AxiosResponse> => {
fetch: (options?: FetchOptions): Promise<AxiosResponse> => {
return authrequest.get("/api/users", { params: options });
},

Expand Down Expand Up @@ -215,7 +217,7 @@ const users = {
// ToolChange
//
const events = {
fetch: (options: FetchOptions): Promise<AxiosResponse> => {
fetch: (options?: FetchOptions): Promise<AxiosResponse> => {
return authrequest.get("/api/events", { params: options });
},

Expand Down Expand Up @@ -247,7 +249,7 @@ const events = {
// Headless Mode / Remote Mode
//
const remoteSetting = {
fetch: (options: FetchOptions): Promise<AxiosResponse> => {
fetch: (options?: FetchOptions): Promise<AxiosResponse> => {
return authrequest.get("/api/remote", { params: options });
},

Expand All @@ -260,7 +262,7 @@ const remoteSetting = {
// Job Stats
//
const jobStats = {
fetch: (options: FetchOptions): Promise<AxiosResponse> => {
fetch: (options?: FetchOptions): Promise<AxiosResponse> => {
return authrequest.get("/api/jobstats", { params: options });
},

Expand All @@ -273,7 +275,7 @@ const jobStats = {
// Maintenance
//
const maintenance = {
fetch: (options: FetchOptions): Promise<AxiosResponse> => {
fetch: (options?: FetchOptions): Promise<AxiosResponse> => {
return authrequest.get("/api/maintenance", { params: options });
},

Expand All @@ -286,7 +288,7 @@ const maintenance = {
// Macros
//
const macros = {
fetch: (options: FetchOptions): Promise<AxiosResponse> => {
fetch: (options?: FetchOptions): Promise<AxiosResponse> => {
return authrequest.get("/api/macros", { params: options });
},

Expand Down Expand Up @@ -314,7 +316,7 @@ const macros = {
// MDI
//
const mdi = {
fetch: (options: FetchOptions): Promise<AxiosResponse> => {
fetch: (options?: FetchOptions): Promise<AxiosResponse> => {
return authrequest.get("/api/mdi", { params: options });
},

Expand Down Expand Up @@ -342,7 +344,7 @@ const mdi = {
// Commands
//
const commands = {
fetch: (options: FetchOptions): Promise<AxiosResponse> => {
fetch: (options?: FetchOptions): Promise<AxiosResponse> => {
return authrequest.get("/api/commands", { params: options });
},

Expand Down Expand Up @@ -370,7 +372,7 @@ const commands = {
// Machines
//
const machines = {
fetch: (options: FetchOptions): Promise<AxiosResponse> => {
fetch: (options?: FetchOptions): Promise<AxiosResponse> => {
return authrequest.get("/api/machines", { params: options });
},

Expand Down Expand Up @@ -403,7 +405,42 @@ const file = {
},
};

export {
//
// Metrics
//
const metrics = {
sendData: (machineProfile: MachineProfile): Promise<AxiosResponse> => {
return authrequest.post('/api/metrics/sendData', machineProfile);
},
getCollectDataStatus: (options?: FetchOptions): Promise<AxiosResponse> => {
return authrequest.get('/api/metrics/collectUserData', { params: options });
},
toggleCollectDataStatus: (options: USER_DATA_COLLECTION_T): Promise<AxiosResponse> => {
return authrequest.post('/api/metrics/collectUserData', options);
},
sendUsageData: (options: Record<string, any>): Promise<AxiosResponse> => {
return authrequest.post('/api/metrics/sendUsageData', options);
},
};

//
// AlarmList
//
const alarmList = {
fetch: (options?: FetchOptions): Promise<AxiosResponse> => {
return authrequest.get("/api/alarmList", { params: options });
},
update: (
options: Record<string, any>
): Promise<AxiosResponse> => {
return authrequest.put("/api/alarmList/", options);
},
clearAll: (): Promise<AxiosResponse> => {
return authrequest.delete("/api/alarmList");
},
};

export default {
signin,
getLatestVersion,
getShouldInstallUpdates,
Expand All @@ -425,4 +462,6 @@ export {
commands,
machines,
file,
metrics,
alarmList
};
Loading

0 comments on commit 4b27fde

Please sign in to comment.