Padding out react application

This commit is contained in:
David Bomba 2022-05-27 13:10:32 +10:00
parent c08cdc4927
commit 13a1447b79
9 changed files with 49 additions and 18 deletions

View File

@ -77,10 +77,9 @@ class Kernel extends ConsoleKernel
$schedule->job(new TaskScheduler())->daily()->withoutOverlapping();
$schedule->job(new SystemMaintenance)->weekly()->withoutOverlapping();
if(Ninja::isSelfHost())
{
$schedule->call(function () {
Account::whereNotNull('id')->update(['is_scheduler_running' => true]);
})->everyFiveMinutes();

View File

@ -780,7 +780,10 @@ class BaseController extends Controller
$this->buildCache();
return response()->view('index.index', $data)->header('X-Frame-Options', 'SAMEORIGIN', false);
if(config('ninja.react_app_enabled'))
return response()->view('react.index', $data)->header('X-Frame-Options', 'SAMEORIGIN', false);
else
return response()->view('index.index', $data)->header('X-Frame-Options', 'SAMEORIGIN', false);
}

View File

@ -63,7 +63,6 @@ class TaskSchedulerController extends BaseController
public function index()
{
set_time_limit(45);
$schedulers = Scheduler::where('company_id', auth()->user()->company()->id);

View File

@ -46,24 +46,35 @@ class TaskScheduler implements ShouldQueue
*/
public function handle()
{
foreach (MultiDB::$dbs as $db) {
foreach (MultiDB::$dbs as $db)
{
MultiDB::setDB($db);
$pending_schedulers = $this->fetchJobs();
foreach ($pending_schedulers as $scheduler) {
$this->doJob($scheduler);
}
Scheduler::with('company','job')
->where('paused', false)
->where('is_deleted', false)
->whereDate('scheduled_run', '<=', Carbon::now())
->cursor()
->each(function ($scheduler){
$this->doJob($scheduler);
});
}
}
private function doJob(Scheduler $scheduler)
{
$job = $scheduler->job;
$company = $scheduler->company;
$company = Company::find($job->company_id);
if (!$job || !$company) {
if (!$job)
return;
}
$parameters = $job->parameters;
@ -120,10 +131,7 @@ class TaskScheduler implements ShouldQueue
private function fetchJobs()
{
return Scheduler::where('paused', false)
->where('is_deleted', false)
->whereDate('scheduled_run', '<=', Carbon::now())
->cursor();
return ;
}
}

View File

@ -48,6 +48,7 @@ class SendToAdmin implements ShouldQueue
public function handle()
{
MultiDB::setDb($this->company->db);
$export = new $this->report_class($this->company, $this->request);
$csv = $export->run();

View File

@ -37,8 +37,8 @@ class Scheduler extends BaseModel
'paused',
'repeat_every',
'scheduled_run',
'company_id'
];
protected $casts = [
'start_from' => 'timestamp',
'scheduled_run' => 'timestamp',

View File

@ -56,6 +56,7 @@ class TaskSchedulerService
$scheduler->scheduled_run = $request->get('start_from') ? Carbon::parse((int)$request->get('start_from')) : Carbon::now();;
$scheduler->company_id = auth()->user()->company()->id;
$scheduler->save();
$this->createJob($request, $scheduler);
}

View File

@ -187,7 +187,7 @@ return [
'ninja_apple_api_key' => env('APPLE_API_KEY', false),
'ninja_apple_private_key' => env('APPLE_PRIVATE_KEY', false),
'ninja_apple_bundle_id' => env('APPLE_BUNDLE_ID', false),
'ninja_apple_issuer_id' => env('APPLE_ISSUER_ID', false)
'ninja_apple_issuer_id' => env('APPLE_ISSUER_ID', false),
'react_app_enabled' => env('REACT_APP_ENABLED', false),
];

View File

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html data-report-errors="{{ $report_errors }}" data-rc="{{ $rc }}" data-user-agent="{{ $user_agent }}" data-login="{{ $login }}">
<head>
<!-- Source: https://github.com/invoiceninja/invoiceninja -->
<!-- Version: {{ config('ninja.app_version') }} -->
<meta charset="UTF-8">
<title>{{ config('ninja.app_name') }}</title>
<meta name="google-signin-client_id" content="{{ config('services.google.client_id') }}">
@include('react.head')
</head>
<body class="h-full">
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>