Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,35 @@
"require": {
"php": "^8.2",
"illuminate/support": "^11.0",
"uspdev/forms": "^0.6",
"uspdev/forms": "*",
"spatie/laravel-activitylog": "^4.9",
"spatie/laravel-permission": "^6.15",
"symfony/workflow": "^7.1",
"zerodahero/laravel-workflow": "^5.0",
"graphp/graph": "^1@dev",
"graphp/graphviz": "1.x-dev"
},
"repositories":
[
{
"type": "path",
"url": "../forms",
"options":{"symlink": true}
}
],
"extra": {
"laravel": {
"providers": [
"Uspdev\\Workflow\\WorkflowServiceProvider"
]
}
}
}
},
"repositories":
[
{
"type": "path",
"url": "../forms",
"options": {"symlink": true}
}
]
}
4 changes: 3 additions & 1 deletion config/workflow.php → config/uspdev-workflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
// Caminho de armazenamento das definições de workflow
// Pega do .env, na variável WORKFLOW_STORAGE_PATH, mas usa 'storage/app/workflow-definitions' como caminho default
return [
'storagePath' => env('WORKFLOW_STORAGE_PATH', storage_path('app/workflow-definitions')),
'storagePath' => env('WORKFLOW_STORAGE_PATH', storage_path('app/workflowsJson')),

'prefix' => 'uspdev-workflow',
];
56 changes: 56 additions & 0 deletions resources/views/show/list-bckps.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
@extends('uspdev-forms::layouts.app')

@section('header')
@endsection

@section('content')

<div class="col-2">@include('uspdev-workflow::show.partials.tabs')</div>
<div class="card">
<div class="card-header h4 card-header-sticky d-flex justify-content-between align-items-center">
<div>
<span class="text-danger">USPdev workflow</span> >
Backups
</div>
</div>
<div class="card-body">
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>Nome</th>
<th>Descrição</th>
<th>Ações</th>
</tr>
</thead>
<tbody>
@foreach ($workflowDefinitions as $workflowDefinition)
@php
$count = is_dir(config('uspdev-workflow.storagePath')) ? count(array_filter(scandir(config('uspdev-workflow.storagePath')), fn($filename) => str_contains($filename,$workflowDefinition->name))) : 0;
@endphp
<tr>
<td>
{{ $workflowDefinition->name }}
<span class="badge badge-warning badge-pill" title="Backups existentes">
{{--
Exibe o número de backups da definição que existem atualmente
--}}
{{ $count }}
</span>
</td>
<td>
{{ $workflowDefinition->description }}
</td>
<td class="d-flex justify-content-start">
@include('uspdev-workflow::show.partials.bckpgen-btn')
@includeWhen($count > 0,'uspdev-workflow::show.partials.bckplist-btn')
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
<div class="mt-2">
@include('uspdev-workflow::show.partials.globalbckp-btn')
</div>
@endsection
46 changes: 46 additions & 0 deletions resources/views/show/list-def-bckps.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
@extends('uspdev-forms::layouts.app')

@section('content')

<div class="card">
<div class="card-header h4 card-header-sticky d-flex justify-content-between align-items-center">
<div>
<span class="text-danger">USPdev workflow</span> >
Backups > {{ $workflowDefinition->name }} >
<a href="{{ route('workflows.backups-idx') }}" class="btn btn-sm btn-outline-secondary ml-2">Voltar</a>
</div>
</div>
<div class="card-body">
<div>@include('uspdev-workflow::show.partials.bckpgen-btn')</div>
<br>
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>Data de criação</th>
<th>Última modificação</th>
<th>Ações</th>
</tr>
</thead>
<tbody>
@foreach ($time_data as $created_time => $updt_time)
<tr>
<td>
{{ str_replace('_',' - ',str_replace('-','/',$created_time)) }}
</td>
<td>
{{ str_replace('_',' - ',str_replace('-','/',$updt_time)) }}
</td>
<td class="d-flex justify-content-start align-item-centered">
@include('uspdev-workflow::show.partials.restore-btn')
@include('uspdev-workflow::show.partials.bckpremove-btn')
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
<div class="mt-2">
@includeWhen(count($time_data) > 0,'uspdev-workflow::show.partials.defbckpremoveall-btn')
</div>
@endsection
44 changes: 44 additions & 0 deletions resources/views/show/list-defs.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
@extends('uspdev-forms::layouts.app')

@section('header')
@endsection

@section('content')

<div class="col-2">@include('uspdev-workflow::show.partials.tabs')</div>
<div class="card">
<div class="card-header h4 card-header-sticky d-flex justify-content-between align-items-center">
<div>
<span class="text-danger">USPdev workflow</span> >
Definições
<a href="{{ route('workflows.create-definition') }}" class="btn btn-sm btn-primary">Nova Definição</a>
</div>
</div>
<div class="card-body">
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>Nome</th>
<th>Descrição</th>
<th>Ações</th>
</tr>
</thead>
<tbody>
@foreach ($workflowDefinitions as $workflowDefinition)
<tr>
<td>
{{ $workflowDefinition->name }}
</td>
<td>
{{ $workflowDefinition->description }}
</td>
<td class="d-flex justify-content-start">
@include('uspdev-workflow::show.partials.edit-btn')
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@endsection
5 changes: 5 additions & 0 deletions resources/views/show/partials/bckpgen-btn.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div>
<a href="{{ route('workflows.gen-backup', $workflowDefinition) }}" class="btn btn-sm btn-info ml-2">
Gerar backup
</a>
</div>
3 changes: 3 additions & 0 deletions resources/views/show/partials/bckplist-btn.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<a href="{{ route('workflows.def-backup-list',$workflowDefinition) }}" class="btn btn-sm btn-warning ml-2">
Listar backups
</a>
3 changes: 3 additions & 0 deletions resources/views/show/partials/bckpremove-btn.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<a href="{{ route('workflows.def-remove-bckp',['workflowDefinition' => $workflowDefinition, 'created_time' => $created_time]) }}" class="btn btn-sm btn-danger ml-2" onclick="return confirm('Tem certeza que deseja remover este backup ? ')">
Remover backup
</a>
3 changes: 3 additions & 0 deletions resources/views/show/partials/bckpremoveall-btn.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<a href="{{ route('workflows.rmv-bckps') }}" class="btn btn-sm btn-danger ml-2" onclick="return confirm('Tem certeza de que quer remover todos os backups atuais ? Essa operação é irreversível.')">
Remover todos os backups
</a>
3 changes: 3 additions & 0 deletions resources/views/show/partials/defbckpremoveall-btn.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<a href="{{ route('workflows.def-rmv-bckps',['workflowDefinition' => $workflowDefinition]) }}" class="btn btn-sm btn-danger ml-2" onclick="return confirm('Tem certeza de que quer remover todos os backups de {{ $workflowDefinition->name }} ?')">
Remover todos os backups da definição
</a>
5 changes: 5 additions & 0 deletions resources/views/show/partials/edit-btn.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div>
<a href="{{ route('workflows.editDefinition', $workflowDefinition->name) }}" class="btn btn-sm btn-warning ml-2">
Editar
</a>
</div>
3 changes: 3 additions & 0 deletions resources/views/show/partials/globalbckp-btn.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<a href="{{ route('workflows.gen-all-backups') }}" class="btn btn-sm btn-info ml-2">
Gerar backups de todas as definições
</a>
5 changes: 5 additions & 0 deletions resources/views/show/partials/restore-btn.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div>
<a href="{{ route('workflows.restore-bckp', ['workflowDefinition' => $workflowDefinition,'created_time'=> $created_time]) }}" class="btn btn-sm btn-success ml-2" onclick="return confirm('Tem certeza de que quer restaurar o backup de {{ $workflowDefinition['name'] }} criado em {{ $created_time }} ? ')">
Restaurar
</a>
</div>
8 changes: 8 additions & 0 deletions resources/views/show/partials/tabs.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link {{ $activeTab == 'index' ? 'active':'' }}" href="{{ route('workflows.list-definitions') }}">Definitions</a>
</li>
<li class="nav-item">
<a class="nav-link {{ $activeTab == 'backup' ? 'active':'' }}" href="{{ route('workflows.backups-idx') }}">Backup</a>
</li>
<br>
16 changes: 16 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

use Illuminate\Support\Facades\Route;
use Uspdev\Workflow\Http\Controllers\WorkflowBackupController;

Route::group(['prefix' => config('uspdev-workflow.prefix'), 'middleware' => ['web']], function () {

Route::get('/backups', [WorkflowBackupController::class, 'backups_index'])->name('workflows.backups-idx');
Route::get('/backups/gen-backups', [WorkflowBackupController::class, 'bckp_gen_all'])->name('workflows.gen-all-backups');
Route::get('/backups/{workflowDefinition}/gen-backup', [WorkflowBackupController::class, 'def_bckp_gen'])->name('workflows.gen-backup');
Route::get('/backups/{workflowDefinition}/list',[WorkflowBackupController::class, 'def_bckp_list'])->name('workflows.def-backup-list');
Route::get('/backups/{workflowDefinition}/remove/{created_time}', [WorkflowBackupController::class, 'remove_bckp'])->name('workflows.def-remove-bckp');
Route::get('/backups/{workflowDefinition}/remove-all', [WorkflowBackupController::class, 'remove_def_bckps'])->name('workflows.def-rmv-bckps');
Route::get('/backups/remove-all', [WorkflowBackupController::class, 'remove_all_bckps'])->name('workflows.rmv-bckps');
Route::get('/backups/{workflowDefinition}/restore/{created_time}', [WorkflowBackupController::class,'restore_backup'])->name('workflows.restore-bckp');
});
37 changes: 37 additions & 0 deletions src/Console/Commands/WorkflowSync.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Uspdev\Workflow\Console\Commands ;

use Illuminate\Console\Command;
use Uspdev\Workflow\Services\WorkflowSyncService;

class WorkflowSync extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'workflow:sync {--path=}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Syncronizes the workflow backup on the specified path with de database';

/**
* Execute the console command.
*/
public function handle()
{
// Pega o arquivo passado na option --path.
// Caso não esteja definido, pega o diretório padrão de armazenamento em uspdev-workflow.php
$path = $this->option('path') ?: config('uspdev-workflow.storagePath');
$this->info('Sicnronizando workflows do caminho: ' . $path);

// Chama o serviço de sincronizar no caminho especificado
app(WorkflowSyncService::class)->workflow_sync($path);
}
}
Loading