Skip to content

Commit

Permalink
[DW-1696] Adds variable retries and fail notice
Browse files Browse the repository at this point in the history
  • Loading branch information
GeoffreyHayward authored and Geoff Hayward committed Oct 15, 2020
1 parent c35af79 commit d69126d
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 25 deletions.
Expand Up @@ -758,6 +758,11 @@ definitions:
jcr:name: Supplementary information hub
jcr:primaryType: hipposys:resourcebundle
jcr:primaryType: hipposys:resourcebundles
/website:tableau:
/en:
jcr:name: Tableau
jcr:primaryType: hipposys:resourcebundle
jcr:primaryType: hipposys:resourcebundles
/website:team:
/en:
jcr:name: Team
Expand Down
Expand Up @@ -42,15 +42,16 @@ definitions:
jcr:primaryType: frontend:plugin
plugin.class: org.hippoecm.frontend.editor.plugins.field.PropertyFieldPlugin
wicket.id: ${cluster.id}.left.item
/device:
/placeholderImageLocation:
/cluster.options:
jcr:primaryType: frontend:pluginconfig
selectable.options: default,desktop,tablet,phone
caption: Device Layout
field: device
caption: Placeholder Image
field: placeholderImageLocation
hint: The URL which hosts the image of the tableau visualisation that
loads first as a placeholder.
jcr:primaryType: frontend:plugin
plugin.class: org.hippoecm.frontend.editor.plugins.field.PropertyFieldPlugin
wicket.id: ${cluster.id}.right.item
wicket.id: ${cluster.id}.left.item
/hidetabs:
/cluster.options:
jcr:primaryType: frontend:pluginconfig
Expand All @@ -59,16 +60,27 @@ definitions:
jcr:primaryType: frontend:plugin
plugin.class: org.hippoecm.frontend.editor.plugins.field.PropertyFieldPlugin
wicket.id: ${cluster.id}.right.item
/placeholderImageLocation:
/device:
/cluster.options:
jcr:primaryType: frontend:pluginconfig
caption: Placeholder Image
field: placeholderImageLocation
hint: The URL which hosts the image of the tableau visualisation that
loads first as a placeholder.
selectable.options: default,desktop,tablet,phone
caption: Device Layout
field: device
jcr:primaryType: frontend:plugin
plugin.class: org.hippoecm.frontend.editor.plugins.field.PropertyFieldPlugin
wicket.id: ${cluster.id}.left.item
/retryIntervals:
/cluster.options:
jcr:primaryType: frontend:pluginconfig
caption: Retry Intervals
field: retryIntervals
hint: "The component will retry loading in the frontend using the given\
\ intervals. An empty list will turn retries off. The intervals are\
\ run in order top down.\_Interval values are in seconds.\r\n\r\nIntervals\
\ values are in seconds."
jcr:primaryType: frontend:plugin
plugin.class: org.hippoecm.frontend.editor.plugins.field.PropertyFieldPlugin
wicket.id: ${cluster.id}.right.item
jcr:primaryType: editor:templateset
/hipposysedit:nodetype:
/hipposysedit:nodetype:
Expand Down Expand Up @@ -98,6 +110,14 @@ definitions:
hipposysedit:validators:
- valid-url
jcr:primaryType: hipposysedit:field
/retryIntervals:
hipposysedit:mandatory: false
hipposysedit:multiple: true
hipposysedit:ordered: true
hipposysedit:path: website:retryIntervals
hipposysedit:primary: false
hipposysedit:type: Long
jcr:primaryType: hipposysedit:field
/url:
hipposysedit:mandatory: false
hipposysedit:multiple: false
Expand Down Expand Up @@ -125,8 +145,11 @@ definitions:
/hipposysedit:prototype:
jcr:primaryType: website:tableau
website:hidetabs: false
website:long: 30000
website:placeholderImageLocation: ''
website:retryIntervals:
- 30
- 45
- 60
website:url: ''
jcr:primaryType: hipposysedit:prototypeset
jcr:mixinTypes:
Expand Down
Expand Up @@ -5,29 +5,32 @@
hippostd:state: draft
hippostdpubwf:createdBy: admin
hippostdpubwf:creationDate: 2020-03-16T10:48:43.786Z
hippostdpubwf:lastModificationDate: 2020-09-30T10:05:04.699Z
hippostdpubwf:lastModificationDate: 2020-10-14T09:43:53.853Z
hippostdpubwf:lastModifiedBy: admin
jcr:mixinTypes:
- mix:referenceable
jcr:primaryType: resourcebundle:resourcebundle
resourcebundle:descriptions:
- ''
- ''
- ''
resourcebundle:id: tableau.lables
resourcebundle:keys:
- load-error
- loading-message
- loading-failed-message
resourcebundle:messages:
- '[Tableau loading error]'
- We are loading the dashboard. This is taking longer than normal and we will
retry in a few seconds for you. Please don't refresh the page.
- The service is busy. Please try again later.
/tableau-lables[2]:
hippo:availability:
- preview
hippostd:state: unpublished
hippostdpubwf:createdBy: admin
hippostdpubwf:creationDate: 2020-03-16T10:48:43.786Z
hippostdpubwf:lastModificationDate: 2020-09-30T10:06:22.441Z
hippostdpubwf:lastModificationDate: 2020-10-14T10:28:45.840Z
hippostdpubwf:lastModifiedBy: admin
jcr:mixinTypes:
- mix:referenceable
Expand All @@ -36,39 +39,45 @@
resourcebundle:descriptions:
- ''
- ''
- ''
resourcebundle:id: tableau.lables
resourcebundle:keys:
- load-error
- loading-message
- loading-failed-message
resourcebundle:messages:
- '[Tableau loading error]'
- We are loading the dashboard. This is taking longer than normal and we will
retry in a few seconds for you. Please don't refresh the page.
- The service is busy. Please try again later.
/tableau-lables[3]:
hippo:availability:
- live
hippostd:state: published
hippostdpubwf:createdBy: admin
hippostdpubwf:creationDate: 2020-03-16T10:48:43.786Z
hippostdpubwf:lastModificationDate: 2020-09-30T10:06:22.441Z
hippostdpubwf:lastModificationDate: 2020-10-14T10:28:45.840Z
hippostdpubwf:lastModifiedBy: admin
hippostdpubwf:publicationDate: 2020-09-30T10:06:26.296Z
hippostdpubwf:publicationDate: 2020-10-14T10:28:49.212Z
jcr:mixinTypes:
- mix:referenceable
jcr:primaryType: resourcebundle:resourcebundle
resourcebundle:descriptions:
- ''
- ''
- ''
resourcebundle:id: tableau.lables
resourcebundle:keys:
- load-error
- loading-message
- loading-failed-message
resourcebundle:messages:
- '[Tableau loading error]'
- We are loading the dashboard. This is taking longer than normal and we will
retry in a few seconds for you. Please don't refresh the page.
- The service is busy. Please try again later.
hippo:name: Tableau Lables
hippo:versionHistory: 803dda41-d54e-44e6-9203-414031ee3569
hippo:versionHistory: bec492c1-bdd2-4cb7-b907-caf1de38b372
jcr:mixinTypes:
- hippo:named
- hippo:versionInfo
Expand Down
Expand Up @@ -30,7 +30,8 @@
<script type="text/javascript">
var vizMessages = {
LOAD_ERROR: "<@fmt.message key="load-error"/>",
LOADING_MESSAGE: "<@fmt.message key="loading-message"/>"
LOADING_MESSAGE: "<@fmt.message key="loading-message"/>",
LOADING_FAILED_MESSAGE: "<@fmt.message key="loading-failed-message"/>"
};
</script>

