Skip to content

Commit d0874a0

Browse files
authored
🎨 [Frontend] Aesthetics: Use Chip in PO's Review Users and Services Updates (#8069)
1 parent 342f7a7 commit d0874a0

File tree

12 files changed

+365
-363
lines changed

12 files changed

+365
-363
lines changed

services/static-webserver/client/source/class/osparc/info/MergedLarge.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,6 @@ qx.Class.define("osparc.info.MergedLarge", {
296296
},
297297

298298
__createDescription: function() {
299-
const maxHeight = 400;
300299
const descriptionLayout = new qx.ui.container.Composite(new qx.ui.layout.VBox(5).set({
301300
alignY: "middle"
302301
}));
@@ -306,7 +305,8 @@ qx.Class.define("osparc.info.MergedLarge", {
306305
});
307306
descriptionLayout.add(label);
308307

309-
const descriptionContainer = osparc.info.StudyUtils.createDescriptionMD(this.getStudy(), maxHeight);
308+
const maxHeight = 400;
309+
const descriptionContainer = osparc.info.StudyUtils.createDescription(this.getStudy(), maxHeight);
310310
descriptionLayout.add(descriptionContainer);
311311

312312
return descriptionLayout;

services/static-webserver/client/source/class/osparc/info/ServiceLarge.js

Lines changed: 100 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -96,28 +96,23 @@ qx.Class.define("osparc.info.ServiceLarge", {
9696
_rebuildLayout: function() {
9797
this._removeAll();
9898

99-
const vBox = new qx.ui.container.Composite(new qx.ui.layout.VBox(15));
99+
const vBox = new qx.ui.container.Composite(new qx.ui.layout.VBox(10));
100100

101101
const deprecated = this.__createDeprecated();
102102
if (deprecated) {
103103
vBox.add(deprecated);
104104
}
105105

106-
const description = this.__createDescription();
107-
const editInTitle = this.__createViewWithEdit(description.getChildren()[0], this.__openDescriptionEditor);
108-
description.addAt(editInTitle, 0);
109-
110106
const copyMetadataButton = new qx.ui.form.Button(this.tr("Copy Raw metadata"), "@FontAwesome5Solid/copy/12").set({
111107
allowGrowX: false
112108
});
113109
copyMetadataButton.addListener("execute", () => osparc.utils.Utils.copyTextToClipboard(osparc.utils.Utils.prettifyJson(this.getService())), this);
114110

115111
if (
116112
this.getService()["descriptionUi"] &&
117-
!osparc.service.Utils.canIWrite(this.getService()["accessRights"]) &&
118-
description.getChildren().length > 1
113+
!osparc.service.Utils.canIWrite(this.getService()["accessRights"])
119114
) {
120-
// Show also the copy Id buttons too
115+
// In case of service instance, show also the copy Id buttons too
121116
const buttonsLayout = new qx.ui.container.Composite(new qx.ui.layout.HBox(10));
122117
if (this.getNodeId()) {
123118
const studyAlias = osparc.product.Utils.getStudyAlias({firstUpperCase: true});
@@ -135,14 +130,12 @@ qx.Class.define("osparc.info.ServiceLarge", {
135130
buttonsLayout.add(copyNodeIdButton);
136131
vBox.add(buttonsLayout);
137132
}
138-
// Also copyMetadataButton if tester
139-
if (osparc.data.Permissions.getInstance().isTester()) {
140-
buttonsLayout.add(copyMetadataButton);
141-
vBox.add(buttonsLayout);
142-
}
133+
143134
// Show description only
144-
vBox.add(description.getChildren()[1]);
135+
const description = this.__createDescription();
136+
vBox.add(description);
145137
} else {
138+
// Icon and title
146139
const hBox = new qx.ui.container.Composite(new qx.ui.layout.HBox(10));
147140
const icon = this.__createIcon();
148141
const iconLayout = this.__createViewWithEdit(icon, this.__openIconEditor);
@@ -152,47 +145,28 @@ qx.Class.define("osparc.info.ServiceLarge", {
152145
hBox.add(titleLayout);
153146
vBox.add(hBox);
154147

155-
const extraInfo = this.__extraInfo();
156-
const extraInfoLayout = this.__createExtraInfo(extraInfo);
157-
const bounds = this.getBounds();
158-
const offset = 30;
159-
const maxThumbnailHeight = extraInfo.length*20;
160-
let widgetWidth = bounds ? bounds.width - offset : 500 - offset;
161-
let thumbnailWidth = widgetWidth - 2 * osparc.info.CardLarge.PADDING - osparc.info.CardLarge.EXTRA_INFO_WIDTH;
162-
thumbnailWidth = Math.min(thumbnailWidth - 20, osparc.info.CardLarge.THUMBNAIL_MAX_WIDTH);
163-
const thumbnail = this.__createThumbnail(thumbnailWidth, maxThumbnailHeight);
164-
const thumbnailLayout = this.__createViewWithEdit(thumbnail, this.__openThumbnailEditor);
165-
thumbnailLayout.getLayout().set({
166-
alignX: "center"
167-
});
168-
const infoAndThumbnail = new qx.ui.container.Composite(new qx.ui.layout.HBox(3).set({
169-
alignX: "center"
170-
}));
171-
infoAndThumbnail.add(extraInfoLayout);
172-
infoAndThumbnail.add(thumbnailLayout, {
173-
flex: 1
174-
});
175-
vBox.add(infoAndThumbnail);
176-
177-
if (osparc.service.Utils.canIWrite(this.getService()["accessRights"])) {
178-
const descriptionUi = this.__createDescriptionUi();
179-
if (descriptionUi) {
180-
vBox.add(descriptionUi);
181-
}
182-
}
183-
vBox.add(description);
148+
// Rest of information
149+
const infoElements = this.__infoElements();
150+
const isStudy = false;
151+
const infoLayout = osparc.info.Utils.infoElementsToLayout(infoElements, isStudy);
152+
vBox.add(infoLayout);
184153

154+
// Resources info if not billable
185155
if (!osparc.desktop.credits.Utils.areWalletsEnabled()) {
186156
const resources = this.__createResources();
187157
if (resources) {
188158
vBox.add(resources);
189159
}
190160
}
191-
vBox.add(copyMetadataButton);
192161
}
193162

163+
// Copy metadata button
164+
vBox.add(copyMetadataButton);
165+
166+
// All in a scroll container
194167
const scrollContainer = new qx.ui.container.Scroll();
195168
scrollContainer.add(vBox);
169+
196170
this._add(scrollContainer, {
197171
flex: 1
198172
});
@@ -246,77 +220,99 @@ qx.Class.define("osparc.info.ServiceLarge", {
246220
return title;
247221
},
248222

249-
__extraInfo: function() {
250-
const extraInfo = [];
223+
__infoElements: function() {
224+
const canIWrite = osparc.service.Utils.canIWrite(this.getService()["accessRights"]);
225+
226+
const infoLayout = {
227+
"THUMBNAIL": {
228+
view: this.__createThumbnail(),
229+
action: {
230+
button: osparc.utils.Utils.getEditButton(canIWrite),
231+
callback: canIWrite ? this.__openThumbnailEditor : null,
232+
ctx: this,
233+
},
234+
},
235+
"KEY": {
236+
label: this.tr("Key"),
237+
view: this.__createKey(),
238+
action: {
239+
button: osparc.utils.Utils.getCopyButton(),
240+
callback: this.__copyKeyToClipboard,
241+
ctx: this,
242+
},
243+
},
244+
"VERSION": {
245+
label: this.tr("Version"),
246+
view: this.__createDisplayVersion(),
247+
action: {
248+
button: canIWrite ? osparc.utils.Utils.getEditButton() : null,
249+
callback: this.__openVersionDisplayEditor,
250+
ctx: this,
251+
},
252+
},
253+
"DATE": {
254+
label: this.tr("Released Date"),
255+
view: this.__createReleasedDate(),
256+
action: null,
257+
},
258+
"CONTACT": {
259+
label: this.tr("Contact"),
260+
view: this.__createContact(),
261+
action: null,
262+
},
263+
"AUTHORS": {
264+
label: this.tr("Authors"),
265+
view: this.__createAuthors(),
266+
action: null,
267+
},
268+
"ACCESS_RIGHTS": {
269+
label: this.tr("Access"),
270+
view: this.__createAccessRights(),
271+
action: {
272+
button: canIWrite ? osparc.utils.Utils.getEditButton() : null,
273+
callback: this.isOpenOptions() ? this.__openAccessRights : "openAccessRights",
274+
ctx: this,
275+
},
276+
},
277+
"DESCRIPTION": {
278+
view: this.__createDescription(),
279+
action: {
280+
button: osparc.utils.Utils.getEditButton(canIWrite),
281+
callback: canIWrite ? this.__openDescriptionEditor : null,
282+
ctx: this,
283+
},
284+
},
285+
};
251286

252287
if (this.getNodeId()) {
253-
extraInfo.push({
254-
label: this.tr("SERVICE ID"),
288+
infoLayout["SERVICE_ID"] = {
289+
label: this.tr("Service ID"),
255290
view: this.__createNodeId(),
256291
action: {
257292
button: osparc.utils.Utils.getCopyButton(),
258293
callback: this.__copyNodeIdToClipboard,
259294
ctx: this
260-
}
261-
});
295+
},
296+
};
262297
}
263298

264-
extraInfo.push({
265-
label: this.tr("Key"),
266-
view: this.__createKey(),
267-
action: {
268-
button: osparc.utils.Utils.getCopyButton(),
269-
callback: this.__copyKeyToClipboard,
270-
ctx: this
271-
}
272-
});
273-
274-
if (osparc.data.Permissions.getInstance().isTester() || osparc.service.Utils.canIWrite(this.getService()["accessRights"])) {
275-
extraInfo.push({
299+
if (osparc.data.Permissions.getInstance().isTester() || canIWrite) {
300+
infoLayout["INTEGRATION_VERSION"] = {
276301
label: this.tr("Integration Version"),
277302
view: this.__createIntegrationVersion(),
278-
action: null
279-
});
303+
action: null,
304+
};
280305
}
281306

282-
extraInfo.push({
283-
label: this.tr("Version"),
284-
view: this.__createDisplayVersion(),
285-
action: {
286-
button: osparc.service.Utils.canIWrite(this.getService()["accessRights"]) ? osparc.utils.Utils.getEditButton() : null,
287-
callback: this.__openVersionDisplayEditor,
288-
ctx: this
289-
}
290-
}, {
291-
label: this.tr("Released Date"),
292-
view: this.__createReleasedDate(),
293-
action: null
294-
}, {
295-
label: this.tr("Contact"),
296-
view: this.__createContact(),
297-
action: null
298-
}, {
299-
label: this.tr("Authors"),
300-
view: this.__createAuthors(),
301-
action: null
302-
}, {
303-
label: this.tr("Access"),
304-
view: this.__createAccessRights(),
305-
action: {
306-
button: osparc.service.Utils.canIWrite(this.getService()["accessRights"]) ? osparc.utils.Utils.getEditButton() : null,
307-
callback: this.isOpenOptions() ? this.__openAccessRights : "openAccessRights",
308-
ctx: this
309-
}
310-
});
311-
312-
return extraInfo;
313-
},
307+
if (canIWrite) {
308+
infoLayout["DESCRIPTION_ONLY"] = {
309+
label: this.tr("Description only"),
310+
view: this.__createDescriptionUi(),
311+
action: null,
312+
};
313+
}
314314

315-
__createExtraInfo: function(extraInfo) {
316-
const moreInfo = osparc.info.Utils.extraInfosToGrid(extraInfo).set({
317-
width: osparc.info.CardLarge.EXTRA_INFO_WIDTH
318-
});
319-
return moreInfo;
315+
return infoLayout;
320316
},
321317

322318
__createNodeId: function() {
@@ -351,15 +347,9 @@ qx.Class.define("osparc.info.ServiceLarge", {
351347
return osparc.info.ServiceUtils.createAccessRights(this.getService());
352348
},
353349

354-
__createClassifiers: function() {
355-
return osparc.info.ServiceUtils.createClassifiers(this.getService());
356-
},
357-
358-
__createQuality: function() {
359-
return osparc.info.ServiceUtils.createQuality(this.getService());
360-
},
361-
362-
__createThumbnail: function(maxWidth, maxHeight = 160) {
350+
__createThumbnail: function() {
351+
let maxWidth = 190;
352+
let maxHeight = 220;
363353
// make sure maxs are not larger than the mins
364354
const minWidth = Math.max(120, maxWidth);
365355
const minHeight = Math.max(139, maxHeight);
@@ -387,9 +377,7 @@ qx.Class.define("osparc.info.ServiceLarge", {
387377

388378
__createDescriptionUi: function() {
389379
const cbAutoPorts = new qx.ui.form.CheckBox().set({
390-
label: this.tr("Show Description only"),
391380
toolTipText: this.tr("From all the metadata shown in this view,\nonly the Description will be shown to Users."),
392-
iconPosition: "right",
393381
});
394382
cbAutoPorts.setValue(Boolean(this.getService()["descriptionUi"]));
395383
cbAutoPorts.addListener("changeValue", e => {
@@ -476,33 +464,6 @@ qx.Class.define("osparc.info.ServiceLarge", {
476464
}, this);
477465
},
478466

479-
__openClassifiers: function() {
480-
const title = this.tr("Classifiers");
481-
let classifiers = null;
482-
if (osparc.service.Utils.canIWrite(this.getService()["accessRights"])) {
483-
classifiers = new osparc.metadata.ClassifiersEditor(this.getService());
484-
const win = osparc.ui.window.Window.popUpInWindow(classifiers, title, 400, 400);
485-
classifiers.addListener("updateClassifiers", e => {
486-
win.close();
487-
const updatedServiceData = e.getData();
488-
this.setService(updatedServiceData);
489-
this.fireDataEvent("updateService", updatedServiceData);
490-
}, this);
491-
} else {
492-
classifiers = new osparc.metadata.ClassifiersViewer(this.getService());
493-
osparc.ui.window.Window.popUpInWindow(classifiers, title, 400, 400);
494-
}
495-
},
496-
497-
__openQuality: function() {
498-
const qualityEditor = osparc.info.ServiceUtils.openQuality(this.getService());
499-
qualityEditor.addListener("updateQuality", e => {
500-
const updatedServiceData = e.getData();
501-
this.setService(updatedServiceData);
502-
this.fireDataEvent("updateService", updatedServiceData);
503-
});
504-
},
505-
506467
__openThumbnailEditor: function() {
507468
const title = this.tr("Edit Thumbnail");
508469
const thumbnailEditor = new osparc.editor.ThumbnailEditor(this.getService()["thumbnail"]);

services/static-webserver/client/source/class/osparc/info/ServiceUtils.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ qx.Class.define("osparc.info.ServiceUtils", {
2020
type: "static",
2121

2222
statics: {
23+
RESOURCES_INFO: {
24+
"limit": {
25+
label: qx.locale.Manager.tr("Limit"),
26+
tooltip: qx.locale.Manager.tr("Runtime check:<br>The service can consume a maximum of 'limit' resources - if it attempts to use more resources than this limit, it will be stopped")
27+
}
28+
},
29+
2330
/**
2431
* @param label {String} label
2532
*/
@@ -168,13 +175,8 @@ qx.Class.define("osparc.info.ServiceUtils", {
168175

169176
/**
170177
* @param serviceData {Object} Serialized Service Object
171-
* @param maxHeight {Number} description's maxHeight
172178
*/
173179
createDescription: function(serviceData) {
174-
const descriptionLayout = new qx.ui.container.Composite(new qx.ui.layout.VBox().set({
175-
alignY: "middle"
176-
}));
177-
178180
const description = new osparc.ui.markdown.Markdown();
179181
// display markdown link content if that's the case
180182
if (
@@ -197,16 +199,10 @@ qx.Class.define("osparc.info.ServiceUtils", {
197199
} else {
198200
description.setValue(this.tr("No description"));
199201
}
200-
descriptionLayout.add(description);
201-
202-
return descriptionLayout;
203-
},
202+
const scrollContainer = new qx.ui.container.Scroll();
203+
scrollContainer.add(description);
204204

205-
RESOURCES_INFO: {
206-
"limit": {
207-
label: qx.locale.Manager.tr("Limit"),
208-
tooltip: qx.locale.Manager.tr("Runtime check:<br>The service can consume a maximum of 'limit' resources - if it attempts to use more resources than this limit, it will be stopped")
209-
}
205+
return scrollContainer;
210206
},
211207

212208
createResourcesInfo: function() {

0 commit comments

Comments
 (0)