Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ qx.Class.define("osparc.dashboard.CardBase", {
construct: function() {
this.base(arguments);

if (osparc.utils.DisabledPlugins.isSimultaneousAccessEnabled()) {
if (osparc.utils.DisabledPlugins.isRTCEnabled()) {
// "IN_USE" is not a blocker anymore
const inUseIdx = qx.util.PropertyUtil.getProperties(osparc.dashboard.CardBase).blocked.check.indexOf("IN_USE");
if (inUseIdx > -1) {
Expand Down Expand Up @@ -804,34 +804,26 @@ qx.Class.define("osparc.dashboard.CardBase", {
},

__applyState: function(state) {
let projectInUse = false;
if ("shareState" in state && "locked" in state["shareState"]) {
projectInUse = state["shareState"]["locked"];
}
const projectLocked = osparc.study.Utils.state.isProjectLocked(state);
const currentUserGroupIds = osparc.study.Utils.state.getCurrentGroupIds(state);
const pipelineState = osparc.study.Utils.state.getPipelineState(state);

if (osparc.utils.DisabledPlugins.isSimultaneousAccessEnabled()) {
if (projectInUse && state["shareState"]["status"] === "OPENED") {
this.__showWhoIsIn(state["shareState"]["currentUserGroupids"]);
} else {
this.__showWhoIsIn(null);
}
} else {
this.setBlocked(projectInUse ? "IN_USE" : false);
if (projectInUse) {
this.__showBlockedCardFromStatus("IN_USE", state["shareState"]);
}
this.__showCurrentUserGroupIds(currentUserGroupIds);

this.setBlocked(projectLocked ? "IN_USE" : false);
if (projectLocked) {
this.__showBlockedCardFromStatus("IN_USE", state["shareState"]);
}

const pipelineState = ("state" in state) ? state["state"]["value"] : undefined;
if (pipelineState) {
this.__applyPipelineState(state["state"]["value"]);
this.__applyPipelineState(pipelineState);
}
},

__applyDebt: function(debt) {
this.setBlocked(debt ? "IN_DEBT" : false);
if (debt) {
this.__showBlockedCardFromStatus("IN_DEBT", debt);
this.__showBlockedCardFromStatus("IN_DEBT");
}
},

Expand Down Expand Up @@ -899,73 +891,70 @@ qx.Class.define("osparc.dashboard.CardBase", {
});
},

__showWhoIsIn: function(whoIsIn) {
let users = [];
if (whoIsIn) {
// replace this once the backend returns a list of group__ids
const allUsers = [
{ name: "Alice", avatar: "https://i.pravatar.cc/150?img=1" },
{ name: "Bob", avatar: "https://i.pravatar.cc/150?img=2" },
{ name: "Charlie", avatar: "https://i.pravatar.cc/150?img=3" },
{ name: "Dana", avatar: "https://i.pravatar.cc/150?img=4" },
{ name: "Eve", avatar: "https://i.pravatar.cc/150?img=5" },
{ name: "Frank", avatar: "https://i.pravatar.cc/150?img=6" },
];
// Random number of users between 1 and 6
const randomCount = Math.floor(Math.random() * 6) + 1;
// Shuffle the array and take the first randomCount users
const shuffled = allUsers.sort(() => 0.5 - Math.random());
users = shuffled.slice(0, randomCount);
}
if (osparc.utils.DisabledPlugins.isSimultaneousAccessEnabled() && this.getResourceType() === "study") {
const avatarGroup = this.getChildControl("avatar-group");
avatarGroup.setUsers(users);
}
__showCurrentUserGroupIds: function(currentUserGroupIds) {
const avatarGroup = this.getChildControl("avatar-group");
avatarGroup.setUserGroupIds(currentUserGroupIds);
},

__showBlockedCardFromStatus: function(reason, moreInfo) {
__showBlockedCardFromStatus: function(reason, shareState) {
switch (reason) {
case "IN_USE":
this.__blockedInUse(moreInfo);
this.__blockedInUse(shareState);
break;
case "IN_DEBT":
this.__blockedInDebt(moreInfo);
this.__blockedInDebt();
break;
}
},

__blockedInUse: function(lockedStatus) {
const status = lockedStatus["status"];
const userGroupIDs = lockedStatus["currentUserGroupids"];
let toolTip = userGroupIDs[0]
// osparc.utils.Utils.firstsUp(userGroupIDs[0]["first_name"] || this.tr("A user"), userGroupIDs[0]["last_name"] || ""); // it will be replaced by "userName"
__blockedInUse: function(shareState) {
const status = shareState["status"];
const currentUserGroupIds = shareState["currentUserGroupids"];
const usersStore = osparc.store.Users.getInstance();
const userPromises = currentUserGroupIds.map(userGroupId => usersStore.getUser(userGroupId));
const usernames = [];
let toolTip = "";
let image = null;
switch (status) {
case "CLOSING":
image = "@FontAwesome5Solid/key/";
toolTip += this.tr(" is closing it...");
break;
case "CLONING":
image = "@FontAwesome5Solid/clone/";
toolTip += this.tr(" is cloning it...");
break;
case "EXPORTING":
image = osparc.task.Export.ICON+"/";
toolTip += this.tr(" is exporting it...");
break;
case "OPENING":
image = "@FontAwesome5Solid/key/";
toolTip += this.tr(" is opening it...");
break;
case "OPENED":
image = "@FontAwesome5Solid/lock/";
toolTip += this.tr(" is using it.");
break;
default:
image = "@FontAwesome5Solid/lock/";
break;
}
this.__showBlockedCard(image, toolTip);
Promise.all(userPromises)
.then(usersResult => {
usersResult.forEach(user => {
usernames.push(user.getUsername());
});
})
.catch(error => {
console.error("Failed to fetch user data for avatars:", error);
})
.finally(() => {
switch (status) {
case "CLOSING":
image = "@FontAwesome5Solid/key/";
toolTip += this.tr("Closing...");
break;
case "CLONING":
image = "@FontAwesome5Solid/clone/";
toolTip += this.tr("Cloning...");
break;
case "EXPORTING":
image = osparc.task.Export.ICON+"/";
toolTip += this.tr("Exporting...");
break;
case "OPENING":
image = "@FontAwesome5Solid/key/";
toolTip += this.tr("Opening...");
break;
case "OPENED":
image = "@FontAwesome5Solid/lock/";
toolTip += this.tr("In use...");
break;
default:
image = "@FontAwesome5Solid/lock/";
break;
}
usernames.forEach(username => {
toolTip += "<br>" + username;
});
this.__showBlockedCard(image, toolTip);
});
},

__blockedInDebt: function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {

resourcesList.forEach(study => {
const state = study["state"];
if (state && "shareState" in state && state["shareState"]["locked"] && state["shareState"]["status"] === "CLOSING") {
const projectLocked = osparc.study.Utils.state.isProjectLocked(state);
const projectStatus = osparc.study.Utils.state.getProjectStatus(state);
if (projectLocked && projectStatus === "CLOSING") {
// websocket might have already notified that the state was closed.
// But the /projects calls response got after the ws message. Ask again to make sure
const delay = 2000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,8 @@ qx.Class.define("osparc.data.model.Study", {
},

isLocked: function() {
if (this.getState() && "shareState" in this.getState()) {
return this.getState()["shareState"]["locked"];
if (this.getState()) {
return osparc.study.Utils.state.isProjectLocked(this.getState());
}
return false;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,15 @@ qx.Class.define("osparc.desktop.MainPageHandler", {
const studyAlias = osparc.product.Utils.getStudyAlias({firstUpperCase: true});
// check if it's locked
let locked = false;
let lockedBy = false;
if ("state" in studyData && "shareState" in studyData["state"]) {
locked = studyData["state"]["shareState"]["locked"];
lockedBy = studyData["state"]["shareState"]["currentUserGroupids"];
let lockedBy = [];
if ("state" in studyData) {
const state = studyData["state"];
locked = osparc.study.Utils.state.isProjectLocked(state);
const currentUserGroupIds = osparc.study.Utils.state.getCurrentGroupIds(state);
lockedBy = currentUserGroupIds.filter(gid => gid !== osparc.store.Groups.getInstance().getMyGroupId());
}
if (locked && lockedBy["user_id"] !== osparc.auth.Data.getInstance().getUserId()) {
const msg = `${studyAlias} ${qx.locale.Manager.tr("is already open by")} ${ // it will be replaced "userName"
"first_name" in lockedBy && lockedBy["first_name"] != null ?
lockedBy["first_name"] :
qx.locale.Manager.tr("another user.")
}`;
if (locked && lockedBy.length) {
const msg = `${studyAlias} ${qx.locale.Manager.tr("is already open by another user.")}`;
throw new Error(msg);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,17 +625,6 @@ qx.Class.define("osparc.desktop.StudyEditor", {
this.__reloadSnapshotsAndIterations();
}
this.getStudyLogger().info(null, "Pipeline started");
/* If no projectStateUpdated comes in 60 seconds, client must
check state of pipeline and update button accordingly. */
const timer = setTimeout(() => {
osparc.store.Study.getInstance().getStudyState(pipelineId);
}, 60000);
const socket = osparc.wrapper.WebSocket.getInstance();
socket.getSocket().once("projectStateUpdated", ({ "project_uuid": projectUuid }) => {
if (projectUuid === pipelineId) {
clearTimeout(timer);
}
});
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ qx.Class.define("osparc.desktop.credits.CreditsIndicatorButton", {

osparc.utils.Utils.setIdToWidget(this, "creditsIndicatorButton");

this.set({
cursor: "pointer",
padding: [3, 8]
});

this.getChildControl("image").set({
width: 24,
height: 24
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ qx.Class.define("osparc.jobs.JobsButton", {
osparc.utils.Utils.setIdToWidget(this, "jobsButton");

this.set({
width: 30,
alignX: "center",
cursor: "pointer",
toolTipText: this.tr("Activity Center"),
});

Expand All @@ -53,12 +50,12 @@ qx.Class.define("osparc.jobs.JobsButton", {
switch (id) {
case "icon": {
control = new qx.ui.basic.Image("@FontAwesome5Solid/tasks/22");

const logoContainer = new qx.ui.container.Composite(new qx.ui.layout.HBox().set({
alignY: "middle"
}));
})).set({
paddingLeft: 5,
});
logoContainer.add(control);

this._add(logoContainer, {
height: "100%"
});
Expand Down
Loading
Loading