Skip to content

Commit

Permalink
Commands : Add an option to execute command with selected on Displays…
Browse files Browse the repository at this point in the history
… and Display Groups grids.

xibo/xibosignage#2927
  • Loading branch information
PeterMis committed Aug 15, 2023
1 parent fb956c6 commit 2f15841
Show file tree
Hide file tree
Showing 5 changed files with 378 additions and 116 deletions.
66 changes: 49 additions & 17 deletions lib/Controller/Command.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* Copyright (C) 2021 Xibo Signage Ltd
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
Expand All @@ -27,7 +27,6 @@
use Slim\Http\ServerRequest as Request;
use Xibo\Event\CommandDeleteEvent;
use Xibo\Factory\CommandFactory;
use Xibo\Factory\DisplayProfileFactory;
use Xibo\Support\Exception\AccessDeniedException;
use Xibo\Support\Exception\ControllerNotImplemented;
use Xibo\Support\Exception\GeneralException;
Expand Down Expand Up @@ -85,10 +84,17 @@ public function displayPage(Request $request, Response $response)
* @SWG\Parameter(
* name="command",
* in="query",
* description="Filter by Command Name",
* description="Filter by Command Name, exact match",
* type="string",
* required=false
* ),
@SWG\Parameter(
* name="commandLike",
* in="query",
* description="Filter by Command Name, LIKE match",
* type="string",
* required=false
* ),
* @SWG\Parameter(
* name="code",
* in="query",
Expand All @@ -112,23 +118,28 @@ public function displayPage(Request $request, Response $response)
* @throws GeneralException
* @throws NotFoundException
*/
function grid(Request $request, Response $response)
public function grid(Request $request, Response $response)
{
$sanitzedParams = $this->getSanitizer($request->getParams());
$sanitizedParams = $this->getSanitizer($request->getParams());

$filter = [
'commandId' => $sanitzedParams->getInt('commandId'),
'command' => $sanitzedParams->getString('command'),
'code' => $sanitzedParams->getString('code')
'commandId' => $sanitizedParams->getInt('commandId'),
'command' => $sanitizedParams->getString('command'),
'code' => $sanitizedParams->getString('code'),
'commandLike' => $sanitizedParams->getString('commandLike'),
];

$commands = $this->commandFactory->query($this->gridRenderSort($sanitzedParams), $this->gridRenderFilter($filter, $sanitzedParams));
$commands = $this->commandFactory->query(
$this->gridRenderSort($sanitizedParams),
$this->gridRenderFilter($filter, $sanitizedParams)
);

foreach ($commands as $command) {
/* @var \Xibo\Entity\Command $command */

if ($this->isApi($request))
if ($this->isApi($request)) {
continue;
}

$command->includeProperty('buttons');

Expand All @@ -146,11 +157,14 @@ function grid(Request $request, Response $response)
if ($this->getUser()->checkDeleteable($command)) {
$command->buttons[] = [
'id' => 'command_button_delete',
'url' => $this->urlFor($request,'command.delete.form', ['id' => $command->commandId]),
'url' => $this->urlFor($request, 'command.delete.form', ['id' => $command->commandId]),
'text' => __('Delete'),
'multi-select' => true,
'dataAttributes' => [
['name' => 'commit-url', 'value' => $this->urlFor($request,'command.delete', ['id' => $command->commandId])],
[
'name' => 'commit-url',
'value' => $this->urlFor($request, 'command.delete', ['id' => $command->commandId])
],
['name' => 'commit-method', 'value' => 'delete'],
['name' => 'id', 'value' => 'command_button_delete'],
['name' => 'text', 'value' => __('Delete')],
Expand All @@ -165,18 +179,36 @@ function grid(Request $request, Response $response)
// Permissions button
$command->buttons[] = [
'id' => 'command_button_permissions',
'url' => $this->urlFor($request,'user.permissions.form', ['entity' => 'Command', 'id' => $command->commandId]),
'url' => $this->urlFor(
$request,
'user.permissions.form',
['entity' => 'Command', 'id' => $command->commandId]
),
'text' => __('Share'),
'multi-select' => true,
'dataAttributes' => [
['name' => 'commit-url', 'value' => $this->urlFor($request,'user.permissions.multi', ['entity' => 'Command', 'id' => $command->commandId])],
[
'name' => 'commit-url',
'value' => $this->urlFor(
$request,
'user.permissions.multi',
['entity' => 'Command', 'id' => $command->commandId]
)
],
['name' => 'commit-method', 'value' => 'post'],
['name' => 'id', 'value' => 'command_button_permissions'],
['name' => 'text', 'value' => __('Share')],
['name' => 'rowtitle', 'value' => $command->command],
['name' => 'sort-group', 'value' => 2],
['name' => 'custom-handler', 'value' => 'XiboMultiSelectPermissionsFormOpen'],
['name' => 'custom-handler-url', 'value' => $this->urlFor($request,'user.permissions.multi.form', ['entity' => 'Command'])],
[
'name' => 'custom-handler-url',
'value' => $this->urlFor(
$request,
'user.permissions.multi.form',
['entity' => 'Command']
)
],
['name' => 'content-id-name', 'value' => 'commandId']
]
];
Expand Down
Loading

0 comments on commit 2f15841

Please sign in to comment.