Pass data to Card - laravel-nova

In the docs it says that you can pass data via withMeta method
https://nova.laravel.com/docs/1.0/customization/cards.html#registering-cards
My question is: how can I get it in Card.vue file?
I have tried to reach them like so:
mounted() {
console.log(this.currentVisitors)
console.log(this.card.currentVisitors)
},
but both output undefined

You have to call that method when you are registering the card. More info: https://github.com/laravel/nova-issues/issues/1270

Related

Access context object when defining a Step Function workflow in the CDK?

I would like to pass in the Step Function Execution ID of the current workflow to my Lambda function when it is executed.
I see in the documentation that to "access the context object, first specify the parameter name by appending .$ to the end" however, I cannot do this as I am defining my workflow using the CDK, which does not have access to parameters. I have to use InputPath.
Despite not being able to follow the instructions I tried a few things anyway. I have tried:
new tasks.LambdaInvoke(this, "InvokeLambdaTask", {
lambdaFunction: myLambda
inputPath: "$$.Execution.id"
})
and got the following error: Invalid path '$.Execution.id' : No results for path: $['Execution']['id']
I also tried a single dollar sign:
new tasks.LambdaInvoke(this, "InvokeLambdaTask", {
lambdaFunction: myLambda
inputPath: "$.Execution.id"
})
and got Invalid path '$.Execution.id' : Missing property in path $['Execution']
Is there any way to achieve this? I've seen a few other questions asking the more or less same thing, however I cannot really make use of these answers using the CDK.
I would like to pass in the Step Function Execution ID of the current workflow to my Lambda function
The LambdaInvoke task's payload is supplied to the Lambda function as input. Note the two equivalent ways of referencing the JSONPath.
new tasks.LambdaInvoke(this, "InvokeLambdaTask", {
lambdaFunction: myLambda,
payload: sfn.TaskInput.fromObject({
executionId: sfn.JsonPath.stringAt("$$.Execution.Id"),
"alsoExecutionId.$": "$$.Execution.Id",
}),
});
The Lambda receives the Execution Id in the event payload:
{
executionId: "arn:aws:states:us-east-1:123456789012:execution:StateMachine2E01...",
alsoExecutionId: "arn:aws:states:us-east-1:123456789012:execution:StateMachine2E01..."
}
The CDK ... does not have access to parameters.
It does. The CDK renders the payload arg into the State Machine definition's Parameters:
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:123456789012:function:Lambda...",
"Parameters": {
"executionId.$": "$$.Execution.Id",
"alsoExecutionId.$": "$$.Execution.Id"
}
You have to use stepfunctions.JsonPath.stringAt("$$.Execution.id"). I'm not 100% sure why, but CDK requires you to use JsonPath.xAt() for any references.

Krakend: Use previous backend response data to populate post body using lua

I am new to Kraken but quite excited about it. What I am trying to do currently is to have two sequential backends where I would like to use parts of the response from the first backend to populate the body of the second request using Lua. the only issue I am having is to get a hold of the data that I can get via {resp0} if I use it outside the Lua scripts.
This is the part of the krakend.json where I would like to access the previous response:
"extra_config": {
"modifier/lua-backend": {
"sources": [ "/etc/krakend/config/lua/enrichRequestBody.lua" ],
"pre": " populate_request_body(request.load(), {resp0});",
"live": false
}
Any input or suggestions would be much appreciated!
Thanks
I have been trying finding {resp0} or the corresponding value from debugging but no luck. I haven't found any documentation or examples for this in the Kraken documentation

Get Response from CREATE_STREAM

We upload a document from SAPUI5 to our SAP System using the CREATE_STREAM Method of the oData Service in ABAP. The creation of the document works fine.
What we would like to achieve is to get the response back to SAPUI5. Especially when there is an error during the creation of the document in the backend.
In Frontend we use the uploadSet Control.
...oUploadSet.uploadItem(oItem);
In the Backend we create a message with
...lo_message_container->add_message( iv_msg_type = /iwbep/cl_cos_logger=>error
iv_msg_number = '018'
iv_msg_id = lv_msg_id
iv_add_to_response_header = abap_true
)....
We can find the created message in the error protocol of our gateway server (/IWFND/ERROR_LOG). But how can this message be retrieved in SAPUI5 and used in the MessageManger Control?
We tried the onUploadCompleted Control but we can't find any response data there.
Can somebody explain how the response or a message header from the CREAT_STREAM method can be used in SAPUI5?
The "new" UploadSet control is kinda half-baked imo. The response will get lost in some internal method. This internal method will then trigger onUploadCompleted and you get nothing but useless information.
Lucky for us we can easily overwrite this internal stuff. UploadSet has an aggregation Uploader. We have to provide our own Uploader. Problem solved. Here is the line that needs to be modified.
sap.ui.define([
"sap/m/upload/Uploader",
...
], function (Uploader, ...) {
return Uploader.extend("my.custom.control.Uploader", {
uploadItem: function (oItem, aHeaders) {
// beginning of the method. take it from the official sources
oXhr.onreadystatechange = function () {
const oHandler = that._mRequestHandlers[oItem.getId()];
if (this.readyState === window.XMLHttpRequest.DONE && !oHandler.aborted) {
// we need to return the xhr object. it contains the response!
that.fireUploadCompleted({ item: oItem, xhr: oXhr });
}
};
// .. rest of the method
}
});
});
Use it like this
<mvc:View xmlns:custom="my.custom.control" ....>
<UploadSet items="....">
.....
<uploader>
<custom:Uploader uploadUrl="......"
uploadCompleted=".onUploadCompleted"
uploadStarted=".onUploadStarted" />
</uploader>
</UploadSet>
Edit: Your own uploader also means implementing your own event handlers (uploadAborted, uploadCompleted, uploadProgressed, uploadStarted). See the official documentation for more information about the events.

How to set links dynamically in Sendgrid v3 using javascript (node.js)

I am trying to add a unique link to a sendgrid template, but so far I have had no luck. The button in the sendgrid is the following:
Accept
I have also tried:
Accept
My javascript function looks like this:
const msg = {
to: process.env.EMAIL_TO,
from: process.env.EMAIL_FROM,
templateId: process.env.SENDGRID_TEMPLATE_ID,
dynamic_template_data: {
org_url: `${process.env.ORG_URL}/${key}`,
},
substitutions: {
'-org_url-': `${process.env.ORG_URL}/${key}`
}
};
Upon checking the sent email, the href field is either empty or only has -org_url- in it. How could I pass it the proper link? Thank you!
You can edit module html code and use string interpolation to insert the handlebar.
<a href=`{{shipperLoadUrl}}`>portal</a>
Assuming that you're using SendGrid's v3 API (which you are if you're using their Library), you need to make sure to pass the Substitution argument within the Personalization argument.
If you're not using the Library and are hand-building your call, you'll need to follow the full format, or implement the Library.

backbone.js fetch error

I am facing a problem with getting a response in fetch function of backbone.js. I am using Backbone.js with rails.
$(document).ready(function(){
window.projectPerformanceReport.fetch({
success: function(e) {
$("#loading").hide();
window.questionListView = new QuestionListView;
window.questionListView.render();
window.headerView = new HeaderView;
window.headerView.render();
},
error: function() {
alert("Error");
}
});
});
There is already a URL set for the fetch method and it does make a request to online server which returns a JSON object. I checked by hitting that request independently in new tab and it worked fine. Also the JSON object returned is valid. But when i run this page i always get popup of 'Error'?
Any help would be great.
Thanks
Okay
I got what was the issue..... The thing that was happening was, The Java_Servlet which i was calling to get the JSON object was returning the data in text format instead of JSON... (But it was a valid JSON string)... and while calling the ajax method i had set the type as 'json' so it was failing.
Thanks to everyone who read my question and thought for a solution.
But one strange thing which i observed was, same code was working in production and not in my local machine??? Does anyone have some idea on why it could be behaving like that..???
Thanks :) Now i can sleep properly!!

Resources