Skip to content
Merged

Tray #22

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
## Version 0.2.0
## Version 0.2.1
---

Release highlights:

* Added copying of logs to the clipboard
* Added tray icon

---

# Copying logs to the clipboard
# Tray Icon

It is now possible to copy the entire log of a terminal to the systems clipboard. This also includes the selected text.

To copy only the selected text, first highlight the desired text then right click on the terminal.

To copy the entire log, select `Copy Log` from the drop down menu of each terminal.
It is now possible to minimize Dotnet Runner to the system tray. A tray icon has been created, when minimized clicking the icon will maximize the application.
25 changes: 25 additions & 0 deletions app/Components/runner/Runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ module.exports = class RunnerElement extends WebComponentBase {
this._runningProccess.on('data', (d) => {
this._terminalProcess.write(d);
});

this._emitEvent('starting');
}

clean() {
Expand Down Expand Up @@ -196,6 +198,8 @@ module.exports = class RunnerElement extends WebComponentBase {
this.setState(RunnerElement.states.stopping);

this._runningProccess.kill();

this._emitEvent('stopped');
}

exportLog() {
Expand Down Expand Up @@ -234,28 +238,49 @@ module.exports = class RunnerElement extends WebComponentBase {
stateEl.textContent = 'Starting';
stateEl.className = 'state badge badge-info';
actionBtn.textContent = 'Stop';
this._emitEvent('state-change', {
state: RunnerElement.states.starting
});
break;
case RunnerElement.states.running:
stateEl.textContent = 'Running';
stateEl.className = 'state badge badge-success';
actionBtn.textContent = 'Stop';
this._enableAction();
this._emitEvent('state-change', {
state: RunnerElement.states.running
});
break;
case RunnerElement.states.stopping:
stateEl.textContent = 'Stopping';
stateEl.className = 'state badge badge-info';
actionBtn.textContent = 'Start';
this._emitEvent('state-change', {
state: RunnerElement.states.stopping
});
break;
case RunnerElement.states.stopped:
stateEl.textContent = 'Stopped';
stateEl.className = 'state badge badge-secondary';
this._enableAction();
this._enableClean();
actionBtn.textContent = 'Start';
this._emitEvent('state-change', {
state: RunnerElement.states.stopped
});
break;
}
}

_emitEvent(key, data) {
const e = new CustomEvent(key, {
detail: data,
bubbles: true
});

this.dispatchEvent(e);
}

static register() {
customElements.define('runner-element', RunnerElement);
}
Expand Down
15 changes: 14 additions & 1 deletion app/DotnetRunnerApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@ module.exports = class DotnetRunnerApp {
this._enableTasks();
}

_handleMinimizeToTray() {
this._mainWindow.on('minimize', (e) => {
e.preventDefault();
this._mainWindow.hide();
});
}

/**
* @returns {Menu}
*/
Expand Down Expand Up @@ -246,6 +253,8 @@ module.exports = class DotnetRunnerApp {

this._menu.setApplicationMenu(this.getMenu());

this._handleMinimizeToTray();

const eixstingApps = getApplications();

if (!eixstingApps || eixstingApps.length === 0) {
Expand All @@ -254,7 +263,7 @@ module.exports = class DotnetRunnerApp {

if (displayReleaseNotes)
this._mainWindow.once('ready-to-show', () => this._displayReleaseNotes());

return this;
}

Expand All @@ -267,4 +276,8 @@ module.exports = class DotnetRunnerApp {
once(...args) {
this._mainWindow.once(...args);
}

on(...args) {
ipcMain.on(...args);
}
}
Binary file added app/assets/icon.ico
Binary file not shown.
10 changes: 10 additions & 0 deletions app/browserWindows/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ let apps = [];

document.addEventListener('DOMContentLoaded', onDomContentLoaded);


document.addEventListener('state-change', () => {
const running = apps.reduce((accu, cur) => cur.component.state !== Runner.states.stopped ? accu + 1 : accu, 0);

if (running === 0)
ipcRenderer.send(ipcMessages.trayTooltipText, '');
else
ipcRenderer.send(ipcMessages.trayTooltipText, `(${running}) ${running ? 'app' : 'apps'} running`);
});

ipcRenderer.on(ipcMessages.reloadApplications, onReloadDataIPC);

ipcRenderer.on(ipcMessages.displayReleaseNotes, onDisplayReleaseNotes);
Expand Down
3 changes: 2 additions & 1 deletion app/ipcMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ module.exports = Object.freeze({
reloadApplications: 'reload-apps',
displayReleaseNotes: 'display-release-notes',
displayPreferences: 'display-preferences',
taskComplete: 'task-complete'
taskComplete: 'task-complete',
trayTooltipText: 'tray-tooltip-text'
});
26 changes: 26 additions & 0 deletions app/tray.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const { Tray, Menu } = require('electron');
const path = require('path');

let trayInstance;

module.exports.create = function({
onQuit,
onClick
}) {
trayInstance = new Tray(path.join(__dirname, 'assets/icon.ico'));

const contextMenu = Menu.buildFromTemplate([
{
label: 'Quit', click: onQuit
}
]);

trayInstance.setContextMenu(contextMenu);

if (onClick)
trayInstance.on('click', onClick);
}

module.exports.setTooltip = function(tooltipText) {
trayInstance.setToolTip(tooltipText);
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dotnet-runner",
"version": "0.2.0",
"version": "0.2.1",
"description": "Electron application to launch dotnet applications",
"main": "startup.js",
"scripts": {
Expand Down
16 changes: 15 additions & 1 deletion startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ const SplashScreenApp = require('./app/SplashScreenApp');

const preferenceStore = require('./app/data/preferencesStore');

const ipcMessages = require('./app/ipcMessages');

const tray = require('./app/tray');

const splashApp = new SplashScreenApp();
const dotnetApp = new DotnetRunnerApp(BrowserWindow, Menu);

Expand All @@ -15,9 +19,19 @@ splashApp.onReady = function(settings) {
.once('ready-to-show', () => {
splashApp.close();
dotnetApp.show();

tray.create({
onQuit() {
app.quit();
},
onClick() {
dotnetApp.show()
}
});

dotnetApp.on(ipcMessages.trayTooltipText, (e, t) => tray.setTooltip(t));
});
}

app.on('ready', () => {
splashApp.run();
});
Expand Down