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] Use new /dev/services endpoint and its new metadata #6016

Merged
merged 113 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 104 commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
82dcbb7
minor
odeimaiz Jul 1, 2024
4b83c92
servicesDev resource
odeimaiz Jul 1, 2024
d9e36bb
osparc.service.Store
odeimaiz Jul 1, 2024
1eba642
resources
odeimaiz Jul 1, 2024
f453e92
refactoring
odeimaiz Jul 1, 2024
82d663b
Merge branch 'master' into feature/new-services-backend
odeimaiz Jul 1, 2024
f03e9fc
refactoring
odeimaiz Jul 1, 2024
9a8e928
refactoring
odeimaiz Jul 1, 2024
53387e8
add history to cache
odeimaiz Jul 1, 2024
9d7b0d3
__getLatestCached
odeimaiz Jul 1, 2024
f0f3ed2
Service Details Versions
odeimaiz Jul 1, 2024
452656e
getVersions reversed
odeimaiz Jul 1, 2024
29cdeaa
minor
odeimaiz Jul 1, 2024
1cede4c
refactoring
odeimaiz Jul 1, 2024
9a2fd99
minor
odeimaiz Jul 1, 2024
807a899
ServiceCatalog
odeimaiz Jul 1, 2024
a656607
Node constructor receives metadata
odeimaiz Jul 1, 2024
858d9c1
Merge branch 'master' into feature/new-services-backend
odeimaiz Jul 2, 2024
cdf9438
refactoring
odeimaiz Jul 2, 2024
aa9baa1
Merge branch 'feature/new-services-backend' of github.com:odeimaiz/os…
odeimaiz Jul 2, 2024
7b64425
minor
odeimaiz Jul 2, 2024
e80c1c4
minor
odeimaiz Jul 2, 2024
1f44331
async createNode
odeimaiz Jul 2, 2024
9a8d2cd
minor
odeimaiz Jul 2, 2024
5fc752a
Merge branch 'master' into feature/new-services-backend
odeimaiz Jul 4, 2024
ac4a7e6
boot-options -> bootOptions
odeimaiz Jul 4, 2024
bc2029e
execute_access -> executeAccess
odeimaiz Jul 4, 2024
7f19047
something changed
odeimaiz Jul 4, 2024
1a1ee08
minor
odeimaiz Jul 4, 2024
ea9b528
minor
odeimaiz Jul 4, 2024
5476802
refactoring
odeimaiz Jul 4, 2024
53c12e6
more refactoring
odeimaiz Jul 4, 2024
5e782cd
minor
odeimaiz Jul 4, 2024
19e734e
getInaccessibleServices Utils
odeimaiz Jul 4, 2024
3418445
getInaccessibleServices from cache
odeimaiz Jul 4, 2024
60719a4
getInaccessibleServicesMsg
odeimaiz Jul 4, 2024
5e16a3b
Merge branch 'master' into feature/new-services-backend
odeimaiz Jul 9, 2024
d6dc214
Merge branch 'master' into feature/new-services-backend
odeimaiz Jul 9, 2024
e1d006a
deprecated
odeimaiz Jul 9, 2024
af29bab
deprecated
odeimaiz Jul 9, 2024
ae01b1a
getPage service resource
odeimaiz Jul 9, 2024
5299ba5
sometimes there is a kind of a double "data"
odeimaiz Jul 9, 2024
5e6fb38
getAllPages
odeimaiz Jul 9, 2024
86b1ef2
isWorkbenchUpdatable
odeimaiz Jul 9, 2024
5612fd9
isWorkbenchDeprecated and isWorkbenchRetired
odeimaiz Jul 9, 2024
52229cf
minor
odeimaiz Jul 9, 2024
7d5673c
refactoring
odeimaiz Jul 9, 2024
f81fd9b
refactoring
odeimaiz Jul 9, 2024
7095635
minor
odeimaiz Jul 9, 2024
0b6342d
refactoring
odeimaiz Jul 9, 2024
6480955
more refactoring
odeimaiz Jul 9, 2024
caf934d
more
odeimaiz Jul 9, 2024
288cabe
createStudyFromService
odeimaiz Jul 9, 2024
4144142
service -> node
odeimaiz Jul 10, 2024
8661f0b
show version display
odeimaiz Jul 10, 2024
8190b2a
retired
odeimaiz Jul 10, 2024
dcf17a3
List in catalog
odeimaiz Jul 10, 2024
a038a20
fix getLatest
odeimaiz Jul 10, 2024
87e64b0
Merge branch 'master' into feature/new-services-backend
odeimaiz Jul 19, 2024
f91ad02
bad merge
odeimaiz Jul 19, 2024
111792f
moved to backend
odeimaiz Jul 19, 2024
a620147
minor
odeimaiz Jul 19, 2024
d97535b
signature
odeimaiz Jul 19, 2024
5f4ca85
minor
odeimaiz Jul 19, 2024
7197920
refactor
odeimaiz Jul 19, 2024
88ec137
not needed
odeimaiz Jul 19, 2024
6c99e64
rename
odeimaiz Jul 19, 2024
e9a76bb
refactor
odeimaiz Jul 19, 2024
453504e
fix
odeimaiz Jul 19, 2024
ecbc453
key and version
odeimaiz Jul 19, 2024
d37b74a
not needed
odeimaiz Jul 19, 2024
316fb7d
don't show latest
odeimaiz Jul 21, 2024
e0261e4
minor
odeimaiz Jul 21, 2024
48901aa
minor
odeimaiz Jul 21, 2024
27829f9
renaming
odeimaiz Jul 21, 2024
a60c655
renaming
odeimaiz Jul 21, 2024
6b2d071
refactor
odeimaiz Jul 21, 2024
b2da174
refactor
odeimaiz Jul 21, 2024
3dfa92c
refactor
odeimaiz Jul 21, 2024
ae1696c
refactor
odeimaiz Jul 21, 2024
1edf5aa
refactor extractThumbnailSuggestions
odeimaiz Jul 21, 2024
07bef23
minor
odeimaiz Jul 21, 2024
185bfbd
more refactor
odeimaiz Jul 21, 2024
0ad4849
not async
odeimaiz Jul 21, 2024
1585ebc
bad merge
odeimaiz Jul 21, 2024
0a23476
minor
odeimaiz Jul 21, 2024
967f6ac
unused
odeimaiz Jul 21, 2024
039ea37
key can now be patched
odeimaiz Jul 21, 2024
2378d5c
bad merge
odeimaiz Jul 21, 2024
df49d1f
do not show frontend services
odeimaiz Jul 21, 2024
6412dd8
minor
odeimaiz Jul 21, 2024
1bc06f9
fix
odeimaiz Jul 21, 2024
a3bec30
patchNodeData
odeimaiz Jul 21, 2024
48b654e
update all templates
odeimaiz Jul 21, 2024
0354d38
metadata
odeimaiz Jul 21, 2024
9f30ad5
more metadata
odeimaiz Jul 21, 2024
af9ea20
don't always show node name
odeimaiz Jul 21, 2024
19579d5
getVersionDisplay and getReleasedDate
odeimaiz Jul 21, 2024
c5a85f2
getVersionDisplay
odeimaiz Jul 21, 2024
7e46907
versionToListItem
odeimaiz Jul 22, 2024
2c3328a
versionDisplay in different field
odeimaiz Jul 22, 2024
ad492fa
clone array instead of changing it
odeimaiz Jul 22, 2024
3273b19
writeAccess -> write, executeAccess -> execute, readAccess -> execute
odeimaiz Jul 22, 2024
180d61e
always show VersionDisplay if its editable
odeimaiz Jul 22, 2024
b012160
show no thumbnail icon
odeimaiz Jul 22, 2024
ada5868
noThumbnail
odeimaiz Jul 22, 2024
ae54fa4
minors
odeimaiz Jul 22, 2024
49a6856
minor
odeimaiz Jul 22, 2024
01c2353
aesthetics
odeimaiz Jul 22, 2024
10d3e14
Merge branch 'master' into feature/new-services-backend
odeimaiz Jul 22, 2024
1e89bea
Merge branch 'master' into feature/new-services-backend
odeimaiz Jul 23, 2024
36be416
Merge branch 'master' into feature/new-services-backend
odeimaiz Jul 23, 2024
68b5d04
fix catalog
odeimaiz Jul 23, 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 @@ -102,7 +102,7 @@ qx.Class.define("osparc.dashboard.CardBase", {
const myGroupId = osparc.auth.Data.getInstance().getGroupId();
if (checks && myGroupId in checks) {
const myAccessRights = checks[myGroupId];
const totalAccess = "delete" in myAccessRights ? myAccessRights["delete"] : myAccessRights["write_access"];
const totalAccess = "delete" in myAccessRights ? myAccessRights["delete"] : myAccessRights["write"];
if (sharedWith === "my-resources") {
return !totalAccess;
} else if (sharedWith === "shared-with-me") {
Expand All @@ -127,10 +127,10 @@ qx.Class.define("osparc.dashboard.CardBase", {
return false;
},

filterServiceType: function(resourceType, metaData, serviceType) {
filterServiceType: function(resourceType, metadata, serviceType) {
if (serviceType && resourceType === "service") {
if (metaData && metaData.type) {
const matches = metaData.type === serviceType;
if (metadata && metadata.type) {
const matches = metadata.type === serviceType;
return !matches;
}
return false;
Expand Down Expand Up @@ -452,27 +452,23 @@ qx.Class.define("osparc.dashboard.CardBase", {
} else if (osparc.study.Utils.isWorkbenchDeprecated(workbench)) {
this.setUpdatable("deprecated");
} else {
osparc.study.Utils.isWorkbenchUpdatable(workbench)
.then(updatable => {
if (updatable) {
this.setUpdatable("updatable");
}
});
const updatable = osparc.study.Utils.isWorkbenchUpdatable(workbench)
if (updatable) {
this.setUpdatable("updatable");
}
}

// Block card
osparc.study.Utils.getInaccessibleServices(workbench)
.then(unaccessibleServices => {
if (unaccessibleServices.length) {
this.__enableCard(false);
const image = "@FontAwesome5Solid/ban/";
let toolTipText = this.tr("Service info missing");
unaccessibleServices.forEach(unSrv => {
toolTipText += "<br>" + unSrv.key + ":" + unSrv.version;
});
this.__showBlockedCard(image, toolTipText);
}
const unaccessibleServices = osparc.study.Utils.getInaccessibleServices(workbench)
if (unaccessibleServices.length) {
this.__enableCard(false);
const image = "@FontAwesome5Solid/ban/";
let toolTipText = this.tr("Service info missing");
unaccessibleServices.forEach(unSrv => {
toolTipText += "<br>" + unSrv.key + ":" + unSrv.version;
});
this.__showBlockedCard(image, toolTipText);
}
},

__applyEmptyWorkbench: function(isEmpty) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ qx.Class.define("osparc.dashboard.Dashboard", {
const preResourcePromises = [];
const store = osparc.store.Store.getInstance();
preResourcePromises.push(store.getAllGroupsAndMembers());
preResourcePromises.push(store.getAllServices(true));
preResourcePromises.push(osparc.service.Store.getServicesLatest(false));
if (permissions.canDo("study.tag")) {
preResourcePromises.push(osparc.data.Resources.get("tags"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
throw new Error("Abstract method called!");
},

_createStudyFromService: async function() {
_createStudyFromService: function() {
throw new Error("Abstract method called!");
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
__qualityPage: null,
__servicesUpdatePage: null,
__openButton: null,
_services: null,

__createToolbar: function() {
const toolbar = new qx.ui.container.Composite(new qx.ui.layout.HBox(20).set({
Expand Down Expand Up @@ -151,10 +150,6 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
let anyUpdatable = false;
for (const nodeId in workbench) {
const node = workbench[nodeId];
const latestCompatibleMetadata = osparc.service.Utils.getLatestCompatible(this._services, node["key"], node["version"]);
if (latestCompatibleMetadata === null) {
osparc.FlashMessenger.logAs(this.tr("Some service information could not be retrieved"), "WARNING");
}
const isUpdatable = osparc.service.Utils.isUpdatable(node);
if (isUpdatable) {
anyUpdatable = true;
Expand Down Expand Up @@ -241,36 +236,34 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
const versionsBox = new osparc.ui.toolbar.SelectBox();
hBox.add(versionsBox);

// populate it with owned versions
const store = osparc.store.Store.getInstance();
store.getAllServices()
.then(services => {
const versions = osparc.service.Utils.getVersions(services, this.__resourceData["key"]);
let selectedItem = null;

// first setSelection
versions.reverse().forEach(version => {
selectedItem = new qx.ui.form.ListItem(version);
versionsBox.add(selectedItem);
if (this.__resourceData["version"] === version) {
versionsBox.setSelection([selectedItem]);
}
});

// then listen to changes
versionsBox.addListener("changeSelection", e => {
const selection = e.getData();
if (selection.length) {
const serviceVersion = selection[0].getLabel();
if (serviceVersion !== this.__resourceData["version"]) {
const serviceData = osparc.service.Utils.getFromObject(services, this.__resourceData["key"], serviceVersion);
const versions = osparc.service.Utils.getVersions(this.__resourceData["key"]);
let selectedItem = null;

// first setSelection
versions.forEach(version => {
selectedItem = osparc.service.Utils.versionToListItem(this.__resourceData["key"], version);
versionsBox.add(selectedItem);
if (this.__resourceData["version"] === version) {
versionsBox.setSelection([selectedItem]);
}
});

// then listen to changes
versionsBox.addListener("changeSelection", e => {
const selection = e.getData();
if (selection.length) {
const serviceVersion = selection[0].getLabel();
if (serviceVersion !== this.__resourceData["version"]) {
osparc.service.Store.getService(this.__resourceData["key"], serviceVersion)
.then(serviceData => {
serviceData["resourceType"] = "service";
this.__resourceData = serviceData;
this.__addPages();
}
}
}, this);
});
});
}
}
}, this);

return hBox;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,49 +43,36 @@ qx.Class.define("osparc.dashboard.ServiceBrowser", {
},

members: {
__servicesAll: null,
__sortBy: null,

// overridden
initResources: function() {
this.__servicesAll = {};
this._resourcesList = [];
const preResourcePromises = [];
const store = osparc.store.Store.getInstance();
preResourcePromises.push(store.getAllServices());
if (osparc.data.Permissions.getInstance().canDo("study.tag")) {
preResourcePromises.push(osparc.data.Resources.get("tags"));
}

Promise.all(preResourcePromises)
.then(() => {
this.getChildControl("resources-layout");
this.reloadResources();
this._hideLoadingPage();
})
.catch(err => console.error(err));
this.getChildControl("resources-layout");
this.reloadResources();
this._hideLoadingPage();
},

reloadResources: function() {
this.__reloadServices();
this.__loadServices();
},

__reloadServices: function() {
const store = osparc.store.Store.getInstance();
store.getAllServices(false, false)
.then(services => {
this.__servicesAll = services;
const favServices = osparc.utils.Utils.localCache.getFavServices();
__loadServices: function() {
osparc.service.Store.getServicesLatest()
.then(servicesLatest => {
const servicesList = [];
for (const key in services) {
const latestService = osparc.service.Utils.getLatest(services, key);
const found = Object.keys(favServices).find(favSrv => favSrv === key);
latestService.hits = found ? favServices[found]["hits"] : 0;
// do not list frontend services
if (!latestService["key"].includes("simcore/services/frontend/")) {
servicesList.push(latestService);
Object.keys(servicesLatest).forEach(key => {
const serviceLatest = servicesLatest[key];
// do not show frontend services
if (key.includes("simcore/services/frontend/")) {
return;
}
}
// do not show retired services
if (servicesLatest[key]["retired"]) {
return;
}
servicesList.push(serviceLatest);
});
this.__setResourcesToList(servicesList);
})
.catch(err => {
Expand Down Expand Up @@ -128,7 +115,7 @@ qx.Class.define("osparc.dashboard.ServiceBrowser", {
this.resetSelection();
},

_createStudyFromService: async function(key, version) {
_createStudyFromService: function(key, version) {
if (!this._checkLoggedIn()) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
// Show "Contact Us" message if studies.length === 0 && templates.length === 0 && services.length === 0
// Most probably is a product-stranger user (it can also be that the catalog is down)
if (nStudies === 0) {
const store = osparc.store.Store.getInstance();
Promise.all([
store.getTemplates(),
store.getAllServices()
osparc.store.Store.getInstance().getTemplates(),
osparc.service.Store.getServicesLatest()
]).then(values => {
const templates = values[0];
const services = values[1];
Expand Down Expand Up @@ -526,17 +525,17 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
});
},

__addNewStudyFromServiceButtons: function(services, serviceKey, newButtonInfo) {
__addNewStudyFromServiceButtons: function(serviceKey, newButtonInfo) {
const mode = this._resourcesContainer.getMode();
// Make sure we have access to that service
const versions = osparc.service.Utils.getVersions(services, serviceKey);
const versions = osparc.service.Utils.getVersions(serviceKey);
if (versions.length && newButtonInfo) {
const title = newButtonInfo.title;
const desc = newButtonInfo.description;
const newStudyFromServiceButton = (mode === "grid") ? new osparc.dashboard.GridButtonNew(title, desc) : new osparc.dashboard.ListButtonNew(title, desc);
newStudyFromServiceButton.setCardKey("new-"+serviceKey);
osparc.utils.Utils.setIdToWidget(newStudyFromServiceButton, newButtonInfo.idToWidget);
newStudyFromServiceButton.addListener("execute", () => this.__newStudyFromServiceBtnClicked(newStudyFromServiceButton, serviceKey, versions[versions.length-1], newButtonInfo.newStudyLabel));
newStudyFromServiceButton.addListener("execute", () => this.__newStudyFromServiceBtnClicked(newStudyFromServiceButton, serviceKey, versions[0], newButtonInfo.newStudyLabel));
if (this._resourcesContainer.getMode() === "list") {
const width = this._resourcesContainer.getBounds().width - 15;
newStudyFromServiceButton.setWidth(width);
Expand All @@ -546,20 +545,16 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
},

__addPlusButtonsFromServices: function() {
const store = osparc.store.Store.getInstance();
store.getAllServices()
.then(services => {
// add new plus buttons if key services exists
osparc.utils.Utils.fetchJSON("/resource/osparc/new_studies.json")
.then(newStudiesData => {
const product = osparc.product.Utils.getProductName()
if (product in newStudiesData) {
const newButtonsInfo = newStudiesData[product].resources;
newButtonsInfo.forEach(newButtonInfo => {
this.__addNewStudyFromServiceButtons(services, newButtonInfo.expectedKey, newButtonInfo);
});
}
// add new plus buttons if key services exists
osparc.utils.Utils.fetchJSON("/resource/osparc/new_studies.json")
.then(newStudiesData => {
const product = osparc.product.Utils.getProductName()
if (product in newStudiesData) {
const newButtonsInfo = newStudiesData[product].resources;
newButtonsInfo.forEach(newButtonInfo => {
this.__addNewStudyFromServiceButtons(newButtonInfo.expectedKey, newButtonInfo);
});
}
});
},

Expand Down Expand Up @@ -956,17 +951,20 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
__getThumbnailStudyMenuButton: function(studyData) {
const thumbButton = new qx.ui.menu.Button(this.tr("Thumbnail..."));
thumbButton.addListener("execute", () => {
const title = this.tr("Edit Thumbnail");
const oldThumbnail = studyData.thumbnail;
const suggestions = osparc.editor.ThumbnailSuggestions.extractThumbnailSuggestions(studyData);
const thumbnailEditor = new osparc.editor.ThumbnailEditor(oldThumbnail, suggestions);
const win = osparc.ui.window.Window.popUpInWindow(thumbnailEditor, title, suggestions.length > 2 ? 500 : 350, 280);
thumbnailEditor.addListener("updateThumbnail", e => {
win.close();
const newUrl = e.getData();
this.__updateThumbnail(studyData, newUrl);
}, this);
thumbnailEditor.addListener("cancel", () => win.close());
osparc.editor.ThumbnailSuggestions.extractThumbnailSuggestions(studyData)
.then(suggestions => {
const title = this.tr("Edit Thumbnail");
const oldThumbnail = studyData.thumbnail;
const thumbnailEditor = new osparc.editor.ThumbnailEditor(oldThumbnail, suggestions);
const win = osparc.ui.window.Window.popUpInWindow(thumbnailEditor, title, suggestions.length > 2 ? 500 : 350, 280);
thumbnailEditor.addListener("updateThumbnail", e => {
win.close();
const newUrl = e.getData();
this.__updateThumbnail(studyData, newUrl);
}, this);
thumbnailEditor.addListener("cancel", () => win.close());
})
.catch(err => console.error(err));
}, this);
return thumbButton;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,10 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", {
// overridden
initResources: function() {
this._resourcesList = [];
const preResourcePromises = [];
const store = osparc.store.Store.getInstance();
preResourcePromises.push(store.getAllServices());
if (osparc.data.Permissions.getInstance().canDo("study.tag")) {
preResourcePromises.push(osparc.data.Resources.get("tags"));
}

Promise.all(preResourcePromises)
.then(() => {
this.getChildControl("resources-layout");
this.reloadResources();
this.__attachEventHandlers();
this._hideLoadingPage();
})
.catch(err => console.error(err));
this.getChildControl("resources-layout");
this.reloadResources();
this.__attachEventHandlers();
this._hideLoadingPage();
},

reloadResources: function() {
Expand Down Expand Up @@ -253,9 +242,17 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", {
const studyData = osparc.data.model.Study.deepCloneStudyObject(uniqueTemplateData);
const templatePromises = [];
for (const nodeId in studyData["workbench"]) {
const newVersion = osparc.metadata.ServicesInStudyUpdate.getLatestVersion(studyData, nodeId)
if (newVersion) {
templatePromises.push(osparc.info.StudyUtils.patchNodeData(uniqueTemplateData, nodeId, "version", newVersion));
const node = studyData["workbench"][nodeId];
const latestCompatible = osparc.service.Utils.getLatestCompatible(node["key"], node["version"]);
if (latestCompatible && (node["key"] !== latestCompatible["key"] || node["version"] !== latestCompatible["version"])) {
const patchData = {};
if (node["key"] !== latestCompatible["key"]) {
patchData["key"] = latestCompatible["key"];
}
if (node["version"] !== latestCompatible["version"]) {
patchData["version"] = latestCompatible["version"];
}
templatePromises.push(osparc.info.StudyUtils.patchNodeData(uniqueTemplateData, nodeId, patchData));
}
}
Promise.all(templatePromises)
Expand Down
Loading
Loading