Skip to content

Commit f0ead1b

Browse files
authored
✨ Sort studies (#5393)
1 parent d4aeeab commit f0ead1b

File tree

11 files changed

+334
-54
lines changed

11 files changed

+334
-54
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,9 @@ qx.Class.define("osparc.dashboard.CardBase", {
417417
const uiModeIcon = this.getChildControl("workbench-mode");
418418
uiModeIcon.set({
419419
source,
420-
toolTipText
420+
toolTipText,
421+
alignY: "bottom",
422+
marginBottom: 10
421423
});
422424
}
423425
},

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

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,22 @@ qx.Class.define("osparc.dashboard.GridButtonBase", {
109109
}
110110
},
111111
FPOS: {
112-
TITLE: {
112+
STATUS: {
113113
row: 0,
114114
column: 0,
115115
rowSpan: 1,
116-
colSpan: 3
116+
colSpan: 4
117117
},
118-
STATUS: {
118+
MODIFIED: {
119119
row: 1,
120120
column: 0,
121121
rowSpan: 1,
122-
colSpan: 4
122+
colSpan: 3
123+
},
124+
UPDATES: {
125+
row: 1,
126+
column: 4,
127+
colSpan: 1
123128
},
124129
TSR: {
125130
row: 3,
@@ -130,11 +135,6 @@ qx.Class.define("osparc.dashboard.GridButtonBase", {
130135
row: 3,
131136
column: 2,
132137
colSpan: 1
133-
},
134-
UPDATES: {
135-
row: 0,
136-
column: 4,
137-
colSpan: 1
138138
}
139139
}
140140
},
@@ -180,7 +180,7 @@ qx.Class.define("osparc.dashboard.GridButtonBase", {
180180
this._mainLayout.add(control, this.self().POS.THUMBNAIL);
181181
break;
182182
case "title-row":
183-
control = new qx.ui.container.Composite(new qx.ui.layout.HBox(6)).set({
183+
control = new qx.ui.container.Composite(new qx.ui.layout.VBox(6)).set({
184184
anonymous: true
185185
});
186186
layout = this.getChildControl("header");
@@ -191,7 +191,7 @@ qx.Class.define("osparc.dashboard.GridButtonBase", {
191191
case "title":
192192
control = new qx.ui.basic.Label().set({
193193
textColor: "contrasted-text-light",
194-
font: "text-16",
194+
font: "text-14",
195195
maxWidth: this.self().ITEM_WIDTH,
196196
maxHeight: this.self().TITLE_MAX_HEIGHT,
197197
rich: true,
@@ -206,7 +206,10 @@ qx.Class.define("osparc.dashboard.GridButtonBase", {
206206
control = new qx.ui.container.Composite(new qx.ui.layout.HBox(6)).set({
207207
anonymous: true
208208
});
209-
this._footerLayout.add(control, this.self().FPOS.TITLE);
209+
layout = this.getChildControl("title-row");
210+
layout.addAt(control, 1, {
211+
flex: 1
212+
});
210213
break;
211214
case "subtitle-icon": {
212215
control = new qx.ui.basic.Image().set({
@@ -248,6 +251,18 @@ qx.Class.define("osparc.dashboard.GridButtonBase", {
248251
layout.add(control, {flex: 1});
249252
break;
250253
}
254+
case "modified-text": {
255+
control = new qx.ui.basic.Label().set({
256+
textColor: "contrasted-text-dark",
257+
alignY: "middle",
258+
rich: true,
259+
anonymous: true,
260+
font: "text-12",
261+
allowGrowY: false
262+
});
263+
this._footerLayout.add(control, this.self().FPOS.MODIFIED);
264+
break;
265+
}
251266
case "project-status":
252267
control = new qx.ui.container.Composite(new qx.ui.layout.HBox(6)).set({
253268
anonymous: true

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,21 +209,25 @@ qx.Class.define("osparc.dashboard.GridButtonItem", {
209209
// overridden
210210
_applyLastChangeDate: function(value, old) {
211211
if (value && (this.isResourceType("study") || this.isResourceType("template"))) {
212-
const label = this.getChildControl("subtitle-text");
212+
const label = this.getChildControl("modified-text");
213213
label.setValue(osparc.utils.Utils.formatDateAndTime(value));
214214
}
215215
},
216216

217+
createOwner: function(label) {
218+
const resourceType = this.getResourceType() === "study" ? "project" : this.getResourceType();
219+
if (label === osparc.auth.Data.getInstance().getEmail()) {
220+
return qx.locale.Manager.tr(`My ${resourceType}`);
221+
}
222+
return osparc.utils.Utils.getNameFromEmail(label);
223+
},
224+
217225
// overridden
218226
_applyOwner: function(value, old) {
219-
if (this.isResourceType("service")) {
220-
const label = this.getChildControl("subtitle-text");
221-
if (value === osparc.auth.Data.getInstance().getEmail()) {
222-
label.setValue(this.tr("me"));
223-
} else {
224-
label.setValue(value);
225-
}
226-
}
227+
const label = this.getChildControl("subtitle-text");
228+
const user = this.createOwner(value);
229+
label.setValue(user);
230+
label.setVisibility(value ? "visible" : "excluded");
227231
},
228232

229233
_applyAccessRights: function(value) {

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

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,11 @@ qx.Class.define("osparc.dashboard.ListButtonBase", {
5454
STATUS: 7,
5555
PERMISSION: 8,
5656
TSR: 9,
57-
SHARED: 10,
58-
LAST_CHANGE: 11,
59-
HITS: 12,
60-
OPTIONS: 13
57+
OWNER: 10,
58+
SHARED: 11,
59+
LAST_CHANGE: 12,
60+
HITS: 13,
61+
OPTIONS: 14
6162
}
6263
},
6364

@@ -72,7 +73,8 @@ qx.Class.define("osparc.dashboard.ListButtonBase", {
7273
minWidth: 40
7374
});
7475
control.getChildControl("image").set({
75-
anonymous: true
76+
anonymous: true,
77+
decorator: "rounded"
7678
});
7779
this._add(control, {
7880
row: 0,
@@ -82,7 +84,8 @@ qx.Class.define("osparc.dashboard.ListButtonBase", {
8284
}
8385
case "title-row":
8486
control = new qx.ui.container.Composite(new qx.ui.layout.HBox(6)).set({
85-
anonymous: true
87+
anonymous: true,
88+
allowGrowX: true
8689
});
8790
this._add(control, {
8891
row: 0,
@@ -94,9 +97,9 @@ qx.Class.define("osparc.dashboard.ListButtonBase", {
9497
textColor: "contrasted-text-light",
9598
font: "text-14",
9699
alignY: "middle",
97-
maxWidth: 400,
98-
maxHeight: 19,
99-
rich: true
100+
maxWidth: 300,
101+
allowGrowX: true,
102+
rich: true,
100103
});
101104
titleRow = this.getChildControl("title-row");
102105
titleRow.addAt(control, 0, {
@@ -118,23 +121,26 @@ qx.Class.define("osparc.dashboard.ListButtonBase", {
118121
column: osparc.dashboard.ListButtonBase.POS.DESCRIPTION
119122
});
120123
break;
121-
case "description-md":
122-
control = new osparc.ui.markdown.Markdown().set({
123-
maxHeight: 16,
124+
case "owner":
125+
control = new qx.ui.basic.Label().set({
126+
textColor: "contrasted-text-dark",
127+
font: "text-12",
124128
alignY: "middle",
125129
allowGrowX: true
126130
});
127131
this._add(control, {
128132
row: 0,
129-
column: osparc.dashboard.ListButtonBase.POS.DESCRIPTION
133+
column: osparc.dashboard.ListButtonBase.POS.OWNER
130134
});
131135
break;
132136
case "project-status":
133137
control = new qx.ui.container.Composite(new qx.ui.layout.HBox(6)).set({
134138
anonymous: true
135139
});
136-
titleRow = this.getChildControl("title-row");
137-
titleRow.add(control);
140+
this._add(control, {
141+
row: 0,
142+
column: osparc.dashboard.ListButtonBase.POS.STATUS
143+
});
138144
break;
139145
case "project-status-icon":
140146
control = new qx.ui.basic.Image().set({
@@ -180,8 +186,7 @@ qx.Class.define("osparc.dashboard.ListButtonBase", {
180186
},
181187

182188
_applyDescription: function(value, old) {
183-
const label = this.getChildControl("description-md");
184-
label.setValue(value);
189+
return
185190
}
186191
},
187192

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ qx.Class.define("osparc.dashboard.ListButtonItem", {
6464
alignY: "middle"
6565
})).set({
6666
anonymous: true,
67-
maxWidth: 100
6867
});
6968
this._add(control, {
7069
row: 0,
@@ -209,8 +208,18 @@ qx.Class.define("osparc.dashboard.ListButtonItem", {
209208
}
210209
},
211210

212-
// overridden
211+
createOwner: function(label) {
212+
if (label === osparc.auth.Data.getInstance().getEmail()) {
213+
return qx.locale.Manager.tr("My project");
214+
}
215+
return osparc.utils.Utils.getNameFromEmail(label);
216+
},
217+
213218
_applyOwner: function(value, old) {
219+
const label = this.getChildControl("owner");
220+
const user = this.createOwner(value);
221+
label.setValue(user);
222+
label.setVisibility(value ? "visible" : "excluded");
214223
return;
215224
},
216225

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,24 +106,26 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
106106
}
107107
},
108108

109-
sortStudyList: function(studyList) {
109+
sortStudyList: function(studyList, sortValue) {
110110
const sortByProperty = function(prop) {
111111
return function(a, b) {
112+
const x = a.toString().toLowerCase();
113+
const y = b.toString().toLowerCase();
112114
if (prop === "lastChangeDate") {
113-
return new Date(b[prop]) - new Date(a[prop]);
115+
return new Date(y[prop]) - new Date(x[prop]);
114116
}
115-
if (typeof a[prop] == "number") {
116-
return a[prop] - b[prop];
117+
if (typeof x[prop] == "number") {
118+
return x[prop] - y[prop];
117119
}
118-
if (a[prop] < b[prop]) {
120+
if (x[prop] < y[prop]) {
119121
return -1;
120-
} else if (a[prop] > b[prop]) {
122+
} else if (x[prop] > y[prop]) {
121123
return 1;
122124
}
123125
return 0;
124126
};
125127
};
126-
studyList.sort(sortByProperty("lastChangeDate"));
128+
studyList.sort(sortByProperty(sortValue || "name"));
127129
},
128130

129131
isCardNewItem: function(card) {

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", {
7272
sortList: function(list) {
7373
list.getChildren().sort((a, b) => {
7474
let sortingValue = a.getPriority() - b.getPriority();
75-
if (sortingValue === 0 && a.isPropertyInitialized("lastChangeDate") && b.isPropertyInitialized("lastChangeDate")) {
76-
return b.get("lastChangeDate") - a.get("lastChangeDate");
77-
}
7875
return sortingValue;
7976
});
8077
},

0 commit comments

Comments
 (0)