mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-06-05 22:09:38 +02:00
Introduzione controller per hook e messaggi informativi
This commit is contained in:
48
app/Http/Controllers/HookController.php
Normal file
48
app/Http/Controllers/HookController.php
Normal file
@@ -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';
|
protected static $bugEmail = 'info@openstamanager.com';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gestore della pagina di informazioni del gestionale.
|
||||||
|
*/
|
||||||
public function info()
|
public function info()
|
||||||
{
|
{
|
||||||
return view('info');
|
return view('info');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gestore della pagina di segnalazione bug del gestionale.
|
||||||
|
*/
|
||||||
public function bug()
|
public function bug()
|
||||||
{
|
{
|
||||||
$account = Account::where('predefined', true)->first();
|
$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)
|
public function send(Request $request)
|
||||||
{
|
{
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
|
24
app/Http/Controllers/MessageController.php
Normal file
24
app/Http/Controllers/MessageController.php
Normal file
@@ -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)
|
protected function registerLog($status)
|
||||||
{
|
{
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
// Log di accesso
|
// Log di accesso
|
||||||
$log = new Log();
|
$log = new Log();
|
||||||
|
|
||||||
$log->username = $this->input('username');
|
$log->username = $this->input('username');
|
||||||
$log->ip = $this->ip();
|
$log->ip = $this->ip();
|
||||||
$log->id_utente = auth()->user()->id;
|
$log->id_utente = $user ? $user->id : null;
|
||||||
$log->setStatus($status);
|
$log->setStatus($status);
|
||||||
|
|
||||||
$log->save();
|
$log->save();
|
||||||
|
2
legacy
2
legacy
Submodule legacy updated: 9310e63a3b...01a293d365
@@ -73,6 +73,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
var firstFocus = true;
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
init();
|
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("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>
|
<p>{{ tr('Ti ringraziamo per il tuo contributo') }},<br>
|
||||||
{{ tr('Lo staff di OSM') }}</p>`;
|
{{ tr('Lo staff di OSM') }}</p>`;
|
||||||
|
|
||||||
let editor = input("body");
|
let editor = input("body");
|
||||||
var firstFocus = true;
|
|
||||||
/*
|
|
||||||
editor.set(html);
|
editor.set(html);
|
||||||
|
|
||||||
editor.on("key", function() {
|
editor.on("change", function() {
|
||||||
setTimeout(function(){
|
setTimeout(function() {
|
||||||
$("#send").prop("disabled", editor.get() === "");
|
$("#send").prop("disabled", editor.get() === "");
|
||||||
}, 10);
|
}, 10);
|
||||||
});
|
});
|
||||||
@@ -99,9 +100,9 @@
|
|||||||
editor.on("focus", function() {
|
editor.on("focus", function() {
|
||||||
if (firstFocus) {
|
if (firstFocus) {
|
||||||
editor.set("");
|
editor.set("");
|
||||||
firstFocus = 0;
|
firstFocus = false;
|
||||||
}
|
}
|
||||||
});*/
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@endsection
|
@endsection
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
globals = {
|
globals = {
|
||||||
|
content_was_modified: false,
|
||||||
rootdir: '{{ base_url() }}',
|
rootdir: '{{ base_url() }}',
|
||||||
|
|
||||||
id_module: '{{ $id_module }}',
|
id_module: '{{ $id_module }}',
|
||||||
@@ -33,7 +34,8 @@
|
|||||||
decimals: "{{ formatter()->getNumberSeparators()['decimals'] }}",
|
decimals: "{{ formatter()->getNumberSeparators()['decimals'] }}",
|
||||||
thousands: "{{ formatter()->getNumberSeparators()['thousands'] }}",
|
thousands: "{{ formatter()->getNumberSeparators()['thousands'] }}",
|
||||||
|
|
||||||
currency: "{{ currency() }}",
|
locale: '{{ substr(app()->getLocale(), 0, strpos(app()->getLocale(), "_")) }}',
|
||||||
|
full_locale: '{{ app()->getLocale() }}',
|
||||||
|
|
||||||
search: search,
|
search: search,
|
||||||
translations: {
|
translations: {
|
||||||
@@ -120,9 +122,6 @@
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
locale: '{{ app()->getLocale() }}',
|
|
||||||
full_locale: '{{ app()->getLocale() }}',
|
|
||||||
|
|
||||||
start_date: '{{ session('period_start') }}',
|
start_date: '{{ session('period_start') }}',
|
||||||
start_date_formatted: '{{ dateFormat(session('period_start')) }}',
|
start_date_formatted: '{{ dateFormat(session('period_start')) }}',
|
||||||
end_date: '{{ session('period_end') }}',
|
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" ],
|
["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') }},
|
tempo_attesa_ricerche: {{ setting('Tempo di attesa ricerche in secondi') }},
|
||||||
restrict_summables_to_selected: {{ setting('Totali delle tabelle ristretti alla selezione') }},
|
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|']) }}",
|
urls: {
|
||||||
dataload_url_plugin: "{{ route('ajax-dataload', ['module_id' => '|module_id|', 'reference_id' => '|reference_id|']) }}",
|
select: "{{ route('ajax-select') }}",
|
||||||
ajax_set_url: "{{ route('ajax-session') }}",
|
dataload: "{{ route('ajax-dataload', ['module_id' => '|module_id|']) }}",
|
||||||
ajax_array_set_url: "{{ route('ajax-session-array') }}",
|
dataload_plugin: "{{ route('ajax-dataload', ['module_id' => '|module_id|', 'reference_id' => '|reference_id|']) }}",
|
||||||
messages_url: "{{ route('messages') }}",
|
ajax_set: "{{ route('ajax-session') }}",
|
||||||
hooks: {
|
ajax_array_set: "{{ route('ajax-session-array') }}",
|
||||||
list: "{{ route('hooks') }}",
|
messages: "{{ route('messages') }}",
|
||||||
lock: "{{ route('hook-lock', ['hook_id' => '|id|']) }}",
|
hooks: {
|
||||||
execute: "{{ route('hook-execute', ['hook_id' => '|id|', 'token' => '|token|']) }}",
|
list: "{{ route('hooks') }}",
|
||||||
response: "{{ route('hook-response', ['hook_id' => '|id|']) }}",
|
lock: "{{ route('hook-lock', ['hook_id' => '|id|']) }}",
|
||||||
|
execute: "{{ route('hook-execute', ['hook_id' => '|id|', 'token' => '|token|']) }}",
|
||||||
|
response: "{{ route('hook-response', ['hook_id' => '|id|']) }}",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@@ -311,6 +313,9 @@
|
|||||||
// Toast
|
// Toast
|
||||||
alertPush();
|
alertPush();
|
||||||
|
|
||||||
|
// Orologio
|
||||||
|
clock();
|
||||||
|
|
||||||
// Hooks
|
// Hooks
|
||||||
startHooks();
|
startHooks();
|
||||||
|
|
||||||
|
@@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
<meta name="robots" content="noindex,nofollow">
|
<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 href="{{ base_url() }}/assets/img/favicon.png" rel="icon" type="image/x-icon" />
|
||||||
<link rel="manifest" href="{{ base_url() }}/manifest.json">
|
<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>
|
</script>
|
||||||
|
|
||||||
@yield('css')
|
@yield('css')
|
||||||
|
@@ -1,8 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Http\Controllers\ConfigurationController;
|
use App\Http\Controllers\ConfigurationController;
|
||||||
|
use App\Http\Controllers\HookController;
|
||||||
use App\Http\Controllers\InfoController;
|
use App\Http\Controllers\InfoController;
|
||||||
use App\Http\Controllers\InitializationController;
|
use App\Http\Controllers\InitializationController;
|
||||||
|
use App\Http\Controllers\MessageController;
|
||||||
use App\Http\Controllers\Test;
|
use App\Http\Controllers\Test;
|
||||||
use App\Http\Controllers\UserController;
|
use App\Http\Controllers\UserController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
@@ -44,7 +46,7 @@ Route::post('/init', [InitializationController::class, 'save'])
|
|||||||
->name('initialization-save');
|
->name('initialization-save');
|
||||||
|
|
||||||
// Messaggi flash
|
// Messaggi flash
|
||||||
Route::get('/messages', [Test::class, 'index'])
|
Route::get('/messages', [MessageController::class, 'index'])
|
||||||
->name('messages');
|
->name('messages');
|
||||||
|
|
||||||
// Operazioni Ajax
|
// Operazioni Ajax
|
||||||
@@ -74,19 +76,19 @@ Route::prefix('ajax')
|
|||||||
Route::prefix('hook')
|
Route::prefix('hook')
|
||||||
->middleware(['auth'])
|
->middleware(['auth'])
|
||||||
->group(function () {
|
->group(function () {
|
||||||
Route::get('/list', [Test::class, 'index'])
|
Route::get('/list', [HookController::class, 'list'])
|
||||||
->name('hooks');
|
->name('hooks');
|
||||||
|
|
||||||
Route::get('/lock/{hook_id}', [Test::class, 'index'])
|
Route::get('/lock/{hook_id}', [HookController::class, 'lock'])
|
||||||
->where('hook_id', '[0-9]+')
|
->whereNumber('hook_id')
|
||||||
->name('hook-lock');
|
->name('hook-lock');
|
||||||
|
|
||||||
Route::get('/execute/{hook_id}/{token}', [Test::class, 'index'])
|
Route::get('/execute/{hook_id}/{token}', [HookController::class, 'execute'])
|
||||||
->where('hook_id', '[0-9]+')
|
->whereNumber('hook_id')
|
||||||
->name('hook-execute');
|
->name('hook-execute');
|
||||||
|
|
||||||
Route::get('/response/{hook_id}', [Test::class, 'index'])
|
Route::get('/response/{hook_id}', [HookController::class, 'response'])
|
||||||
->where('hook_id', '[0-9]+')
|
->whereNumber('hook_id')
|
||||||
->name('hook-response');
|
->name('hook-response');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user