Introduzione controller per hook e messaggi informativi
This commit is contained in:
parent
1610f17255
commit
566f268a8c
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Models\Hook;
|
||||
|
||||
class HookController extends Controller
|
||||
{
|
||||
public function list(Request $request)
|
||||
{
|
||||
$hooks = Hook::all();
|
||||
|
||||
$results = [];
|
||||
foreach ($hooks as $hook) {
|
||||
$results[] = [
|
||||
'id' => $hook->id,
|
||||
'name' => $hook->name,
|
||||
];
|
||||
}
|
||||
|
||||
return response()->json($results);
|
||||
}
|
||||
|
||||
public function lock(Request $request, $hook_id)
|
||||
{
|
||||
$hook = Hook::find($hook_id);
|
||||
$token = $hook->lock();
|
||||
|
||||
return response()->json($token);
|
||||
}
|
||||
|
||||
public function execute(Request $request, $hook_id, $token)
|
||||
{
|
||||
$hook = Hook::find($hook_id);
|
||||
$results = $hook->execute($token);
|
||||
|
||||
return response()->json($results);
|
||||
}
|
||||
|
||||
public function response(Request $request, $hook_id)
|
||||
{
|
||||
$hook = Hook::find($hook_id);
|
||||
$results = $hook->response();
|
||||
|
||||
return response()->json($results);
|
||||
}
|
||||
}
|
|
@ -12,11 +12,17 @@ class InfoController extends Controller
|
|||
{
|
||||
protected static $bugEmail = 'info@openstamanager.com';
|
||||
|
||||
/**
|
||||
* Gestore della pagina di informazioni del gestionale.
|
||||
*/
|
||||
public function info()
|
||||
{
|
||||
return view('info');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gestore della pagina di segnalazione bug del gestionale.
|
||||
*/
|
||||
public function bug()
|
||||
{
|
||||
$account = Account::where('predefined', true)->first();
|
||||
|
@ -27,6 +33,9 @@ class InfoController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Operazione di invio di una segnalazione bug.
|
||||
*/
|
||||
public function send(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class MessageController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$list = [
|
||||
'error',
|
||||
'warning',
|
||||
'info',
|
||||
];
|
||||
|
||||
$results = [];
|
||||
foreach ($list as $element) {
|
||||
$results[$element] = flash()->getMessage($element);
|
||||
}
|
||||
|
||||
return response()->json($results);
|
||||
}
|
||||
}
|
|
@ -106,12 +106,14 @@ class LoginRequest extends FormRequest
|
|||
*/
|
||||
protected function registerLog($status)
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
// Log di accesso
|
||||
$log = new Log();
|
||||
|
||||
$log->username = $this->input('username');
|
||||
$log->ip = $this->ip();
|
||||
$log->id_utente = auth()->user()->id;
|
||||
$log->id_utente = $user ? $user->id : null;
|
||||
$log->setStatus($status);
|
||||
|
||||
$log->save();
|
||||
|
|
2
legacy
2
legacy
|
@ -1 +1 @@
|
|||
Subproject commit 9310e63a3b0ec69cf43481bedcf0f1099e876bd1
|
||||
Subproject commit 01a293d3650fcf96d8617fab2b14a0c193bca6d9
|
|
@ -73,6 +73,8 @@
|
|||
</div>
|
||||
|
||||
<script>
|
||||
var firstFocus = true;
|
||||
|
||||
$(document).ready(function() {
|
||||
init();
|
||||
|
||||
|
@ -85,13 +87,12 @@
|
|||
<p>{{ tr("Assicurati inoltre di controllare che il checkbox relativo ai file di log sia contrassegnato, oppure riporta qui l'errore visualizzato") }}.</p>
|
||||
<p>{{ tr('Ti ringraziamo per il tuo contributo') }},<br>
|
||||
{{ tr('Lo staff di OSM') }}</p>`;
|
||||
|
||||
let editor = input("body");
|
||||
var firstFocus = true;
|
||||
/*
|
||||
editor.set(html);
|
||||
|
||||
editor.on("key", function() {
|
||||
setTimeout(function(){
|
||||
editor.on("change", function() {
|
||||
setTimeout(function() {
|
||||
$("#send").prop("disabled", editor.get() === "");
|
||||
}, 10);
|
||||
});
|
||||
|
@ -99,9 +100,9 @@
|
|||
editor.on("focus", function() {
|
||||
if (firstFocus) {
|
||||
editor.set("");
|
||||
firstFocus = 0;
|
||||
firstFocus = false;
|
||||
}
|
||||
});*/
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
@endforeach
|
||||
|
||||
globals = {
|
||||
content_was_modified: false,
|
||||
rootdir: '{{ base_url() }}',
|
||||
|
||||
id_module: '{{ $id_module }}',
|
||||
|
@ -33,7 +34,8 @@
|
|||
decimals: "{{ formatter()->getNumberSeparators()['decimals'] }}",
|
||||
thousands: "{{ formatter()->getNumberSeparators()['thousands'] }}",
|
||||
|
||||
currency: "{{ currency() }}",
|
||||
locale: '{{ substr(app()->getLocale(), 0, strpos(app()->getLocale(), "_")) }}',
|
||||
full_locale: '{{ app()->getLocale() }}',
|
||||
|
||||
search: search,
|
||||
translations: {
|
||||
|
@ -120,9 +122,6 @@
|
|||
},
|
||||
},
|
||||
|
||||
locale: '{{ app()->getLocale() }}',
|
||||
full_locale: '{{ app()->getLocale() }}',
|
||||
|
||||
start_date: '{{ session('period_start') }}',
|
||||
start_date_formatted: '{{ dateFormat(session('period_start')) }}',
|
||||
end_date: '{{ session('period_end') }}',
|
||||
|
@ -132,20 +131,23 @@
|
|||
["Undo","Redo","-","Cut","Copy","Paste","PasteText","PasteFromWord","-","Scayt", "-","Link","Unlink","-","Bold","Italic","Underline","Superscript","SpecialChar","HorizontalRule","-","JustifyLeft","JustifyCenter","JustifyRight","JustifyBlock","-","NumberedList","BulletedList","Outdent","Indent","Blockquote","-","Styles","Format","Image","Table", "TextColor", "BGColor" ],
|
||||
],
|
||||
|
||||
order_manager_id: '{{ module('Stato dei servizi')['id'] }}',
|
||||
order_manager_id: '{{ module('Stato dei servizi')->id }}',
|
||||
tempo_attesa_ricerche: {{ setting('Tempo di attesa ricerche in secondi') }},
|
||||
restrict_summables_to_selected: {{ setting('Totali delle tabelle ristretti alla selezione') }},
|
||||
select_url: "{{ route('ajax-select') }}",
|
||||
dataload_url: "{{ route('ajax-dataload', ['module_id' => '|module_id|']) }}",
|
||||
dataload_url_plugin: "{{ route('ajax-dataload', ['module_id' => '|module_id|', 'reference_id' => '|reference_id|']) }}",
|
||||
ajax_set_url: "{{ route('ajax-session') }}",
|
||||
ajax_array_set_url: "{{ route('ajax-session-array') }}",
|
||||
messages_url: "{{ route('messages') }}",
|
||||
hooks: {
|
||||
list: "{{ route('hooks') }}",
|
||||
lock: "{{ route('hook-lock', ['hook_id' => '|id|']) }}",
|
||||
execute: "{{ route('hook-execute', ['hook_id' => '|id|', 'token' => '|token|']) }}",
|
||||
response: "{{ route('hook-response', ['hook_id' => '|id|']) }}",
|
||||
|
||||
urls: {
|
||||
select: "{{ route('ajax-select') }}",
|
||||
dataload: "{{ route('ajax-dataload', ['module_id' => '|module_id|']) }}",
|
||||
dataload_plugin: "{{ route('ajax-dataload', ['module_id' => '|module_id|', 'reference_id' => '|reference_id|']) }}",
|
||||
ajax_set: "{{ route('ajax-session') }}",
|
||||
ajax_array_set: "{{ route('ajax-session-array') }}",
|
||||
messages: "{{ route('messages') }}",
|
||||
hooks: {
|
||||
list: "{{ route('hooks') }}",
|
||||
lock: "{{ route('hook-lock', ['hook_id' => '|id|']) }}",
|
||||
execute: "{{ route('hook-execute', ['hook_id' => '|id|', 'token' => '|token|']) }}",
|
||||
response: "{{ route('hook-response', ['hook_id' => '|id|']) }}",
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -311,6 +313,9 @@
|
|||
// Toast
|
||||
alertPush();
|
||||
|
||||
// Orologio
|
||||
clock();
|
||||
|
||||
// Hooks
|
||||
startHooks();
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
<meta name="robots" content="noindex,nofollow">
|
||||
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
|
||||
<link href="{{ base_url() }}/assets/img/favicon.png" rel="icon" type="image/x-icon" />
|
||||
<link rel="manifest" href="{{ base_url() }}/manifest.json">
|
||||
|
||||
|
@ -68,8 +70,17 @@
|
|||
},
|
||||
},
|
||||
|
||||
messages_url: "{{ route('messages') }}",
|
||||
urls: {
|
||||
messages: "{{ route('messages') }}",
|
||||
}
|
||||
};
|
||||
|
||||
// CSRF Token automatico per richieste AJAX
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@yield('css')
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
<?php
|
||||
|
||||
use App\Http\Controllers\ConfigurationController;
|
||||
use App\Http\Controllers\HookController;
|
||||
use App\Http\Controllers\InfoController;
|
||||
use App\Http\Controllers\InitializationController;
|
||||
use App\Http\Controllers\MessageController;
|
||||
use App\Http\Controllers\Test;
|
||||
use App\Http\Controllers\UserController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
@ -44,7 +46,7 @@ Route::post('/init', [InitializationController::class, 'save'])
|
|||
->name('initialization-save');
|
||||
|
||||
// Messaggi flash
|
||||
Route::get('/messages', [Test::class, 'index'])
|
||||
Route::get('/messages', [MessageController::class, 'index'])
|
||||
->name('messages');
|
||||
|
||||
// Operazioni Ajax
|
||||
|
@ -74,19 +76,19 @@ Route::prefix('ajax')
|
|||
Route::prefix('hook')
|
||||
->middleware(['auth'])
|
||||
->group(function () {
|
||||
Route::get('/list', [Test::class, 'index'])
|
||||
Route::get('/list', [HookController::class, 'list'])
|
||||
->name('hooks');
|
||||
|
||||
Route::get('/lock/{hook_id}', [Test::class, 'index'])
|
||||
->where('hook_id', '[0-9]+')
|
||||
Route::get('/lock/{hook_id}', [HookController::class, 'lock'])
|
||||
->whereNumber('hook_id')
|
||||
->name('hook-lock');
|
||||
|
||||
Route::get('/execute/{hook_id}/{token}', [Test::class, 'index'])
|
||||
->where('hook_id', '[0-9]+')
|
||||
Route::get('/execute/{hook_id}/{token}', [HookController::class, 'execute'])
|
||||
->whereNumber('hook_id')
|
||||
->name('hook-execute');
|
||||
|
||||
Route::get('/response/{hook_id}', [Test::class, 'index'])
|
||||
->where('hook_id', '[0-9]+')
|
||||
Route::get('/response/{hook_id}', [HookController::class, 'response'])
|
||||
->whereNumber('hook_id')
|
||||
->name('hook-response');
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue