mirror of
https://gitlab.com/ryzen-controller-team/ryzen-controller.git
synced 2024-12-21 17:43:29 +07:00
fix: Better status scene, now displaying error messages.
This commit is contained in:
parent
f8721ad229
commit
06c9d0d7c6
@ -230,9 +230,9 @@ export const ryzenAdjProcess = function(parameters: Array<string>): Promise<stri
|
||||
console.log(`${executablePath} ${parameters.join(" ")}`);
|
||||
|
||||
child(executablePath, parameters, function(err: string, data: Buffer) {
|
||||
var output = data?.toString();
|
||||
const output = data?.toString();
|
||||
if (err) {
|
||||
rej(err);
|
||||
rej({ error: err, output });
|
||||
} else if (output) {
|
||||
res(output);
|
||||
}
|
||||
|
@ -126,5 +126,7 @@
|
||||
"statusScene.showRawData": "Rohdaten anzeigen",
|
||||
"statusScene.tableParameter": "Parameter",
|
||||
"statusScene.tableValue": "Aktueller Wert",
|
||||
"statusScene.tableMaxValue": "Max. Wert"
|
||||
"statusScene.tableMaxValue": "Max. Wert",
|
||||
"statusScene.failed": "Fehler beim Laden der Daten von rjzenadj. Bitte prüfe die Einstellungen",
|
||||
"statusScene.permissions": "Fehler beim Datenzugriff. Stelle sicher, dass Ryzen Controller als Administrator ausgeführt wird"
|
||||
}
|
||||
|
@ -126,5 +126,7 @@
|
||||
"statusScene.showRawData": "Show raw data",
|
||||
"statusScene.tableParameter": "Parameter",
|
||||
"statusScene.tableValue": "Current value",
|
||||
"statusScene.tableMaxValue": "Max. value"
|
||||
"statusScene.tableMaxValue": "Max. value",
|
||||
"statusScene.failed": "Failed to fetch data from ryzenadj. Please check your settings",
|
||||
"statusScene.permissions": "Error accessing data. Make sure Ryzen Controller is running as Administrator"
|
||||
}
|
||||
|
@ -6,8 +6,19 @@ import LightModeContext from "../contexts/LightModeContext";
|
||||
import { appContextSettingsKey, RyzenControllerSettingsDefinitions } from "../contexts/RyzenControllerAppContext";
|
||||
const electronSettings = window.require("electron-settings");
|
||||
|
||||
enum State {
|
||||
Init,
|
||||
Valid,
|
||||
PermissionError,
|
||||
GernericError,
|
||||
}
|
||||
const i18n = {
|
||||
noData: getTranslation("statusScene.noData", "No data to show"),
|
||||
failed: getTranslation("statusScene.failed", "Failed to fetch data from ryzenadj. Please check your settings"),
|
||||
permissions: getTranslation(
|
||||
"statusScene.permissions",
|
||||
"Error accessing data. Make sure Ryzen Controller is running as Administrator"
|
||||
),
|
||||
thmValueCore: getTranslation("statusScene.thmValueCore", "Core Temperature"),
|
||||
pptValueApu: getTranslation("statusScene.pptValueApu", "Package Power Consumption"),
|
||||
showRawData: getTranslation("statusScene.showRawData", "Show raw data"),
|
||||
@ -18,12 +29,25 @@ const i18n = {
|
||||
|
||||
class PresetsScene extends React.Component {
|
||||
_isMounted = false;
|
||||
_state = State.Init;
|
||||
data: { [key: string]: number } = {};
|
||||
allData = false;
|
||||
__constructor() {}
|
||||
async loadData() {
|
||||
try {
|
||||
this.parseData(await ryzenAdjProcess(["-i"]));
|
||||
} catch (e) {
|
||||
console.warn(e.output);
|
||||
if (e.output.includes("check permission")) {
|
||||
this._state = State.PermissionError;
|
||||
} else {
|
||||
this._state = State.GernericError;
|
||||
}
|
||||
}
|
||||
}
|
||||
async componentDidMount() {
|
||||
this._isMounted = true;
|
||||
this.parseData(await ryzenAdjProcess(["-i"]));
|
||||
this.loadData();
|
||||
let intervalDuration =
|
||||
electronSettings.get(appContextSettingsKey)?.settings.statusUpdateInterval ||
|
||||
RyzenControllerSettingsDefinitions["statusUpdateInterval"].default;
|
||||
@ -33,10 +57,15 @@ class PresetsScene extends React.Component {
|
||||
clearInterval(interval);
|
||||
return;
|
||||
}
|
||||
this.parseData(await ryzenAdjProcess(["-i"]));
|
||||
this.loadData();
|
||||
}, intervalDuration as number);
|
||||
}
|
||||
parseData(output: string) {
|
||||
if (!output && this._state !== State.Valid) {
|
||||
this._state = State.GernericError;
|
||||
return;
|
||||
}
|
||||
console.warn(output);
|
||||
output
|
||||
.split("\n")
|
||||
.slice(2)
|
||||
@ -60,8 +89,14 @@ class PresetsScene extends React.Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this._state === State.GernericError) {
|
||||
return <h2 className="uk-flex uk-flex-center uk-text-center">{i18n.failed}</h2>;
|
||||
}
|
||||
if (this._state === State.PermissionError) {
|
||||
return <h2 className="uk-flex uk-flex-center uk-text-center">{i18n.permissions}</h2>;
|
||||
}
|
||||
if (Object.keys(this.data).length === 0) {
|
||||
return <h2 className="uk-flex uk-flex-center">{i18n.noData}</h2>;
|
||||
return <h2 className="uk-flex uk-flex-center uk-text-center">{i18n.noData}</h2>;
|
||||
}
|
||||
return (
|
||||
<LightModeContext.Consumer>
|
||||
|
Loading…
Reference in New Issue
Block a user