diff --git a/README.md b/README.md index 4679a6b..95d5dea 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Hotelier -Tray App for [Hotel](https://github.com/typicode/hotel) process manager which works on Windows, Mac and Linux. +Tray App for [Hotel](https://github.com/typicode/hotel) process manager which works on Windows, Mac and (potentially) Linux. ## Install @@ -8,6 +8,8 @@ Download the [latest release](http://www.github.com/macav/hotelier/releases) and ## About +![windows_screenshot](public/assets/hotelier_windows.png) + ### Description The main purpose of the app is allowing easy management of the servers directly from the tray / menu bar, without the need of opening the `Hotel` in the browser, or using the CLI. @@ -22,7 +24,7 @@ I decided to create the app because all other alternatives didn't work properly ### Builds -The builds are available for Mac (`.dmg`), Windows (32 & 64 bit) and Linux (`.deb`). +The builds are available for Mac (`.dmg`) and Windows (32 & 64 bit). ## Features diff --git a/icon.icns b/icon.icns deleted file mode 100644 index c5b968f..0000000 Binary files a/icon.icns and /dev/null differ diff --git a/package.json b/package.json index 3bc7472..2eb6664 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ }, "license": "MIT", "description": "Tray App for Hotel Process Manager", - "version": "0.1.0", + "version": "0.1.2", "dependencies": { "is-electron": "^2.1.0", "react": "^16.3.2", @@ -40,7 +40,8 @@ "mac": { "extendInfo": { "LSUIElement": 1 - } + }, + "icon": "build/icon.icns" }, "linux": { "target": [ @@ -51,7 +52,8 @@ ] } ], - "category": "Development" + "category": "Development", + "icon": "build/icon.ico" }, "win": { "target": [ @@ -62,11 +64,12 @@ "ia32" ] } - ] + ], + "icon": "build/icon.ico" }, "files": [ "build/**/*", - "icon.*" + "build/icon.*" ] } } diff --git a/public/assets/hotelTemplate.pxm b/public/assets/hotelTemplate.pxm index 844d737..81396a8 100644 Binary files a/public/assets/hotelTemplate.pxm and b/public/assets/hotelTemplate.pxm differ diff --git a/public/assets/hotelTemplate_white.png b/public/assets/hotelTemplate_white.png new file mode 100644 index 0000000..af10ac0 Binary files /dev/null and b/public/assets/hotelTemplate_white.png differ diff --git a/public/assets/hotelier_windows.png b/public/assets/hotelier_windows.png new file mode 100644 index 0000000..6ef3038 Binary files /dev/null and b/public/assets/hotelier_windows.png differ diff --git a/public/electron.js b/public/electron.js index 3dba3c4..64795ea 100644 --- a/public/electron.js +++ b/public/electron.js @@ -1,11 +1,14 @@ -const { app, BrowserWindow, ipcMain, Tray } = require('electron') -const path = require('path') +const electron = require('electron'); +const { app, BrowserWindow, ipcMain, Tray } = electron; +const path = require('path'); const url = require('url'); const assetsDirectory = path.join(__dirname, './assets') -let tray = undefined -let window = undefined +let tray = undefined; +let window = undefined; +// workaround for Windows, where blur event occured when clicking on a tray icon +let blurredRecently = false; if (process.platform === 'darwin') { app.dock.hide() @@ -21,9 +24,12 @@ app.on('window-all-closed', () => { }) const createTray = () => { - tray = new Tray(path.join(assetsDirectory, 'hotelTemplate.png')) + if (process.platform === 'darwin') { + tray = new Tray(path.join(assetsDirectory, 'hotelTemplate.png')) + } else { + tray = new Tray(path.join(assetsDirectory, 'hotelTemplate_white.png')) + } tray.on('right-click', toggleWindow) - tray.on('double-click', toggleWindow) tray.on('click', function (event) { toggleWindow() @@ -36,10 +42,15 @@ const createTray = () => { const getWindowPosition = () => { const windowBounds = window.getBounds() const trayBounds = tray.getBounds() + const { width, height } = electron.screen.getPrimaryDisplay().workAreaSize; const x = Math.round(trayBounds.x + (trayBounds.width / 2) - (windowBounds.width / 2)) - const y = Math.round(trayBounds.y + trayBounds.height + 4) + let y = Math.round(trayBounds.y + trayBounds.height + 4) + + if (height < y) { + y = Math.round(trayBounds.y - windowBounds.height - 4) + } return { x: x, y: y } } @@ -66,6 +77,8 @@ const createWindow = () => { window.loadURL(startUrl); window.on('blur', () => { + blurredRecently = true; + setTimeout(() => blurredRecently = false, 100); if (!window.webContents.isDevToolsOpened()) { window.hide() } @@ -73,7 +86,7 @@ const createWindow = () => { } const toggleWindow = () => { - if (window.isVisible()) { + if (window.isVisible() || blurredRecently) { window.hide() } else { showWindow() diff --git a/public/favicon.ico b/public/favicon.ico index a11777c..a2fbbe7 100644 Binary files a/public/favicon.ico and b/public/favicon.ico differ diff --git a/public/icon.icns b/public/icon.icns new file mode 100644 index 0000000..3b5ac9b Binary files /dev/null and b/public/icon.icns differ diff --git a/public/icon.ico b/public/icon.ico new file mode 100644 index 0000000..a2fbbe7 Binary files /dev/null and b/public/icon.ico differ diff --git a/icon.png b/public/icon.png similarity index 100% rename from icon.png rename to public/icon.png diff --git a/public/preload.js b/public/preload.js index 958a9a6..b0b6e18 100644 --- a/public/preload.js +++ b/public/preload.js @@ -1,2 +1,2 @@ -const { shell } = require('electron'); +const { shell, Tray } = require('electron'); window.shell = shell; diff --git a/src/App.css b/src/App.css deleted file mode 100644 index 5c3ae4d..0000000 --- a/src/App.css +++ /dev/null @@ -1,12 +0,0 @@ -.footer-link { - padding-top: 8px; - padding-left: 10px; - font-size: calc(var(--font-size) - 4px); - float: left; -} - -.footer-link a { - color: var(--text-color); - cursor: pointer; - text-decoration: underline; -} diff --git a/src/app.css b/src/app.css new file mode 100644 index 0000000..2700983 --- /dev/null +++ b/src/app.css @@ -0,0 +1,4 @@ +.window { + border: 1px solid #d2d2d2; + right: 1px; +} \ No newline at end of file diff --git a/src/App.js b/src/app.js similarity index 94% rename from src/App.js rename to src/app.js index 4ed7371..f0f0393 100644 --- a/src/App.js +++ b/src/app.js @@ -13,6 +13,7 @@ class App extends Component { } loadServers = () => { + this.setState({ loading: true }); this.getServers().then(servers => { servers = Object.keys(servers).map(serverId => { const server = servers[serverId]; @@ -29,7 +30,11 @@ class App extends Component { getServers = () => { return window.fetch(`${this.getHotelUrl()}/_/servers`).then(response => { this.setState({ loading: false }); - return response.json(); + if (response.ok) { + return response.json(); + } else { + return []; + } }); }; @@ -153,8 +158,8 @@ class App extends Component {