Skip to content

Commit

Permalink
Replaced the old pendant and added more features to the react pendant
Browse files Browse the repository at this point in the history
  • Loading branch information
breiler committed May 12, 2024
1 parent 95415b1 commit f683953
Show file tree
Hide file tree
Showing 159 changed files with 3,729 additions and 33,639 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ public void unsetGcodeFile() throws Exception {

initGcodeParser();
this.gcodeFile = null;
this.gcodeStream = null;
this.processedGcodeFile = null;
}

Expand All @@ -378,6 +379,9 @@ private void processGcodeFile() throws Exception {

eventDispatcher.sendUGSEvent(new FileStateEvent(FileState.FILE_LOADING));
initializeProcessedLines(true, this.gcodeFile, this.gcp);
if (this.processedGcodeFile != null) {
gcodeStream = new GcodeStreamReader(this.processedGcodeFile, getCommandCreator());
}
eventDispatcher.sendUGSEvent(new FileStateEvent(FileState.FILE_LOADED));
}

Expand Down
8 changes: 3 additions & 5 deletions ugs-pendant/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
<artifactId>frontend-maven-plugin</artifactId>
<version>1.12.0</version>
<configuration>
<workingDirectory>${project.basedir}/src/main/webapp</workingDirectory>
<workingDirectory>src/main/webapp</workingDirectory>
</configuration>
<executions>
<execution>
Expand All @@ -139,10 +139,8 @@
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v16.13.2</nodeVersion>
<npmVersion>8.1.2</npmVersion>
<!--nodeVersion>v20.12.2</nodeVersion>
<npmVersion>10.5.0</npmVersion-->
<nodeVersion>v20.12.2</nodeVersion>
<npmVersion>10.5.0</npmVersion>
</configuration>
</execution>
<execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public List<PendantURLBean> start() {

contextHandlerCollection.addHandler(createResourceConfigHandler(new StaticConfig(), ""));
contextHandlerCollection.addHandler(createResourceConfigHandler(new AppV1Config(backendAPI, jogService), API_CONTEXT_PATH));
contextHandlerCollection.addHandler(createResourceConfigHandler(new StaticConfig(), "/*"));
contextHandlerCollection.addHandler(createWebSocketHandler(WEBSOCKET_CONTEXT_PATH));

try {
Expand Down Expand Up @@ -139,7 +140,7 @@ public List<PendantURLBean> getUrlList() {
String url = "http://" + hostAddress + ":" + port;
ByteArrayOutputStream bout = QRCode.from(url).to(ImageType.PNG).stream();
out.add(new PendantURLBean(url, bout.toByteArray()));
LOG.info("Listening on: " + url);
LOG.info(() -> "Listening on: " + url);
}
}
}
Expand Down Expand Up @@ -167,11 +168,9 @@ public BackendAPI getBackendAPI() {

@Override
public void UGSEvent(UGSEvent evt) {
if (evt instanceof SettingChangedEvent) {
if (backendAPI.getSettings().getPendantPort() != port && isStarted()) {
stop();
start();
}
if (evt instanceof SettingChangedEvent && (backendAPI.getSettings().getPendantPort() != port && isStarted())) {
stop();
start();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,15 @@ public Response getIndex() throws Exception {
return getStaticResource("");
}

@GET
@Path("{path:(jog|macros|run)$}")
public Response getSubPage() throws Exception {
return getStaticResource("");
}

@GET
@Path("{path:.*\\.(jpg|gif|html|js|css|ico|ttf)$}")
public Response getStaticResource(@PathParam("path") String path) throws Exception {
public Response getStaticResource(@PathParam("path") String path) {
if (path.equalsIgnoreCase("")) {
path = "index.html";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ public void onWebSocketClose(Session session) {
@OnError
public void onWebSocketError(Session session, Throwable cause) {
sessions.remove(session.getId());
LOGGER.log(Level.WARNING, "WebSocket Closed: " + session.getId(), cause);
LOGGER.log(Level.WARNING, cause, () -> "WebSocket Closed: " + session.getId());
}

@Override
public void UGSEvent(UGSEvent evt) {
try {
String data = getEventAsString(evt);
String data = getEventAsJsonString(evt);
sessions.values().forEach(session -> {
try {
session.getBasicRemote().sendText(data);
Expand All @@ -99,7 +99,7 @@ public void UGSEvent(UGSEvent evt) {
}
}

private String getEventAsString(UGSEvent evt) {
private String getEventAsJsonString(UGSEvent evt) {
if (evt instanceof ControllerStatusEvent controllerStatusEvent) {
Settings settings = BackendProvider.getBackendAPI().getSettings();
ControllerStatus currentStatus = convertToPreferredUnits(controllerStatusEvent.getStatus(), settings.getPreferredUnits());
Expand Down
11 changes: 0 additions & 11 deletions ugs-pendant/src/main/webapp/.browserslistrc

This file was deleted.

13 changes: 0 additions & 13 deletions ugs-pendant/src/main/webapp/.editorconfig

This file was deleted.

File renamed without changes.
59 changes: 20 additions & 39 deletions ugs-pendant/src/main/webapp/.gitignore
Original file line number Diff line number Diff line change
@@ -1,44 +1,25 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

# compiled output
/dist
/tmp
/out-tsc
node_modules
dist
dist-ssr
*.local

# dependencies
/node_modules

# profiling files
chrome-profiler-events.json
speed-measure-plugin.json

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
# Editor directories and files
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# System Files
.idea
.DS_Store
Thumbs.db
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
node/*
41 changes: 22 additions & 19 deletions ugs-pendant/src/main/webapp/README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
# UgsPendant
# React + TypeScript + Vite

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.2.2.
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

## Development server
Currently, two official plugins are available:

Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Code scaffolding
## Expanding the ESLint configuration

Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

## Build
- Configure the top-level `parserOptions` property like this:

Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
```js
export default {
// other rules...
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json'],
tsconfigRootDir: __dirname,
},
}
```

## Running unit tests

Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).

## Running end-to-end tests

Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).

## Further help

To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
139 changes: 0 additions & 139 deletions ugs-pendant/src/main/webapp/angular.json

This file was deleted.

Loading

0 comments on commit f683953

Please sign in to comment.