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.
🎨 Frontend: Replace Credits Indicator with just a Label (ITISFoundati…
- Loading branch information
Showing
11 changed files
with
134 additions
and
243 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
118 changes: 0 additions & 118 deletions
118
services/static-webserver/client/source/class/osparc/desktop/credits/CreditsIndicator.js
This file was deleted.
Oops, something went wrong.
84 changes: 0 additions & 84 deletions
84
...ices/static-webserver/client/source/class/osparc/desktop/credits/CreditsIndicatorWText.js
This file was deleted.
Oops, something went wrong.
104 changes: 104 additions & 0 deletions
104
services/static-webserver/client/source/class/osparc/desktop/credits/CreditsLabel.js
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 |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* ************************************************************************ | ||
osparc - the simcore frontend | ||
https://osparc.io | ||
Copyright: | ||
2023 IT'IS Foundation, https://itis.swiss | ||
License: | ||
MIT: https://opensource.org/licenses/MIT | ||
Authors: | ||
* Odei Maiz (odeimaiz) | ||
************************************************************************ */ | ||
|
||
qx.Class.define("osparc.desktop.credits.CreditsLabel", { | ||
extend: qx.ui.basic.Atom, | ||
|
||
construct: function(wallet, shortWording) { | ||
this.base(arguments); | ||
|
||
this.set({ | ||
font: "text-16", | ||
allowGrowX: false | ||
// icon: "@MaterialIcons/monetization_on/16", | ||
// iconPosition: "right" | ||
}); | ||
|
||
if (wallet) { | ||
this.setWallet(wallet); | ||
} | ||
|
||
if (shortWording !== undefined) { | ||
this.setShortWording(shortWording); | ||
} | ||
|
||
this.bind("creditsAvailable", this, "label", { | ||
converter: () => this.__recomputeLabel() | ||
}); | ||
|
||
this.bind("creditsAvailable", this, "textColor", { | ||
converter: val => { | ||
if (val > 20) { | ||
return "text"; | ||
} else if (val > 0.1) { | ||
return "warning-yellow"; | ||
} | ||
return "danger-red"; | ||
} | ||
}); | ||
|
||
this.bind("shortWording", this, "label", { | ||
converter: () => this.__recomputeLabel() | ||
}); | ||
}, | ||
|
||
properties: { | ||
wallet: { | ||
check: "osparc.data.model.Wallet", | ||
init: null, | ||
nullable: true, | ||
event: "changeWallet", | ||
apply: "__applyWallet" | ||
}, | ||
|
||
creditsAvailable: { | ||
check: "Number", | ||
init: 0, | ||
nullable: false, | ||
event: "changeCreditsAvailable" | ||
}, | ||
|
||
shortWording: { | ||
check: "Boolean", | ||
init: false, | ||
nullable: false, | ||
event: "changeShortWording" | ||
} | ||
}, | ||
|
||
members: { | ||
__applyWallet: function(wallet) { | ||
if (wallet) { | ||
wallet.bind("creditsAvailable", this, "creditsAvailable"); | ||
} | ||
}, | ||
|
||
__recomputeLabel: function() { | ||
const creditsAvailable = this.getCreditsAvailable(); | ||
if (creditsAvailable === null) { | ||
return "-"; | ||
} | ||
let label = creditsAvailable.toFixed(2); | ||
if (this.isShortWording()) { | ||
label += this.tr(" cr."); | ||
} else { | ||
label += this.tr(" credits"); | ||
} | ||
return label; | ||
} | ||
} | ||
}); |
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
Oops, something went wrong.