1
0
Fork 0
internet-everythings-agricu.../app/Admin/Controllers/DeviceController.php

104 lines
4.4 KiB
PHP

<?php
namespace App\Admin\Controllers;
use Slowlyo\OwlAdmin\Renderers\Page;
use Slowlyo\OwlAdmin\Renderers\Form;
use Slowlyo\OwlAdmin\Renderers\TableColumn;
use Slowlyo\OwlAdmin\Renderers\TextControl;
use Slowlyo\OwlAdmin\Renderers\CRUDTable;
use Slowlyo\OwlAdmin\Controllers\AdminController;
use App\Services\Admin\DeviceService;
use App\Models\Device;
class DeviceController extends AdminController
{
protected string $serviceName = DeviceService::class;
protected string $pageTitle = '设备管理';
public function list(): Page
{
$crud = $this->baseCRUD()
->filterTogglable(false)
->headerToolbar([
$this->createButton(true, 'lg'),
...$this->baseHeaderToolBar(),
])
->columns([
TableColumn::make()->name('id')->label('ID')->sortable(true),
TableColumn::make()->name('name')->label('名称'),
TableColumn::make()->name('sn')->label('编号'),
TableColumn::make()->name('created_at')->label('创建时间')->type('datetime')->sortable(true),
TableColumn::make()->name('updated_at')->label('更新时间')->type('datetime')->sortable(true),
$this->rowActions(true),
]);
return $this->baseList($crud);
}
public function form(): Form
{
return $this->baseForm()->body([
TextControl::make()->name('name')->label('名称')->required(true),
TextControl::make()->name('sn')->label('编号'),
\amisMake()->SelectControl()->name('powered_by')->label('厂家')->options(),
TextControl::make()->name('model_sn')->label('型号'),
\amisMake()->RadiosControl()->name('type')->label('类型')->options(Device::typeMap())->required(true),
//监控设备-额外参数
\amisMake()->TextControl()->name('extends.ip')->hiddenOn('data.type != '.Device::TYPE_MONITOR)->label('设备IP'),
\amisMake()->TextControl()->name('extends.username')->hiddenOn('data.type != '.Device::TYPE_MONITOR)->label('设备用户名'),
\amisMake()->TextControl()->name('extends.password')->hiddenOn('data.type != '.Device::TYPE_MONITOR)->label('设备密码'),
\amisMake()->GroupControl()->body([
\amisMake()->TextControl()->name('extends.live_port')->hiddenOn('data.type != '.Device::TYPE_MONITOR)->label('实时端口'),
\amisMake()->TextControl()->name('extends.live_channel')->hiddenOn('data.type != '.Device::TYPE_MONITOR)->label('实时通道'),
]),
\amisMake()->GroupControl()->body([
\amisMake()->TextControl()->name('extends.back_port')->hiddenOn('data.type != '.Device::TYPE_MONITOR)->label('回放端口'),
\amisMake()->TextControl()->name('extends.back_channel')->hiddenOn('data.type != '.Device::TYPE_MONITOR)->label('回放通道'),
]),
]);
}
public function detail(): Form
{
return $this->baseDetail()->body([
TextControl::make()->static(true)->name('id')->label('ID'),
TextControl::make()->static(true)->name('name')->label('名称'),
TextControl::make()->static(true)->name('sn')->label('编号'),
TextControl::make()->static(true)->name('created_at')->label('创建时间'),
TextControl::make()->static(true)->name('updated_at')->label('更新时间')
]);
}
/**
* 监控设备列表
*/
public function monitorList(){
return CRUDTable::make()->mode('cards')->columnsCount(3)
->data([
'items' => [
[
'id'=>1,
'src'=>'ws://183.221.204.29:8100/rtsp?url=cnRzcDovL2FkbWluOjEyMzQ1Njc4OXhAMTE3LjE3NC4xODQuMTE4OjkwMDkvY2FtL3JlYWxtb25pdG9yP2NoYW5uZWw9MSZzdWJ0eXBlPTA='
],
]
])
// ->filter([
// 'title' => '指定位置',
// 'body' => [
// \amisMake()->TableControl()->name('name')->label('点位名称')->size('sm')->actions([
// ["type"=> "submit","level"=> "primary","label"=> "查询"]
// ])
// ]
// ])
->itemClassName('col-sm-4')
->card([
'header' => [],
'body' => amisMake()->Video()
->isLive(true)->videoType('video/x-flv')->muted(true)->autoPlay(true)
->src('${src}')
]);
}
}