Skip to content
This repository has been archived by the owner on Aug 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #42 from leaphy-robotics/development
Browse files Browse the repository at this point in the history
bug and enhancement: wrong code; device information
  • Loading branch information
koen1711 authored Sep 23, 2023
2 parents cdc693d + 251148c commit dc006cc
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 20 deletions.
5 changes: 0 additions & 5 deletions src/app/effects/backend.wired.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,9 @@ export class BackendWiredEffects {
width: '450px', disableClose: true,
data: {source_code: source_code, libraries: libraries, board: board}
}).afterClosed().subscribe((result) => {
console.log(result);
if (result) {
if (result == "HELP_ENVIRONMENT") {
const langcode = this.appState.getCurrentLanguageCode();
console.log(langcode);
this.router.navigateByUrl('/' + langcode + '/driverissues', { skipLocationChange: true });
}
}
Expand Down Expand Up @@ -326,8 +324,6 @@ export class BackendWiredEffects {
const workspaceTemp = sessionStorage.getItem('workspace');
const robotType = sessionStorage.getItem('robotType');
const type = sessionStorage.getItem('type');
console.log(type);
console.log(this.appState.getCurrentEditor());
if (type == 'beginner' && this.appState.getCurrentEditor() == CodeEditorType.Beginner) {
if (robotType != this.appState.getSelectedRobotType().id) {
return;
Expand All @@ -342,7 +338,6 @@ export class BackendWiredEffects {
} else if (type == 'advanced' && this.appState.getCurrentEditor() == CodeEditorType.Advanced) {
try {
args[1].session.setValue(workspaceTemp);
console.log(workspaceTemp);
this.codeEditorState.setOriginalCode(workspaceTemp);
this.codeEditorState.setCode(workspaceTemp);
} catch (error) {
Expand Down
5 changes: 3 additions & 2 deletions src/app/effects/blockly-editor.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ export class BlocklyEditorEffects {
Blockly.Xml.domToWorkspace(xml, workspace);
this.blocklyState.setWorkspace(workspace);
this.blocklyState.setToolboxXml(toolboxXmlString);
this.backEndWiredEffects.send('restore-workspace-temp', robotType.id);
if (this.blocklyState.workspaceStatus == WorkspaceStatus.Clean) {
this.backEndWiredEffects.send('restore-workspace-temp', robotType.id);
}
toolbox.selectItemByPosition(0);
toolbox.refreshTheme();

Expand Down Expand Up @@ -251,7 +253,6 @@ export class BlocklyEditorEffects {
this.blocklyState.setWorkspaceStatus(WorkspaceStatus.Clean);
break;
case 'WORKSPACE_RESTORING':
console.log('WORKSPACE_RESTORING');
if (message.payload.type == 'advanced') {
this.blocklyState.setCode(message.payload.data as string);
this.appState.setSelectedCodeEditor(CodeEditorType.Advanced);
Expand Down
15 changes: 9 additions & 6 deletions src/app/effects/code-editor.effects.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Injectable } from "@angular/core";
import { filter, withLatestFrom } from "rxjs/operators";
import { BlocklyEditorState } from "../state/blockly-editor.state";
import { CodeEditorState } from "../state/code-editor.state";
import {Injectable} from "@angular/core";
import {filter, withLatestFrom} from "rxjs/operators";
import {BlocklyEditorState} from "../state/blockly-editor.state";
import {CodeEditorState} from "../state/code-editor.state";

import * as ace from "ace-builds";
import { BackEndState } from "../state/backend.state";
import {BackEndState} from "../state/backend.state";
import {BackendWiredEffects} from "./backend.wired.effects";
import {WorkspaceStatus} from "../domain/workspace.status";

@Injectable({
providedIn: 'root',
Expand Down Expand Up @@ -40,7 +41,9 @@ export class CodeEditorEffects {
this.codeEditorState.setOriginalCode(startingCode);
this.codeEditorState.setCode(startingCode);

this.backEndWiredEffects.send('restore-workspace-temp', -1, aceEditor);
if (this.blocklyState.workspaceStatus == WorkspaceStatus.Clean) {
this.backEndWiredEffects.send('restore-workspace-temp', -1, aceEditor);
}

aceEditor.on("change", () => {
const changedCode = aceEditor.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {Component} from '@angular/core';
import {AppState} from 'src/app/state/app.state';
import {RobotType} from 'src/app/domain/robot.type';
import {CodeEditorType} from "../../../../domain/code-editor.type";
import {BackendWiredEffects} from "../../../../effects/backend.wired.effects";

@Component({
selector: 'app-robot-selection',
Expand All @@ -14,7 +13,6 @@ export class RobotSelectionComponent {
constructor(public appState: AppState) { }
public onRobotSelected(robot: RobotType) {
this.appState.setSelectedRobotType(robot);
console.log(robot);
if (robot.id === 'l_code') {
this.appState.setSelectedCodeEditor(CodeEditorType.Advanced)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,16 @@
<div class="upload-log-data">{{item}}</div>
</div>
</div>

<div id="device-information">
{{ "DEVICE_INFORMATION" | translate}}
</div>
<div class="device-information">
<div class="operating-system device-specification">Platform: {{os}}</div>
<div class="browser device-specification">Browser: {{browser}}</div>
<div class="version-browser device-specification">Version {{browserVersion}}</div>
<div *ngIf="serialPort" class="serial-device device-specification">Serial Port; Device ID: {{serialPort?.getInfo().usbProductId}}; USB Vendor ID: {{serialPort?.getInfo().usbVendorId}}</div>
<div class="supported-vendors device-specification">Supported Vendor IDs: 6790, 9025, 2341, 1027</div>
<div class="web-serial-supported device-specification">Web Serial Supported: {{webSerialSupported}}</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
background-color: lightgray;
}

.device-information {
width: 100%;
height: fit-content;
margin: 0;
background-color: lightgray;
}

#header:hover {
cursor: grab;
}
Expand All @@ -45,3 +52,13 @@
padding-left: 10px;
width: 100%;
}

#device-information {
background-color: var(--leaphy-color-primary);
color: var(--leaphy-color-light);
display: flex;
justify-content: space-between;
align-items: center;
padding-left: 10px;
width: 100%;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Component} from '@angular/core';
import {MatDialogRef} from '@angular/material/dialog';
import {RobotWiredState} from "../../../../state/robot.wired.state";
import {TranslateService} from "@ngx-translate/core";

@Component({
selector: 'debug-information',
Expand All @@ -9,11 +10,30 @@ import {RobotWiredState} from "../../../../state/robot.wired.state";
})
export class DebugInformationDialog {

public os: string = '';
public browser: string = '';
public browserVersion: string = '';
public serialPort: SerialPort | undefined;
public webSerialSupported: string = 'Supported';


constructor(
public dialogRef: MatDialogRef<DebugInformationDialog>,
public robotWiredState: RobotWiredState,
private translate: TranslateService,
) {

// @ts-ignore
this.os = navigator.userAgentData?.platform ?? translate.instant("UNKNOWN");
// @ts-ignore
this.browser = navigator.userAgentData?.brands[0].brand ?? translate.instant("UNKNOWN");
// @ts-ignore
this.browserVersion = navigator.userAgentData?.brands[0].version ?? translate.instant("UNKNOWN");
this.serialPort = this.robotWiredState.getSerialPort();
if (!('serial' in navigator)) {
this.webSerialSupported = translate.instant("WEB_SERIAL_NOT_SUPPORTED");
} else {
this.webSerialSupported = translate.instant("WEB_SERIAL_SUPPORTED");
}
}

public onCloseClicked() {
Expand Down
2 changes: 0 additions & 2 deletions src/app/modules/core/dialogs/name-file/name-file.dialog.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Component } from '@angular/core';
import { MatDialogRef } from '@angular/material/dialog';
import { Language } from 'src/app/domain/language';
import { AppState } from 'src/app/state/app.state';

@Component({
Expand All @@ -15,7 +14,6 @@ export class NameFileDialog {
) { }

public onNameSelected(name: string) {
console.log(name);
this.dialogRef.close(name);
}

Expand Down
4 changes: 4 additions & 0 deletions src/app/state/blockly-editor.state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,8 @@ export class BlocklyEditorState {
get workspace(): any {
return this.workspaceSubject$.getValue();
}

get workspaceStatus(): WorkspaceStatus {
return this.workspaceStatusSubject$.getValue();
}
}
6 changes: 5 additions & 1 deletion src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,9 @@
"GO_BACK_TO_BLOCKS": "Go back to blocks",
"NO_SERIAL_SUPPORT": "No web serial supported on your browser, look at the upload issue page for more information",
"CHOOSE_ROBOT": "Choose a robot",
"UPLOAD_OUTPUT": "Upload output"
"UPLOAD_OUTPUT": "Upload output",
"WEB_SERIAL_NOT_SUPPORTED": "Web serial not supported",
"WEB_SERIAL_SUPPORTED": "Web serial supported",
"UNKNOWN": "Unknown",
"DEVICE_INFORMATION": "Device information"
}
6 changes: 5 additions & 1 deletion src/assets/i18n/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,9 @@
"GO_BACK_TO_BLOCKS": "Ga terug naar blokken",
"NO_SERIAL_SUPPORT": "Geen seriële verbinding mogelijk vanwege de browser, kijk naar de upload hulp voor meer informatie",
"CHOOSE_ROBOT": "Kies een robot",
"UPLOAD_OUTPUT": "Upload output"
"UPLOAD_OUTPUT": "Upload output",
"WEB_SERIAL_NOT_SUPPORTED": "Web serial wordt niet ondersteund",
"WEB_SERIAL_SUPPORTED": "Web serial wordt ondersteund",
"UNKNOWN": "Niet gevonden",
"DEVICE_INFORMATION": "Apparaat informatie"
}

0 comments on commit dc006cc

Please sign in to comment.