Skip to content

Commit

Permalink
Merge branch 'release/0.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Cavoj committed May 7, 2018
2 parents 6fd7174 + eb92c1f commit 2dad331
Show file tree
Hide file tree
Showing 16 changed files with 46 additions and 31 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# 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

Download the [latest release](http://www.github.com/macav/hotelier/releases) and install it.

## 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.
Expand All @@ -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

Expand Down
Binary file removed icon.icns
Binary file not shown.
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -40,7 +40,8 @@
"mac": {
"extendInfo": {
"LSUIElement": 1
}
},
"icon": "build/icon.icns"
},
"linux": {
"target": [
Expand All @@ -51,7 +52,8 @@
]
}
],
"category": "Development"
"category": "Development",
"icon": "build/icon.ico"
},
"win": {
"target": [
Expand All @@ -62,11 +64,12 @@
"ia32"
]
}
]
],
"icon": "build/icon.ico"
},
"files": [
"build/**/*",
"icon.*"
"build/icon.*"
]
}
}
Binary file modified public/assets/hotelTemplate.pxm
Binary file not shown.
Binary file added public/assets/hotelTemplate_white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/assets/hotelier_windows.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 21 additions & 8 deletions public/electron.js
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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()

Expand All @@ -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 }
}
Expand All @@ -66,14 +77,16 @@ const createWindow = () => {
window.loadURL(startUrl);

window.on('blur', () => {
blurredRecently = true;
setTimeout(() => blurredRecently = false, 100);
if (!window.webContents.isDevToolsOpened()) {
window.hide()
}
})
}

const toggleWindow = () => {
if (window.isVisible()) {
if (window.isVisible() || blurredRecently) {
window.hide()
} else {
showWindow()
Expand Down
Binary file modified public/favicon.ico
Binary file not shown.
Binary file added public/icon.icns
Binary file not shown.
Binary file added public/icon.ico
Binary file not shown.
File renamed without changes
2 changes: 1 addition & 1 deletion public/preload.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
const { shell } = require('electron');
const { shell, Tray } = require('electron');
window.shell = shell;
12 changes: 0 additions & 12 deletions src/App.css

This file was deleted.

4 changes: 4 additions & 0 deletions src/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.window {
border: 1px solid #d2d2d2;
right: 1px;
}
11 changes: 8 additions & 3 deletions src/App.js → src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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 [];
}
});
};

Expand Down Expand Up @@ -153,8 +158,8 @@ class App extends Component {

<footer className="toolbar toolbar-footer">

<div className="footer-link">
<a onClick={this.openHotel}>Hotel</a>
<div className="toolbar-actions pull-left">
<button className="btn btn-default" onClick={this.openHotel}>Hotel</button>
</div>

<div className="toolbar-actions pull-right">
Expand Down
File renamed without changes.

0 comments on commit 2dad331

Please sign in to comment.