Skip to content

Commit 6394d85

Browse files
authored
Screen size message (#2217)
1 parent f1d18cf commit 6394d85

File tree

3 files changed

+60
-17
lines changed

3 files changed

+60
-17
lines changed

services/web/client/source/class/osparc/Application.js

+59-15
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ qx.Class.define("osparc.Application", {
3030
qx.locale.MTranslation
3131
],
3232

33+
statics: {
34+
MIN_WIDTH: 1240,
35+
MIN_HEIGHT: 700
36+
},
37+
3338
members: {
3439
__current: null,
3540
__mainPage: null,
@@ -61,15 +66,9 @@ qx.Class.define("osparc.Application", {
6166
}
6267

6368
const webSocket = osparc.wrapper.WebSocket.getInstance();
64-
webSocket.addListener("connect", () => {
65-
osparc.io.WatchDog.getInstance().setOnLine(true);
66-
});
67-
webSocket.addListener("disconnect", () => {
68-
osparc.io.WatchDog.getInstance().setOnLine(false);
69-
});
70-
webSocket.addListener("logout", e => {
71-
this.logout();
72-
});
69+
webSocket.addListener("connect", () => osparc.io.WatchDog.getInstance().setOnLine(true));
70+
webSocket.addListener("disconnect", () => osparc.io.WatchDog.getInstance().setOnLine(false));
71+
webSocket.addListener("logout", () => this.logout());
7372
// alert the users that they are about to navigate away
7473
// from osparc. unfortunately it is not possible
7574
// to provide our own message here
@@ -88,15 +87,62 @@ qx.Class.define("osparc.Application", {
8887
}
8988

9089
// Setting up auth manager
91-
osparc.auth.Manager.getInstance().addListener("logout", function() {
92-
this.__restart();
93-
}, this);
90+
osparc.auth.Manager.getInstance().addListener("logout", () => this.__restart(), this);
9491

9592
this.__initRouting();
9693
this.__loadCommonCss();
9794

9895
this.__updateTabName();
9996
this.__checkCookiesAccepted();
97+
98+
// onload, load, DOMContentLoaded, appear... didn't work
99+
// bit of a hack
100+
setTimeout(() => this.__checkScreenSize(), 100);
101+
window.addEventListener("resize", () => this.__checkScreenSize());
102+
},
103+
104+
__checkScreenSize: function() {
105+
const title = this.tr("Oops, the window is a bit too small!");
106+
const tooSmallWindow = new osparc.ui.window.SingletonWindow("tooSmallScreen", title).set({
107+
height: 100,
108+
width: 400,
109+
layout: new qx.ui.layout.VBox(),
110+
appearance: "service-window",
111+
showMinimize: false,
112+
showMaximize: false,
113+
showClose: false,
114+
resizable: false,
115+
modal: true,
116+
contentPadding: 10
117+
});
118+
const w = document.documentElement.clientWidth;
119+
const h = document.documentElement.clientHeight;
120+
if (this.self().MIN_WIDTH > w || this.self().MIN_HEIGHT > h) {
121+
const msg = this.tr(`
122+
oSPARC is designed for slightly bigger window size.<br>\
123+
A mininum window size of ${this.self().MIN_WIDTH}x${this.self().MIN_HEIGHT} is recommended<br>\
124+
Touch devices are not fully supported.
125+
`);
126+
const label = new qx.ui.basic.Label().set({
127+
value: msg,
128+
rich: true
129+
});
130+
tooSmallWindow.add(label, {
131+
flex: 1
132+
});
133+
const okBtn = new qx.ui.form.Button(this.tr("Got it")).set({
134+
allowGrowX: false,
135+
allowGrowY: false,
136+
alignX: "right"
137+
});
138+
okBtn.addListener("execute", () => tooSmallWindow.close());
139+
tooSmallWindow.add(okBtn);
140+
setTimeout(() => tooSmallWindow.center(), 100);
141+
tooSmallWindow.center();
142+
tooSmallWindow.open();
143+
} else {
144+
tooSmallWindow.close();
145+
}
100146
},
101147

102148
__initRouting: function() {
@@ -262,9 +308,7 @@ qx.Class.define("osparc.Application", {
262308
__loadLoginPage: function() {
263309
this.__disconnectWebSocket();
264310
const view = new osparc.auth.LoginPage();
265-
view.addListener("done", function(msg) {
266-
this.__restart();
267-
}, this);
311+
view.addListener("done", () => this.__restart(), this);
268312
this.__loadView(view, {
269313
top: "10%"
270314
});

services/web/client/source/class/osparc/ui/basic/Logo.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ qx.Class.define("osparc.ui.basic.Logo", {
3838
},
3939

4040
members: {
41-
__resetSourcePath: function(statics) {
41+
__resetSourcePath: function() {
4242
const sourcePath = osparc.utils.Utils.getLogoPath();
4343
this.set({
4444
source: sourcePath

services/web/client/source/class/osparc/ui/window/SingletonWindow.js

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ qx.Class.define("osparc.ui.window.SingletonWindow", {
1818
.filter(child => child.classname === this.classname);
1919
const thisWindow = singletonWindows.find(win => win.getId() === id);
2020
if (thisWindow) {
21-
console.log(`Trying to create another SingletonWindow with id ${id}, disposing the old one...`);
2221
thisWindow.dispose();
2322
}
2423
this.base(arguments, caption, icon);

0 commit comments

Comments
 (0)