-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from NREL/issue-1
- Loading branch information
Showing
31 changed files
with
15,534 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# See http://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# Compiled output | ||
/dist | ||
/tmp | ||
/out-tsc | ||
/bazel-out | ||
/output | ||
# Node | ||
/node_modules | ||
npm-debug.log | ||
yarn-error.log | ||
|
||
# IDEs and editors | ||
.idea/ | ||
.project | ||
.classpath | ||
.c9/ | ||
*.launch | ||
.settings/ | ||
*.sublime-workspace | ||
|
||
# Visual Studio Code | ||
.vscode/* | ||
.history/* | ||
|
||
# Miscellaneous | ||
/.angular/cache | ||
.sass-cache/ | ||
/connect.lock | ||
/coverage | ||
/libpeerconnection.log | ||
testem.log | ||
/typings | ||
|
||
# System files | ||
.DS_Store | ||
Thumbs.db | ||
.editorconfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# NEB Tool | ||
|
||
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 16.2.8. | ||
|
||
## Dependencies | ||
|
||
- We are using NodeJS v 20.9 LTS [nodejs.org](https://nodejs.org/en/download) | ||
|
||
- To install all required packages: `npm install` | ||
|
||
- To install the Angular CLI which is required for tests, `npm install -g @angular/cli` | ||
|
||
- Note: If you don't want to install angular cli globally, you can install it locally using `npm install @angular/cli` and then run it using `npm run-script ng` | ||
|
||
## For Developers | ||
|
||
- When developing in electron window use `npm run build-watch` and a re-build will trigger on save of changes | ||
|
||
- To start the electron app (kill and restart app after rebuild on save): `npm run electron` | ||
|
||
- When developing for web run `npm run start` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. | ||
|
||
## Build | ||
|
||
- Built artifacts will be stored in the `/dist` directory. | ||
|
||
- General build for electron `npm run build` | ||
|
||
- Production Web Build `npm run build-prod` | ||
|
||
- Production Electron Build `npm run build-prod-electron` | ||
|
||
## Native Installers | ||
|
||
- `npm run dist` will create electron installers for your operating system | ||
|
||
- Installer will be created in an `./output/neb-tool/` directory | ||
|
||
|
||
## Running unit tests | ||
|
||
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). | ||
|
||
Karma unit tests use Google Chrome as a default browser. This will need to be installed on your machine for the tests to run. Otherwise you can check the documentation on how to target other browsers using a config file: [Karma Config](https://karma-runner.github.io/6.4/config/configuration-file.html) | ||
|
||
## Further help | ||
|
||
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
{ | ||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json", | ||
"version": 1, | ||
"newProjectRoot": "projects", | ||
"projects": { | ||
"NEB-Tool": { | ||
"projectType": "application", | ||
"schematics": {}, | ||
"root": "", | ||
"sourceRoot": "src", | ||
"prefix": "app", | ||
"architect": { | ||
"build": { | ||
"builder": "@angular-devkit/build-angular:browser", | ||
"options": { | ||
"outputPath": "dist/neb-tool", | ||
"index": "src/index.html", | ||
"main": "src/main.ts", | ||
"polyfills": [ | ||
"zone.js" | ||
], | ||
"tsConfig": "tsconfig.app.json", | ||
"assets": [ | ||
"src/favicon.ico", | ||
"src/assets" | ||
], | ||
"styles": [ | ||
"src/styles.css", | ||
"node_modules/bootstrap/dist/css/bootstrap.min.css" | ||
], | ||
"scripts": [ | ||
"node_modules/bootstrap/dist/js/bootstrap.bundle.js" | ||
] | ||
}, | ||
"configurations": { | ||
"production": { | ||
"budgets": [ | ||
{ | ||
"type": "initial", | ||
"maximumWarning": "500kb", | ||
"maximumError": "1mb" | ||
}, | ||
{ | ||
"type": "anyComponentStyle", | ||
"maximumWarning": "2kb", | ||
"maximumError": "4kb" | ||
} | ||
], | ||
"outputHashing": "all" | ||
}, | ||
"development": { | ||
"buildOptimizer": false, | ||
"optimization": false, | ||
"vendorChunk": true, | ||
"extractLicenses": false, | ||
"sourceMap": true, | ||
"namedChunks": true | ||
} | ||
}, | ||
"defaultConfiguration": "production" | ||
}, | ||
"serve": { | ||
"builder": "@angular-devkit/build-angular:dev-server", | ||
"configurations": { | ||
"production": { | ||
"browserTarget": "NEB-Tool:build:production" | ||
}, | ||
"development": { | ||
"browserTarget": "NEB-Tool:build:development" | ||
} | ||
}, | ||
"defaultConfiguration": "development" | ||
}, | ||
"extract-i18n": { | ||
"builder": "@angular-devkit/build-angular:extract-i18n", | ||
"options": { | ||
"browserTarget": "NEB-Tool:build" | ||
} | ||
}, | ||
"test": { | ||
"builder": "@angular-devkit/build-angular:karma", | ||
"options": { | ||
"polyfills": [ | ||
"zone.js", | ||
"zone.js/testing" | ||
], | ||
"tsConfig": "tsconfig.spec.json", | ||
"assets": [ | ||
"src/favicon.ico", | ||
"src/assets" | ||
], | ||
"styles": [ | ||
"src/styles.css" | ||
], | ||
"scripts": [] | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"cli": { | ||
"analytics": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
const { app, BrowserWindow, ipcMain, Menu, shell } = require('electron'); | ||
const path = require('path'); | ||
const url = require('url'); | ||
const log = require('electron-log'); | ||
const { autoUpdater } = require('electron-updater'); | ||
|
||
function isDev() { | ||
return require.main.filename.indexOf('app.asar') === -1; | ||
}; | ||
|
||
app.allowRendererProcessReuse = false | ||
// Logger for autoUpdater | ||
autoUpdater.logger = log; | ||
autoUpdater.logger.transports.file.level = 'info'; | ||
//needed for forcing update check in develop | ||
// autoUpdater.forceDevUpdateConfig = true; | ||
log.info('App starting...'); | ||
|
||
let win = null; | ||
|
||
app.on('ready', function () { | ||
// Initialize the window to our specified dimensions | ||
win = new BrowserWindow({ | ||
width: 1000, | ||
height: 600, | ||
webPreferences: { | ||
contextIsolation: true, | ||
nodeIntegration: false, | ||
preload: path.join(__dirname, 'preload.js') | ||
}, | ||
}); | ||
win.maximize(); | ||
|
||
// Specify entry point | ||
win.loadURL(url.format({ | ||
pathname: path.join(__dirname, 'dist/neb-tool/index.html'), | ||
protocol: 'file', | ||
slashes: true | ||
})); | ||
|
||
if (isDev()) { | ||
win.toggleDevTools(); | ||
} | ||
// Remove window once app is closed | ||
win.on('closed', function () { | ||
win = null; | ||
}); | ||
|
||
//signal from core.component to check for update | ||
ipcMain.on('ready', (coreCompEvent, arg) => { | ||
|
||
if (!isDev()) { | ||
autoUpdater.checkForUpdates().then(() => { | ||
log.info('done checking for updates'); | ||
if (autoUpdater.updateInfoAndProvider) { | ||
win.webContents.send('release-info', autoUpdater.updateInfoAndProvider.info); | ||
} | ||
}); | ||
autoUpdater.on('update-available', (event, info) => { | ||
log.info('update available'); | ||
win.webContents.send('available', true); | ||
}); | ||
autoUpdater.on('error', (event, error) => { | ||
log.info('error'); | ||
win.webContents.send('error', error); | ||
}); | ||
|
||
autoUpdater.on('update-downloaded', (event, info) => { | ||
autoUpdater.quitAndInstall(); | ||
win.webContents.send('update-downloaded'); | ||
}); | ||
} | ||
}) | ||
|
||
ipcMain.once('quit-and-install', (event, arg) => { | ||
autoUpdater.quitAndInstall(false); | ||
}) | ||
|
||
//Check for updates and install | ||
autoUpdater.autoDownload = false; | ||
autoUpdater.autoInstallOnAppQuit = false; | ||
|
||
var template = [{ | ||
label: "Application", | ||
submenu: [ | ||
{ label: "Quit", accelerator: "Command+Q", click: function () { app.quit(); } }, | ||
{ label: "Dev Tools", accelerator: "CmdOrCtrl+I", click: function () { win.toggleDevTools(); } } | ||
] | ||
}, { | ||
label: "Edit", | ||
submenu: [ | ||
{ label: "Undo", accelerator: "CmdOrCtrl+Z", selector: "undo:" }, | ||
{ label: "Redo", accelerator: "Shift+CmdOrCtrl+Z", selector: "redo:" }, | ||
{ type: "separator" }, | ||
{ label: "Copy", accelerator: "CmdOrCtrl+C", selector: "copy:" }, | ||
{ label: "Paste", accelerator: "CmdOrCtrl+V", selector: "paste:" }, | ||
{ label: "Select All", accelerator: "CmdOrCtrl+A", selector: "selectAll:" } | ||
] | ||
} | ||
]; | ||
|
||
Menu.setApplicationMenu(Menu.buildFromTemplate(template)); | ||
win.setMenuBarVisibility(false) | ||
|
||
win.webContents.on('new-window', function (e, url) { | ||
// make sure local urls stay in electron perimeter | ||
if ('file://' === url.substr(0, 'file://'.length)) { | ||
return; | ||
} | ||
|
||
e.preventDefault(); | ||
shell.openExternal(url); | ||
}); | ||
|
||
}); | ||
|
||
// Listen for message from application (electron component) to either download updates | ||
ipcMain.once('update', (event, arg) => { | ||
log.info('update') | ||
autoUpdater.downloadUpdate(); | ||
}); | ||
|
||
ipcMain.once('later', (event, arg) => { | ||
update = null; | ||
}); | ||
|
||
ipcMain.once('relaunch', () => { | ||
app.relaunch(); | ||
app.exit(); | ||
}); | ||
|
||
app.on('activate', () => { | ||
if (win === null) { | ||
createWindow(); | ||
} | ||
}); | ||
|
||
app.on('window-all-closed', function () { | ||
app.quit(); | ||
}); |
Oops, something went wrong.