Skip to content

Commit af4e55c

Browse files
committed
__showWhoIsIn dynamic
1 parent ebf8d67 commit af4e55c

File tree

3 files changed

+24
-42
lines changed

3 files changed

+24
-42
lines changed

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

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -775,8 +775,10 @@ qx.Class.define("osparc.dashboard.CardBase", {
775775
}
776776

777777
if (osparc.utils.DisabledPlugins.isSimultaneousAccessEnabled()) {
778-
if (projectInUse && "OPENED" === state["locked"]["status"]) {
778+
if (projectInUse && state["locked"]["status"] === "OPENED") {
779779
this.__showWhoIsIn(state["locked"]["owner"]);
780+
} else {
781+
this.__showWhoIsIn(null);
780782
}
781783
} else {
782784
this.setBlocked(projectInUse ? "IN_USE" : false);
@@ -863,9 +865,27 @@ qx.Class.define("osparc.dashboard.CardBase", {
863865
},
864866

865867
__showWhoIsIn: function(whoIsIn) {
866-
this.set({
867-
toolTipText: String(whoIsIn["user_id"])
868-
});
868+
let users = [];
869+
if (whoIsIn) {
870+
// remove this, testing purposes
871+
const allUsers = [
872+
{ name: "Alice", avatar: "https://i.pravatar.cc/150?img=1" },
873+
{ name: "Bob", avatar: "https://i.pravatar.cc/150?img=2" },
874+
{ name: "Charlie", avatar: "https://i.pravatar.cc/150?img=3" },
875+
{ name: "Dana", avatar: "https://i.pravatar.cc/150?img=4" },
876+
{ name: "Eve", avatar: "https://i.pravatar.cc/150?img=5" },
877+
{ name: "Frank", avatar: "https://i.pravatar.cc/150?img=6" },
878+
];
879+
// Random number of users between 1 and 6
880+
const randomCount = Math.floor(Math.random() * 6) + 1;
881+
// Shuffle the array and take the first randomCount users
882+
const shuffled = allUsers.sort(() => 0.5 - Math.random());
883+
users = shuffled.slice(0, randomCount);
884+
}
885+
if (osparc.utils.DisabledPlugins.isSimultaneousAccessEnabled() && this.getResourceType() === "study") {
886+
const avatarGroup = this.getChildControl("avatar-group");
887+
avatarGroup.setUsers(users);
888+
}
869889
},
870890

871891

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -251,25 +251,6 @@ qx.Class.define("osparc.dashboard.GridButtonItem", {
251251
const user = this.__createOwner(value);
252252
label.setValue(user);
253253
label.setVisibility(value ? "visible" : "excluded");
254-
255-
// remove this, testing purposes
256-
if (osparc.utils.DisabledPlugins.isSimultaneousAccessEnabled() && this.getResourceType() === "study") {
257-
const avatarGroup = this.getChildControl("avatar-group");
258-
const allUsers = [
259-
{ name: "Alice", avatar: "https://i.pravatar.cc/150?img=1" },
260-
{ name: "Bob", avatar: "https://i.pravatar.cc/150?img=2" },
261-
{ name: "Charlie", avatar: "https://i.pravatar.cc/150?img=3" },
262-
{ name: "Dana", avatar: "https://i.pravatar.cc/150?img=4" },
263-
{ name: "Eve", avatar: "https://i.pravatar.cc/150?img=5" },
264-
{ name: "Frank", avatar: "https://i.pravatar.cc/150?img=6" },
265-
];
266-
// Random number of users between 1 and 6
267-
const randomCount = Math.floor(Math.random() * 6) + 1;
268-
// Shuffle the array and take the first randomCount users
269-
const shuffled = allUsers.sort(() => 0.5 - Math.random());
270-
const randomUsers = shuffled.slice(0, randomCount);
271-
avatarGroup.setUsers(randomUsers);
272-
}
273254
},
274255

275256
_applyAccessRights: function(value) {

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -246,25 +246,6 @@ qx.Class.define("osparc.dashboard.ListButtonItem", {
246246
const user = this.__createOwner(value);
247247
label.setValue(user);
248248

249-
// remove this, testing purposes
250-
if (osparc.utils.DisabledPlugins.isSimultaneousAccessEnabled() && this.getResourceType() === "study") {
251-
const avatarGroup = this.getChildControl("avatar-group");
252-
const allUsers = [
253-
{ name: "Alice", avatar: "https://i.pravatar.cc/150?img=1" },
254-
{ name: "Bob", avatar: "https://i.pravatar.cc/150?img=2" },
255-
{ name: "Charlie", avatar: "https://i.pravatar.cc/150?img=3" },
256-
{ name: "Dana", avatar: "https://i.pravatar.cc/150?img=4" },
257-
{ name: "Eve", avatar: "https://i.pravatar.cc/150?img=5" },
258-
{ name: "Frank", avatar: "https://i.pravatar.cc/150?img=6" },
259-
];
260-
// Random number of users between 1 and 6
261-
const randomCount = Math.floor(Math.random() * 6) + 1;
262-
// Shuffle the array and take the first randomCount users
263-
const shuffled = allUsers.sort(() => 0.5 - Math.random());
264-
const randomUsers = shuffled.slice(0, randomCount);
265-
avatarGroup.setUsers(randomUsers);
266-
}
267-
268249
this.__makeItemResponsive(label);
269250
},
270251

0 commit comments

Comments
 (0)