mode application clusterisé

This commit is contained in:
WEBER Antoine 2015-10-11 22:13:49 +02:00
parent b3e2fe85bc
commit a9205daf7e
3 changed files with 39 additions and 52 deletions

View File

@ -26,7 +26,6 @@ class CustomTrayMenu {
this.tray.remove();
this.tray = null;
this.trayMenu.close();
process.emit('log', 'Remove tray icon');
}
_initTray() {
@ -37,7 +36,6 @@ class CustomTrayMenu {
tooltip: window.document.title,
iconsAreTemplates: false
});
process.emit('log', 'Add tray icon');
}
_initMenuWindow() {
@ -57,13 +55,13 @@ class CustomTrayMenu {
// add class to new window's body to apply platform specific css
this.trayMenu.on('document-end', function() {
this.trayMenu.window.document.body.className += ' ' + process.platform;
process.emit('log', "Adding class " + process.platform);
//console.log("Adding class " + process.platform);
}.bind(this));
this.trayMenu.on('blur', function () {
this.trayMenu.hide();
this.shown = false;
process.emit('log', 'Hide custom menu');
//console.log('Hide custom menu');
}.bind(this));
}
@ -81,13 +79,13 @@ class CustomTrayMenu {
this.trayMenu.show();
//this.trayMenu.focus();
this.shown = true;
process.emit('log', 'Show custom menu');
//console.log('Show custom menu');
//}
}
// calculdate position for window to appear
translate(pos) {
process.emit('log', "Click position: " + util.inspect(pos));
//console.log("Click position: " + util.inspect(pos));
if (process.platform == 'darwin') {
pos.x -= Math.floor(this.trayMenu.width / 2 - this.iconWidth);
} else {

View File

@ -1,53 +1,36 @@
"use strict";
var gui = require('nw.gui');
var CustomTrayMenu = require('./js/custom-tray-menu');
var win = gui.Window.get();
global.main_win = win;
// Extend application menu for Mac OS
if (process.platform == "darwin") {
var menu = new gui.Menu({type: "menubar"});
menu.createMacBuiltin && menu.createMacBuiltin(window.document.title);
win.menu = menu;
}
//sur le master on cree l'interface
"use strict";
var gui = require('nw.gui');
var CustomTrayMenu = require('./js/custom-tray-menu');
var win = gui.Window.get();
global.main_win = win;
var $ = function (selector) {
return document.querySelector(selector);
}
// Extend application menu for Mac OS
if (process.platform == "darwin") {
var menu = new gui.Menu({type: "menubar"});
menu.createMacBuiltin && menu.createMacBuiltin(window.document.title);
win.menu = menu;
}
var customTray;
var $ = function (selector) {
return document.querySelector(selector);
}
customTray = new CustomTrayMenu('./views/custom-tray-menu.html', 'public/icon.png', {
width: 200,
height: 150
});
var customTray;
// for nw-notify frameless windows
win.on('close', function() {
gui.App.quit();
});
customTray = new CustomTrayMenu('views/custom-tray-menu.html', 'public/icon.png', {
width: 200,
height: 180
});
win.on('click',function(t){
console.log(t);
});
win.hide();
// bring window to front when open via terminal
//win.focus();
win.hide();
//lancement du serveur
var child_process = require('child_process');
global.main_server = child_process.fork('./js/clustering.js');
var writeLog = function (msg, type) {
console.log(msg);
};
process.on('log', function (message) {
writeLog(message);
});
//on lance l'application en commencant par la creation des cluster
//require('./clustering');
var child_process = require('child_process');
// exec: spawns a shell.
child_process.exec('node js/clustering.js', function(error, stdout, stderr){
console.log(stdout);
});
//on tue le serveur quand on quite l'interface
process.on('exit', function (exitCode) {
child_process.kill();
});

View File

@ -11,6 +11,12 @@
console.log(stdout);
});
}
function proper_quit(){
gui.App.closeAllWindows();
global.main_server.kill();
gui.App.quit();
}
</script>
<style>
body, html {
@ -94,7 +100,7 @@
<h4>Plex Web Downloader</h4>
<p><button onclick="win.hide();">Minimiser le Menu</button></p>
<p><button onclick="open_conf();">Ouvrir la configuration</button></p>
<p><button onclick="gui.App.closeAllWindows();">Arreter le Serveur</button></p>
<p><button onclick="proper_quit();">Arreter le Serveur</button></p>
</section>
</body>
</html>