angularjs - Refresh Events In Angular Calendar UI (Fullcalendar) With Laravel As A Backend -


i trying make automated refresh calendar. using calendar ui , getting data backend in way

  /**calendar config***/       //config object                 $scope.uiconfig = {                     calendar:{                         height: 500,                         width: 800,                         editable: false,                         //first hour                         firsthour: 8,                         //devide half hour                         slotminutes: 30,                         //default duration 01:30                         defaulteventminutes: 90,                         axisformat: 'hh:mm',                         timeformat: {                             agenda: 'h:mm{ - h:mm}'                         },                     header:{                         //buttons                         center: 'month agendaweek agendaday',                         left: 'title',                         right: 'today prev,next'               },               defaultview: 'agendaweek'             }           };        //get planings group             $scope.getplaningsbygroup = function(groupid){                 planing.getplaningsbygroup(groupid)                     .success(function(data){                         //populate event object                         $scope.populateplan(data);                     });                 }        //populating plan       $scope.events = [];       $scope.populateplan = function(plans){         plans.foreach(function(plan){           start_time = moment.duration(plan.start_time);;           duration = moment.duration(plan.course.duration);           start_course = moment()                           .day(plan.day)                           .hour(start_time.hours())                           .minutes(start_time.minutes())                           .seconds(start_time.seconds())                           .format("yyyy-mm-ddthh:mm:ss");              end_time = start_time.add(duration);           end_course = moment()                           .day(plan.day)                           .hour(end_time.hours())                           .minutes(end_time.minutes())                           .seconds(end_time.seconds())                           .format("yyyy-mm-ddthh:mm:ss");            console.log(end_course);            $scope.events.push(                   {                     id:plan.id,                     title:plan.course.title,                     start:start_course,                     end :end_course,                     allday:false,                   }             );           });       }       //event source object       $scope.eventsources = [$scope.events]; 

i don't know if wierdest way still babe @ angular js please excuse crime scene ^^ . did little reasearch , decided go $interval provider refresh events. , here problems faced after trying: try 1 : //refresh events var refresh = function(){ $('#calendar').fullcalendar('rerenderevents'); console.log("refreshed"); } $interval(refresh, 3000); refresh();

basically did nothing try 2 : //refresh events var refresh = function(){ $scope.events.length = 0; $scope.getplaningsbygroup($scope.student.group_id); console.log("refreshed"); } $interval(refresh, 3000); refresh();

and worked know suicide attempt backend. question how solve madness.

you can use 2 strategies keep calendar in sync server without make lots of requests.

the first one, called long polling. put simply, client makes request, server keep alive until new events available.

the second one, called websocket. it's full-duplex communication channel can send data in both directions.

i don't work php, don't know if laravel has support long polling or websocket, think not difficult create.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -