Skip to content

Commit

Permalink
Added import / export config opts in dropdown, fixed autoupdate, fixe…
Browse files Browse the repository at this point in the history
…d plans, updated readme.
  • Loading branch information
aredden committed Dec 18, 2020
1 parent da0c0de commit f919229
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 41 deletions.
34 changes: 11 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
- Displays most related (ASUS / AMD / NVIDIA / Realtek / Dolby) software.
- Displays the current G14ControlV2 configuration.

### **Plans page:**

- Allows you to create full plans which include CPU Tuning, Fan Curve, Armoury Crate profile, Windows power plans, Switchable Dynamic Graphics settings, and processor performance boost which you can enable with a single click.
- Plan builder with select dropdowns to choose between profiles for each category.

### **Fan Curve page:**

- Allows you to choose a manual fan curve using two graphs for CPU / GPU which you can save or apply.
Expand Down Expand Up @@ -57,6 +62,7 @@

- Option to open the location where logs are stored so you can send them to me if you experience issues! : )
- Option to have the app start on boot using task scheduler to avoid UAC.
- Option to import / export configuration so you don't lose your configurations between updates.
</ul>

If you like the app, and would like to support me, [donate](https://www.paypal.com/pools/c/8uiaar8Sl9) : ) <3
Expand All @@ -68,10 +74,11 @@ Be aware that **I have no idea what I'm doing**. All of this stuff works for me,
## Prerequisites for Development

Getting Node, Python, and Visual Studio setup:
* Install Nodejs 14 for Windows: https://nodejs.org/en/
* Verify installed correctly through command prompt `node -v` and `npm -v`
* Install Python from the Windows Store: https://www.microsoft.com/en-us/p/python-39/9p7qfqmjrfp7
* Run an elevated (as administrator) command prompt, and run: `npm install --global windows-build-tools`

- Install Nodejs 14 for Windows: https://nodejs.org/en/
- Verify installed correctly through command prompt `node -v` and `npm -v`
- Install Python from the Windows Store: https://www.microsoft.com/en-us/p/python-39/9p7qfqmjrfp7
- Run an elevated (as administrator) command prompt, and run: `npm install --global windows-build-tools`

File setup:

Expand Down Expand Up @@ -108,30 +115,11 @@ Pull requests are welcome. For major changes, please open an issue first to disc

This is just a starting list. I'm sure there is much more to do.

- ~~Functionality for the electron tray icon similar to the original in G14ControlR3, but initially without G14Control preset plans.~~
- ~~Main window styling and suggestions.~~
- ~~Allow user to choose temperature polling time. \*_In progess_\*
- ~~Improved code commenting.~~
- ~~FanCurve page front end logic -- the ipcRenderer listener functions under /electron are already built.~~
- ~~Atrofac command building.~~
- ~~Integrating interactive draggable graph nodes on front end for building fan curve.~~
- ~~Persistent storage of commonly used fan curves that can be saved / edited / loaded from a configuration file.~~
- ~~Command validation.~~
- ~~Persistent storage for configuration and runtime events.~~
- ~~config.json file for configuration loaded into electron process & sent to react renderer process.~~
- ~~Saving / Editing / Adding configurations during runtime. ~~
- ~~Give all components the ability to modify redux as necessary.~~
- ~~Ability for users to create new, remove, edit configuration options using the implemented redux store. (Fan curve profiles / atrofac profiles / loop speeds /armory crate plans~~)
- ~~Status page design and relevent data to show.~~
- ~~Collect data from WMI & Windows PerformanceCounters such as BIOS version, ram, names of hardware vendors, important software versions, etc...~~
- Add settings page for more options such as "exit on window close" vs "run as icon app on window close", etc.
- Header main page ~~custom exit and minimize buttons~~, as well as possible dropdown menu (could use this as a 'settings page')
- Low level hardware monitoring \*_In progress_\*
- Bug fixing. \*_In progress_\*
...

- Eventually add G14Control plans configuration.

## License

[MIT](https://github.com/aredden/electron-G14Control/blob/main/LICENSE)
Expand Down
33 changes: 19 additions & 14 deletions electron/src/AppUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { BrowserWindow, IpcMain } from 'electron';
import { autoUpdater, AppUpdater, UpdateInfo } from 'electron-updater';
import getLogger from './Logger';

import is_dev from 'electron-is-dev';
interface Updater {}

const LOGGER = getLogger('AppUpdater');
Expand Down Expand Up @@ -35,19 +35,24 @@ export default class AutoUpdater<Updater> {
checkForUpdate = async () => {
LOGGER.info('Checking for update.');
let { updater } = this.state;
updater
.checkForUpdatesAndNotify({
title: 'G14ControlV2',
body: 'New update available!',
})
.then((r) => {
this.state.updateAvailable = true;
this.state.version = r.updateInfo.version;
this.state.updateInfo = r.updateInfo;
LOGGER.info(
`Got update info:\n${JSON.stringify(r.updateInfo, null, 2)}`
);
});
if (!is_dev)
updater
.checkForUpdatesAndNotify({
title: 'G14ControlV2',
body: 'New update available!',
})
.then((r) => {
if (r) {
this.state.version = r.updateInfo.version;
this.state.updateAvailable = true;
this.state.updateInfo = r.updateInfo;
LOGGER.info(
`Got update info:\n${JSON.stringify(r.updateInfo, null, 2)}`
);
} else {
LOGGER.info('Current update info: ' + JSON.stringify(r, null, 2));
}
});
};

getAllInfo = () => {
Expand Down
16 changes: 16 additions & 0 deletions electron/src/IPCEvents/AutoPowerSwitching.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/** @format */

import { BrowserWindow, IpcMain } from 'electron';

export type PowerSwitchArgs = {
enabled: boolean;
acPlan: string;
dcPlan: string;
};

export const buildAutoPowerSwitchingListeners = (
win: BrowserWindow,
ipc: IpcMain
) => {
ipc.handle('setAutoPowerSwitching', (evt, args: PowerSwitchArgs) => {});
};
66 changes: 64 additions & 2 deletions electron/src/IPCEvents/ConfigLoader.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/** @format */

import dotenv from 'dotenv';
import { IpcMain } from 'electron';
import { dialog, IpcMain } from 'electron';
import fs from 'fs';
import is_dev from 'electron-is-dev';
import getLogger from '../Logger';
import path from 'path';
import { app } from 'electron';
import { setG14Config } from '../electron';
import { browserWindow, getConfig, setG14Config } from '../electron';

dotenv.config();

Expand Down Expand Up @@ -83,4 +83,66 @@ export const buildConfigLoaderListeners = (ipc: IpcMain) => {
return false;
}
});

ipc.on('importConfig', () => {
dialog
.showOpenDialog({
title: 'Load Config',
defaultPath: app.getPath('home'),
properties: ['openFile'],
filters: [{ name: 'G14Config', extensions: ['datas'] }],
})
.then((val) => {
if (val.canceled) {
return;
}
if (val.filePaths) {
let path2file = val.filePaths[0];
fs.readFile(path2file, 'utf-8', (err, datas) => {
if (err) {
LOGGER.error('Error importing config file.');
} else {
LOGGER.info('Successfully read config file.');
writeConfig(JSON.parse(datas) as G14Config).then((ok) => {
if (ok) {
browserWindow.reload();
} else {
LOGGER.info('Issue writing new configuration file.');
}
});
}
});
}
});
});

ipc.on('exportConfig', () => {
dialog
.showOpenDialog({
title: 'Save Config',
defaultPath: app.getPath('home'),
properties: ['openDirectory'],
})
.then((val) => {
if (val.canceled) {
return;
}
if (val.filePaths) {
let dir = val.filePaths[0];
fs.writeFile(
path.join(dir, 'G14Config.datas'),
JSON.stringify(getConfig()),
(e) => {
if (e) {
LOGGER.error(
'Error writing config to directory: \n' + JSON.stringify(e)
);
} else {
LOGGER.info('Successfully exported config file.');
}
}
);
}
});
});
};
Loading

0 comments on commit f919229

Please sign in to comment.