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

View File

@ -1,3 +1,5 @@
//sur le master on cree l'interface
"use strict"; "use strict";
var gui = require('nw.gui'); var gui = require('nw.gui');
var CustomTrayMenu = require('./js/custom-tray-menu'); var CustomTrayMenu = require('./js/custom-tray-menu');
@ -17,37 +19,18 @@ var $ = function (selector) {
var customTray; var customTray;
customTray = new CustomTrayMenu('./views/custom-tray-menu.html', 'public/icon.png', { customTray = new CustomTrayMenu('views/custom-tray-menu.html', 'public/icon.png', {
width: 200, width: 200,
height: 150 height: 180
}); });
// for nw-notify frameless windows
win.on('close', function() {
gui.App.quit();
});
win.on('click',function(t){
console.log(t);
});
// bring window to front when open via terminal
//win.focus();
win.hide(); win.hide();
var writeLog = function (msg, type) { //lancement du serveur
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'); var child_process = require('child_process');
global.main_server = child_process.fork('./js/clustering.js');
// exec: spawns a shell. //on tue le serveur quand on quite l'interface
child_process.exec('node js/clustering.js', function(error, stdout, stderr){ process.on('exit', function (exitCode) {
console.log(stdout); child_process.kill();
}); });

View File

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