Skip to content

Commit

Permalink
Merge pull request #972 from dasgarner/develop
Browse files Browse the repository at this point in the history
Misc fixes for 3.0.0-alpha3
  • Loading branch information
dasgarner authored Sep 3, 2020
2 parents f003363 + 9597ce1 commit 8d88d2c
Show file tree
Hide file tree
Showing 21 changed files with 1,064 additions and 167 deletions.
1 change: 0 additions & 1 deletion bin/locale.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
$twig->addExtension(new \Slim\Views\TwigExtension());
$twig->addExtension(new \Xibo\Twig\TransExtension());
$twig->addExtension(new \Xibo\Twig\ByteFormatterTwigExtension());
$twig->addExtension(new \Xibo\Twig\UrlDecodeTwigExtension());
$twig->addExtension(new \Xibo\Twig\DateFormatTwigExtension());


Expand Down
22 changes: 12 additions & 10 deletions lib/Controller/Campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -888,18 +888,20 @@ public function preview(Request $request, Response $response, $id)
$duration = 0 ;
$extendedLayouts = [];

foreach($layouts as $layout)
foreach ($layouts as $layout)
{
$duration += $layout->duration;
$extendedLayouts[] = ['layout' => $layout,
'duration' => $layout->duration,
'previewOptions' => [
'getXlfUrl' => $this->urlFor($request,'layout.getXlf', ['id' => $layout->layoutId]),
'getResourceUrl' => $this->urlFor($request,'module.getResource', ['regionId' => ':regionId', 'id' => ':id']),
'libraryDownloadUrl' => $this->urlFor($request,'library.download'),
'layoutBackgroundDownloadUrl' => $this->urlFor($request,'layout.download.background', ['id' => ':id']),
'loaderUrl' => $this->getConfig()->uri('img/loader.gif')]
];
$extendedLayouts[] = [
'layout' => $layout,
'duration' => $layout->duration,
'previewOptions' => [
'getXlfUrl' => $this->urlFor($request,'layout.getXlf', ['id' => $layout->layoutId]),
'getResourceUrl' => $this->urlFor($request,'module.getResource', ['regionId' => ':regionId', 'id' => ':id']),
'libraryDownloadUrl' => $this->urlFor($request,'library.download'),
'layoutBackgroundDownloadUrl' => $this->urlFor($request,'layout.download.background', ['id' => ':id']),
'loaderUrl' => $this->getConfig()->uri('img/loader.gif')
]
];
}
$this->getState()->template = 'campaign-preview';
$this->getState()->setData([
Expand Down
43 changes: 43 additions & 0 deletions lib/Controller/Display.php
Original file line number Diff line number Diff line change
Expand Up @@ -2225,4 +2225,47 @@ public function checkLicence(Request $request, Response $response, $id)

return $this->render($request, $response);
}

/**
* @SWG\Get(
* path="/display/status/{id}",
* operationId="displayStatus",
* tags={"display"},
* summary="Display Status",
* description="Get the display status window for this Display.",
* @SWG\Parameter(
* name="id",
* in="path",
* description="Display Id",
* type="integer",
* required=true
* ),
* @SWG\Response(
* response=200,
* description="successful operation",
* @SWG\Schema(
* type="array",
* @SWG\Items(type="string")
* )
* )
* )
*
* @param Request $request
* @param Response $response
* @param int $id displayId
* @return \Psr\Http\Message\ResponseInterface|Response
* @throws \Xibo\Support\Exception\AccessDeniedException
* @throws \Xibo\Support\Exception\InvalidArgumentException
* @throws \Xibo\Support\Exception\NotFoundException
*/
public function statusWindow(Request $request, Response $response, $id)
{
$display = $this->displayFactory->getById($id);

if (!$this->getUser()->checkViewable($display)) {
throw new AccessDeniedException();
}

return $response->withJson($display->getStatusWindow($this->pool));
}
}
10 changes: 5 additions & 5 deletions lib/Controller/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -1327,18 +1327,18 @@ public function getResource(Request $request, Response $response, $regionId, $id

if ($module->getModule()->regionSpecific == 0) {
// Non region specific module - no caching required as this is only ever called via preview.
$resource = $module->download($request, $response);
$response = $module->download($request, $response);
} else {
// Region-specific module, need to handle caching and locking.
$resource = $module->getResourceOrCache();

if (!empty($resource)) {
$response->getBody()->write($resource);
}
}

$this->setNoOutput(true);

if (!empty($resource)) {
$response->getBody()->write($resource);
}

return $this->render($request, $response);
}

