Skip to content

Commit

Permalink
Merge branch 'master' into 6948-expose-licensing-endpoints-api-server
Browse files Browse the repository at this point in the history
  • Loading branch information
bisgaard-itis committed Dec 12, 2024
2 parents 3577938 + e6fc642 commit 2cdaab8
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ async def progress_create_containers(
start_duration = (
scheduler_data.dynamic_sidecar.instrumentation.elapsed_since_start_request()
)
assert start_duration is not None # nosec
get_instrumentation(app).dynamic_sidecar_metrics.start_time_duration.labels(
**get_metrics_labels(scheduler_data)
).observe(start_duration)
if start_duration is not None:
get_instrumentation(app).dynamic_sidecar_metrics.start_time_duration.labels(
**get_metrics_labels(scheduler_data)
).observe(start_duration)

_logger.info("Internal state after creating user services %s", scheduler_data)
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,10 @@ async def attempt_pod_removal_and_data_saving(
stop_duration = (
scheduler_data.dynamic_sidecar.instrumentation.elapsed_since_close_request()
)
assert stop_duration is not None # nosec
get_instrumentation(app).dynamic_sidecar_metrics.stop_time_duration.labels(
**get_metrics_labels(scheduler_data)
).observe(stop_duration)
if stop_duration is not None:
get_instrumentation(app).dynamic_sidecar_metrics.stop_time_duration.labels(
**get_metrics_labels(scheduler_data)
).observe(stop_duration)


async def attach_project_networks(app: FastAPI, scheduler_data: SchedulerData) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ qx.Class.define("osparc.data.model.User", {
if (userData["login"]) {
description += userData["login"];
}
const thumbnail = osparc.utils.Avatar.emailToThumbnail(userData["login"]);
const thumbnail = osparc.utils.Avatar.emailToThumbnail(userData["login"], userData["userName"]);
this.set({
userId: parseInt(userData["id"]),
groupId: parseInt(userData["gid"]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ qx.Class.define("osparc.desktop.account.MyAccount", {
});

const authData = osparc.auth.Data.getInstance();

const username = authData.getUsername();
const email = authData.getEmail();
const avatarSize = 80;
const img = new qx.ui.basic.Image().set({
source: osparc.utils.Avatar.getUrl(email, avatarSize),
source: osparc.utils.Avatar.emailToThumbnail(email, username, avatarSize),
maxWidth: avatarSize,
maxHeight: avatarSize,
scale: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ qx.Class.define("osparc.info.CommentAdd", {
maxHeight: 32,
decorator: "rounded",
});
const myEmail = osparc.auth.Data.getInstance().getEmail();
const authData = osparc.auth.Data.getInstance();
const myUsername = authData.getUsername();
const myEmail = authData.getEmail();
control.set({
source: osparc.utils.Avatar.getUrl(myEmail, 32)
source: osparc.utils.Avatar.emailToThumbnail(myEmail, myUsername, 32)
});
const layout = this.getChildControl("add-comment-layout");
layout.add(control, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ qx.Class.define("osparc.info.CommentUI", {

__buildLayout: function() {
const thumbnail = this.getChildControl("thumbnail");
thumbnail.setSource(osparc.utils.Avatar.getUrl("", 32));
thumbnail.setSource(osparc.utils.Avatar.emailToThumbnail("", "", 32));

const userName = this.getChildControl("user-name");
userName.setValue("Unknown");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ qx.Class.define("osparc.navigation.UserMenuButton", {
const preferencesSettings = osparc.Preferences.getInstance();
preferencesSettings.addListener("changeCreditsWarningThreshold", () => this.__updateHaloColor());

const myUsername = authData.getUsername() || "Username";
const myEmail = authData.getEmail() || "[email protected]";
const icon = this.getChildControl("icon");
authData.bind("role", this, "icon", {
Expand All @@ -64,7 +65,7 @@ qx.Class.define("osparc.navigation.UserMenuButton", {
icon.getContentElement().setStyles({
"margin-left": "-4px"
});
return osparc.utils.Avatar.getUrl(myEmail, 32);
return osparc.utils.Avatar.emailToThumbnail(myEmail, myUsername, 32);
}
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ qx.Class.define("osparc.store.Groups", {
groupMe.set({
label: myAuthData.getUsername(),
description: `${myAuthData.getFirstName()} ${myAuthData.getLastName()} - ${myAuthData.getEmail()}`,
thumbnail: osparc.utils.Avatar.emailToThumbnail(myAuthData.getEmail()),
thumbnail: osparc.utils.Avatar.emailToThumbnail(myAuthData.getEmail(), myAuthData.getUsername()),
})
return orgs;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ qx.Class.define("osparc.store.Store", {
check: "Array",
init: []
},
market: {
licensedItems: {
check: "Array",
init: []
},
Expand Down Expand Up @@ -618,7 +618,7 @@ qx.Class.define("osparc.store.Store", {
__getOrgClassifiers: function(orgId, useCache = false) {
const params = {
url: {
"gid": orgId
"gid": parseInt(orgId)
}
};
return osparc.data.Resources.get("classifiers", params, useCache);
Expand All @@ -640,7 +640,7 @@ qx.Class.define("osparc.store.Store", {
}
const classifierPromises = [];
orgs.forEach(org => {
classifierPromises.push(this.__getOrgClassifiers(org["gid"], !reload));
classifierPromises.push(this.__getOrgClassifiers(org.getGroupId(), !reload));
});
Promise.all(classifierPromises)
.then(orgsClassifiersMD => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,22 @@
* Here is a little example of how to use the widget.
*
* <pre class='javascript'>
* let image = osparc.utils.Avatar.getUrl(userEmail);
* let image = osparc.utils.Avatar.emailToThumbnail(userEmail);
* </pre>
*/

qx.Class.define("osparc.utils.Avatar", {
type: "static",

statics: {
emailToThumbnail: function(email) {
return this.getUrl(email, 32)
emailToThumbnail: function(email, username) {
return this.__getUrl(email, username, 32);
},

getUrl: function(email = "", size = 100, defIcon = "identicon", rating = "g") {
__getUrl: function(email, username, size = 100) {
email = email || "";
// MD5 (Message-Digest Algorithm) by WebToolkit
let MD5 = function(s) {
const MD5 = function(s) {
function L(k, d) {
return (k << d) | (k >>> (32 - d));
}
Expand Down Expand Up @@ -257,8 +258,9 @@ qx.Class.define("osparc.utils.Avatar", {
return i.toLowerCase();
};

return "https://secure.gravatar.com/avatar/" + MD5(email) + "?s=" + size + "&d=" + defIcon + "&r=" + rating;
}

const emailHash = MD5(email);
const defaultImageUrl = `https://ui-avatars.com/api/${username}/${size}`;
return `https://www.gravatar.com/avatar/${emailHash}?d=${defaultImageUrl}&s=${size}&r=g`;
},
}
});
2 changes: 1 addition & 1 deletion tests/e2e-playwright/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def log_in_and_out(
def _open_with_resources(page: Page, *, click_it: bool):
study_title_field = page.get_by_test_id("studyTitleField")
# wait until the title is automatically filled up
expect(study_title_field).not_to_have_value("", timeout=5000)
expect(study_title_field).not_to_have_value("")

open_with_resources_button = page.get_by_test_id("openWithResources")
if click_it:
Expand Down

0 comments on commit 2cdaab8

Please sign in to comment.