Skip to content

Commit

Permalink
added missing binary error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
death7654 committed Oct 12, 2024
1 parent 9c34540 commit c352f30
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/app/custom-fan/fan-curves/fan-curves.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
</select>
</div>
<button
class="btn btn-outline-secondary btn-outline-none fs-4"
class="btn btn-outline-secondary border-0 fs-4"
(click)="save()"
>
Save
</button>
<button
class="btn btn-outline-secondary btn-outline-none fs-4"
class="btn btn-outline-secondary border-0 fs-4"
(click)="saveAndApply()"
>
Save and Apply
Expand Down
18 changes: 9 additions & 9 deletions src/app/diagnostics/diagnostics.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@ <h4 class="fs-3">Diagnostics</h4>
<option value="Coreboot Extended Log" [disabled]="disabled">
Coreboot Extended Log
</option>
<option value="Battery Information">Battery Information</option>
<option value="EC Console Log">EC Console Log</option>
<option value="EC Chip Information">EC Chip Information</option>
<option value="SPI Information">SPI Information</option>
<option value="EC Protocol Information">EC Protocol Information</option>
<option value="Temperature Sensor Information">
<option value="Battery Information" [disabled]="ectools">Battery Information</option>
<option value="EC Console Log" [disabled]="ectools">EC Console Log</option>
<option value="EC Chip Information" [disabled]="ectools">EC Chip Information</option>
<option value="SPI Information" [disabled]="ectools">SPI Information</option>
<option value="EC Protocol Information" [disabled]="ectools">EC Protocol Information</option>
<option value="Temperature Sensor Information" [disabled]="ectools">
Temperature Sensor Information
</option>
<option value="Power Delivery Information">
<option value="Power Delivery Information" [disabled]="ectools">
Power Delivery Information
</option>
</select>
<div class="pt-2">
<button class="btn btn-outline-secondary fs-4 btn-border-none w-100 h-100" (click)="select()">
<button class="btn btn-outline-secondary fs-4 border-0 w-100 h-100" (click)="select()">
Generate Report
</button>
</div>
<div class="pt-2">
<button class="btn btn-outline-secondary fs-4 btn-border-none w-100 h-100" (click)="save()">
<button class="btn btn-outline-secondary fs-4 border-0 w-100 h-100" (click)="save()">
Save to Files
</button>
</div>
Expand Down
46 changes: 39 additions & 7 deletions src/app/diagnostics/diagnostics.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,60 @@ import { invoke } from "@tauri-apps/api/core";
standalone: true,
imports: [],
templateUrl: "./diagnostics.component.html",
styleUrl: "./diagnostics.component.scss",
styleUrl: "./diagnostics.component.scss"
})
export class DiagnosticsComponent implements OnInit {
collected_info: string = "";
selected_function: string = "";
disabled: boolean = false;
ectools: boolean = false;

ngOnInit() {
invoke("os").then((os) => {
invoke("os").then(os => {
if (os == "macOS") {
this.disabled = true;
}
});
invoke("execute", {
program: "ectool",
arguments: ["hello"],
reply: true
}).then((event: any) => {
let output = event.toLowerCase().trim();
console.log(output);
if (output !== "ec says hello!") {
this.ectools = true;
this.collected_info = "You are missing the ECTOOL Binary";
}
});

invoke("execute", {
program: "cbmem",
arguments: ["-v"],
reply: true
}).then((event: any) => {
let output = event
.toLowerCase()
.trim()
.split(" ");
if (output[0] !== "cbmem") {
this.disabled = true;
if (this.ectools == true) {
this.collected_info = "You are missing ECTOOL and CBMEM Binaries";
} else {
this.collected_info = "You are missing the CBMEM Binary";
}
}
});
}

async select() {
this.selected_function = (
document.getElementById("diagnostic_dropdown") as HTMLInputElement
).value;
this.selected_function = (document.getElementById(
"diagnostic_dropdown"
) as HTMLInputElement).value;
if (this.selected_function !== "Select") {
this.collected_info = await invoke("diagnostics", {
selected: this.selected_function,
selected: this.selected_function
});
}
}
Expand All @@ -39,7 +71,7 @@ export class DiagnosticsComponent implements OnInit {
save() {
invoke("save", {
filename: this.selected_function,
content: this.collected_info,
content: this.collected_info
});
}
}
2 changes: 2 additions & 0 deletions src/app/home/home.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
<app-keyboard-section></app-keyboard-section>
<app-activity-light-section></app-activity-light-section>
<app-extra-section></app-extra-section>

<div class="noectools text-center rounded-3" [class]="class"><span>ECTOOL BINARY NOT FOUND</span></div>
14 changes: 14 additions & 0 deletions src/app/home/home.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.noectools{
z-index: 10;
background-color: #837685;
height: 25px;
width: 90%;
position: absolute;
top: 75px;
left: 20px;
}

.displaynone
{
display: none;
}
25 changes: 24 additions & 1 deletion src/app/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FanSectionComponent } from "./fan-section/fan-section.component";
import { KeyboardSectionComponent } from "./keyboard-section/keyboard-section.component";
import { ActivityLightSectionComponent } from "./activity-light-section/activity-light-section.component";
import { ExtraSectionComponent } from "./extra-section/extra-section.component";
import { invoke } from "@tauri-apps/api/core";

@Component({
selector: "app-home",
Expand All @@ -16,4 +17,26 @@ import { ExtraSectionComponent } from "./extra-section/extra-section.component";
templateUrl: "./home.component.html",
styleUrl: "./home.component.scss",
})
export class HomeComponent {}
export class HomeComponent {

class: string = " "

ngOnInit()
{
setTimeout(() => {
invoke("execute", {
program: "ectool",
arguments: ["hello"],
reply: true,
}).then((event: any) =>
{
let output = event.toLowerCase().trim();
if (output == "ec says hello!")
{
this.class = "displaynone"
}
});
})
}

}

0 comments on commit c352f30

Please sign in to comment.