Skip to content

Commit

Permalink
4.0.5 issues part2 (#2172)
Browse files Browse the repository at this point in the history
* Folders : Improve styling on the tree and search. xibosignage/xibo#3183
* Display Profile : Fix not found error when filtering the grid where there are no results returned.
* Library : video thumbnail column should be empty if no thumbnail is available. xibosignage/xibo#3191
* Applications : Fix scope checkboxes on edit form. xibosignage/xibo#3186
  • Loading branch information
PeterMis authored Oct 19, 2023
1 parent bbadc29 commit cf9b33c
Show file tree
Hide file tree
Showing 18 changed files with 132 additions and 107 deletions.
29 changes: 22 additions & 7 deletions lib/Controller/DisplayProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,14 @@ function grid(Request $request, Response $response)
'logicalOperatorName' => $parsedQueryParams->getString('logicalOperatorName'),
];

$embed = ($parsedQueryParams->getString('embed') != null) ? explode(',', $parsedQueryParams->getString('embed')) : [];
$profiles = $this->displayProfileFactory->query($this->gridRenderSort($parsedQueryParams), $this->gridRenderFilter($filter, $parsedQueryParams));
$embed = ($parsedQueryParams->getString('embed') != null)
? explode(',', $parsedQueryParams->getString('embed'))
: [];

if (count($profiles) <= 0)
throw new NotFoundException(__('Display Profile not found'), 'DisplayProfile');
$profiles = $this->displayProfileFactory->query(
$this->gridRenderSort($parsedQueryParams),
$this->gridRenderFilter($filter, $parsedQueryParams)
);

foreach ($profiles as $profile) {
// Load the config
Expand All @@ -189,20 +192,32 @@ function grid(Request $request, Response $response)
// Default Layout
$profile->buttons[] = array(
'id' => 'displayprofile_button_edit',
'url' => $this->urlFor($request,'displayProfile.edit.form', ['id' => $profile->displayProfileId]),
'url' => $this->urlFor(
$request,
'displayProfile.edit.form',
['id' => $profile->displayProfileId]
),
'text' => __('Edit')
);

$profile->buttons[] = array(
'id' => 'displayprofile_button_copy',
'url' => $this->urlFor($request,'displayProfile.copy.form', ['id' => $profile->displayProfileId]),
'url' => $this->urlFor(
$request,
'displayProfile.copy.form',
['id' => $profile->displayProfileId]
),
'text' => __('Copy')
);

if ($this->getUser()->checkDeleteable($profile)) {
$profile->buttons[] = array(
'id' => 'displayprofile_button_delete',
'url' => $this->urlFor($request,'displayProfile.delete.form', ['id' => $profile->displayProfileId]),
'url' => $this->urlFor(
$request,
'displayProfile.delete.form',
['id' => $profile->displayProfileId]
),
'text' => __('Delete')
);
}
Expand Down
25 changes: 17 additions & 8 deletions lib/Controller/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -551,14 +551,23 @@ public function grid(Request $request, Response $response)
try {
$module = $this->moduleFactory->getByType($media->mediaType);
if ($module->hasThumbnail) {
$media->setUnmatchedProperty(
'thumbnail',
$this->urlFor($request, 'library.download', [
'id' => $media->mediaId
], [
'preview' => 1
])
);
$renderThumbnail = true;
// for video, check if the cover image exists here.
if ($media->mediaType === 'video') {
$libraryLocation = $this->getConfig()->getSetting('LIBRARY_LOCATION');
$renderThumbnail = file_exists($libraryLocation . $media->mediaId . '_videocover.png');
}

if ($renderThumbnail) {
$media->setUnmatchedProperty(
'thumbnail',
$this->urlFor($request, 'library.download', [
'id' => $media->mediaId
], [
'preview' => 1
])
);
}
}
} catch (NotFoundException $notFoundException) {
$this->getLog()->error('Module ' . $media->mediaType . ' not found');
Expand Down
130 changes: 63 additions & 67 deletions lib/Factory/DisplayProfileFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
* 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 Down Expand Up @@ -363,93 +363,89 @@ public function query($sortOrder = null, $filterBy = [])
$sortOrder = ['name'];
}

try {
$params = array();
$select = 'SELECT displayProfileId, name, type, config, isDefault, userId, isCustom ';

$body = ' FROM `displayprofile` WHERE 1 = 1 ';
$params = [];
$select = 'SELECT displayProfileId, name, type, config, isDefault, userId, isCustom ';

if ($parsedFilter->getInt('displayProfileId') !== null) {
$body .= ' AND displayProfileId = :displayProfileId ';
$params['displayProfileId'] = $parsedFilter->getInt('displayProfileId');
}
$body = ' FROM `displayprofile` WHERE 1 = 1 ';

if ($parsedFilter->getInt('isDefault') !== null) {
$body .= ' AND isDefault = :isDefault ';
$params['isDefault'] = $parsedFilter->getInt('isDefault');
}
if ($parsedFilter->getInt('displayProfileId') !== null) {
$body .= ' AND displayProfileId = :displayProfileId ';
$params['displayProfileId'] = $parsedFilter->getInt('displayProfileId');
}

// Filter by DisplayProfile Name?
if ($parsedFilter->getString('displayProfile') != null) {
$terms = explode(',', $parsedFilter->getString('displayProfile'));
$logicalOperator = $parsedFilter->getString('logicalOperatorName', ['default' => 'OR']);
$this->nameFilter(
'displayprofile',
'name',
$terms,
$body,
$params,
($parsedFilter->getCheckbox('useRegexForName') == 1),
$logicalOperator
);
}
if ($parsedFilter->getInt('isDefault') !== null) {
$body .= ' AND isDefault = :isDefault ';
$params['isDefault'] = $parsedFilter->getInt('isDefault');
}

if ($parsedFilter->getString('type') != null) {
$body .= ' AND type = :type ';
$params['type'] = $parsedFilter->getString('type');
}
// Filter by DisplayProfile Name?
if ($parsedFilter->getString('displayProfile') != null) {
$terms = explode(',', $parsedFilter->getString('displayProfile'));
$logicalOperator = $parsedFilter->getString('logicalOperatorName', ['default' => 'OR']);
$this->nameFilter(
'displayprofile',
'name',
$terms,
$body,
$params,
($parsedFilter->getCheckbox('useRegexForName') == 1),
$logicalOperator
);
}

if ($parsedFilter->getString('type') != null) {
$body .= ' AND type = :type ';
$params['type'] = $parsedFilter->getString('type');
}

if ($parsedFilter->getInt('commandId') !== null) {
$body .= '
if ($parsedFilter->getInt('commandId') !== null) {
$body .= '
AND `displayprofile`.displayProfileId IN (
SELECT `lkcommanddisplayprofile`.displayProfileId
FROM `lkcommanddisplayprofile`
WHERE `lkcommanddisplayprofile`.commandId = :commandId
)
';

$params['commandId'] = $parsedFilter->getInt('commandId');
}

if ($parsedFilter->getInt('userId') !== null) {
$body .= ' AND `displayprofile`.userId = :userId ';
$params['userId'] = $parsedFilter->getInt('userId');
}

// Sorting?
$order = '';
if (is_array($sortOrder)) {
$order .= 'ORDER BY ' . implode(',', $sortOrder);
}
$params['commandId'] = $parsedFilter->getInt('commandId');
}

$limit = '';
// Paging
if ($filterBy !== null && $parsedFilter->getInt('start') !== null && $parsedFilter->getInt('length') !== null) {
$limit = ' LIMIT ' . $parsedFilter->getInt('start', ['default' => 0]) . ', ' . $parsedFilter->getInt('length', ['default' => 10]);
}
if ($parsedFilter->getInt('userId') !== null) {
$body .= ' AND `displayprofile`.userId = :userId ';
$params['userId'] = $parsedFilter->getInt('userId');
}

$sql = $select . $body . $order . $limit;
// Sorting?
$order = '';
if (is_array($sortOrder)) {
$order .= 'ORDER BY ' . implode(',', $sortOrder);
}

foreach ($this->getStore()->select($sql, $params) as $row) {
$profile = $this->createEmpty()->hydrate($row, ['intProperties' => ['isDefault', 'isCustom']]);
$limit = '';
// Paging
if ($filterBy !== null && $parsedFilter->getInt('start') !== null && $parsedFilter->getInt('length') !== null) {
$limit = ' LIMIT ' . $parsedFilter->getInt('start', ['default' => 0]) .
', ' . $parsedFilter->getInt('length', ['default' => 10]);
}

$profile->excludeProperty('configDefault');
$profile->excludeProperty('configTabs');
$profiles[] = $profile;
}
$sql = $select . $body . $order . $limit;

// Paging
if ($limit != '' && count($profiles) > 0) {
$results = $this->getStore()->select('SELECT COUNT(*) AS total ' . $body, $params);
$this->_countLast = intval($results[0]['total']);
}
foreach ($this->getStore()->select($sql, $params) as $row) {
$profile = $this->createEmpty()->hydrate($row, ['intProperties' => ['isDefault', 'isCustom']]);

return $profiles;
} catch (\Exception $e) {
$this->getLog()->error($e);
$profile->excludeProperty('configDefault');
$profile->excludeProperty('configTabs');
$profiles[] = $profile;
}

throw new NotFoundException();
// Paging
if ($limit != '' && count($profiles) > 0) {
$results = $this->getStore()->select('SELECT COUNT(*) AS total ' . $body, $params);
$this->_countLast = intval($results[0]['total']);
}

return $profiles;
}

public function getAvailableTypes()
Expand Down
19 changes: 10 additions & 9 deletions ui/src/core/xibo-cms.js
Original file line number Diff line number Diff line change
Expand Up @@ -3682,7 +3682,7 @@ function initJsTreeAjax(container, id, isForm, ttl, onReady = null, onSelected =

$(container).jstree({
"state" : state,
"plugins" : ["contextmenu", "state", "unique", "sort", "themes", "types", 'search'].concat(plugins),
"plugins" : ["contextmenu", "state", "unique", "sort", "types", 'search'].concat(plugins),
"contextmenu":{
"items": function($node, checkContextMenuPermissions) {
// items in context menu need to check user permissions before we render them
Expand Down Expand Up @@ -3766,21 +3766,18 @@ function initJsTreeAjax(container, id, isForm, ttl, onReady = null, onSelected =
}
});
}},
"themes" : {
"responsive" : true
},
"types" : {
"root" : {
"icon" : "fa fa-file text-warning"
"icon" : "fa fa-file text-xibo-primary"
},
"home" : {
"icon" : "fa fa-home text-success"
"icon" : "fa fa-home text-xibo-primary"
},
"default" : {
"icon" : "fa fa-folder text-warning"
"icon" : "fa fa-folder text-xibo-primary"
},
"open" : {
"icon" : "fa fa-folder-open text-warning"
"icon" : "fa fa-folder-open text-xibo-primary"
}
},
'search' : {
Expand All @@ -3799,7 +3796,11 @@ function initJsTreeAjax(container, id, isForm, ttl, onReady = null, onSelected =
},
'data' : {
"url": foldersUrl + (homeFolderId ? '?homeFolderId='+homeFolderId : '')
}
},
"themes" : {
'responsive' : true,
'dots' : false,
},
}
}).bind('ready.jstree', function(e, data) {
// depending on the state of folder tree, hide/show as needed when we load the grid page
Expand Down
6 changes: 3 additions & 3 deletions views/applications-form-edit.twig
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{#
/**
* Copyright (C) 2022 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 Down Expand Up @@ -128,7 +128,7 @@
{% for scope in scopes %}
{% set title %}{{ scope.description }}{% endset %}
{% set id %}scope_{{ scope.id }}{% endset %}
{{ forms.checkbox(id, title, scope.selected) }}
{{ forms.checkbox(id, title, scope.getUnmatchedProperty('selected')) }}
{% endfor %}

{% set title %}{% trans "Owner" %}{% endset %}
Expand Down
2 changes: 1 addition & 1 deletion views/authed.twig
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@
</div>
<div class="modal-body">
<div class="form-group card p-3 mb-3 bg-light">
<input id="jstree-search-form" type="text" placeholder="{% trans "Search" %}">
<input id="jstree-search-form" class="form-control" type="text" placeholder="{% trans "Search" %}">
<div class="folder-search-no-results d-none">
<p>{% trans 'No Folders matching the search term' %}</p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion views/campaign-page.twig
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@

<div class="row">
<div class="col-sm-2 p-3 bg-light" id="grid-folder-filter">
<input id="jstree-search" type="text" placeholder="{% trans "Search" %}">
<input id="jstree-search" class="form-control" type="text" placeholder="{% trans "Search" %}">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="folder-tree-clear-selection-button">
<label class="form-check-label" for="folder-tree-clear-selection-button" title="{% trans "Search in all folders" %}">{% trans "All Folders" %}</label>
Expand Down
2 changes: 1 addition & 1 deletion views/dataset-page.twig
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

<div class="row">
<div class="col-sm-2 p-3 bg-light" id="grid-folder-filter">
<input id="jstree-search" type="text" placeholder="{% trans "Search" %}">
<input id="jstree-search" class="form-control" type="text" placeholder="{% trans "Search" %}">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="folder-tree-clear-selection-button">
<label class="form-check-label" for="folder-tree-clear-selection-button" title="{% trans "Search in all folders" %}">{% trans "All Folders" %}</label>
Expand Down
2 changes: 1 addition & 1 deletion views/display-page.twig
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
</div>
<div class="row">
<div class="col-sm-2 p-3 bg-light" id="grid-folder-filter">
<input id="jstree-search" type="text" placeholder="{% trans "Search" %}">
<input id="jstree-search" class="form-control" type="text" placeholder="{% trans "Search" %}">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="folder-tree-clear-selection-button">
<label class="form-check-label" for="folder-tree-clear-selection-button" title="{% trans "Search in all folders" %}">{% trans "All Folders" %}</label>
Expand Down
2 changes: 1 addition & 1 deletion views/displaygroup-page.twig
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
</div>
<div class="row">
<div class="col-sm-2 p-3 bg-light" id="grid-folder-filter">
<input id="jstree-search" type="text" placeholder="{% trans "Search" %}">
<input id="jstree-search" class="form-control" type="text" placeholder="{% trans "Search" %}">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="folder-tree-clear-selection-button">
<label class="form-check-label" for="folder-tree-clear-selection-button" title="{% trans "Search in all folders" %}">{% trans "All Folders" %}</label>
Expand Down
2 changes: 1 addition & 1 deletion views/folders-page.twig
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<div class="widget-body">
<div class="row">
<div class="col-md-3">
<input id="jstree-search" type="text" placeholder="{% trans "Search" %}">
<input id="jstree-search" class="form-control" type="text" placeholder="{% trans "Search" %}">
<div class="folder-search-no-results d-none">
<p>{% trans 'No Folders matching the search term' %}</p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion views/layout-page.twig
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@

<div class="row">
<div class="col-sm-2 p-3 bg-light" id="grid-folder-filter">
<input id="jstree-search" type="text" placeholder="{% trans "Search" %}">
<input id="jstree-search" class="form-control" type="text" placeholder="{% trans "Search" %}">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="folder-tree-clear-selection-button">
<label class="form-check-label" for="folder-tree-clear-selection-button" title="{% trans "Search in all folders" %}">{% trans "All Folders" %}</label>
Expand Down
Loading

0 comments on commit cf9b33c

Please sign in to comment.