Skip to content

Commit 6eb8bc8

Browse files
Merge branch 'changing-wallet-after-running-out-of-credits' of github.com:matusdrobuliak66/osparc-simcore into changing-wallet-after-running-out-of-credits
2 parents 2e56581 + 537e44d commit 6eb8bc8

File tree

13 files changed

+321
-52
lines changed

13 files changed

+321
-52
lines changed

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

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,27 +151,27 @@ qx.Class.define("osparc.dashboard.CardBase", {
151151
populateShareIcon: function(shareIcon, accessRights) {
152152
const gids = Object.keys(accessRights).map(key => parseInt(key));
153153

154-
const groupsStore = osparc.store.Groups.getInstance();
155-
156154
// Icon
155+
const groupsStore = osparc.store.Groups.getInstance();
157156
const groupEveryone = groupsStore.getEveryoneGroup();
158157
const groupProductEveryone = groupsStore.getEveryoneProductGroup();
159158
const organizations = groupsStore.getOrganizations();
159+
const myGroupId = groupsStore.getMyGroupId();
160+
160161
const organizationIds = Object.keys(organizations).map(key => parseInt(key));
161162
if (gids.includes(groupEveryone.getGroupId()) || gids.includes(groupProductEveryone.getGroupId())) {
162163
shareIcon.setSource(osparc.dashboard.CardBase.SHARED_ALL);
163164
} else if (organizationIds.filter(value => gids.includes(value)).length) { // find intersection
164165
shareIcon.setSource(osparc.dashboard.CardBase.SHARED_ORGS);
165-
} else if (gids.length === 1) {
166+
} else if (gids.length === 1 && gids[0] === myGroupId) {
166167
shareIcon.setSource(osparc.dashboard.CardBase.SHARE_ICON);
167168
} else {
168169
shareIcon.setSource(osparc.dashboard.CardBase.SHARED_USER);
169170
}
170171

171172
// Tooltip
172-
const canIWrite = osparc.data.model.Study.canIWrite(accessRights);
173-
const myGroupId = groupsStore.getMyGroupId();
174173
if (gids.length === 0 || (gids.length === 1 && gids[0] === myGroupId)) {
174+
const canIWrite = osparc.data.model.Study.canIWrite(accessRights);
175175
if (canIWrite) {
176176
shareIcon.set({
177177
toolTipText: qx.locale.Manager.tr("Share")
@@ -180,6 +180,16 @@ qx.Class.define("osparc.dashboard.CardBase", {
180180
return;
181181
}
182182

183+
this.addHintFromGids(shareIcon, gids);
184+
},
185+
186+
addHintFromGids: function(icon, gids) {
187+
const groupsStore = osparc.store.Groups.getInstance();
188+
const groupEveryone = groupsStore.getEveryoneGroup();
189+
const groupProductEveryone = groupsStore.getEveryoneProductGroup();
190+
const organizations = groupsStore.getOrganizations();
191+
const myGroupId = groupsStore.getMyGroupId();
192+
183193
const sharedGrps = [];
184194
const groups = [];
185195
groups.push(groupEveryone);
@@ -193,8 +203,8 @@ qx.Class.define("osparc.dashboard.CardBase", {
193203
}
194204
});
195205

196-
const hint = new osparc.ui.hint.Hint(shareIcon);
197-
shareIcon.addListener("mouseover", async () => {
206+
const hint = new osparc.ui.hint.Hint(icon);
207+
icon.addListener("mouseover", async () => {
198208
hint.show();
199209

200210
// lazy load tooltip, this can be an expensive call
@@ -230,7 +240,7 @@ qx.Class.define("osparc.dashboard.CardBase", {
230240
}
231241
}
232242
}, this);
233-
shareIcon.addListener("mouseout", () => hint.exclude(), this);
243+
icon.addListener("mouseout", () => hint.exclude(), this);
234244
},
235245
},
236246

@@ -308,6 +318,18 @@ qx.Class.define("osparc.dashboard.CardBase", {
308318
nullable: true
309319
},
310320

321+
trashedAt: {
322+
check: "Date",
323+
apply: "_applyTrasehdAt",
324+
nullable: true
325+
},
326+
327+
trashedBy: {
328+
check: "Number",
329+
apply: "_applyTrashedBy",
330+
nullable: true
331+
},
332+
311333
classifiers: {
312334
check: "Array"
313335
},
@@ -457,6 +479,8 @@ qx.Class.define("osparc.dashboard.CardBase", {
457479
owner,
458480
accessRights: resourceData.accessRights ? resourceData.accessRights : {},
459481
lastChangeDate: resourceData.lastChangeDate ? new Date(resourceData.lastChangeDate) : null,
482+
trashedAt: resourceData.trashedAt ? new Date(resourceData.trashedAt) : null,
483+
trashedBy: resourceData.trashedBy || null,
460484
icon: resourceData.thumbnail || this.self().PRODUCT_ICON,
461485
state: resourceData.state ? resourceData.state : {},
462486
classifiers: resourceData.classifiers && resourceData.classifiers ? resourceData.classifiers : [],
@@ -523,6 +547,14 @@ qx.Class.define("osparc.dashboard.CardBase", {
523547
throw new Error("Abstract method called!");
524548
},
525549

550+
_applyTrasehdAt: function(value, old) {
551+
throw new Error("Abstract method called!");
552+
},
553+
554+
_applyTrashedBy: function(value, old) {
555+
throw new Error("Abstract method called!");
556+
},
557+
526558
_applyAccessRights: function(value, old) {
527559
throw new Error("Abstract method called!");
528560
},

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

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,18 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
9090
nullable: true,
9191
apply: "__applyLastModified"
9292
},
93+
94+
trashedAt: {
95+
check: "Date",
96+
nullable: true,
97+
apply: "__applyTrashedAt"
98+
},
99+
100+
trashedBy: {
101+
check: "Number",
102+
nullable: true,
103+
apply: "__applyTrashedBy"
104+
},
93105
},
94106

95107
members: {
@@ -107,16 +119,12 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
107119
}
108120
case "title":
109121
control = new qx.ui.basic.Label().set({
110-
anonymous: true,
111122
font: "text-14",
112123
});
113124
this._add(control, osparc.dashboard.FolderButtonBase.POS.TITLE);
114125
break;
115-
case "last-modified":
116-
control = new qx.ui.basic.Label().set({
117-
anonymous: true,
118-
font: "text-12",
119-
});
126+
case "date-by":
127+
control = new osparc.ui.basic.DateAndBy();
120128
this._add(control, osparc.dashboard.FolderButtonBase.POS.SUBTITLE);
121129
break;
122130
case "menu-button": {
@@ -150,6 +158,8 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
150158
folder.bind("parentFolderId", this, "parentFolderId");
151159
folder.bind("name", this, "title");
152160
folder.bind("lastModified", this, "lastModified");
161+
folder.bind("trashedAt", this, "trashedAt");
162+
folder.bind("trashedBy", this, "trashedBy");
153163

154164
osparc.utils.Utils.setIdToWidget(this, "folderItem_" + folder.getFolderId());
155165

@@ -222,15 +232,36 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
222232

223233
__applyTitle: function(value) {
224234
const label = this.getChildControl("title");
225-
label.setValue(value);
226-
227-
this.setToolTipText(value);
235+
label.set({
236+
value,
237+
toolTipText: value,
238+
});
228239
},
229240

230241
__applyLastModified: function(value) {
231242
if (value) {
232-
const label = this.getChildControl("last-modified");
233-
label.setValue(osparc.utils.Utils.formatDateAndTime(value));
243+
const dateBy = this.getChildControl("date-by");
244+
dateBy.set({
245+
date: value,
246+
toolTipText: this.tr("Last modified"),
247+
})
248+
}
249+
},
250+
251+
__applyTrashedAt: function(value) {
252+
if (value && value.getTime() !== new Date(0).getTime()) {
253+
const dateBy = this.getChildControl("date-by");
254+
dateBy.set({
255+
date: value,
256+
toolTipText: this.tr("Moved to the bin"),
257+
});
258+
}
259+
},
260+
261+
__applyTrashedBy: function(gid) {
262+
if (gid) {
263+
const dateBy = this.getChildControl("date-by");
264+
dateBy.setGroupid(gid);
234265
}
235266
},
236267

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,8 @@ qx.Class.define("osparc.dashboard.GridButtonBase", {
251251
layout.add(control, {flex: 1});
252252
break;
253253
}
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-
});
254+
case "date-by":
255+
control = new osparc.ui.basic.DateAndBy();
263256
layout = this.getChildControl("footer");
264257
layout.add(control, this.self().FPOS.MODIFIED);
265258
break;

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

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,37 @@ qx.Class.define("osparc.dashboard.GridButtonItem", {
176176

177177
// overridden
178178
_applyLastChangeDate: function(value, old) {
179-
if (value && (this.isResourceType("study") || this.isResourceType("template"))) {
180-
const label = this.getChildControl("modified-text");
181-
label.setValue(osparc.utils.Utils.formatDateAndTime(value));
179+
if (value) {
180+
if (this.isResourceType("study") || this.isResourceType("template")) {
181+
const dateBy = this.getChildControl("date-by");
182+
dateBy.set({
183+
date: value,
184+
toolTipText: this.tr("Last modified"),
185+
});
186+
}
187+
}
188+
},
189+
190+
// overridden
191+
_applyTrasehdAt: function(value) {
192+
if (value && value.getTime() !== new Date(0).getTime()) {
193+
if (this.isResourceType("study") || this.isResourceType("template")) {
194+
const dateBy = this.getChildControl("date-by");
195+
dateBy.set({
196+
date: value,
197+
toolTipText: this.tr("Moved to the bin"),
198+
});
199+
}
200+
}
201+
},
202+
203+
// overridden
204+
_applyTrashedBy: function(gid) {
205+
if (gid) {
206+
if (this.isResourceType("study") || this.isResourceType("template")) {
207+
const dateBy = this.getChildControl("date-by");
208+
dateBy.setGroupId(gid);
209+
}
182210
}
183211
},
184212

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

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,8 @@ qx.Class.define("osparc.dashboard.ListButtonItem", {
6868
column: osparc.dashboard.ListButtonBase.POS.SHARED
6969
});
7070
break;
71-
case "last-change":
71+
case "date-text":
7272
control = new qx.ui.basic.Label().set({
73-
anonymous: true,
7473
font: "text-13",
7574
allowGrowY: false,
7675
minWidth: 120,
@@ -191,10 +190,39 @@ qx.Class.define("osparc.dashboard.ListButtonItem", {
191190
return control || this.base(arguments, id);
192191
},
193192

193+
// overridden
194194
_applyLastChangeDate: function(value, old) {
195195
if (value) {
196-
const label = this.getChildControl("last-change");
197-
label.setValue(osparc.utils.Utils.formatDateAndTime(value));
196+
if (this.isResourceType("study") || this.isResourceType("template")) {
197+
const dateBy = this.getChildControl("date-by");
198+
dateBy.set({
199+
date: value,
200+
toolTipText: this.tr("Last modified"),
201+
});
202+
}
203+
}
204+
},
205+
206+
// overridden
207+
_applyTrasehdAt: function(value) {
208+
if (value && value.getTime() !== new Date(0).getTime()) {
209+
if (this.isResourceType("study") || this.isResourceType("template")) {
210+
const dateBy = this.getChildControl("date-by");
211+
dateBy.set({
212+
date: value,
213+
toolTipText: this.tr("Moved to the bin"),
214+
});
215+
}
216+
}
217+
},
218+
219+
// overridden
220+
_applyTrashedBy: function(gid) {
221+
if (gid) {
222+
if (this.isResourceType("study") || this.isResourceType("template")) {
223+
const dateBy = this.getChildControl("date-by");
224+
dateBy.setGroupId(gid);
225+
}
198226
}
199227
},
200228

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonBase", {
9090
MENU: 2,
9191
},
9292
FPOS: {
93-
MODIFIED: 0
93+
DATE: 0,
9494
}
9595
},
9696

0 commit comments

Comments
 (0)