Expand Down
34 changes: 34 additions & 0 deletions lib/Entity/Display.php
Original file line number Diff line number Diff line change
Expand Up @@ -1109,4 +1109,38 @@ public function setCurrentScreenShotTime($pool, $date)

return $this;
}

/**
* @param PoolInterface $pool
* @return array
*/
public function getStatusWindow($pool)
{
$item = $pool->getItem('/statusWindow/' . $this->displayId);

if ($item->isMiss()) {
return [];
} else {
return $item->get();
}
}

/**
* @param PoolInterface $pool
* @param array $status
* @return $this
*/
public function setStatusWindow($pool, $status)
{
// Cache it
$this->getLog()->debug('Caching statusWindow with Pool');

$item = $pool->getItem('/statusWindow/' . $this->displayId);
$item->set($status);
$item->expiresAfter(new \DateInterval('P1D'));

$pool->saveDeferred($item);

return $this;
}
}
2 changes: 1 addition & 1 deletion lib/Entity/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class Module implements \JsonSerializable
public $defaultDuration;

/**
* @SWG\Property(description="An array of additional module specific settings")
* @SWG\Property(description="An array of additional module specific settings", type="array", @SWG\Items(type="string"))
* @var array
*/
public $settings = [];
Expand Down
8 changes: 6 additions & 2 deletions lib/Entity/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,9 @@ public function getEvents($fromDt, $toDt)
$this->getLog()->debug('The main event has a start and end date within the month, no need to pull it in from the prior month. [eventId:' . $this->eventId . ']');
}

// Keep a cache of schedule exclusions, so we look them up by eventId only one time per event
$scheduleExclusions = $this->scheduleExclusionFactory->query(null, ['eventId' => $this->eventId]);

// Request month cache
while ($fromDt < $toDt) {

Expand All @@ -823,8 +826,6 @@ public function getEvents($fromDt, $toDt)
foreach ($this->scheduleEvents as $scheduleEvent) {

// Find the excluded recurring events
$scheduleExclusions = $this->scheduleExclusionFactory->query(null, ['eventId' => $this->eventId]);

$exclude = false;
foreach ($scheduleExclusions as $exclusion) {
if ($scheduleEvent->fromDt == $exclusion->fromDt &&
Expand Down Expand Up @@ -857,6 +858,9 @@ public function getEvents($fromDt, $toDt)
$fromDt->addMonth();
}

// Clear our cache of schedule exclusions
$scheduleExclusions = null;

$this->getLog()->debug('Filtered ' . count($this->scheduleEvents) . ' to ' . count($events) . ', events: ' . json_encode($events, JSON_PRETTY_PRINT));

return $events;
Expand Down
5 changes: 3 additions & 2 deletions lib/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -1202,9 +1202,10 @@ public function routeViewable($route)
if ($this->isSuperAdmin())
return true;

// All users have access to the logout page
if ($route === '/logout')
// All users have access to the logout page and welcome page
if ($route === '/logout' || $route === '/welcome') {
return true;
}

try {
if ($this->pagePermissionCache == null) {
Expand Down
15 changes: 6 additions & 9 deletions lib/Factory/ContainerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ public static function create()
]);
$view->addExtension(new TransExtension());
$view->addExtension(new ByteFormatterTwigExtension());
$view->addExtension(new UrlDecodeTwigExtension());
$view->addExtension(new DateFormatTwigExtension());

return $view;
Expand All @@ -122,25 +121,23 @@ public static function create()
},
'timeSeriesStore' => function(ContainerInterface $c) {
if ($c->get('configService')->timeSeriesStore == null) {
return (new MySqlTimeSeriesStore())
->setDependencies($c->get('logService'),
$c->get('layoutFactory'),
$c->get('campaignFactory'))
->setStore($c->get('store'));
$timeSeriesStore = new MySqlTimeSeriesStore();
} else {
$timeSeriesStore = $c->get('configService')->timeSeriesStore;
$timeSeriesStore = $timeSeriesStore();
}

return $timeSeriesStore->setDependencies(
return $timeSeriesStore
->setDependencies(
$c->get('logService'),
$c->get('layoutFactory'),
$c->get('campaignFactory'),
$c->get('mediaFactory'),
$c->get('widgetFactory'),
$c->get('displayFactory'),
$c->get('displayGroupFactory')
);
}
)
->setStore($c->get('store'));
},
'state' => function() {
return new ApplicationState();
Expand Down
Loading

0 comments on commit 8d88d2c

Please sign in to comment.