Merge pull request 'ranjith-dev' (#1501) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #1501
This commit was merged in pull request #1501.
This commit is contained in:
57
app/Console/Commands/SyncFtpFiles.php
Normal file
57
app/Console/Commands/SyncFtpFiles.php
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Symfony\Component\Process\Process;
|
||||||
|
|
||||||
|
class SyncFtpFiles extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'ftp:sync';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Sync FTP files from Windows FTP server';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$process = new Process([
|
||||||
|
'/usr/bin/flock',
|
||||||
|
'-n',
|
||||||
|
'/tmp/rclone-ftp.lock',
|
||||||
|
'/usr/bin/rclone',
|
||||||
|
'copy',
|
||||||
|
'windowsftp:/LaserQS4/',
|
||||||
|
'/srv/pds.iotsignin.com/www/ftpdata',
|
||||||
|
'--include',
|
||||||
|
'*.txt',
|
||||||
|
'--log-file=' . storage_path('logs/rclone-ftp.log'),
|
||||||
|
'--log-level',
|
||||||
|
'INFO',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$process->setTimeout(null);
|
||||||
|
$process->run();
|
||||||
|
|
||||||
|
if (!$process->isSuccessful()) {
|
||||||
|
$this->error($process->getErrorOutput());
|
||||||
|
|
||||||
|
return self::FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->info('FTP synchronization completed successfully.');
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,6 +25,8 @@ use Filament\Tables\Table;
|
|||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
|
use Illuminate\Support\Facades\Artisan;
|
||||||
|
|
||||||
class ProductionTempResource extends Resource
|
class ProductionTempResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -1745,6 +1747,28 @@ class ProductionTempResource extends Resource
|
|||||||
]),
|
]),
|
||||||
])
|
])
|
||||||
->headerActions([
|
->headerActions([
|
||||||
|
Tables\Actions\Action::make('Manual Synchronization FTP')
|
||||||
|
->label('Manual Synchronization FTP')
|
||||||
|
->action(function (array $data) {
|
||||||
|
|
||||||
|
$exitCode = Artisan::call('ftp:sync');
|
||||||
|
|
||||||
|
if ($exitCode === 0) {
|
||||||
|
Notification::make()
|
||||||
|
->title('FTP synchronization completed')
|
||||||
|
->success()
|
||||||
|
->send();
|
||||||
|
} else {
|
||||||
|
Notification::make()
|
||||||
|
->title('FTP synchronization failed')
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
->visible(function () {
|
||||||
|
return Filament::auth()->user()->can('view manual synchronization ftp');
|
||||||
|
}),
|
||||||
ImportAction::make()
|
ImportAction::make()
|
||||||
->label('Import Production Temp')
|
->label('Import Production Temp')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
|
|||||||
Reference in New Issue
Block a user