Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.controller('programador', function($scope,$http) {
- // La funcion get() que hace la solicitud para obtener los datos
- $scope.get = function(id){
- // Si la Id esta en blanco, entonces la solicitud es general
- if(id=="") {
- $http.get("api/sala").then(function (response) {
- $scope.datos = response.data.data;
- //Materialize.toast(response.data.statusMessage, 4000);
- }, function(response) {
- // Aqui va el codigo en caso de error
- });
- // Si la Id no esta en blanco, la solicitud se hace a un elemento especifico
- } else {
- $http.get("api/sala/" + id).then(function (response) {
- $scope.datos = response.data.data[0];
- //Materialize.toast(response.data.statusMessage, 4000);
- }, function(response) {
- // Aqui va el codigo en caso de error
- });
- }
- }
- setInterval(function() {
- $scope.get('');
- }, 2000);
- angular.element(document).ready(function () {
- $scope.config = {
- schedulerLicenseKey: 'CC-Attribution-NonCommercial-NoDerivatives',
- now: new Date(),
- editable: true, // enable draggable events
- droppable: true, // this allows things to be dropped onto the calendar
- aspectRatio: 1.8,
- scrollTime: '00:00', // undo default 6am scrollTime
- header: {
- left: 'today prev,next',
- center: 'title',
- right: 'timelineDay,timelineThreeDays,agendaWeek,month'
- },
- defaultView: 'timelineDay',
- views: {
- // timelineThreeDays: {
- // type: 'timeline',
- // duration: { days: 3 }
- // }
- },
- resourceLabelText: 'Salas disponibles',
- resources : $scope.datos,
- events: [
- { id: '1', resourceId: '1', start: '2017-02-07T02:00:00', end: '2017-02-07T07:00:00', title: 'event 1' },
- { id: '2', resourceId: '2', start: '2017-02-07T05:00:00', end: '2017-02-07T22:00:00', title: 'event 2' },
- { id: '3', resourceId: '3', start: '2017-02-06', end: '2017-02-08', title: 'event 3' },
- { id: '4', resourceId: '4', start: '2017-02-07T03:00:00', end: '2017-02-07T08:00:00', title: 'event 4' },
- { id: '5', resourceId: '5', start: '2017-02-07T00:30:00', end: '2017-02-07T02:30:00', title: 'event 5' }
- ],
- drop: function(date, jsEvent, ui, resourceId) {
- console.log('drop', date.format(), resourceId);
- // is the "remove after drop" checkbox checked?
- if ($('#drop-remove').is(':checked')) {
- // if so, remove the element from the "Draggable Events" list
- $(this).remove();
- }
- },
- eventReceive: function(event) { // called when a proper external event is dropped
- console.log('eventReceive', event);
- },
- eventDrop: function(event) { // called when an event (already on the calendar) is moved
- console.log('eventDrop', event);
- }
- };
- $('#external-events .fc-event').each(function() {
- // store data so the calendar knows to render an event upon drop
- $(this).data('event', {
- title: $.trim($(this).text()), // use the element's text as the event title
- stick: true // maintain when user navigates (see docs on the renderEvent method)
- });
- // make the event draggable using jQuery UI
- $(this).draggable({
- zIndex: 999,
- revert: true, // will cause the event to go back to its
- revertDuration: 0 // original position after the drag
- });
- });
- /* initialize the calendar
- -----------------------------------------------------------------*/
- $('#calendar').fullCalendar($scope.config);
- });
- resourceLabelText: 'Salas disponibles',
- resources : JSON.stringfy($scope.datos),
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement