Skip to content

Commit

Permalink
Merge pull request #4 from odeimaiz/jsaq007-study-start-refactor
Browse files Browse the repository at this point in the history
Jsaq007 study start refactor
  • Loading branch information
jsaq007 authored Mar 6, 2024
2 parents 79165c3 + c32a908 commit 38acfb1
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ qx.Class.define("osparc.dashboard.ResourceMoreOptions", {
HEIGHT: 700,

popUpInWindow: function(moreOpts) {
const prjAlias = osparc.product.Utils.getStudyAlias({firstUpperCase: true});
// eslint-disable-next-line no-underscore-dangle
const title = qx.locale.Manager.tr(`Project Details - ${moreOpts.__resourceData.name}`);
const title = qx.locale.Manager.tr(prjAlias + ` Details - ${moreOpts.__resourceData.name}`);
return osparc.ui.window.Window.popUpInWindow(moreOpts, title, this.WIDTH, this.HEIGHT).set({
maxHeight: 1000,
layout: new qx.ui.layout.Grow(),
Expand Down Expand Up @@ -79,7 +80,6 @@ qx.Class.define("osparc.dashboard.ResourceMoreOptions", {
__permissionsPage: null,
__tagsPage: null,
__billingSettings: null,
__previewPage: null,
__classifiersPage: null,
__qualityPage: null,
__servicesUpdatePage: null,
Expand Down Expand Up @@ -242,10 +242,6 @@ qx.Class.define("osparc.dashboard.ResourceMoreOptions", {
this.__openPage(this.__billingSettings);
},

openPreviewPage: function() {
this.__openPage(this.__previewPage);
},

openUpdateServices: function() {
this.__openPage(this.__servicesUpdatePage);
},
Expand Down Expand Up @@ -321,7 +317,8 @@ qx.Class.define("osparc.dashboard.ResourceMoreOptions", {
this.__getSaveAsTemplatePage,
this.__getTagsPage,
this.__getQualityPage,
this.__getClassifiersPage
this.__getClassifiersPage,
this.__getPreviewPage
].forEach(pageCallee => {
if (pageCallee) {
const page = pageCallee.call(this);
Expand Down Expand Up @@ -375,9 +372,7 @@ qx.Class.define("osparc.dashboard.ResourceMoreOptions", {
const page = new osparc.dashboard.resources.pages.BasePage(title, iconSrc, id);
page.showLabelOnTab();
const toolBar = this.__addToolbar();
page.add(toolBar, {
flex: 1
});
page.add(toolBar);
page.add(infoCard, {
flex: 1
});
Expand Down Expand Up @@ -407,22 +402,24 @@ qx.Class.define("osparc.dashboard.ResourceMoreOptions", {
return page;
},

// Fix me - Julian or remove
// __getPreviewPage: function() {
// const resourceData = this.__resourceData;
// const id = "Pipeline Preview";
// const title = this.tr("Pipeline Preview");
// const iconSrc = "@FontAwesome5Solid/eye/22";
// // const preview = new osparc.dashboard.StudyThumbnailExplorer(this.getStudy().serialize());
// const preview = new osparc.study.StudyPreview(resourceData);
// const page = this.__previewPage = new osparc.dashboard.resources.pages.BasePage(title, iconSrc, id);
// page.showLabelOnTab();
// page.add(preview, {
// flex: 1
// });
//
// return page;
// },
__getPreviewPage: function() {
const resourceData = this.__resourceData;
if (osparc.utils.Resources.isService(resourceData)) {
return null;
}

const id = "Pipeline Preview";
const title = this.tr("Pipeline Preview");
const iconSrc = "@FontAwesome5Solid/eye/22";
const preview = new osparc.study.StudyPreview(resourceData);
const page = new osparc.dashboard.resources.pages.BasePage(title, iconSrc, id);
page.showLabelOnTab();
page.add(preview, {
flex: 1
});

return page;
},

__getCommentsPage: function() {
const resourceData = this.__resourceData;
Expand Down Expand Up @@ -453,10 +450,14 @@ qx.Class.define("osparc.dashboard.ResourceMoreOptions", {
},

__getDataPage: function() {
const resourceData = this.__resourceData;
if (osparc.utils.Resources.isService(resourceData)) {
return null;
}

const id = "Data";
const title = this.tr("Project Files");
const iconSrc = "@FontAwesome5Solid/file/22";
const resourceData = this.__resourceData;
const studyDataManager = new osparc.widget.NodeDataManager(resourceData["uuid"]);

const page = this.__dataPage = new osparc.dashboard.resources.pages.BasePage(title, iconSrc, id);
Expand Down Expand Up @@ -662,6 +663,18 @@ qx.Class.define("osparc.dashboard.ResourceMoreOptions", {
page.add(servicesBootOpts, {
flex: 1
});

if (osparc.utils.Resources.isStudy(resourceData)) {
if (osparc.product.Utils.showDisableServiceAutoStart()) {
const study = new osparc.data.model.Study(resourceData);
const autoStartButton = osparc.info.StudyUtils.createDisableServiceAutoStart(study);
// eslint-disable-next-line no-underscore-dangle
servicesBootOpts._add(new qx.ui.core.Spacer(null, 15));
// eslint-disable-next-line no-underscore-dangle
servicesBootOpts._add(autoStartButton);
}
}

return page;
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
},

__getRenameStudyMenuButton: function(studyData) {
const renameButton = new qx.ui.menu.Button(this.tr("Rename"));
const renameButton = new qx.ui.menu.Button(this.tr("Rename..."));
renameButton.addListener("execute", () => {
const renamer = new osparc.widget.Renamer(studyData["name"]);
renamer.addListener("labelChanged", e => {
Expand All @@ -904,7 +904,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
},

__getThumbnailStudyMenuButton: function(studyData) {
const thumbButton = new qx.ui.menu.Button(this.tr("Edit Thumbnail"));
const thumbButton = new qx.ui.menu.Button(this.tr("Edit Thumbnail..."));
thumbButton.addListener("execute", () => {
const title = this.tr("Edit Thumbnail");
const oldThumbnail = studyData.thumbnail;
Expand All @@ -914,9 +914,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
thumbnailEditor.addListener("updateThumbnail", e => {
win.close();
const validUrl = e.getData();
this.__updateStudy({
"thumbnail": validUrl
});
const studyDataCopy = osparc.data.model.Study.deepCloneStudyObject(studyData);
studyDataCopy["thumbnail"] = validUrl;
this.__updateStudy(studyDataCopy);
}, this);
thumbnailEditor.addListener("cancel", () => win.close());
}, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,36 +70,7 @@ qx.Class.define("osparc.info.StudyLarge", {

const vBox = new qx.ui.container.Composite(new qx.ui.layout.VBox(15));

const title = osparc.info.StudyUtils.createTitle(this.getStudy()).set({
font: "text-14"
});
const titleLayout = this.__createViewWithEdit(title, this.__openTitleEditor);
let text = osparc.product.Utils.getStudyAlias({firstUpperCase: true}) + " Id";
if (this.__isTemplate) {
text = osparc.product.Utils.getTemplateAlias({firstUpperCase: true}) + " Id";
}
const button = new qx.ui.form.Button(null, "@FontAwesome5Solid/copy/12").set({
label: text,
toolTipText: "Copy " + text
});
button.addListener("execute", () => osparc.utils.Utils.copyTextToClipboard(this.getStudy().getUuid()));
let autoStartButton = null;
if (osparc.product.Utils.showDisableServiceAutoStart() && this.__canIWrite()) {
autoStartButton = this.__createDisableServiceAutoStart();
}

const titleAndCopyLayout = new qx.ui.container.Composite(new qx.ui.layout.HBox(10));
titleAndCopyLayout.add(titleLayout);
titleAndCopyLayout.add(new qx.ui.core.Spacer(), {
flex: 1
});
titleAndCopyLayout.add(button);
if (autoStartButton) {
titleAndCopyLayout.add(autoStartButton);
}
// vBox.add(titleAndCopyLayout);

const mainHBox = new qx.ui.container.Composite(new qx.ui.layout.VBox(20));
const mainHBox = new qx.ui.container.Composite(new qx.ui.layout.VBox(10));

const leftVBox = new qx.ui.container.Composite(new qx.ui.layout.VBox(5));
mainHBox.add(leftVBox, {
Expand All @@ -112,8 +83,22 @@ qx.Class.define("osparc.info.StudyLarge", {
const extraInfoLayout = this.__createExtraInfo(extraInfo);
leftVBox.add(extraInfoLayout);

let text = osparc.product.Utils.getStudyAlias({firstUpperCase: true}) + " Id";
if (this.__isTemplate) {
text = osparc.product.Utils.getTemplateAlias({firstUpperCase: true}) + " Id";
}
const copyIdButton = new qx.ui.form.Button(null, "@FontAwesome5Solid/copy/12").set({
label: text,
toolTipText: "Copy " + text,
marginTop: 15,
allowGrowX: false
});
copyIdButton.addListener("execute", () => osparc.utils.Utils.copyTextToClipboard(this.getStudy().getUuid()));
leftVBox.add(copyIdButton);

const scrollContainer = new qx.ui.container.Scroll();
scrollContainer.add(vBox);

this._add(scrollContainer, {
flex: 1
});
Expand Down Expand Up @@ -253,10 +238,6 @@ qx.Class.define("osparc.info.StudyLarge", {
return thumb;
},

__createDisableServiceAutoStart: function() {
return osparc.info.StudyUtils.createDisableServiceAutoStart(this.getStudy());
},

__openTitleEditor: function() {
const title = this.tr("Edit Title");
const titleEditor = new osparc.widget.Renamer(this.getStudy().getName(), null, title);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ qx.Class.define("osparc.metadata.ServicesInStudy", {
grid.setColumnMaxWidth(this.self().GRID_POS.NAME, 160);
grid.setColumnFlex(this.self().GRID_POS.NAME, 1);
this._servicesGrid = new qx.ui.container.Composite(grid);
this._add(this._servicesGrid, {
flex: 1
});
this._add(this._servicesGrid);

this._studyData = osparc.data.model.Study.deepCloneStudyObject(studyData);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ qx.Class.define("osparc.study.StudyPreview", {
extend: qx.ui.core.Widget,

/**
* @param studyData {osparc.data.model.Study|Object} Study or Serialized Study Object
* @param studyData {Object} Serialized Study Object
*/
construct: function(studyData) {
this.base(arguments);
Expand All @@ -39,8 +39,13 @@ qx.Class.define("osparc.study.StudyPreview", {
},

__buildPreview: function() {
if (osparc.product.Utils.showStudyPreview(this.__studyData) && !this.__studyData.isPipelineEmpty()) {
this.add(new osparc.dashboard.StudyThumbnailExplorer(this.__studyData));
const study = new osparc.data.model.Study(this.__studyData);
if (osparc.product.Utils.showStudyPreview(this.__studyData) && !study.isPipelineEmpty()) {
const workbenchUIPreview = new osparc.workbench.WorkbenchUIPreview();
workbenchUIPreview.setStudy(study);
workbenchUIPreview.loadModel(study.getWorkbench());
workbenchUIPreview.setMaxHeight(600);
this._add(workbenchUIPreview);
}
}
}
Expand Down

0 comments on commit 38acfb1

Please sign in to comment.