Skip to content

Commit

Permalink
Merge pull request #585 from xibosignage/release20
Browse files Browse the repository at this point in the history
Release 2.0.3 - merge to master
  • Loading branch information
dasgarner authored Jun 4, 2019
2 parents 420d70f + 4da4156 commit 93a8416
Show file tree
Hide file tree
Showing 69 changed files with 2,335 additions and 1,549 deletions.
8 changes: 4 additions & 4 deletions cypress/integration/dashboard_spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
describe('Dashboard', function () {

beforeEach(function () {
cy.login();

cy.visit('/');
cy.login().then(function() {
cy.visit('/');
});
});

it('should be at the dashboard page', function() {
Expand All @@ -18,7 +18,7 @@ describe('Dashboard', function () {
it('should show the welcome tutorial', function() {

// Open user dropdown menu
cy.get('.user .dropdown-toggle img').click();
cy.get('.dropdown-toggle img.nav-avatar').click();

// Click Reshow welcome
cy.get('#reshowWelcomeMenuItem').click();
Expand Down
6 changes: 4 additions & 2 deletions cypress/integration/layout_designer_populated_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,11 +421,13 @@ describe('Layout Designer (Populated)', function() {
.trigger('mouseup');

// Close the navigator edit
cy.wait('@reloadRegion');
cy.get('#layout-navigator-edit #save-btn').click();

// Close navigator
cy.get('#layout-navigator-edit #close-btn').click();

// Wait for the layout to reload
cy.wait('@reloadRegion');
cy.reload();
cy.wait('@reloadLayout');

// Open navigator edit
Expand Down
21 changes: 8 additions & 13 deletions cypress/integration/layout_designer_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,9 @@ describe('Layout Designer (Empty)', function() {

// Select and search image items
cy.get('.toolbar-pane.active .input-type').select('audio');
cy.get('.toolbar-pane.active [data-test="searchButton"]').click();

// Check if there are audio items in the search content
cy.get('#layout-editor-toolbar .toolbar-pane-content [data-sub-type="audio"]').should('be.visible');
cy.get('#layout-editor-toolbar .media-table tbody tr:first').should('be.visible').contains('audio');
});

it('creates multiple tabs and then closes them all', () => {
Expand Down Expand Up @@ -317,6 +316,7 @@ describe('Layout Designer (Empty)', function() {
cy.route('POST', '**/playlist/widget/embedded/*').as('createWidget');

// Open toolbar Widgets tab
cy.get('#layout-editor-toolbar .btn-menu-tab').contains('Tools').should('be.visible').click();
cy.get('#layout-editor-toolbar .btn-menu-tab').contains('Widgets').should('be.visible').click();

cy.get('#layout-editor-toolbar .toolbar-pane-content [data-sub-type="embedded"]').should('be.visible').then(() => {
Expand All @@ -337,9 +337,7 @@ describe('Layout Designer (Empty)', function() {

});

it('creates a new widget by dragging a searched media from the toolbar to ' + target + ' region', () => {

//populateLibraryWithMedia();
it('creates a new widget by selecting a searched media from the toolbar to ' + target + ' region', () => {

// Create and alias for reload Layout
cy.server();
Expand All @@ -350,14 +348,10 @@ describe('Layout Designer (Empty)', function() {

// Select and search image items
cy.get('.toolbar-pane.active .input-type').select('image');
cy.get('.toolbar-pane.active [data-test="searchButton"]').click();

// Get a card and drag it to the region
cy.get('#layout-editor-toolbar .toolbar-pane-content [data-type="media"]').should('be.visible').then(() => {
dragToElement(
'#layout-editor-toolbar .toolbar-pane-content [data-type="media"]:first-child .drag-area',
'#' + target + ' [data-type="region"]:first-child'
).then(() => {
// Get a table row, select it and add to the region
cy.get('#layout-editor-toolbar .media-table .assignItem:first').click().then(() => {
cy.get('#' + target + ' [data-type="region"]:first-child').click({force: true}).then(() => {

// Wait for the layout to reload
cy.wait('@reloadLayout');
Expand Down Expand Up @@ -392,10 +386,11 @@ describe('Layout Designer (Empty)', function() {
populateLibraryWithMedia();

// Open toolbar Widgets tab
cy.get('#layout-editor-toolbar .btn-menu-tab').contains('Tools').should('be.visible').click();
cy.get('#layout-editor-toolbar .btn-menu-tab').contains('Widgets').should('be.visible').click();

// Activate the Add button
cy.get('#layout-editor-toolbar .toolbar-pane-content [data-sub-type="audio"] .add-area').invoke('show').click();
cy.get('#layout-editor-toolbar #content-1 .toolbar-pane-content [data-sub-type="audio"] .add-area').invoke('show').click();

// Click on the region to add
cy.get('#' + target + ' [data-type="region"]:first-child').click();
Expand Down
9 changes: 5 additions & 4 deletions cypress/integration/layout_view_spec.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
describe('Layout View', function() {

beforeEach(function() {
cy.login();
cy.visit('/layout/view');
cy.login().then(function() {
cy.visit('/layout/view');
});
});

it('should create a new layout and be redirected to the layout designer', function() {

cy.get('a[href="/layout/form/add"]').click();

// Create random name
const uuid = Cypress._.random(0, 1e8);
const uuid = Cypress._.random(0, 1e10);

// Save id as an alias
cy.wrap(uuid).as('layout_view_test_layout');
Expand All @@ -30,7 +31,7 @@ describe('Layout View', function() {
cy.route('DELETE', '/layout/*').as('deleteLayout');

// Create random name
const uuid = Cypress._.random(0, 1e9);
const uuid = Cypress._.random(0, 1e10);

// Create a new layout and go to the layout's designer page, then load toolbar prefs
cy.createLayout(uuid).as('testLayoutId').then((res) => {
Expand Down
23 changes: 8 additions & 15 deletions cypress/integration/playlist_editor_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ describe('Playlist Editor', function() {
cy.route('POST', '**/playlist/widget/embedded/*').as('createWidget');

// Open toolbar Widgets tab
cy.get('#playlist-editor-toolbar .btn-menu-tab').contains('Tools').should('be.visible').click();
cy.get('#playlist-editor-toolbar .btn-menu-tab').contains('Widgets').should('be.visible').click();

cy.get('#playlist-editor-toolbar .toolbar-pane-content [data-sub-type="embedded"]').should('be.visible').then(() => {
Expand All @@ -117,7 +118,7 @@ describe('Playlist Editor', function() {

});

it('creates a new widget by dragging a searched media from the toolbar to the editor', () => {
it('creates a new widget by selecting a searched media from the toolbar to the editor', () => {

populateLibraryWithMedia();

Expand All @@ -130,14 +131,10 @@ describe('Playlist Editor', function() {

// Select and search image items
cy.get('.toolbar-pane.active .input-type').select('image');
cy.get('.toolbar-pane.active [data-test="searchButton"]').click();

// Get a card and drag it to the region
cy.get('#playlist-editor-toolbar .toolbar-pane-content [data-type="media"]').should('be.visible').then(() => {
dragToElement(
'#playlist-editor-toolbar .toolbar-pane-content [data-type="media"]:first-child .drag-area',
'#dropzone-container'
).then(() => {
// Get a table row, select it and add to the dropzone
cy.get('#playlist-editor-toolbar .media-table .assignItem:first').click().then(() => {
cy.get('#dropzone-container').click({force: true}).then(() => {

// Wait for the layout to reload
cy.wait('@reloadPlaylist');
Expand All @@ -162,14 +159,10 @@ describe('Playlist Editor', function() {

// Select and search image items
cy.get('.toolbar-pane.active .input-type').select('image');
cy.get('.toolbar-pane.active [data-test="searchButton"]').click();

// Get a card and drag it to the region
cy.get('#playlist-editor-toolbar .toolbar-pane-content [data-type="media"]').should('be.visible').then(() => {
dragToElement(
'#playlist-editor-toolbar .toolbar-pane-content [data-type="media"]:first-child .drag-area',
'#dropzone-container'
).then(() => {
// Get a table row, select it and add to the dropzone
cy.get('#playlist-editor-toolbar .media-table .assignItem:first').click().then(() => {
cy.get('#dropzone-container').click({force: true}).then(() => {

// Wait for the layout to reload
cy.wait('@reloadPlaylist');
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/unauthed_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe('Unauthenticated CMS access', function () {

cy.url().should('include', '/login');

cy.contains('Version 2.0.2');
cy.contains('Version 2.0.3');
});

it('should redirect to login when an authenticated page is requested', function() {
Expand Down
29 changes: 16 additions & 13 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,23 @@
// -- This is will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
Cypress.Commands.add('login', function() {
cy.request({
method: 'POST',
url: '/login',
form: true,
body: {
'username': 'xibo_admin',
'password': 'password'
}
}).then((res) => {
// Get access token and save it as a environment variable
cy.getAccessToken();
});

cy.getCookie('PHPSESSID').should('exist');
cy.visit('/').then(function() {
cy.request({
method: 'POST',
url: '/login',
form: true,
body: {
'username': 'xibo_admin',
'password': 'password'
}
}).then((res) => {
// Get access token and save it as a environment variable
cy.getAccessToken().then(function(){
cy.getCookie('PHPSESSID').should('exist');
});
});
});
});

Cypress.Commands.add('getAccessToken', function() {
Expand Down
16 changes: 8 additions & 8 deletions db/migrations/20180130073838_install_migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,19 +197,19 @@ private function addStructure()
->addColumn('display', 'string', ['limit' => 50])
->addColumn('auditingUntil', 'integer', ['default' => 0])
->addColumn('defaultLayoutId', 'integer')
->addColumn('license', 'string', ['limit' => 40])
->addColumn('license', 'string', ['limit' => 40, 'default' => null, 'null' => true])
->addColumn('licensed', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, 'default' => 0])
->addColumn('loggedIn', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, 'default' => 0])
->addColumn('lastAccessed', 'integer')
->addColumn('lastAccessed', 'integer', ['limit' => 11, 'default' => null, 'null' => true])
->addColumn('inc_schedule', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, 'default' => 0])
->addColumn('email_alert', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, 'default' => 0])
->addColumn('alert_timeout', 'integer')
->addColumn('clientAddress', 'string', ['limit' => 50])
->addColumn('alert_timeout', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, 'default' => 0])
->addColumn('clientAddress', 'string', ['limit' => 50, 'default' => null, 'null' => true])
->addColumn('mediaInventoryStatus', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, 'default' => 0])
->addColumn('macAddress', 'string', ['limit' => 254])
->addColumn('lastChanged', 'integer')
->addColumn('numberOfMacAddressChanges', 'integer')
->addColumn('lastWakeOnLanCommandSent', 'integer')
->addColumn('macAddress', 'string', ['limit' => 254, 'default' => null, 'null' => true])
->addColumn('lastChanged', 'integer', ['default' => null, 'null' => true])
->addColumn('numberOfMacAddressChanges', 'integer', ['default' => 0])
->addColumn('lastWakeOnLanCommandSent', 'integer', ['default' => null, 'null' => true])
->addColumn('wakeOnLan', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, 'default' => 0])
->addColumn('wakeOnLanTime', 'string', ['limit' => 5, 'default' => null, 'null' => true])
->addColumn('broadCastAddress', 'string', ['limit' => 100, 'default' => null, 'null' => true])
Expand Down
2 changes: 1 addition & 1 deletion docker/tmp/settings-custom.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# // Initial User Group
# 'group' => 'Users',
# // Home Page
# 'homePage' => 'dashboard',
# 'homePage' => 'icondashboard',
# // Enable/Disable Single Logout
# 'slo' => true,
# // Attribute mapping between XIBO-CMS and the IdP
Expand Down
10 changes: 10 additions & 0 deletions lib/Controller/Campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,16 @@ public function assignLayout($campaignId)
if ($layout->isChild())
throw new InvalidArgumentException('Cannot assign a Draft Layout to a Campaign', 'layoutId');

// Make sure this layout is not a template - for API, in web ui templates are not available for assignment
$tags = $layout->tags;
$tagsArray = explode(',', $tags);

foreach ($tagsArray as $tag) {
if ($tag === 'template') {
throw new InvalidArgumentException('Cannot assign a Template to a Campaign', 'layoutId');
}
}

// Set the Display Order
$layout->displayOrder = $this->getSanitizer()->getInt('displayOrder', $object);

Expand Down
31 changes: 28 additions & 3 deletions lib/Controller/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,22 @@ function add()
* )
* )
*
* @throws InvalidArgumentException
* @throws NotFoundException
* @throws XiboException
*/
function edit($layoutId)
{
$layout = $this->layoutFactory->getById($layoutId);
$isTemplate = false;

// check if we're dealing with the template
$currentTags = explode(',', $layout->tags);
foreach ($currentTags as $tag) {
if ($tag === 'template') {
$isTemplate = true;
}
}

// Make sure we have permission
if (!$this->getUser()->checkEditable($layout))
Expand All @@ -393,6 +404,17 @@ function edit($layoutId)
$layout->replaceTags($this->tagFactory->tagsFromString($this->getSanitizer()->getString('tags')));
$layout->retired = $this->getSanitizer()->getCheckbox('retired');

$tags = $this->getSanitizer()->getString('tags');
$tagsArray = explode(',', $tags);

if (!$isTemplate) {
foreach ($tagsArray as $tag) {
if ($tag === 'template') {
throw new InvalidArgumentException('Cannot assign a Template tag to a Layout, to create a template use the Save Template button instead.', 'tags');
}
}
}

// Save
$layout->save([
'saveLayout' => true,
Expand All @@ -411,7 +433,7 @@ function edit($layoutId)
}

/**
* Edit Layout
* Edit Layout Background
* @param int $layoutId
*
* @SWG\Put(
Expand Down Expand Up @@ -826,7 +848,7 @@ function grid()
'layoutId' => $this->getSanitizer()->getInt('layoutId'),
'ownerUserGroupId' => $this->getSanitizer()->getInt('ownerUserGroupId'),
'mediaLike' => $this->getSanitizer()->getString('mediaLike'),
'publishedStateId' => $this->getSanitizer()->getInt('publishedStateId'),
'publishedStatusId' => $this->getSanitizer()->getInt('publishedStatusId'),
]));

foreach ($layouts as $layout) {
Expand Down Expand Up @@ -1930,13 +1952,16 @@ public function checkout($layoutId)
'notify' => false
]);

// Permissions
// Permissions && Sub-Playlists
// Layout level permissions are managed on the Campaign entity, so we do not need to worry about that
// Regions/Widgets need to copy down our layout permissions
foreach ($draft->regions as $region) {
// Match our original region id to the id in the parent layout
$original = $layout->getRegion($region->getOriginalValue('regionId'));

// Make sure Playlist closure table from the published one are copied over
$original->getPlaylist()->cloneClosureTable($region->getPlaylist()->playlistId);

// Copy over original permissions
foreach ($original->permissions as $permission) {
$new = clone $permission;
Expand Down
19 changes: 18 additions & 1 deletion lib/Controller/MediaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,17 @@ public function __construct($log, $sanitizerService, $state, $user, $help, $date

public function displayPage()
{
$moduleFactory = $this->moduleFactory;

$this->getState()->template .= 'media-manager-page';
$this->getState()->setData([
// Users we have permission to see
'modules' => $this->moduleFactory->query(null, ['assignable' => 1, 'enabled' => 1])
'modules' => $this->moduleFactory->query(null, ['assignable' => 1, 'enabled' => 1]),
'assignableModules' => array_map(function($element) use ($moduleFactory) {
$module = $moduleFactory->createForInstall($element->class);
$module->setModule($element);
return $module;
}, $moduleFactory->getAssignableModules())
]);
}

Expand Down Expand Up @@ -141,9 +148,19 @@ public function grid()
continue;
}

// Get region dimensions
foreach ($regions as $region) {
$regionWidth = $region->width;
$regionHeight = $region->height;
}

$row['buttons'][] = [
'id' => 'WidgetEditForm',
'class' => 'WidgetEditForm',
'dataAttributes' => [
['name' => 'region-width', 'value' => $regionWidth],
['name' => 'region-height', 'value' => $regionHeight]
],
'url' => $this->urlFor('module.widget.edit.form', ['id' => $widget->widgetId]),
'text' => __('Edit')
];
Expand Down
Loading

0 comments on commit 93a8416

Please sign in to comment.