Expand Down Expand Up @@ -62,12 +63,14 @@
};
// Setup reload attempt
var viz${index}LoadTimer = setInterval(_retry, 15000);
var viz${index}Load = false;
var viz${index}LoadTimer = setInterval(_retry, 1000);
function loadViz(containerDiv, placeholderElements) {
var url = "${section.url}";
var options = {
"onFirstInteractive": function () {
viz${index}Load = true;
clearInterval(viz${index}LoadTimer);
_onFirstInteractive(containerDiv, placeholderElements);
},
Expand All @@ -77,6 +80,9 @@
</#if>
};
if(typeof tableau !== 'undefined' && typeof tableau.Viz !== 'undefined') {
if(!!viz${index}) {
viz${index}.dispose();
}
viz${index} = new tableau.Viz(containerDiv, url, options);
} else {
_showLoadingError();
Expand All @@ -95,20 +101,43 @@
}
function _load() {
<#if section.placeholderImageLocation?has_content>
loadViz(viz${index}Elements.vizDiv(), [viz${index}Elements.placeholderImage(), viz${index}Elements.loadingDiv()]);
<#else>
loadViz(viz${index}Elements.vizDiv());
</#if>
if(!viz${index}Load) {
<#if section.placeholderImageLocation?has_content>
loadViz(viz${index}Elements.vizDiv(), [viz${index}Elements.placeholderImage(), viz${index}Elements.loadingDiv()]);
<#else>
loadViz(viz${index}Elements.vizDiv());
</#if>
}
}
window.addEventListener('load', function() {
_load();
});
// Retry timestamp
var viz${index}StartLoadTimeStart = Date.now();
var viz${index}RetryAtempIntervales=[<#list section.retryIntervals as intervale>${intervale},</#list>];
function _retry() {
_setRetryMessage();
_load();
if(!viz${index}Load && viz${index}RetryAtempIntervales.length <= 0){
clearInterval(viz${index}LoadTimer);
_fail();
} else {
if(!viz${index}Load && (Date.now() - viz${index}StartLoadTimeStart) > (viz${index}RetryAtempIntervales[0] * 1000)){
viz${index}StartLoadTimeStart += viz${index}RetryAtempIntervales.shift() * 1000; <#-- Update for the next round -->
_setRetryMessage();
_load();
}
}
}
function _fail(){
setTimeout(function(){
if(!viz${index}Load) {
_setFailMessage();
}
}, 60000); <#-- Allow Tableau last atempt to load finish before showing the fail message. -->
}
function _setRetryMessage() {
Expand All @@ -119,6 +148,18 @@
}
}
function _setFailMessage() {
var message${index} = viz${index}Elements.loadingMessage();
if(!!(message${index})) {
message${index}.classList.add("fade-in-2");
message${index}.innerHTML = vizMessages.LOADING_FAILED_MESSAGE;
}
var loading${index} = viz${index}Elements.loadingIcon();
if(!!(loading${index})) {
loading${index}.remove();
}
}
function _showLoadingError() {
viz${index}Elements.containerDiv().innerHTML = vizMessages.LOAD_ERROR;
}
Expand Down
Expand Up @@ -30,6 +30,11 @@ public String getUrl() {
return getSingleProperty("website:url");
}

@HippoEssentialsGenerated(internalName = "website:retryIntervals")
public Long[] getRetryIntervals() {
return getMultipleProperty("website:retryIntervals");
}

public String getTableauBase() throws MalformedURLException {
URL url = new URL(getUrl());
return String.format("%s://%s/", url.getProtocol(), url.getAuthority());
Expand Down

0 comments on commit d69126d

Please sign in to comment.