Skip to content

Commit

Permalink
Player: Add 404 handling when requesting data
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenberttpingol committed Jul 27, 2023
1 parent 99d5c4b commit 9b39079
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 8 deletions.
11 changes: 11 additions & 0 deletions modules/calendar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@
<default></default>
</property>
</properties>
<onDataError><![CDATA[
if (typeof httpStatus === 'undefined' || typeof response === 'undefined') {
return false;
}
var hasSucceed = response.hasOwnProperty('success') && response.success === true;
if (!hasSucceed) {
return false;
}
]]></onDataError>
<onParseData><![CDATA[
// item - element to be parsed
// properties - object containing the values to be evaluated/used
Expand Down
2 changes: 1 addition & 1 deletion modules/src/player-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ window.Hls = require('hls.js');
window.transformer = require('../../ui/src/helpers/transformer.js');

// Our own imports
import '../vendor/xibo-interactive-control.min.js';
import 'xibo-interactive-control/dist/xibo-interactive-control.min.js';
import './xibo-calendar-render';
import './xibo-countdown-render';
import './xibo-finance-render';
Expand Down
19 changes: 19 additions & 0 deletions modules/src/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,21 @@ $(function() {
}).done(function(data) {
resolve(data);
}).fail(function(jqXHR, textStatus, errorThrown) {
if (
typeof window[`onDataError_${widget.widgetId}`] === 'function'
) {
const onDataError = window[
`onDataError_${widget.widgetId}`
](jqXHR.status, jqXHR.responseJSON);

if (onDataError == false) {
xiboIC.reportFault({
code: '5001',
reason: 'No Data',
});
}
}

console.log(jqXHR, textStatus, errorThrown);
});
} else {
Expand Down Expand Up @@ -192,6 +207,10 @@ $(function() {
showError,
} = composeFinalData(widget, data);

if (dataItems.length === 0 && showError) {
xiboIC.expireNow({targetId: widget.widgetId});
}

if (showError && data?.message) {
$target.append(
'<div class="error-message" role="alert">' +
Expand Down
1 change: 0 additions & 1 deletion modules/vendor/xibo-interactive-control.min.js

This file was deleted.

9 changes: 4 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
"select2-bootstrap-theme": "0.1.0-beta.10",
"serialize-javascript": "^3.1.0",
"toastr": "~2.1.4",
"underscore": "^1.12.1"
"underscore": "^1.12.1",
"xibo-interactive-control": "git+https://github.com/xibosignage/xibo-interactive-control.git#0f3d5e62b9fc3daa57689047b740399cc28eac19"
}
}

0 comments on commit 9b39079

Please sign in to comment.