-
Notifications
You must be signed in to change notification settings - Fork 32
✨ [Frontend] PO Center: Pending Users #7699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mergify
merged 17 commits into
ITISFoundation:master
from
odeimaiz:feature/pending-users
May 19, 2025
Merged
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b58011a
UsersPending
odeimaiz 611131d
[skip ci] getPendingUsers
odeimaiz 458800f
buttons with actions
odeimaiz 54189ee
minor
odeimaiz 6f8afa6
unused
odeimaiz e4fd000
User Info
odeimaiz 4ce295d
createInfoButton
odeimaiz a003436
isDevelopmentPlatform
odeimaiz f029d0d
minor
odeimaiz d1cfa46
wording minor
odeimaiz 5a52e12
done
odeimaiz 7f85488
adapt resources
odeimaiz bcaa361
Merge branch 'master' into feature/pending-users
odeimaiz 002a969
Merge branch 'master' into feature/pending-users
mergify[bot] 5f9aa7b
minor
odeimaiz d750d2e
Merge branch 'feature/pending-users' of github.com:odeimaiz/osparc-si…
odeimaiz 570f0b5
minor
odeimaiz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
274 changes: 274 additions & 0 deletions
274
services/static-webserver/client/source/class/osparc/po/UsersPending.js
This file contains hidden or 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,274 @@ | ||
| /* ************************************************************************ | ||
|
|
||
| osparc - the simcore frontend | ||
|
|
||
| https://osparc.io | ||
|
|
||
| Copyright: | ||
| 2024 IT'IS Foundation, https://itis.swiss | ||
|
|
||
| License: | ||
| MIT: https://opensource.org/licenses/MIT | ||
|
|
||
| Authors: | ||
| * Pedro Crespo-Valero (pcrespov) | ||
| * Odei Maiz (odeimaiz) | ||
|
|
||
| ************************************************************************ */ | ||
|
|
||
| qx.Class.define("osparc.po.UsersPending", { | ||
| extend: osparc.po.BaseView, | ||
|
|
||
| statics: { | ||
| getPendingUsers: function() { | ||
| return new Promise(resolve => { | ||
| resolve({ | ||
| data: [{ | ||
| name: "John Doe", | ||
| email: "[email protected]", | ||
| date: "2025-01-01 00:00:00.702394", | ||
| status: "PENDING", | ||
| info: { | ||
| "institution": "ETH Zurich", | ||
| "department": "Department of Physics", | ||
| "position": "PhD Student", | ||
| "country": "Switzerland", | ||
| "city": "Zurich", | ||
| }, | ||
| }, { | ||
| name: "Jane Doe", | ||
| email: "[email protected]", | ||
| date: "2025-01-01 00:01:00.702394", | ||
| status: "REJECTED", | ||
| info: { | ||
| "institution": "ETH Zurich", | ||
| "department": "Department of Physics", | ||
| "position": "PhD Student", | ||
| "country": "Switzerland", | ||
| "city": "Zurich", | ||
| }, | ||
| }, { | ||
| name: "Alice Smith", | ||
| email: "[email protected]", | ||
| date: "2025-01-01 00:02:00.702394", | ||
| status: "APPROVED", | ||
| info: { | ||
| "institution": "ETH Zurich", | ||
| "department": "Department of Physics", | ||
| "position": "PhD Student", | ||
| "country": "Switzerland", | ||
| "city": "Zurich", | ||
| }, | ||
| }] | ||
| }); | ||
| }); | ||
| }, | ||
|
|
||
| createApproveButton: function(email) { | ||
| const button = new osparc.ui.form.FetchButton(qx.locale.Manager.tr("Approve")); | ||
| button.addListener("execute", () => { | ||
| button.setFetching(true); | ||
| const params = { | ||
| data: { | ||
| email, | ||
| }, | ||
| }; | ||
| osparc.data.Resources.fetch("poUsers", "approveUser", params) | ||
| .then(() => { | ||
| osparc.FlashMessenger.logAs(qx.locale.Manager.tr("User approved"), "INFO"); | ||
| }) | ||
| .catch(err => osparc.FlashMessenger.logError(err)) | ||
| .finally(() => button.setFetching(false)); | ||
| }); | ||
| return button; | ||
| }, | ||
|
|
||
| createRejectButton: function(email) { | ||
| const button = new osparc.ui.form.FetchButton(qx.locale.Manager.tr("Reject")); | ||
| button.addListener("execute", () => { | ||
| button.setFetching(true); | ||
| const params = { | ||
| data: { | ||
| email, | ||
| }, | ||
| }; | ||
| osparc.data.Resources.fetch("poUsers", "rejectUser", params) | ||
| .then(() => { | ||
| osparc.FlashMessenger.logAs(qx.locale.Manager.tr("User denied"), "INFO"); | ||
| }) | ||
| .catch(err => osparc.FlashMessenger.logError(err)) | ||
| .finally(() => button.setFetching(false)); | ||
| }); | ||
| return button; | ||
| }, | ||
|
|
||
| createResendEmailButton: function(email) { | ||
| const button = new osparc.ui.form.FetchButton(qx.locale.Manager.tr("Resend Email")); | ||
| button.addListener("execute", () => { | ||
| button.setFetching(true); | ||
| const params = { | ||
| data: { | ||
| email, | ||
| }, | ||
| }; | ||
| osparc.data.Resources.fetch("poUsers", "resendConfirmationEmail", params) | ||
| .then(() => { | ||
| osparc.FlashMessenger.logAs(qx.locale.Manager.tr("Email sent"), "INFO"); | ||
| }) | ||
| .catch(err => osparc.FlashMessenger.logError(err)) | ||
| .finally(() => button.setFetching(false)); | ||
| }); | ||
| return button; | ||
| }, | ||
|
|
||
| createInfoButton: function(infoMetadata) { | ||
| const infoButton = new qx.ui.form.Button(null, "@MaterialIcons/info_outline/16"); | ||
| infoButton.addListener("execute", () => { | ||
| const container = new qx.ui.container.Scroll(); | ||
| container.add(new osparc.ui.basic.JsonTreeWidget(infoMetadata, "pendingUserInfo")); | ||
| osparc.ui.window.Window.popUpInWindow(container, qx.locale.Manager.tr("User Info")); | ||
| }); | ||
| return infoButton; | ||
| }, | ||
| }, | ||
|
|
||
| members: { | ||
| _createChildControlImpl: function(id) { | ||
| let control; | ||
| switch (id) { | ||
| case "pending-users-container": | ||
| control = new qx.ui.container.Scroll(); | ||
| this._add(control, { | ||
| flex: 1 | ||
| }); | ||
| break; | ||
| case "pending-users-layout": { | ||
| const grid = new qx.ui.layout.Grid(15, 5); | ||
| control = new qx.ui.container.Composite(grid); | ||
| this.getChildControl("pending-users-container").add(control); | ||
| break; | ||
| } | ||
| } | ||
| return control || this.base(arguments, id); | ||
| }, | ||
|
|
||
| _buildLayout: function() { | ||
| this.getChildControl("pending-users-container"); | ||
|
|
||
| this.__populatePendingUsersLayout(); | ||
| }, | ||
|
|
||
| __addHeader: function() { | ||
| const pendingUsersLayout = this.getChildControl("pending-users-layout"); | ||
|
|
||
| pendingUsersLayout.add(new qx.ui.basic.Label(this.tr("Name")).set({ | ||
| font: "text-14" | ||
| }), { | ||
| row: 0, | ||
| column: 0, | ||
| }); | ||
|
|
||
| pendingUsersLayout.add(new qx.ui.basic.Label(this.tr("Email")).set({ | ||
| font: "text-14" | ||
| }), { | ||
| row: 0, | ||
| column: 1, | ||
| }); | ||
|
|
||
| pendingUsersLayout.add(new qx.ui.basic.Label(this.tr("Date")).set({ | ||
| font: "text-14" | ||
| }), { | ||
| row: 0, | ||
| column: 2, | ||
| }); | ||
|
|
||
| pendingUsersLayout.add(new qx.ui.basic.Label(this.tr("Info")).set({ | ||
| font: "text-14" | ||
| }), { | ||
| row: 0, | ||
| column: 3, | ||
| }); | ||
|
|
||
| pendingUsersLayout.add(new qx.ui.basic.Label(this.tr("Status")).set({ | ||
| font: "text-14" | ||
| }), { | ||
| row: 0, | ||
| column: 4, | ||
| }); | ||
|
|
||
| pendingUsersLayout.add(new qx.ui.basic.Label(this.tr("Action")).set({ | ||
| font: "text-14" | ||
| }), { | ||
| row: 0, | ||
| column: 5, | ||
| }); | ||
| }, | ||
|
|
||
| __addRows: function(pendingUsers) { | ||
| const pendingUsersLayout = this.getChildControl("pending-users-layout"); | ||
|
|
||
| let row = 1; | ||
| pendingUsers.forEach(pendingUser => { | ||
| pendingUsersLayout.add(new qx.ui.basic.Label(pendingUser.name), { | ||
| row, | ||
| column: 0, | ||
| }); | ||
| pendingUsersLayout.add(new qx.ui.basic.Label(pendingUser.email), { | ||
| row, | ||
| column: 1, | ||
| }); | ||
| pendingUsersLayout.add(new qx.ui.basic.Label(osparc.utils.Utils.formatDateAndTime(new Date(pendingUser.date))), { | ||
| row, | ||
| column: 2, | ||
| }); | ||
| const infoButton = this.self().createInfoButton(pendingUser.info); | ||
| pendingUsersLayout.add(infoButton, { | ||
| row, | ||
| column: 3, | ||
| }); | ||
| pendingUsersLayout.add(new qx.ui.basic.Label(pendingUser.status.toLowerCase()), { | ||
| row, | ||
| column: 4, | ||
| }); | ||
| const buttonsLayout = new qx.ui.container.Composite(new qx.ui.layout.HBox(5)); | ||
| pendingUsersLayout.add(buttonsLayout, { | ||
| row, | ||
| column: 5, | ||
| }); | ||
|
|
||
| switch (pendingUser.status) { | ||
| case "PENDING": { | ||
| const approveButton = this.self().createApproveButton(pendingUser.email); | ||
| buttonsLayout.add(approveButton); | ||
| const rejectButton = this.self().createRejectButton(pendingUser.email); | ||
| buttonsLayout.add(rejectButton); | ||
| break; | ||
| } | ||
| case "REJECTED": { | ||
| const approveButton = this.self().createApproveButton(pendingUser.email); | ||
| buttonsLayout.add(approveButton); | ||
| break; | ||
| } | ||
| case "APPROVED": { | ||
| const resendEmailButton = this.self().createResendEmailButton(pendingUser.email); | ||
| buttonsLayout.add(resendEmailButton); | ||
| break; | ||
| } | ||
| } | ||
| row++; | ||
| }); | ||
| }, | ||
|
|
||
| __populatePendingUsersLayout: function() { | ||
| // osparc.data.Resources.fetch("poUsers", "getPendingUsers", params) | ||
| this.self().getPendingUsers() | ||
| .then(pendingUsers => { | ||
| const pendingUsersLayout = this.getChildControl("pending-users-layout"); | ||
| pendingUsersLayout.removeAll(); | ||
| this.__addHeader(); | ||
| this.__addRows(pendingUsers["data"]); | ||
| }) | ||
| .catch(err => osparc.FlashMessenger.logError(err)); | ||
| } | ||
| } | ||
| }); | ||
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.