Stefan Huber

feature: fullscreen for electron apps via event propagation

1 export declare class Device { 1 export declare class Device {
2 reload(): void; 2 reload(): void;
3 exit(): void; 3 exit(): void;
4 + fullscreen(fullscreen: any): void;
4 } 5 }
......
...@@ -15,6 +15,14 @@ var Device = (function () { ...@@ -15,6 +15,14 @@ var Device = (function () {
15 } 15 }
16 } 16 }
17 }; 17 };
18 + Device.prototype.fullscreen = function (fullscreen) {
19 + if (window && window['require']) {
20 + var electron = window['require']('electron');
21 + if (electron && electron.ipcRenderer) {
22 + electron.ipcRenderer.send('fullscreen', fullscreen);
23 + }
24 + }
25 + };
18 return Device; 26 return Device;
19 }()); 27 }());
20 exports.Device = Device; 28 exports.Device = Device;
......
1 -{"version":3,"file":"device.js","sourceRoot":"","sources":["../../src/services/device.ts"],"names":[],"mappings":";AAAA;IAAA;IAiBA,CAAC;IAfG,uBAAM,GAAN;QACI,EAAE,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC5B,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QAC7B,CAAC;IACL,CAAC;IAED,qBAAI,GAAJ;QACI,EAAE,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YAC9B,IAAI,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,CAAC;YAC7C,EAAE,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;gBACnC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACtC,CAAC;QACL,CAAC;IACL,CAAC;IAEL,aAAC;AAAD,CAAC,AAjBD,IAiBC;AAjBY,wBAAM"}
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"device.js","sourceRoot":"","sources":["../../src/services/device.ts"],"names":[],"mappings":";AAAA;IAAA;IA0BA,CAAC;IAxBG,uBAAM,GAAN;QACI,EAAE,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC5B,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QAC7B,CAAC;IACL,CAAC;IAED,qBAAI,GAAJ;QACI,EAAE,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YAC9B,IAAI,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,CAAC;YAC7C,EAAE,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;gBACnC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACtC,CAAC;QACL,CAAC;IACL,CAAC;IAED,2BAAU,GAAV,UAAW,UAAU;QACjB,EAAE,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YAC9B,IAAI,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,CAAC;YAC7C,EAAE,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;gBACnC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;YACxD,CAAC;QACL,CAAC;IACL,CAAC;IAEL,aAAC;AAAD,CAAC,AA1BD,IA0BC;AA1BY,wBAAM"}
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -72,6 +72,9 @@ var Repository = (function () { ...@@ -72,6 +72,9 @@ var Repository = (function () {
72 return new Promise(function (resolve, reject) { 72 return new Promise(function (resolve, reject) {
73 _this.rest.heartbeat(deviceInfo) 73 _this.rest.heartbeat(deviceInfo)
74 .then(function (response) { 74 .then(function (response) {
75 + if (response && typeof response.fullscreen == 'boolean') {
76 + _this.device.fullscreen(response.fullscreen);
77 + }
75 if (response && response.restart == 1) { 78 if (response && response.restart == 1) {
76 _this.device.reload(); 79 _this.device.reload();
77 } 80 }
...@@ -105,6 +108,7 @@ var Repository = (function () { ...@@ -105,6 +108,7 @@ var Repository = (function () {
105 console.log("prepare local couch url: ", localCouchUrl); 108 console.log("prepare local couch url: ", localCouchUrl);
106 resolve(_this.prepare(localCouchUrl)); 109 resolve(_this.prepare(localCouchUrl));
107 }).catch(function () { 110 }).catch(function () {
111 + _this._node = null;
108 resolve(_this.prepare(response.db_url)); 112 resolve(_this.prepare(response.db_url));
109 }); 113 });
110 }); 114 });
......
This diff is collapsed. Click to expand it.
...@@ -15,4 +15,13 @@ export class Device { ...@@ -15,4 +15,13 @@ export class Device {
15 } 15 }
16 } 16 }
17 17
18 + fullscreen(fullscreen) {
19 + if (window && window['require']) {
20 + let electron = window['require']('electron');
21 + if (electron && electron.ipcRenderer) {
22 + electron.ipcRenderer.send('fullscreen', fullscreen);
23 + }
24 + }
25 + }
26 +
18 } 27 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -78,6 +78,10 @@ export class Repository { ...@@ -78,6 +78,10 @@ export class Repository {
78 return new Promise<boolean>((resolve, reject) => { 78 return new Promise<boolean>((resolve, reject) => {
79 this.rest.heartbeat(deviceInfo) 79 this.rest.heartbeat(deviceInfo)
80 .then(response => { 80 .then(response => {
81 + if (response && typeof response.fullscreen == 'boolean') {
82 + this.device.fullscreen(response.fullscreen);
83 + }
84 +
81 if (response && response.restart == 1) { 85 if (response && response.restart == 1) {
82 this.device.reload(); 86 this.device.reload();
83 } else if (response && response.exit == 1) { 87 } else if (response && response.exit == 1) {
......