forked from ITISFoundation/osparc-simcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎨 Integrate Current usage into Credits indicator (ITISFoundation#4928)
- Loading branch information
Showing
9 changed files
with
135 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,9 @@ qx.Class.define("osparc.navigation.UserMenuButton", { | |
this.__bindWalletToHalo(); | ||
store.addListener("changeContextWallet", () => this.__bindWalletToHalo()); | ||
|
||
const preferencesSettings = osparc.Preferences.getInstance(); | ||
preferencesSettings.addListener("changeCreditsWarningThreshold", () => this.__updateHalloCredits()); | ||
|
||
const userEmail = authData.getEmail() || "[email protected]"; | ||
const icon = this.getChildControl("icon"); | ||
authData.bind("role", this, "icon", { | ||
|
@@ -78,23 +81,28 @@ qx.Class.define("osparc.navigation.UserMenuButton", { | |
const store = osparc.store.Store.getInstance(); | ||
const contextWallet = store.getContextWallet(); | ||
if (contextWallet) { | ||
this.__updateHalloCredits(contextWallet.getCreditsAvailable()); | ||
contextWallet.addListener("changeCreditsAvailable", e => this.__updateHalloCredits(e.getData())); | ||
this.__updateHalloCredits(); | ||
contextWallet.addListener("changeCreditsAvailable", () => this.__updateHalloCredits()); | ||
} | ||
}, | ||
|
||
__updateHalloCredits: function(credits) { | ||
if (credits !== null) { | ||
const progress = osparc.desktop.credits.Utils.normalizeCredits(credits); | ||
const creditsColor = osparc.desktop.credits.Utils.creditsToColor(credits, "strong-main"); | ||
const color1 = qx.theme.manager.Color.getInstance().resolve(creditsColor); | ||
const textColor = qx.theme.manager.Color.getInstance().resolve("text"); | ||
const arr = qx.util.ColorUtil.stringToRgb(textColor); | ||
arr[3] = 0.5; | ||
const color2 = qx.util.ColorUtil.rgbToRgbString(arr); | ||
this.getContentElement().setStyles({ | ||
"background": `radial-gradient(closest-side, white 79%, transparent 80% 100%), conic-gradient(${color1} ${progress}%, ${color2} 0)` | ||
}); | ||
__updateHalloCredits: function() { | ||
const store = osparc.store.Store.getInstance(); | ||
const contextWallet = store.getContextWallet(); | ||
if (contextWallet) { | ||
const credits = contextWallet.getCreditsAvailable(); | ||
if (credits !== null) { | ||
const progress = osparc.desktop.credits.Utils.normalizeCredits(credits); | ||
const creditsColor = osparc.desktop.credits.Utils.creditsToColor(credits, "strong-main"); | ||
const color1 = qx.theme.manager.Color.getInstance().resolve(creditsColor); | ||
const textColor = qx.theme.manager.Color.getInstance().resolve("text"); | ||
const arr = qx.util.ColorUtil.stringToRgb(textColor); | ||
arr[3] = 0.5; | ||
const color2 = qx.util.ColorUtil.rgbToRgbString(arr); | ||
this.getContentElement().setStyles({ | ||
"background": `radial-gradient(closest-side, white 79%, transparent 80% 100%), conic-gradient(${color1} ${progress}%, ${color2} 0)` | ||
}); | ||
} | ||
} | ||
}, | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters