| @ -0,0 +1,91 @@ | |||||
| <?php | |||||
| namespace App\Commands; | |||||
| use Illuminate\Console\Scheduling\Schedule; | |||||
| use LaravelZero\Framework\Commands\Command; | |||||
| use PhpSchool\CliMenu\Builder\CliMenuBuilder; | |||||
| use PhpSchool\CliMenu\CliMenu; | |||||
| class AdminLogsCommand extends Command | |||||
| { | |||||
| /** | |||||
| * The signature of the command. | |||||
| * | |||||
| * @var string | |||||
| */ | |||||
| protected $signature = 'admin:logs'; | |||||
| /** | |||||
| * The description of the command. | |||||
| * | |||||
| * @var string | |||||
| */ | |||||
| protected $description = 'Command description'; | |||||
| /** | |||||
| * | |||||
| * | |||||
| */ | |||||
| private function addInputItem() | |||||
| { | |||||
| $callable = function(CliMenu $menu) | |||||
| { | |||||
| $input = $menu->askText(); | |||||
| $result = $input->ask(); | |||||
| $menu->redraw(); | |||||
| }; | |||||
| return $callable; | |||||
| } | |||||
| /** | |||||
| * | |||||
| * | |||||
| */ | |||||
| private function addCreateItem() | |||||
| { | |||||
| $menu = function(CliMenuBuilder $builder) | |||||
| { | |||||
| $data = []; | |||||
| $builder | |||||
| ->setTitle('Settings > Add') | |||||
| ->disableDefaultItems() | |||||
| // input name | |||||
| ->addItem('name', $this->addInputItem()) | |||||
| // input url | |||||
| ->addItem('url', $this->addInputItem()) | |||||
| ->addItem('handler', $this->addInputItem()) | |||||
| ->addLineBreak('-') | |||||
| ->addSubMenu('actions', $this->addActions()) | |||||
| ->addLineBreak('-'); | |||||
| }; | |||||
| return $menu; | |||||
| } | |||||
| /** | |||||
| * Execute the console command. | |||||
| * | |||||
| * @return mixed | |||||
| */ | |||||
| public function handle() | |||||
| { | |||||
| // create menu | |||||
| $builder = $this->menu('Settings'); | |||||
| $builder | |||||
| ->addSubMenu('Add', $this->addCreateItem()) | |||||
| ->addLineBreak('-'); | |||||
| $mainmenu = $builder->build(); | |||||
| $mainmenu->open(); | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,91 @@ | |||||
| <?php | |||||
| namespace App\Commands; | |||||
| use Illuminate\Console\Scheduling\Schedule; | |||||
| use LaravelZero\Framework\Commands\Command; | |||||
| use PhpSchool\CliMenu\Builder\CliMenuBuilder; | |||||
| use PhpSchool\CliMenu\CliMenu; | |||||
| class AdminSourcesCommand extends Command | |||||
| { | |||||
| /** | |||||
| * The signature of the command. | |||||
| * | |||||
| * @var string | |||||
| */ | |||||
| protected $signature = 'admin:sources'; | |||||
| /** | |||||
| * The description of the command. | |||||
| * | |||||
| * @var string | |||||
| */ | |||||
| protected $description = 'Command description'; | |||||
| /** | |||||
| * | |||||
| * | |||||
| */ | |||||
| private function addInputItem() | |||||
| { | |||||
| $callable = function(CliMenu $menu) | |||||
| { | |||||
| $input = $menu->askText(); | |||||
| $result = $input->ask(); | |||||
| $menu->redraw(); | |||||
| }; | |||||
| return $callable; | |||||
| } | |||||
| /** | |||||
| * | |||||
| * | |||||
| */ | |||||
| private function addCreateItem() | |||||
| { | |||||
| $menu = function(CliMenuBuilder $builder) | |||||
| { | |||||
| $data = []; | |||||
| $builder | |||||
| ->setTitle('Settings > Add') | |||||
| ->disableDefaultItems() | |||||
| // input name | |||||
| ->addItem('name', $this->addInputItem()) | |||||
| // input url | |||||
| ->addItem('url', $this->addInputItem()) | |||||
| ->addItem('handler', $this->addInputItem()) | |||||
| ->addLineBreak('-') | |||||
| ->addSubMenu('actions', $this->addActions()) | |||||
| ->addLineBreak('-'); | |||||
| }; | |||||
| return $menu; | |||||
| } | |||||
| /** | |||||
| * Execute the console command. | |||||
| * | |||||
| * @return mixed | |||||
| */ | |||||
| public function handle() | |||||
| { | |||||
| // create menu | |||||
| $builder = $this->menu('Settings'); | |||||
| $builder | |||||
| ->addSubMenu('Add', $this->addCreateItem()) | |||||
| ->addLineBreak('-'); | |||||
| $mainmenu = $builder->build(); | |||||
| $mainmenu->open(); | |||||
| } | |||||
| } | |||||
| @ -1,43 +0,0 @@ | |||||
| <?php | |||||
| namespace App\Commands; | |||||
| use Illuminate\Console\Scheduling\Schedule; | |||||
| use LaravelZero\Framework\Commands\Command; | |||||
| class SettingsMenuCommand extends Command | |||||
| { | |||||
| /** | |||||
| * The signature of the command. | |||||
| * | |||||
| * @var string | |||||
| */ | |||||
| protected $signature = 'settings:menu'; | |||||
| /** | |||||
| * The description of the command. | |||||
| * | |||||
| * @var string | |||||
| */ | |||||
| protected $description = 'Command description'; | |||||
| /** | |||||
| * Execute the console command. | |||||
| * | |||||
| * @return mixed | |||||
| */ | |||||
| public function handle() | |||||
| { | |||||
| // create menu | |||||
| $builder = $this->menu('Settings') | |||||
| ->addSubMenu('Sources', [ | |||||
| 'd', | |||||
| 'e' | |||||
| ]); | |||||
| $builder->addLineBreak('-'); | |||||
| $mainmenu = $builder->build(); | |||||
| $mainmenu->open(); | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,26 @@ | |||||
| <?php | |||||
| namespace App\ResponseHandler; | |||||
| use App\Handlers\Handler; | |||||
| /** | |||||
| * | |||||
| * | |||||
| * | |||||
| */ | |||||
| class ActionHandler extends Handler implements ActionHandlerInterface | |||||
| { | |||||
| protected $data; | |||||
| /** | |||||
| * | |||||
| * @param mixed $data | |||||
| * | |||||
| */ | |||||
| public function __construct($data) | |||||
| { | |||||
| $this->data = $data; | |||||
| } | |||||
| } | |||||
| @ -1,11 +0,0 @@ | |||||
| <?php | |||||
| /** | |||||
| * | |||||
| * | |||||
| * | |||||
| */ | |||||
| class FileMoveActionHandler extends ActionHandler { | |||||
| } | |||||
| @ -0,0 +1,42 @@ | |||||
| <?php | |||||
| namespace App\Handlers; | |||||
| /** | |||||
| * | |||||
| * | |||||
| * | |||||
| */ | |||||
| abstract class Handler | |||||
| { | |||||
| /** | |||||
| * | |||||
| * | |||||
| * @param String $className | |||||
| * @return Mixed | |||||
| * | |||||
| */ | |||||
| protected function getHandlerClass(String $className) | |||||
| { | |||||
| $result = NULL; | |||||
| // create class | |||||
| $class = 'App\\Handlers\\'.$className); | |||||
| // if not found check for custom handlers | |||||
| if (class_exists($class)) { | |||||
| $result = new $class(); | |||||
| } else { | |||||
| // create class | |||||
| $class = 'CustomHandlers\\'.$className; | |||||
| if (class_exists($class)) { | |||||
| $result = new $class(); | |||||
| } | |||||
| } | |||||
| return $result; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,20 @@ | |||||
| <?php | |||||
| namespace App\Models; | |||||
| use Illuminate\Database\Eloquent\Model; | |||||
| /** | |||||
| * | |||||
| * | |||||
| * | |||||
| */ | |||||
| class Action extends Model | |||||
| { | |||||
| protected $fillable = [ | |||||
| 'action_handler_class', | |||||
| 'priority', | |||||
| 'source_id' | |||||
| ]; | |||||
| } | |||||
| @ -0,0 +1,19 @@ | |||||
| <?php | |||||
| namespace App\Models; | |||||
| use Illuminate\Database\Eloquent\Model; | |||||
| /** | |||||
| * | |||||
| * | |||||
| * | |||||
| */ | |||||
| class Log extends Model | |||||
| { | |||||
| protected $fillable = [ | |||||
| 'message', | |||||
| 'state' | |||||
| ]; | |||||
| } | |||||
| @ -1,13 +1,20 @@ | |||||
| <?php | <?php | ||||
| namespace App\Models; | |||||
| use Illuminate\Database\Eloquent\Model; | |||||
| /** | /** | ||||
| * | |||||
| * | * | ||||
| * | * | ||||
| * | * | ||||
| */ | */ | ||||
| class Source | |||||
| class Source extends Model | |||||
| { | { | ||||
| protected $fillable = [ | |||||
| 'name', | |||||
| 'url', | |||||
| 'response_handler_class' | |||||
| ]; | |||||
| } | } | ||||
| @ -0,0 +1,13 @@ | |||||
| <?php | |||||
| namespace CustomHandlers\Actions; | |||||
| /** | |||||
| * | |||||
| * | |||||
| * | |||||
| */ | |||||
| class FileMove extends ActionHandler { | |||||
| } | |||||