mode application clusterisé
This commit is contained in:
parent
b3e2fe85bc
commit
a9205daf7e
|
@ -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 {
|
||||||
|
|
|
@ -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
|
//sur le master on cree l'interface
|
||||||
if (process.platform == "darwin") {
|
"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"});
|
var menu = new gui.Menu({type: "menubar"});
|
||||||
menu.createMacBuiltin && menu.createMacBuiltin(window.document.title);
|
menu.createMacBuiltin && menu.createMacBuiltin(window.document.title);
|
||||||
win.menu = menu;
|
win.menu = menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
var $ = function (selector) {
|
var $ = function (selector) {
|
||||||
return document.querySelector(selector);
|
return document.querySelector(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.hide();
|
||||||
win.on('close', function() {
|
|
||||||
gui.App.quit();
|
|
||||||
});
|
|
||||||
|
|
||||||
win.on('click',function(t){
|
//lancement du serveur
|
||||||
console.log(t);
|
var child_process = require('child_process');
|
||||||
});
|
global.main_server = child_process.fork('./js/clustering.js');
|
||||||
|
|
||||||
// bring window to front when open via terminal
|
//on tue le serveur quand on quite l'interface
|
||||||
//win.focus();
|
process.on('exit', function (exitCode) {
|
||||||
win.hide();
|
child_process.kill();
|
||||||
|
});
|
||||||
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);
|
|
||||||
});
|
|
||||||
|
|
|
@ -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>
|
||||||
|
|
Loading…
Reference in New Issue