lavorato su calendario

This commit is contained in:
Amministratore 2023-10-23 16:51:43 +02:00
parent fbb0276055
commit 908d8f9328
13 changed files with 11271 additions and 2229 deletions

View File

@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use App\Models\Event;
use Illuminate\Http\Request;
use Spatie\GoogleCalendar\Event as Events;
class FullCalenderController extends Controller
{
@ -18,31 +19,14 @@ class FullCalenderController extends Controller
*/
public function index(Request $request)
{
if($request->ajax()) {
$data = Event::whereDate('start', '>=', $request->start)
$data = Event::whereDate('start', '>=', $request->start)
->whereDate('end', '<=', $request->end)
->get(['id', 'title', 'start', 'end']);
return response()->json($data);
return response()->json($data);
}
return view('fullcalendar');
return view('calendario.fullcalendar');
}
@ -58,69 +42,33 @@ class FullCalenderController extends Controller
*/
public function ajax(Request $request)
{
switch ($request->type) {
case 'add':
$event = Event::create([
'title' => $request->title,
'start' => $request->start,
'end' => $request->end,
]);
return response()->json($event);
break;
case 'update':
$event = Event::find($request->id)->update([
'title' => $request->title,
'start' => $request->start,
'end' => $request->end,
]);
return response()->json($event);
break;
case 'delete':
$event = Event::find($request->id)->delete();
return response()->json($event);
break;
break;
default:
# code...
break;
}
@ -131,4 +79,14 @@ class FullCalenderController extends Controller
{
return view('calendario.fullcalendar');
}
public function testCalendar()
{
$event = Events::get();
//return json_encode($event);
foreach ($events as $evento)
{
}
}
}

View File

@ -27,7 +27,7 @@
"sfneal/view-export": "^2.10",
"snapappointments/bootstrap-select": "^1.13",
"spatie/laravel-backup": "^7.0",
"spatie/laravel-google-calendar": "^3.6",
"spatie/laravel-google-calendar": "^3.7",
"spatie/laravel-permission": "^5.10",
"webklex/laravel-imap": "^2.4"
},

