Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.13 KB | None | 0 0
  1. app.controller('programador', function($scope,$http) {
  2.  
  3.  
  4. // La funcion get() que hace la solicitud para obtener los datos
  5. $scope.get = function(id){
  6. // Si la Id esta en blanco, entonces la solicitud es general
  7. if(id=="") {
  8. $http.get("api/sala").then(function (response) {
  9. $scope.datos = response.data.data;
  10. //Materialize.toast(response.data.statusMessage, 4000);
  11.  
  12. }, function(response) {
  13. // Aqui va el codigo en caso de error
  14. });
  15. // Si la Id no esta en blanco, la solicitud se hace a un elemento especifico
  16. } else {
  17. $http.get("api/sala/" + id).then(function (response) {
  18. $scope.datos = response.data.data[0];
  19. //Materialize.toast(response.data.statusMessage, 4000);
  20. }, function(response) {
  21. // Aqui va el codigo en caso de error
  22. });
  23. }
  24. }
  25.  
  26. setInterval(function() {
  27. $scope.get('');
  28. }, 2000);
  29.  
  30. angular.element(document).ready(function () {
  31.  
  32.  
  33. $scope.config = {
  34. schedulerLicenseKey: 'CC-Attribution-NonCommercial-NoDerivatives',
  35. now: new Date(),
  36. editable: true, // enable draggable events
  37. droppable: true, // this allows things to be dropped onto the calendar
  38. aspectRatio: 1.8,
  39. scrollTime: '00:00', // undo default 6am scrollTime
  40. header: {
  41. left: 'today prev,next',
  42. center: 'title',
  43. right: 'timelineDay,timelineThreeDays,agendaWeek,month'
  44.  
  45.  
  46. },
  47. defaultView: 'timelineDay',
  48. views: {
  49. // timelineThreeDays: {
  50. // type: 'timeline',
  51. // duration: { days: 3 }
  52. // }
  53. },
  54. resourceLabelText: 'Salas disponibles',
  55. resources : $scope.datos,
  56. events: [
  57. { id: '1', resourceId: '1', start: '2017-02-07T02:00:00', end: '2017-02-07T07:00:00', title: 'event 1' },
  58. { id: '2', resourceId: '2', start: '2017-02-07T05:00:00', end: '2017-02-07T22:00:00', title: 'event 2' },
  59. { id: '3', resourceId: '3', start: '2017-02-06', end: '2017-02-08', title: 'event 3' },
  60. { id: '4', resourceId: '4', start: '2017-02-07T03:00:00', end: '2017-02-07T08:00:00', title: 'event 4' },
  61. { id: '5', resourceId: '5', start: '2017-02-07T00:30:00', end: '2017-02-07T02:30:00', title: 'event 5' }
  62. ],
  63. drop: function(date, jsEvent, ui, resourceId) {
  64. console.log('drop', date.format(), resourceId);
  65.  
  66. // is the "remove after drop" checkbox checked?
  67. if ($('#drop-remove').is(':checked')) {
  68. // if so, remove the element from the "Draggable Events" list
  69. $(this).remove();
  70. }
  71. },
  72. eventReceive: function(event) { // called when a proper external event is dropped
  73. console.log('eventReceive', event);
  74. },
  75. eventDrop: function(event) { // called when an event (already on the calendar) is moved
  76. console.log('eventDrop', event);
  77. }
  78. };
  79.  
  80.  
  81. $('#external-events .fc-event').each(function() {
  82. // store data so the calendar knows to render an event upon drop
  83. $(this).data('event', {
  84. title: $.trim($(this).text()), // use the element's text as the event title
  85. stick: true // maintain when user navigates (see docs on the renderEvent method)
  86. });
  87. // make the event draggable using jQuery UI
  88. $(this).draggable({
  89. zIndex: 999,
  90. revert: true, // will cause the event to go back to its
  91. revertDuration: 0 // original position after the drag
  92. });
  93. });
  94.  
  95. /* initialize the calendar
  96. -----------------------------------------------------------------*/
  97. $('#calendar').fullCalendar($scope.config);
  98.  
  99.  
  100. });
  101.  
  102. resourceLabelText: 'Salas disponibles',
  103. resources : JSON.stringfy($scope.datos),
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement