Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎨 Frontend: Dashboard card bind to model #5807

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
de8c54a
minor
odeimaiz May 13, 2024
6d924d0
minor
odeimaiz May 13, 2024
49a40aa
minor
odeimaiz May 13, 2024
fdf822a
Study model
odeimaiz May 13, 2024
af01278
unused
odeimaiz May 13, 2024
df3962d
Service Model
odeimaiz May 13, 2024
64fd6c9
show footer by default
odeimaiz May 13, 2024
8e43e9f
__bindModelToCard
odeimaiz May 13, 2024
8533822
attach resourceType
odeimaiz May 13, 2024
4c7e5d9
serialize Service
odeimaiz May 13, 2024
df63fc2
minor
odeimaiz May 14, 2024
3c7e9bd
serialize
odeimaiz May 14, 2024
29e5ec4
Merge branch 'master' into feature/bind-model-to-card
odeimaiz May 14, 2024
7864353
patch classifiers
odeimaiz May 14, 2024
6a8b338
Merge branch 'feature/bind-model-to-card' of github.com:odeimaiz/ospa…
odeimaiz May 14, 2024
357b54f
patch Quality
odeimaiz May 14, 2024
89e2176
delete by removing collaborator
odeimaiz May 14, 2024
b448d08
Merge branch 'master' into feature/bind-model-to-card
odeimaiz May 15, 2024
64a5470
rename and thumbnail
odeimaiz May 15, 2024
711b093
rename from study options
odeimaiz May 15, 2024
73b1862
Merge branch 'master' into feature/bind-model-to-card
odeimaiz May 16, 2024
28692b9
static patchStudy
odeimaiz May 16, 2024
c94bd36
patchStudy
odeimaiz May 16, 2024
4a31903
patchStudy
odeimaiz May 16, 2024
476e913
more refactoring
odeimaiz May 16, 2024
ec495c5
renaming
odeimaiz May 16, 2024
ba26709
fix
odeimaiz May 16, 2024
861ebc4
minor
odeimaiz May 16, 2024
d6b2aed
mode patchStudy and deprecate access_rights (snake)
odeimaiz May 16, 2024
2149062
minor
odeimaiz May 16, 2024
a7043e0
last on project
odeimaiz May 16, 2024
d4ec342
store cards
odeimaiz May 16, 2024
f14be05
minor
odeimaiz May 16, 2024
046b3ac
minors
odeimaiz May 16, 2024
379d320
_updateCard
odeimaiz May 16, 2024
7685677
lastChangeDate after patch
odeimaiz May 16, 2024
13d0a2b
add new buttons first
odeimaiz May 16, 2024
85e472e
Merge branch 'master' into feature/bind-model-to-card
odeimaiz May 16, 2024
6b63dbf
renaming
odeimaiz May 16, 2024
0db5f9c
Merge branch 'master' into feature/bind-model-to-card
odeimaiz May 17, 2024
414c7f2
Merge branch 'master' into feature/bind-model-to-card
odeimaiz May 17, 2024
5f3a988
patchStudyData
odeimaiz May 17, 2024
30c2766
patchStudy
odeimaiz May 17, 2024
a2f9805
serializeStudyData
odeimaiz May 17, 2024
ac2e537
Merge branch 'master' into feature/bind-model-to-card
odeimaiz May 17, 2024
2484ceb
minor
odeimaiz May 17, 2024
ca56e5c
_openResourceDetails
odeimaiz May 17, 2024
8e8021d
Merge branch 'master' into feature/bind-model-to-card
odeimaiz May 28, 2024
80009ab
Merge branch 'feature/bind-model-to-card' of github.com:odeimaiz/ospa…
odeimaiz May 28, 2024
a35ae68
not used
odeimaiz May 28, 2024
536c7cf
pass data and model
odeimaiz May 28, 2024
c5d2ed1
Merge branch 'master' into feature/bind-model-to-card
odeimaiz May 30, 2024
73a19fb
Merge branch 'master' into feature/bind-model-to-card
odeimaiz Aug 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ qx.Class.define("osparc.dashboard.CardBase", {
},

workbench: {
check: "Object",
check: "osparc.data.model.Workbench",
nullable: true,
apply: "__applyWorkbench"
},
Expand Down Expand Up @@ -403,49 +403,70 @@ qx.Class.define("osparc.dashboard.CardBase", {
dragover : true
},

__resourceModel: null,

isResourceType: function(resourceType) {
return this.getResourceType() === resourceType;
},

__applyResourceData: function(resourceData) {
let uuid = null;
let owner = null;
let workbench = null;
let defaultHits = null;
switch (resourceData["resourceType"]) {
case "study":
uuid = resourceData.uuid ? resourceData.uuid : null;
owner = resourceData.prjOwner ? resourceData.prjOwner : "";
workbench = resourceData.workbench ? resourceData.workbench : {};
break;
case "template":
uuid = resourceData.uuid ? resourceData.uuid : null;
owner = resourceData.prjOwner ? resourceData.prjOwner : "";
workbench = resourceData.workbench ? resourceData.workbench : {};
break;
case "service":
uuid = resourceData.key ? resourceData.key : null;
owner = resourceData.owner ? resourceData.owner : "";
defaultHits = 0;
break;
if (resourceData["resourceType"]) {
this.set({
resourceType: resourceData.resourceType
});

let model = null;
switch (resourceData["resourceType"]) {
case "study":
case "template":
model = new osparc.data.model.Study(resourceData);
model["resourceType"] = resourceData["resourceType"];
break;
case "service":
model = new osparc.data.model.Service(resourceData);
model["resourceType"] = resourceData["resourceType"];
break;
}
if (model) {
this.__bindModelToCard(model);
}
}
},

this.set({
resourceType: resourceData.resourceType,
uuid,
title: resourceData.name,
description: resourceData.description,
owner,
accessRights: resourceData.accessRights ? resourceData.accessRights : {},
lastChangeDate: resourceData.lastChangeDate ? new Date(resourceData.lastChangeDate) : null,
icon: resourceData.thumbnail || this.self().PRODUCT_ICON,
state: resourceData.state ? resourceData.state : {},
classifiers: resourceData.classifiers && resourceData.classifiers ? resourceData.classifiers : [],
quality: resourceData.quality ? resourceData.quality : null,
uiMode: resourceData.ui && resourceData.ui.mode ? resourceData.ui.mode : null,
hits: resourceData.hits ? resourceData.hits : defaultHits,
workbench
});
getResourceModel: function() {
return this.__resourceModel;
},

__bindModelToCard: function(model) {
this.__resourceModel = model;
if (model instanceof osparc.data.model.Study) {
model.bind("uuid", this, "uuid");
model.bind("name", this, "title");
model.bind("description", this, "description");
model.bind("workbench", this, "workbench");
model.bind("prjOwner", this, "owner");
model.bind("accessRights", this, "accessRights");
model.bind("lastChangeDate", this, "lastChangeDate");
model.bind("thumbnail", this, "icon", {
converter: t => t || this.self().PRODUCT_ICON
});
model.bind("state", this, "state");
model.bind("classifiers", this, "classifiers");
model.bind("quality", this, "quality");
model.getUi().bind("mode", this, "uiMode");
} else if (model instanceof osparc.data.model.Service) {
model.bind("key", this, "uuid");
model.bind("name", this, "title");
model.bind("description", this, "description");
model.bind("owner", this, "owner");
model.bind("accessRights", this, "accessRights");
model.bind("thumbnail", this, "icon", {
converter: t => t || this.self().PRODUCT_ICON
});
model.bind("classifiers", this, "classifiers");
model.bind("quality", this, "quality");
model.bind("hits", this, "hits");
}
},

__applyUuid: function(value, old) {
Expand Down Expand Up @@ -533,14 +554,15 @@ qx.Class.define("osparc.dashboard.CardBase", {
return;
}

const workbenchData = workbench.serialize();
if (this.isResourceType("study") || this.isResourceType("template")) {
this.setEmptyWorkbench(Object.keys(workbench).length === 0);
this.setEmptyWorkbench(Object.keys(workbenchData).length === 0);
}

// Updatable study
if (osparc.study.Utils.isWorkbenchRetired(workbench)) {
if (osparc.study.Utils.isWorkbenchRetired(workbenchData)) {
this.setUpdatable("retired");
} else if (osparc.study.Utils.isWorkbenchDeprecated(workbench)) {
} else if (osparc.study.Utils.isWorkbenchDeprecated(workbenchData)) {
this.setUpdatable("deprecated");
} else {
const updatable = osparc.study.Utils.isWorkbenchUpdatable(workbench)
Expand Down Expand Up @@ -786,7 +808,7 @@ qx.Class.define("osparc.dashboard.CardBase", {
},

__openMoreOptions: function() {
const resourceData = this.getResourceData();
const resourceData = this.__resourceModel.serialize();
const resourceDetails = new osparc.dashboard.ResourceDetails(resourceData);
const win = osparc.dashboard.ResourceDetails.popUpInWindow(resourceDetails);
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,16 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
return isLogged;
},

_updateCard: function(resourceData) {
const cards = this._resourcesContainer.getCards();
const found = cards.filter(c => osparc.dashboard.ResourceBrowserBase.isCardButtonItem(c) && c.getUuid() === resourceData["uuid"]);
found.forEach(f => {
// since we are passing and object, the property change won't be triggered. reset the value first
f.setResourceData({});
f.setResourceData(resourceData);
});
},

_removeResourceCards: function() {
const cards = this._resourcesContainer.getCards();
for (let i=cards.length-1; i>=0; i--) {
Expand Down Expand Up @@ -481,8 +491,8 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
return openButton;
},

_openResourceDetails: function(resourceData) {
const resourceDetails = new osparc.dashboard.ResourceDetails(resourceData);
_openResourceDetails: function(resourceData, resourceModel) {
const resourceDetails = new osparc.dashboard.ResourceDetails(resourceData, resourceModel);
const win = osparc.dashboard.ResourceDetails.popUpInWindow(resourceDetails);
resourceDetails.addListener("updateStudy", e => this._updateStudyData(e.getData()));
resourceDetails.addListener("updateTemplate", e => this._updateTemplateData(e.getData()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
qx.Class.define("osparc.dashboard.ResourceDetails", {
extend: osparc.ui.window.TabbedView,

construct: function(resourceData) {
construct: function(resourceData, resourceModel) {
this.base(arguments);

this.__resourceData = resourceData;
this.__resourceModel = resourceModel;

this.__resourceModel = null;
switch (resourceData["resourceType"]) {
Expand Down Expand Up @@ -136,6 +137,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
this.__openResource();
return;
}

this.__openButton.setFetching(true);
const params = {
url: {
Expand Down Expand Up @@ -344,6 +346,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
infoCard.addListener("openAccessRights", () => this.openAccessRights());
infoCard.addListener("openClassifiers", () => this.openClassifiers());
infoCard.addListener("openQuality", () => this.openQuality());

page.addToContent(infoCard);
}
page.addListenerOnce("appear", lazyLoadContent, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {

if (!item.isMultiSelectionMode()) {
const studyData = this.__getStudyData(item.getUuid(), false);
this._openResourceDetails(studyData);
this._openResourceDetails(studyData, item.getResourceModel());
this.resetSelection();
}
},
Expand Down Expand Up @@ -996,7 +996,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
} else {
studies[index] = studyData;
}
this._reloadCards();
this._updateCard(studyData);
},

__removeFromStudyList: function(studyId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", {
if (!card.isLocked()) {
card.setValue(false);
const templateData = this.__getTemplateData(card.getUuid());
this._openResourceDetails(templateData);
this._openResourceDetails(templateData, card.getResourceModel());
}
this.resetSelection();
},
Expand Down
Loading