Skip to content

Commit

Permalink
🎨 Request new link for invoice (#5555)
Browse files Browse the repository at this point in the history
  • Loading branch information
odeimaiz authored Mar 27, 2024
1 parent 467a45d commit 56d4f35
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,10 @@ qx.Class.define("osparc.data.Resources", {
payWithPaymentMethod: {
method: "POST",
url: statics.API + "/wallets/{walletId}/payments-methods/{paymentMethodId}:pay"
},
invoiceLink: {
method: "GET",
url: statics.API + "/wallets/{walletId}/payments/{paymentId}/invoice-link"
}
}
},
Expand Down Expand Up @@ -1077,6 +1081,20 @@ qx.Class.define("osparc.data.Resources", {
},

members: {
/**
* @param {String} resource Name of the resource as defined in the static property 'resources'.
* @param {String} endpoint Name of the endpoint. Several endpoints can be defined for each resource.
* @param {Object} urlParams Object containing only the parameters for the url of the request.
*/
replaceUrlParams: function(resource, endpoint, urlParams) {
const resourceDefinition = this.self().resources[resource];
const res = new osparc.io.rest.Resource(resourceDefinition.endpoints);
// Use qooxdoo's Get request configuration
// eslint-disable-next-line no-underscore-dangle
const getReqConfig = res._resource._getRequestConfig(endpoint, urlParams);
return getReqConfig;
},

/**
* Method to fetch resources from the server. If configured properly, the resources in the response will be cached in {osparc.store.Store}.
* @param {String} resource Name of the resource as defined in the static property 'resources'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ qx.Class.define("osparc.desktop.credits.TransactionsTableModel", {
credits: rawRow.osparcCredits ? rawRow.osparcCredits.toFixed(2) * 1 : 0,
status: this.__addColorTag(rawRow.completedStatus),
comment: rawRow.comment,
invoice: rawRow.invoiceUrl ? this.__createPdfIconWithLink(rawRow.invoiceUrl) : ""
invoice: rawRow.invoiceUrl ? this.__createPdfIconWithLink(rawRow.walletId, rawRow.paymentId) : ""
})
})
return data
Expand Down Expand Up @@ -147,8 +147,14 @@ qx.Class.define("osparc.desktop.credits.TransactionsTableModel", {
__addColorTag: function(status) {
return `<font color=${this.__getLevelColor(status)}>${osparc.utils.Utils.onlyFirstsUp(status)}</font>`;
},
__createPdfIconWithLink: function(link) {
return `<a href='${link}' target='_blank'><img src='https://upload.wikimedia.org/wikipedia/commons/thumb/8/87/PDF_file_icon.svg/833px-PDF_file_icon.svg.png' alt='Invoice' width='16' height='20'></a>`;

__createPdfIconWithLink: function(walletId, paymentId) {
const urlParams = {
walletId,
paymentId
};
const req = osparc.data.Resources.getInstance().replaceUrlParams("payments", "invoiceLink", urlParams);
return `<a href='${req.url}' target='_blank'><img src='https://upload.wikimedia.org/wikipedia/commons/thumb/8/87/PDF_file_icon.svg/833px-PDF_file_icon.svg.png' alt='Invoice' width='16' height='20'></a>`;
}
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ qx.Class.define("osparc.navigation.UserMenu", {
case "log-out": {
const authData = osparc.auth.Data.getInstance();
control = new qx.ui.menu.Button(authData.isGuest() ? this.tr("Exit") : this.tr("Log out"));
control.addListener("execute", () => qx.core.Init.getApplication().logout());
control.addListener("execute", () => {
this.exclude();
qx.core.Init.getApplication().logout();
});
osparc.utils.Utils.setIdToWidget(control, "userMenuLogoutBtn");
this.add(control);
break;
Expand Down

0 comments on commit 56d4f35

Please sign in to comment.