Skip to content

Commit

Permalink
Ordenação das operações de projeto e lendo a resposta com UTF-8
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Lima committed Oct 20, 2023
1 parent b469e9d commit 00de2fe
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@

public class RuntimeExecutor implements Executor {

private static final String CHARSET = "UTF-8";

@Override
public String execute(String command, boolean mantainLineBreak) {
try {
Process process = Runtime.getRuntime().exec(command);
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream(), CHARSET))) {
String output = reader.lines().collect(Collectors.joining());
if (!mantainLineBreak) {
return output.replace(FileUtils.BREAK_LINE, "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ private synchronized String executeInRemote(String command) {
channel.connect();
byte[] tmp = new byte[1024];

String output = "";
StringBuilder output = new StringBuilder();
while (true) {
while (in.available() > 0) {
int i = in.read(tmp, 0, 1024);
if (i < 0) {
break;
}
output = output + (new String(tmp, 0, i));
output.append(new String(tmp, 0, i));
}
if (channel.isClosed()) {
if (channel.getExitStatus() != 0) {
Expand All @@ -146,7 +146,7 @@ private synchronized String executeInRemote(String command) {
}
}
channel.disconnect();
return output;
return output.toString();
} catch (Exception e) {
e.printStackTrace();
} finally {
Expand Down
12 changes: 7 additions & 5 deletions sysconfig/ui/src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@
<button class="project__options" ref="projectOptionsButton">
<Toggle type="click" parent-position>
<template v-slot:options>
<button @click="downloadProject(project)">Export</button>
<button @click="selectCreatedProject(index)">Rename</button>
<button class="severe">
Delete
<Popup is-children title="Delete project">
Expand All @@ -109,8 +111,6 @@
</template>
</Popup>
</button>
<button @click="selectCreatedProject(index)">Rename</button>
<button @click="downloadProject(project)">Export</button>
</template>
</Toggle>
</button>
Expand All @@ -119,6 +119,8 @@
ref="inputProject" spellcheck="false"/>
<Toggle type="contextmenu" click-position>
<template v-slot:options>
<button @click="downloadProject(project)">Export</button>
<button @click="selectCreatedProject(index)">Rename</button>
<button class="severe">
Delete
<Popup is-children title="Delete project">
Expand All @@ -141,8 +143,6 @@
</template>
</Popup>
</button>
<button @click="selectCreatedProject(index)">Rename</button>
<button @click="downloadProject(project)">Download</button>
</template>
</Toggle>
</div>
Expand Down Expand Up @@ -171,6 +171,8 @@ import Popup from "@/components/Popup";
import {removeRipple, useRipple} from "@/composable/Ripple";
import {Routes} from "@/router/routes";
const PROJECT_EXTESION = ".chon";
export default {
name: "Home",
components: {Header, Toggle, Button, Popup},
Expand Down Expand Up @@ -298,7 +300,7 @@ export default {
'blob'})
.then((response) => {
if (response.status === 200) {
const filename = project.name + ".json";
const filename = project.name + PROJECT_EXTESION;
const blob = new Blob([response.data]);
const url = window.URL.createObjectURL(blob);
Expand Down
12 changes: 7 additions & 5 deletions sysconfig/ui/src/views/Project/Project.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="project flex flex-col h-screen">
<Popup title="Sketch compiled" ref="boardResponse" can-close width="var(--container-width-1)">
<Popup title="Board response" ref="boardResponse" can-close width="var(--container-width-1)">
<template v-slot:content>
<div class="project__compiled-response">
{{ boardResponse }}
Expand Down Expand Up @@ -442,6 +442,7 @@ export default {
}).then((response) => {
this.boardResponse = response.data.data;
this.$refs.boardResponse.showing(true);
this.$emit(AppEvent.MESSAGE, {content: 'Sketch compiled', type: MessageType.SUCCESS});
}).finally(() => {
this.compilingSketch = false;
});
Expand All @@ -463,9 +464,10 @@ export default {
serialPort: this.currentBoard.port,
boardName: this.currentBoard.fqbn
}
}).then((response) => {
this.$refs.boardResponse.showing(true);
this.boardResponse = response.data.data;
}).then(() => {
this.$emit(AppEvent.MESSAGE, {content: 'Sketch deployed', type: MessageType.SUCCESS});
}).catch(() => {
this.$emit(AppEvent.MESSAGE, {content: 'ERROR: Sketch was not deployed', type: MessageType.ERROR});
}).finally(() => {
this.deployingSketch = false;
});
Expand Down Expand Up @@ -653,7 +655,7 @@ export default {
.project__compiled-response {
background-color: var(--pallete-color-black-3);
word-break: break-word;
@apply p-2.5 rounded-sm text-lg;
@apply p-2.5 rounded-sm text-xl;
}
.project__project-status {
Expand Down

0 comments on commit 00de2fe

Please sign in to comment.