Skip to content

Commit 673d4d8

Browse files
committed
Merge branch 'master' into ensure-api-key-expiration-is-functional
2 parents abea161 + b7ac77b commit 673d4d8

File tree

18 files changed

+261
-157
lines changed

18 files changed

+261
-157
lines changed

services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", {
191191
const workbench = newStudyData["workbench"];
192192
const nodesIdsListed = [];
193193
Object.keys(workbench).forEach(nodeId => {
194-
const node = workbench[nodeId];
195-
if (osparc.study.StudyPricingUnits.includeInList(node)) {
194+
const nodeData = workbench[nodeId];
195+
if (osparc.study.StudyPricingUnits.includeInList(nodeData)) {
196196
nodesIdsListed.push(nodeId);
197197
}
198198
});

services/static-webserver/client/source/class/osparc/data/model/LicensedItemResource.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ qx.Class.define("osparc.data.model.LicensedItemResource", {
5252
}
5353

5454
this.set({
55+
modelId: licensedItemResourceData.id,
5556
description: description,
5657
title: title,
5758
subtitle: subtitle,
@@ -66,6 +67,13 @@ qx.Class.define("osparc.data.model.LicensedItemResource", {
6667
},
6768

6869
properties: {
70+
modelId: {
71+
check: "Number",
72+
nullable: false,
73+
init: null,
74+
event: "changeModelId",
75+
},
76+
6977
description: {
7078
check: "String",
7179
nullable: false,

services/static-webserver/client/source/class/osparc/data/model/Study.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ qx.Class.define("osparc.data.model.Study", {
487487
// Do not listen to output related backend updates if the node is a frontend node.
488488
// The frontend controls its output values, progress and states.
489489
// If a File Picker is uploading a file, the backend could override the current state with some older state.
490-
if (node && nodeData && !osparc.data.model.Node.isFrontend(node)) {
490+
if (node && nodeData && !osparc.data.model.Node.isFrontend(node.getMetaData())) {
491491
node.setOutputData(nodeData.outputs);
492492
if ("progress" in nodeData) {
493493
const progress = Number.parseInt(nodeData["progress"]);

services/static-webserver/client/source/class/osparc/file/FilePicker.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,18 @@ qx.Class.define("osparc.file.FilePicker", {
414414
if (files.length === 1) {
415415
const fileUploader = new osparc.file.FileUploader(this.getNode());
416416
fileUploader.addListener("uploadAborted", () => this.__resetOutput());
417-
fileUploader.addListener("fileUploaded", () => {
417+
fileUploader.addListener("fileUploaded", e => {
418+
const fileMetadata = e.getData();
419+
if (
420+
"location" in fileMetadata &&
421+
"dataset" in fileMetadata &&
422+
"path" in fileMetadata &&
423+
"name" in fileMetadata
424+
) {
425+
osparc.file.FilePicker.setOutputValueFromStore(this.getNode(), fileMetadata["location"], fileMetadata["dataset"], fileMetadata["path"], fileMetadata["name"]);
426+
} else {
427+
console.error("metadata info missing", fileMetadata);
428+
}
418429
this.fireEvent("fileUploaded");
419430
this.getNode().fireEvent("fileUploaded");
420431
}, this);

services/static-webserver/client/source/class/osparc/file/FileUploader.js

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ qx.Class.define("osparc.file.FileUploader", {
3939

4040
events: {
4141
"uploadAborted": "qx.event.type.Event",
42-
"fileUploaded": "qx.event.type.Event"
42+
"fileUploaded": "qx.event.type.Data",
4343
},
4444

4545
statics: {
@@ -60,6 +60,7 @@ qx.Class.define("osparc.file.FileUploader", {
6060
members: {
6161
__presignedLinkData: null,
6262
__uploadedParts: null,
63+
__fileMetadata: null,
6364

6465
// Request to the server an upload URL.
6566
retrieveUrlAndUpload: function(file) {
@@ -80,6 +81,14 @@ qx.Class.define("osparc.file.FileUploader", {
8081
.then(presignedLinkData => {
8182
if (presignedLinkData.resp.urls) {
8283
this.__presignedLinkData = presignedLinkData;
84+
85+
this.__fileMetadata = {
86+
location: presignedLinkData.locationId,
87+
dataset: studyId,
88+
path: presignedLinkData.fileUuid,
89+
name: file.name
90+
};
91+
8392
try {
8493
this.__uploadFile(file);
8594
} catch (error) {
@@ -124,7 +133,7 @@ qx.Class.define("osparc.file.FileUploader", {
124133
const nProgress = Math.min(Math.max(100*progress-min, min), max);
125134
this.getNode().getStatus().setProgress(nProgress);
126135
if (this.__uploadedParts.every(uploadedPart => uploadedPart["e_tag"] !== null)) {
127-
this.__checkCompleteUpload(file);
136+
this.__checkCompleteUpload();
128137
}
129138
}
130139
} catch (err) {
@@ -153,7 +162,7 @@ qx.Class.define("osparc.file.FileUploader", {
153162
},
154163

155164
// Use XMLHttpRequest to complete the upload to S3
156-
__checkCompleteUpload: function(file) {
165+
__checkCompleteUpload: function() {
157166
if (this.getNode()["fileUploadAbortRequested"]) {
158167
this.__abortUpload();
159168
return;
@@ -162,29 +171,21 @@ qx.Class.define("osparc.file.FileUploader", {
162171
const presignedLinkData = this.__presignedLinkData;
163172
this.getNode().getStatus().setProgress(this.self().PROGRESS_VALUES.COMPLETING);
164173
const completeUrl = presignedLinkData.resp.links.complete_upload;
165-
const location = presignedLinkData.locationId;
166-
const path = presignedLinkData.fileUuid;
167174
const xhr = new XMLHttpRequest();
168175
xhr.onloadend = () => {
169-
const fileMetadata = {
170-
location,
171-
dataset: this.getNode().getStudy().getUuid(),
172-
path,
173-
name: file.name
174-
};
175176
const resp = JSON.parse(xhr.responseText);
176177
if ("error" in resp && resp["error"]) {
177178
console.error(resp["error"]);
178179
this.__abortUpload();
179180
} else if ("data" in resp) {
180181
if (xhr.status == 202) {
181-
console.log("waiting for completion", file.name);
182+
console.log("waiting for completion", this.__fileMetadata.name);
182183
// @odeimaiz: we need to poll the received new location in the response
183184
// we do have links.state -> poll that link until it says ok
184185
// right now this kind of work if files are small and this happens fast
185-
this.__pollFileUploadState(resp["data"]["links"]["state"], fileMetadata);
186+
this.__pollFileUploadState(resp["data"]["links"]["state"]);
186187
} else if (xhr.status == 200) {
187-
this.__completeUpload(fileMetadata);
188+
this.__completeUpload();
188189
}
189190
}
190191
};
@@ -196,30 +197,27 @@ qx.Class.define("osparc.file.FileUploader", {
196197
xhr.send(JSON.stringify(body));
197198
},
198199

199-
__pollFileUploadState: function(stateLink, fileMetadata) {
200+
__pollFileUploadState: function(stateLink) {
200201
const xhr = new XMLHttpRequest();
201202
xhr.open("POST", stateLink, true);
202203
xhr.setRequestHeader("Content-Type", "application/json");
203204
xhr.onloadend = () => {
204205
const resp = JSON.parse(xhr.responseText);
205206
if ("data" in resp && resp["data"] && resp["data"]["state"] === "ok") {
206-
this.__completeUpload(fileMetadata);
207+
this.__completeUpload();
207208
} else {
208209
const interval = 2000;
209-
qx.event.Timer.once(() => this.__pollFileUploadState(stateLink, fileMetadata), this, interval);
210+
qx.event.Timer.once(() => this.__pollFileUploadState(stateLink), this, interval);
210211
}
211212
};
212213
xhr.send();
213214
},
214215

215-
__completeUpload: function(fileMetadata) {
216+
__completeUpload: function() {
216217
this.getNode()["fileUploadAbortRequested"] = false;
217218

218-
if ("location" in fileMetadata && "dataset" in fileMetadata && "path" in fileMetadata && "name" in fileMetadata) {
219-
osparc.file.FilePicker.setOutputValueFromStore(this.getNode(), fileMetadata["location"], fileMetadata["dataset"], fileMetadata["path"], fileMetadata["name"]);
220-
}
221219
this.__presignedLinkData = null;
222-
this.fireEvent("fileUploaded");
220+
this.fireDataEvent("fileUploaded", this.__fileMetadata);
223221
},
224222

225223
__abortUpload: function() {

services/static-webserver/client/source/class/osparc/navigation/UserMenu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ qx.Class.define("osparc.navigation.UserMenu", {
8686
this.add(control);
8787
break;
8888
case "market":
89-
control = new qx.ui.menu.Button(this.tr("Model Store"));
89+
control = new qx.ui.menu.Button(this.tr("The Shop"));
9090
control.addListener("execute", () => osparc.vipMarket.MarketWindow.openWindow());
9191
this.add(control);
9292
break;

services/static-webserver/client/source/class/osparc/pricing/PlanDetails.js

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,27 @@ qx.Class.define("osparc.pricing.PlanDetails", {
3333
"backToPricingPlans": "qx.event.type.Event"
3434
},
3535

36+
statics: {
37+
createTabPage: function(label, icon) {
38+
const tabPage = new qx.ui.tabview.Page().set({
39+
layout: new qx.ui.layout.VBox()
40+
});
41+
if (label) {
42+
tabPage.setLabel(label);
43+
}
44+
if (icon) {
45+
tabPage.setIcon(icon);
46+
}
47+
tabPage.getChildControl("button").set({
48+
font: "text-13"
49+
});
50+
return tabPage;
51+
}
52+
},
53+
3654
members: {
55+
__servicesPage: null,
56+
3757
_createChildControlImpl: function(id) {
3858
let control;
3959
let layout;
@@ -68,7 +88,7 @@ qx.Class.define("osparc.pricing.PlanDetails", {
6888
break;
6989
case "pricing-units": {
7090
control = new osparc.pricing.UnitsList();
71-
const tabPage = this.__createTabPage(this.tr("Pricing Units"), "@FontAwesome5Solid/paw/14");
91+
const tabPage = this.self().createTabPage(this.tr("Pricing Units"), "@FontAwesome5Solid/paw/14");
7292
tabPage.add(control, {
7393
flex: 1
7494
});
@@ -78,7 +98,7 @@ qx.Class.define("osparc.pricing.PlanDetails", {
7898
}
7999
case "service-list": {
80100
control = new osparc.pricing.ServicesList();
81-
const tabPage = this.__createTabPage(this.tr("Services"), "@FontAwesome5Solid/cogs/14");
101+
const tabPage = this.__servicesPage = this.self().createTabPage(this.tr("Services"), "@FontAwesome5Solid/cogs/14");
82102
tabPage.add(control, {
83103
flex: 1
84104
});
@@ -90,38 +110,27 @@ qx.Class.define("osparc.pricing.PlanDetails", {
90110
return control || this.base(arguments, id);
91111
},
92112

93-
setCurrentPricingPlan: function(pricingPlanModel) {
94-
if (pricingPlanModel === null) {
113+
setCurrentPricingPlan: function(pricingPlan) {
114+
if (pricingPlan === null) {
95115
return;
96116
}
97117

98118
const pricingPlanListItem = this.getChildControl("pricing-plan-details");
99-
pricingPlanModel.bind("model", pricingPlanListItem, "model");
100-
pricingPlanModel.bind("ppId", pricingPlanListItem, "ppId");
101-
pricingPlanModel.bind("ppKey", pricingPlanListItem, "ppKey");
102-
pricingPlanModel.bind("title", pricingPlanListItem, "title");
103-
pricingPlanModel.bind("description", pricingPlanListItem, "description");
104-
pricingPlanModel.bind("isActive", pricingPlanListItem, "isActive");
119+
pricingPlan.bind("model", pricingPlanListItem, "model");
120+
pricingPlan.bind("ppId", pricingPlanListItem, "ppId");
121+
pricingPlan.bind("ppKey", pricingPlanListItem, "ppKey");
122+
pricingPlan.bind("title", pricingPlanListItem, "title");
123+
pricingPlan.bind("description", pricingPlanListItem, "description");
124+
pricingPlan.bind("isActive", pricingPlanListItem, "isActive");
105125

106126
// set PricingPlanId to the tab views
107-
this.getChildControl("pricing-units").setPricingPlanId(pricingPlanModel.getModel());
108-
this.getChildControl("service-list").setPricingPlanId(pricingPlanModel.getModel());
109-
},
127+
this.getChildControl("pricing-units").setPricingPlanId(pricingPlan.getModel());
128+
this.getChildControl("service-list").setPricingPlanId(pricingPlan.getModel());
110129

111-
__createTabPage: function(label, icon) {
112-
const tabPage = new qx.ui.tabview.Page().set({
113-
layout: new qx.ui.layout.VBox()
114-
});
115-
if (label) {
116-
tabPage.setLabel(label);
117-
}
118-
if (icon) {
119-
tabPage.setIcon(icon);
120-
}
121-
tabPage.getChildControl("button").set({
122-
font: "text-13"
130+
// show services only if it's a TIER pricing plan
131+
this.__servicesPage.getChildControl("button").set({
132+
visibility: pricingPlan.getClassification() === "TIER" ? "visible" : "excluded"
123133
});
124-
return tabPage;
125-
}
134+
},
126135
}
127136
});

0 commit comments

Comments
 (0)