14
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "6ea1c68b72b752163572b68dfb52147e",
"content-hash": "d70c281bd37ad4883769ad206aee020c",
"packages": [
{
"name": "almasaeed2010/adminlte",
@ -6035,16 +6035,16 @@
},
{
"name": "spatie/laravel-google-calendar",
"version": "3.6.0",
"version": "3.7.1",
"source": {
"type": "git",
"url": "https://github.com/spatie/laravel-google-calendar.git",
"reference": "2c292b0eaa743105643987cd73c1c187d6183784"
"reference": "cad3ac5b8f883922cab61af80f60dba239666f04"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/laravel-google-calendar/zipball/2c292b0eaa743105643987cd73c1c187d6183784",
"reference": "2c292b0eaa743105643987cd73c1c187d6183784",
"url": "https://api.github.com/repos/spatie/laravel-google-calendar/zipball/cad3ac5b8f883922cab61af80f60dba239666f04",
"reference": "cad3ac5b8f883922cab61af80f60dba239666f04",
"shasum": ""
},
"require": {
@ -6097,7 +6097,7 @@
"spatie"
],
"support": {
"source": "https://github.com/spatie/laravel-google-calendar/tree/3.6.0"
"source": "https://github.com/spatie/laravel-google-calendar/tree/3.7.1"
},
"funding": [
{
@ -6105,7 +6105,7 @@
"type": "custom"
}
],
"time": "2023-04-20T06:44:04+00:00"
"time": "2023-10-09T13:16:27+00:00"
},
{
"name": "spatie/laravel-package-tools",

View File

@ -0,0 +1,44 @@
<?php
return [
'default_auth_profile' => env('GOOGLE_CALENDAR_AUTH_PROFILE', 'service_account'),
'auth_profiles' => [
/*
* Authenticate using a service account.
*/
'service_account' => [
/*
* Path to the json file containing the credentials.
*/
'credentials_json' => storage_path('app/google-calendar/service-account-credentials.json'),
],
/*
* Authenticate with actual google user account.
*/
'oauth' => [
/*
* Path to the json file containing the oauth2 credentials.
*/
'credentials_json' => storage_path('app/google-calendar/oauth-credentials.json'),
/*
* Path to the json file containing the oauth2 token.
*/
'token_json' => storage_path('app/google-calendar/oauth-token.json'),
],
],
/*
* The id of the Google Calendar that will be used by default.
*/
'calendar_id' => env('GOOGLE_CALENDAR_ID'),
/*
* The email address of the user account to impersonate.
*/
'user_to_impersonate' => env('GOOGLE_CALENDAR_IMPERSONATE'),
];

13063
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -21,6 +21,7 @@
"sass-loader": "^11.0.1"
},
"dependencies": {
"@fullcalendar/google-calendar": "^6.1.9",
"bootstrap-select": "^1.13.18",
"fullcalendar": "^5.10.2"
}

144
public/js/app/calendario.js vendored Normal file
View File

@ -0,0 +1,144 @@
document.addEventListener('DOMContentLoaded', function() {
// import { Calendar } from '@fullcalendar/core';
// import googleCalendarPlugin from '@fullcalendar/google-calendar';
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
timeZone: 'UTC',
initialView: 'timeGridWeek',
// plugins: [ googleCalendarPlugin ],
googleCalendarApiKey: 'AIzaSyClqRqDMqD4grSx5HeLq1lXMxan1-UjK_E',
events: {
googleCalendarId: 'brebar.family@gmail.com'
},
// events: 'admin/test/calendar/google',
editable: true,
selectable: true,
// plugins: [dayGridPlugin],
// initialView: 'dayGridWeek',
headerToolbar: {
left: 'prev,next',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay' // user can switch between the two
},
dateClick: function(info) {
// alert('Clicked on: ' + info.dateStr);
$('#start').val(info.dateStr);
$('#event').modal('show');
console.log(info.dateStr);
//inserire qui richiamo a pagina modale di inserimento appuntamento.
}
});
calendar.setOption('locale', 'it');
calendar.render();
});
$(document).ready(function () {
var SITEURL = "{{ url('/admin/') }}";
// $(".draggable").draggable();
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
});
/*
var calendar = $('#calendar').fullCalendar({
editable: true,
events: SITEURL + "/fullcalendar",
displayEventTime: true,
editable: true,
eventRender: function (event, element, view) {
if (event.allDay === 'true') {
event.allDay = true;
} else {
event.allDay = false;
}
},
selectable: true,
selectHelper: true,
select: function (start, end, allDay) {
var title = prompt('Titolo evento:');
if (title) {
var start = $.fullCalendar.formatDate(start, "Y-MM-DD");
var end = $.fullCalendar.formatDate(end, "Y-MM-DD");
$.ajax({
url: SITEURL + "/fullcalendar",
data: {
title: title,
start: start,
end: end,
type: 'add'
},
type: "POST",
success: function (data) {
displayMessage("Evento creato con successo");
calendar.fullCalendar('renderEvent',
{
id: data.id,
title: title,
start: start,
end: end,
allDay: allDay
},true);
calendar.fullCalendar('unselect');
}
});
}
},
eventDrop: function (event, delta) {
var start = $.fullCalendar.formatDate(event.start, "Y-MM-DD");
var end = $.fullCalendar.formatDate(event.end, "Y-MM-DD");
$.ajax({
url: SITEURL + '/fullcalendar',
data: {
title: event.title,
start: start,
end: end,
id: event.id,
type: 'update'
},
type: "POST",
success: function (response) {
displayMessage("Event Updated Successfully");
}
});
},
eventClick: function (event) {
var deleteMsg = confirm("vuoi veramente cancellare?");
if (deleteMsg) {
$.ajax({
type: "POST",
url: SITEURL + '/fullcalendar',
data: {
id: event.id,
type: 'delete'
},
success: function (response) {
calendar.fullCalendar('removeEvents', event.id);
displayMessage("Event Deleted Successfully");
}
});
}
}
});
});
function displayMessage(message) {
toastr.success(message, 'Event');
}
/**/

View File

@ -5,35 +5,21 @@
@endsection
@section('content')
<div id="calendar"></div>
<div class="modal fade " id="event" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog draggable" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Nuovo Appuntamento</h4>
</div>
<div class="modal-body">
Start <input type="text" id="start" name="start">
</div>
</div>
</div>
</div>
@endsection
@section('js')
<script>
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
timeZone: 'UTC',
initialView: 'dayGridMonth',
events: '/api/demo-feeds/events.json',
editable: true,
selectable: true,
// plugins: [dayGridPlugin],
// initialView: 'dayGridWeek',
headerToolbar: {
left: 'prev,next',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay' // user can switch between the two
},
dateClick: function(info) {
alert('Clicked on: ' + info.dateStr);
}
});
calendar.setOption('locale', 'it');
calendar.render();
});
</script>
<script src="/js/app/calendario.js"></script>
@endsection

View File

