Skip to content

Commit 37d7e09

Browse files
authored
* getManuals refactored * fix * minor * accept button * cookies text * getLicenseLink * minor * minor * License on user menu * true by default
1 parent 77191cc commit 37d7e09

File tree

7 files changed

+119
-52
lines changed

7 files changed

+119
-52
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,8 @@ qx.Class.define("osparc.Application", {
274274
if (!osparc.CookiePolicy.areCookiesAccepted()) {
275275
const cookiePolicy = new osparc.CookiePolicy();
276276
const title = this.tr("Cookie Policy");
277-
const win = osparc.ui.window.Window.popUpInWindow(cookiePolicy, title, 360, 140).set({
277+
const height = osparc.utils.Utils.isProduct("tis") ? 180 : 145;
278+
const win = osparc.ui.window.Window.popUpInWindow(cookiePolicy, title, 400, height).set({
278279
clickAwayClose: false,
279280
resizable: false,
280281
showClose: false

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

Lines changed: 62 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ qx.Class.define("osparc.CookiePolicy", {
2424

2525
construct: function() {
2626
this.base(arguments);
27-
this._setLayout(new qx.ui.layout.VBox());
27+
28+
const grid = new qx.ui.layout.Grid(5, 10);
29+
grid.setColumnFlex(0, 1);
30+
this._setLayout(grid);
2831

2932
this.__buildLayout();
3033
},
@@ -56,36 +59,62 @@ qx.Class.define("osparc.CookiePolicy", {
5659
_createChildControlImpl: function(id) {
5760
let control;
5861
switch (id) {
59-
case "text": {
60-
const text = this.tr("This website applies cookies to personalize your \
61-
experience and to make our site easier to navigate. By visiting \
62-
the site, you are agreeing to this use and to our \
63-
<a href=https://itis.swiss/meta-navigation/privacy-policy/ style='color: white' target='_blank'>Privacy Policy.</a>");
62+
case "cookie-text": {
63+
const color = qx.theme.manager.Color.getInstance().resolve("text");
64+
const textLink = `<a href=https://itis.swiss/meta-navigation/privacy-policy/ style='color: ${color}' target='_blank'>Privacy Policy.</a>`;
65+
const text = this.tr("This website applies cookies to personalize your experience and to make our site easier to navigate. By visiting the site, you agree to the ") + textLink;
66+
control = new qx.ui.basic.Label(text).set({
67+
rich : true
68+
});
69+
this._add(control, {
70+
column: 0,
71+
row: 0
72+
});
73+
break;
74+
}
75+
case "accept-cookie":
76+
control = new qx.ui.form.CheckBox().set({
77+
value: true
78+
});
79+
this._add(control, {
80+
column: 1,
81+
row: 0
82+
});
83+
break;
84+
case "license-text": {
85+
const licenseLink = osparc.navigation.Manuals.getLicenseLink();
86+
const color = qx.theme.manager.Color.getInstance().resolve("text");
87+
const textLink = `<a href=${licenseLink} style='color: ${color}' target='_blank'>Licensing.</a>`;
88+
const text = this.tr("It also uses third party software and libraries. By visiting the site, you agree to the ") + textLink;
6489
control = new qx.ui.basic.Label(text).set({
6590
rich : true
6691
});
6792
this._add(control, {
68-
flex: 1
93+
column: 0,
94+
row: 1
6995
});
7096
break;
7197
}
98+
case "accept-license":
99+
control = new qx.ui.form.CheckBox().set({
100+
value: true
101+
});
102+
this._add(control, {
103+
column: 1,
104+
row: 1
105+
});
106+
break;
72107
case "control-buttons": {
73108
control = new qx.ui.container.Composite(new qx.ui.layout.HBox(5).set({
74109
alignX: "right"
75110
})).set({
76111
padding: 2
77112
});
78-
this._add(control);
79-
break;
80-
}
81-
case "decline-button": {
82-
const ctrlBtns = this.getChildControl("control-buttons");
83-
control = new qx.ui.form.Button(this.tr("Decline")).set({
84-
visibility: "excluded",
85-
allowGrowX: false
113+
this._add(control, {
114+
column: 0,
115+
row: 2,
116+
colSpan: 2
86117
});
87-
osparc.utils.Utils.setIdToWidget(control, "declineCookiesBtn");
88-
ctrlBtns.add(control);
89118
break;
90119
}
91120
case "accept-button": {
@@ -102,17 +131,24 @@ qx.Class.define("osparc.CookiePolicy", {
102131
},
103132

104133
__buildLayout: function() {
105-
this.getChildControl("text");
106-
107-
const declineBtn = this.getChildControl("decline-button");
108-
declineBtn.addListener("execute", () => {
109-
this.fireEvent("cookiesDeclined");
110-
}, this);
134+
const checkButtons = [];
135+
this.getChildControl("cookie-text");
136+
const acceptCookie = this.getChildControl("accept-cookie");
137+
checkButtons.push(acceptCookie);
138+
139+
if (osparc.utils.Utils.isProduct("tis")) {
140+
this.getChildControl("license-text");
141+
const acceptLicense = this.getChildControl("accept-license");
142+
checkButtons.push(acceptLicense);
143+
}
111144

112145
const acceptBtn = this.getChildControl("accept-button");
113-
acceptBtn.addListener("execute", () => {
114-
this.fireEvent("cookiesAccepted");
115-
}, this);
146+
const evalAcceptButton = () => {
147+
acceptBtn.setEnabled(checkButtons.every(checkButton => checkButton.getValue()));
148+
};
149+
checkButtons.forEach(checkButton => checkButton.addListener("changeValue", () => evalAcceptButton()));
150+
acceptBtn.addListener("execute", () => this.fireEvent("cookiesAccepted"), this);
151+
evalAcceptButton();
116152
}
117153
}
118154
});

services/web/client/source/class/osparc/dashboard/ResourceBrowserBase.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
205205
.then(resp => {
206206
const resources = resp["data"];
207207
this._resourcesContainer.nextRequest = resp["_links"]["next"];
208+
this._addResourcesToList(resources);
209+
208210
if (osparc.utils.Utils.isProduct("tis")) {
209211
const dontShow = osparc.utils.Utils.localCache.getLocalStorageItem("tiDontShowQuickStart");
210212
if (dontShow !== "true" && templates === false && resources.length === 0 && this._resourcesContainer.nextRequest === null) {
@@ -214,7 +216,6 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
214216
tutorialWindow.open();
215217
}
216218
}
217-
this._addResourcesToList(resources);
218219
})
219220
.catch(err => {
220221
console.error(err);

services/web/client/source/class/osparc/navigation/Manuals.js

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,49 @@ qx.Class.define("osparc.navigation.Manuals", {
33
type: "static",
44

55
statics: {
6-
getManuals: function(statics) {
7-
let manuals = [];
8-
if (statics && statics.osparcManualUrl) {
9-
manuals.push({
10-
label: qx.locale.Manager.tr("User Manual"),
11-
icon: "@FontAwesome5Solid/book/22",
12-
url: statics.osparcManualUrl
13-
});
14-
}
15-
16-
if (osparc.utils.Utils.isInZ43() && statics && statics.osparcManualExtraUrl) {
17-
manuals.push({
18-
label: qx.locale.Manager.tr("Z43 Manual"),
19-
icon: "@FontAwesome5Solid/book-medical/22",
20-
url: statics.osparcManualExtraUrl
21-
});
6+
getLicenseLink: function() {
7+
let licenseLink = null;
8+
const productName = osparc.utils.Utils.getProductName();
9+
switch (productName) {
10+
case "osparc":
11+
case "s4l":
12+
licenseLink = "http://docs.osparc.io/#/docs/support/license";
13+
break;
14+
case "tis":
15+
licenseLink = "https://itisfoundation.github.io/ti-planning-tool-manual/#/docs/support/license";
16+
break;
2217
}
18+
return licenseLink;
19+
},
2320

24-
if (osparc.utils.Utils.isProduct("tis") && statics && statics.tisManualUrl) {
25-
// "TI Planning Tool Manual" only
26-
manuals = [{
27-
label: qx.locale.Manager.tr("TI Planning Tool Manual"),
28-
icon: "@FontAwesome5Solid/book/22",
29-
url: statics.tisManualUrl
30-
}];
21+
getManuals: function(statics) {
22+
const productName = osparc.utils.Utils.getProductName();
23+
const manualUrlKey = productName + "ManualUrl";
24+
const manualExtraUrlKey = productName + "ManualExtraUrl";
25+
const manuals = [];
26+
switch (productName) {
27+
case "osparc":
28+
case "s4l":
29+
manuals.push({
30+
label: qx.locale.Manager.tr("User Manual"),
31+
icon: "@FontAwesome5Solid/book/22",
32+
url: statics[manualUrlKey]
33+
});
34+
if (osparc.utils.Utils.isInZ43() && statics && manualExtraUrlKey in statics) {
35+
manuals.push({
36+
label: qx.locale.Manager.tr("Z43 Manual"),
37+
icon: "@FontAwesome5Solid/book-medical/22",
38+
url: statics[manualExtraUrlKey]
39+
});
40+
}
41+
break;
42+
case "tis":
43+
manuals.push({
44+
label: qx.locale.Manager.tr("TI Planning Tool Manual"),
45+
icon: "@FontAwesome5Solid/book/22",
46+
url: statics[manualUrlKey]
47+
});
48+
break;
3149
}
3250

3351
return manuals;

services/web/client/source/class/osparc/navigation/UserMenuButton.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ qx.Class.define("osparc.navigation.UserMenuButton", {
138138
});
139139
this.getMenu().add(control);
140140
break;
141+
case "license":
142+
control = new qx.ui.menu.Button(this.tr("License"));
143+
control.addListener("execute", () => window.open(osparc.navigation.Manuals.getLicenseLink()));
144+
this.getMenu().add(control);
145+
break;
141146
case "about":
142147
control = new qx.ui.menu.Button(this.tr("About"));
143148
control.addListener("execute", () => osparc.About.getInstance().open());
@@ -162,6 +167,7 @@ qx.Class.define("osparc.navigation.UserMenuButton", {
162167
this.getChildControl("quick-start");
163168
}
164169
this.getMenu().addSeparator();
170+
this.getChildControl("license");
165171
this.getChildControl("about");
166172
this.getMenu().addSeparator();
167173
this.getChildControl("logout");
@@ -181,6 +187,7 @@ qx.Class.define("osparc.navigation.UserMenuButton", {
181187
this.getChildControl("quick-start");
182188
}
183189
this.getMenu().addSeparator();
190+
this.getChildControl("license");
184191
this.getChildControl("about");
185192
this.getMenu().addSeparator();
186193
this.getChildControl("logout");

services/web/client/source/class/osparc/utils/Utils.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ qx.Class.define("osparc.utils.Utils", {
184184
});
185185
},
186186

187+
getProductName: function() {
188+
return qx.core.Environment.get("product.name");
189+
},
190+
187191
isProduct: function(productName) {
188192
const product = qx.core.Environment.get("product.name");
189193
return (productName === product);

services/web/server/src/simcore_service_webserver/storage_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ async def get_project_total_size(
6666
list_of_files_enveloped = Envelope[list[FileMetaDataGet]].parse_obj(
6767
await response.json()
6868
)
69-
assert list_of_files_enveloped.data # nosec
69+
assert list_of_files_enveloped.data is not None # nosec
7070
for file_metadata in list_of_files_enveloped.data:
7171
project_size_bytes += file_metadata.file_size
7272
project_size = parse_obj_as(ByteSize, project_size_bytes)

0 commit comments

Comments
 (0)