fullCalendar how to set the events programmatically - fullcalendar

I'm having a problem setting the calendar event grammatically.
I have a page where the user can select the client to display the event for using a drop down. I request the events via an Ajax call. And this all looks good. But I'm having a problem setting the events in fullCalendar.
This is my code to set the events:
success: function(resp){
var r = resp.output;
console.dir(r);
jQuery('#student').html(r.studentname);
jQuery('#calendar').fullCalendar( 'removeEvents' ); // <= This works
jQuery('#calendar').fullCalendar( 'events', r.events ); // <= This doesn't
}
This is a dump of the ajax response:
events "[{
id: 1,
title: 'Acupuncture',
start: new Date(2013, 5, 29, 10, 00),
end: new Date(2013, 5, 29, 10, 30),
allDay: false
}
,
{
id: 2,
title: 'Acupuncture',
start: new Date(2013, 6, 30, 10, 00),
end: new Date(2013, 6, 30, 10, 30),
allDay: false
}
,
{
id: 3,
title: 'Chiropractor',
start: new Date(2013, 6, 31, 11, 00),
end: new Date(2013, 6, 31, 11, 15),
allDay: false
}
]
"
id "1"
studentname "Tarah Yates"
I couldn't find any examples on how to do this so I'm not sure if I am doing it right.
I just noticed the quotes around the event list, maybe that's the problem?
If that's not the problem, does anybody have any thoughts on why it's not working?

gwardell that response needs to be iterated so you can fetch the elements of the array. But i would change the type of response to JSON like this:
[{
"id": "1",
"title": "Acupuncture",
"start": "29-05-2013 10:00", //adapted this date format is accepted by fullcalendar
"end": "29-05-2013 10:30",
"allDay": false //You dont need to adapt this it was a mistake of me. Leave it be.
},etc, etc, etc]
Notice that there can only be simple JSON, you can't have a response with complex JSON with sub-arrays.
PS. - Go and study a bit of JSON format on the NET and you will figure it out i'm sure.
Not sure about that line, but what you wanna do will only create the event in that view while your are there, when you switch to other view will disapear. What you want to do is to save to a Database or whatever you use to store data to store the events. Then they will be persistent and when you refetchevents the event will apear...so jQuery('#calendar').fullCalendar( 'events', 'refetchevents' );
How to pass the ID in ajax call assuming you are doing this with JSON and Jquery Ajax
$.ajax({
type: 'POST',
url: _url,
data: {'id': 9999, //Just pass like this or you can set like a function 'id':getMyID(),
'title':name,
'start':start,
'end':end,
'allDay': allDay,
'editable': true,
},
success: function(data) {
//TODO Do stuff
}
});
or if you have an array of eventsources
var othersources = {
ausencias: {
url: _url,
type: 'POST',
data:{
'id':getMyId(), // 'id':myidvalue
'func':func,
'year':y
},
cache: false,
color: '#C1272D',
textColor: 'white'
}}

Related

Custom metric/dimension not visible in GA4 DebugView on item/product-list level

We're trying to configure GA4 to gather same data that we have in UA.
The problem is that we cant see custom metrics data on item-level in DebugView.
In TagAssistant we can see that data is sent:
{
event: "purchase",
gtm: {uniqueEventId: 10, start: 1651XXX},
gtag: {
targets: {
G-XXX: {_ee: true, _uei: 3, _upi: 2},
UA-XXX: {
currency: "PLN",
country: "PL",
custom_map: {
dimension2: "referrer",
...
dimension13: "ecomm_totalvalue",
metric1: "metric1",
...
metric5: "metric5"
},
_uei: 4
},
AW-106XXX: {}
}
},
eventModel: {
transaction_id: "40XXX",
affiliation: "XXX",
value: "9.99",
currency: "PLN",
tax: "1.87",
shipping: "0",
coupon: "",
items: [
{
id: "670",
name: "Tusz Zamiennik T0711 do Epson (C13T07114010) (Czarny)",
brand: "XXX",
category: "Wkłady/Atramentowe/Zamienniki/Tusze/XXX -> Do:E" +
"pson",
quantity: 1,
price: "9.99",
coupon: "",
metric1: "9.99",
metric2: "9.99",
metric3: "9.99",
metric4: "9.99",
metric5: "9.99"
}
],
send_to: ""
}
}
However, on DebugView side we can see purchase event that:
contains all orginal parameters on event level (like transaction_id, shipping etc.)
contains all orginal parameters on item level (like item_id, quantity, etc.)
But our custom metrics are missing
In the other hand, we tried (with different event) push some custom-dumension data and:
they are visible on GA4 DebugView
we can create custom dimension in GA4 basing on this data and it works
I am thinking about:
Creating event-level custom metric to test if it will be passed to GA4 DebugView
Creating item-level custom dimension to test if it will be passed to GA4 DebugView
However, due to fact that GA requires 24h to make conclusions i decided to ask here for any sugestions why it is not working and what else may i test.

Missing endtime whie inserting to calendar event

while trying to insert and event i continously getting the same error although i try to use different time zone and even copy pasted the the code snippet provided Events:insert.
The error i am getting is :
<HttpError 400 when requesting https://www.googleapis.com/calendar/v3/calendars/primary/events?alt=json returned "Missing end time.". Details: "Missing end time.">
The code i am using to create the event is :
event = {
'summary': data['summary'],
'description': data['description'],
'start': {
'dateTime': data['start_time'],
'timeZone': 'ASIA/KOLKATA',
},
'end': {
'dateTime': data['end_time'],
'timeZone': 'ASIA/KOLKATA',
},
'recurrence': [
'RRULE:FREQ=DAILY;COUNT=2'
],
'attendees': [
{'email': 'moinkhan8439#gmail.com'},
{'email': 'zainkhanjune#gmail.com'},
],
'reminders': {
'useDefault': False,
'overrides': [
{'method': 'email', 'minutes': 24 * 60},
{'method': 'popup', 'minutes': 10},
],
}
}
created_event = service.events().insert(calendarId='primary', body=event).execute()
I tried converting to RFC3339 but same error .
Note - i am getting data from a POST request through a serializer.
This error occur when we dont pass the correct format in the body section of the insert fucntion.
service.events().insert(calendarId='primary',sendNotifications=True, body=event).execute()
I found out that i was passing the datetime object into datetime keyword for event whereas we have to first convert the datetime into standard RFC339 as specififed under authorization section here
and then convert it to string to be passed into event body.
To convert Django models.datetime object into RFC3339 string do this:
str(date.isoformat('T'))

Httpt batch call for multiple POST operations

I am trying to do multiple $http post call and my code looks something like this:
var data = [{"id": 1, "Name": A}, {"id": 2, "Name": B},...];
var requests = [];
angular.forEach(data, function(value) {
requests.push($http(
url:'/example.com',
method: "POST",
dataType: 'json',
contentType:'application/json',
data:value ))
});
$q.all(requests).then(function(results){
results.forEach(function(data,status,headers,config){
console.log('success');
})
})
This works fine, but when the length of data array is more the number of service calls from client side is high. So I would like to make it as a batch request. Am not able to find any proper documentation for batch request for POST operation. Kindly help me on this.

Missing likes/comments in LinkedIn API response

since 4 days my job which is fetching linkedIn updates is getting null responses for likes and comments (requests on specific updates : /updates/key={update-key}/likes and /updates/key={update-key}/update-comments endpoints). This is probably expected since when requesting on /updates/key={update-key}, the response does not have likes nor comments field.
My question is how can I get those values for specific updates (which I managed to get previously) since I can get them differently (maybe? read following)
Here's the strangest part : when I don't specify the update (request only on /updates endpoint), I get the following response : (modified a bit for readability/privacy)
{
"_count": 10,
"_start": 0,
"_total": 212,
"values": [
{
"isCommentable": false,
"isLikable": false,
"isLiked": false,
"likes": {
"_total": 3,
"values": [...]
},
"numLikes": 7,
"timestamp": ...,
"updateComments": {"_total": 0},
"updateContent": {...},
"updateKey": ...
"updateType": ...
},{
"isCommentable": false,
"isLikable": false,
"isLiked": false,
"likes": {
"_total": 3,
"values": [...]
},
"numLikes": 9,
"timestamp": ...,
"updateComments": {"_total": 0},
"updateContent": {...},
"updateKey": "...",
"updateType": "..."
}, ....
So first, the updates have their fields isCommentable, isLikable and isLiked set to false, despite the fact that they have likes/comments.
Second, there is an inconsistency between the fields likes._total and numLikes (the latter one is the correct amount of likes)
Does anyone else encountered a similar problem? (well linkedin api update comment count null) Is it something expected or a change from LinkedIn side?
I already ask to LinkedIn help center which redirected me to StackOverflow.
Thanks for your time.
Ok, I retried today :
{
"isCommentable": true,
"isLikable": true,
"isLiked": false,
"likes": {
"_total": 9,
"values": [
{ ...
So definitely an issues on linkedin side, fixed for now.
Same issue.
If you get a specific company update (with comment and like)
//api.linkedin.com/v1/companies/xxxx/updates/key=yyyy?format=json
{
"isCommentable": false,
"isLikable": false,
...
}
If you get comments for a specific company update
//api.linkedin.com/v1/companies/xxxx/updates/key=yyyy/likes?format=json
Result null
If you get likes for a specific company update
//api.linkedin.com/v1/companies/xxxx/updates/key=yyyy/update-comments?format=json
Result null

Fullcalendar with JSON feed returning eventSource in extended form

I'm using the excellent fullcalendar by arshaw with Angular UI and right now I'm having a problem with eventSource objects in extended form not rendering when fetched as JSON feeds.
The data is fetched using the following code in the controller:
$scope.events = [
'/api/v1/users/104/events?format=cal&type=9',
'/api/v1/users/104/events?format=cal&type=10'
];
$scope.eventSources = $scope.events;
When the JSON feed returns an array with event objects it actually works:
// returned by - /api/v1/users/104/events?format=cal&type=9
[
{
url: "/#/events/86893",
start: "2013-03-15",
title: ": Event - 86893"
},
{
url: "/#/events/31348",
start: "2013-03-27T09:30Z",
title: "Event - 31348"
}
],
// returned by - /api/v1/users/104/events?format=cal&type=10
[
{
url: "/#/events/86899",
start: "2013-03-25",
title: ": Event - 86899"
},
{
url: "/#/events/31349",
start: "2013-03-17T09:30Z",
title: "Event - 31349"
}
]
However I would like to specify some options along with the event data, for example different colors for different JSON feeds. Hence I settled for the API to return the event source in its extended form . This is what it API returns.
// returned by - /api/v1/users/104/events?format=cal&type=9
{
events: [
{
url: "/#/events/86893",
start: "2013-03-15",
title: "Event - 86893"
},
{
url: "/#/events/31348",
start: "2013-03-27T09:30Z",
title: "Event - 31348"
}
],
color: "#ff9900",
allDayDefault: false,
ignoreTimezone: true
},
// returned by - /api/v1/users/104/events?format=cal&type=10
{
events: [
{
url: "/#/events/86899",
start: "2013-03-25",
title: "Event - 86899"
},
{
url: "/#/events/31349",
start: "2013-03-17T09:30Z",
title: "Event - 31349"
}
],
color: "#3366FF",
allDayDefault: false,
ignoreTimezone: true
}
Unfortunately this format isn't rendered when fetched as JSON. When fetching the extended format I changed the eventSources assignment somewhat to look like this:
$scope.eventSources = [ $scope.events ];
If I cut and paste the raw JSON response (with the event source in its extended form) from the API straight into the eventSources method it works. Isn't it possible to consume the event source in extended form when it is returned as a JSON feed?
Could it be that the eventSource being returned from the API is not where the extended form options should be used, but rather in the event functions used as the eventSource's.
The documentation states that the extended form should be used inside of the Json object used to call the API.
http://arshaw.com/fullcalendar/docs/event_data/events_json_feed/
If the API was too return the extra options for the events, then it would need to set each one individually.
Currently in this post, The only place I see where the extended options are called is from the returned api data.
I think this should be the other way around. And the calendar should know about the extended form before it even requests the data at all. This would mean the server will not need to return any extra options and the calendar will organize the event objects by feed and extended options.
If you could post a plunk, then we could nail this.

Resources