@ -29,21 +29,12 @@
<script>
$(document).ready(function () {
var SITEURL = "{{ url('/admin/') }}";
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
@ -51,167 +42,87 @@ $.ajaxSetup({
var calendar = $('#calendar').fullCalendar({
editable: true,
events: SITEURL + "/fullcalendar",
displayEventTime: false,
editable: true,
eventRender: function (event, element, view) {
if (event.allDay === 'true') {
event.allDay = true;
} else {
event.allDay = false;
}
},
selectable: true,
selectHelper: true,
select: function (start, end, allDay) {
var title = prompt('Event Title:');
var title = prompt('Titolo evento:');
if (title) {
var start = $.fullCalendar.formatDate(start, "Y-MM-DD");
var end = $.fullCalendar.formatDate(end, "Y-MM-DD");
$.ajax({
url: SITEURL + "/fullcalendar",
data: {
title: title,
start: start,
end: end,
type: 'add'
},
type: "POST",
success: function (data) {
displayMessage("Event Created Successfully");
displayMessage("Evento creato con successo");
calendar.fullCalendar('renderEvent',
{
id: data.id,
title: title,
start: start,
end: end,
allDay: allDay
},true);
calendar.fullCalendar('unselect');
}
});
}
},
eventDrop: function (event, delta) {
var start = $.fullCalendar.formatDate(event.start, "Y-MM-DD");
var end = $.fullCalendar.formatDate(event.end, "Y-MM-DD");
$.ajax({
url: SITEURL + '/fullcalendar',
data: {
title: event.title,
start: start,
end: end,
id: event.id,
type: 'update'
},
type: "POST",
success: function (response) {
displayMessage("Event Updated Successfully");
}
});
},
eventClick: function (event) {
var deleteMsg = confirm("Do you really want to delete?");
var deleteMsg = confirm("vuoi veramente cancellare?");
if (deleteMsg) {
$.ajax({
type: "POST",
url: SITEURL + '/fullcalendar',
data: {
id: event.id,
type: 'delete'
},
success: function (response) {
calendar.fullCalendar('removeEvents', event.id);
displayMessage("Event Deleted Successfully");
}
});
}
}
});
@ -221,9 +132,7 @@ var calendar = $('#calendar').fullCalendar({
function displayMessage(message) {
toastr.success(message, 'Event');
}

View File

@ -189,6 +189,7 @@ Route::group(['middleware'=>['permission:documenti']], function(){
/// TEST ROUTES
Route::get('test/fullcalendar', [FullCalenderController::class, 'index']);
Route::post('test/fullcalendar', [FullCalenderController::class, 'ajax']);
Route::get('test/calendar/google',[FullCalenderController::class, 'testcalendar']);
Route::get('test/condominio',[CondominioController::class,'testPdf']);
Route::get('test/err403',[CondominioController::class,'err403'])->name('errore-403');

6
wget-log Normal file
View File

@ -0,0 +1,6 @@
--2023-10-23 15:21:09-- https://www.googleapis.com/calendar/v3/calendars/brebar.family%40gmail.com/events?key=AIzaSyClqRqDMqD4grSx5HeLq1lXMxan1-UjK_E
Resolving www.googleapis.com (www.googleapis.com)... 216.58.204.138, 216.58.205.42, 142.250.180.138, ...
Connecting to www.googleapis.com (www.googleapis.com)|216.58.204.138|:443... connected.
HTTP request sent, awaiting response... 403 Forbidden
2023-10-23 15:21:09 ERROR 403: Forbidden.

6
wget-log.1 Normal file
View File

@ -0,0 +1,6 @@
--2023-10-23 15:24:09-- https://www.googleapis.com/calendar/v3/calendars/brebar.family%40gmail.com/events?key=AIzaSyClqRqDMqD4grSx5HeLq1lXMxan1-UjK_E
Resolving www.googleapis.com (www.googleapis.com)... 216.58.209.42, 216.58.204.138, 216.58.205.42, ...
Connecting to www.googleapis.com (www.googleapis.com)|216.58.209.42|:443... connected.
HTTP request sent, awaiting response... 403 Forbidden
2023-10-23 15:24:09 ERROR 403: Forbidden.

6
wget-log.2 Normal file
View File

@ -0,0 +1,6 @@
--2023-10-23 15:24:55-- https://www.googleapis.com/calendar/v3/calendars/brebar.family@gmail.com/events?key=AIzaSyClqRqDMqD4grSx5HeLq1lXMxan1-UjK_E
Resolving www.googleapis.com (www.googleapis.com)... 142.250.180.138, 142.250.180.170, 142.251.209.10, ...
Connecting to www.googleapis.com (www.googleapis.com)|142.250.180.138|:443... connected.
HTTP request sent, awaiting response... 403 Forbidden
2023-10-23 15:24:55 ERROR 403: Forbidden.