-
Notifications
You must be signed in to change notification settings - Fork 993
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
744 additions
and
360 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
function load_dynamic_javascripts(html) { | ||
function waitForAllLoaded() { | ||
// Wait for all plugins js modules to be loaded before loading the javascript content | ||
return new Promise(function(resolve) { | ||
if (Object.values(window.allPluginsLoaded).every(Boolean)) { | ||
resolve(); | ||
} else { | ||
function handleLoad() { | ||
if (Object.values(window.allPluginsLoaded).every(Boolean)) { | ||
resolve(); | ||
// Remove the event listener | ||
document.removeEventListener('loadPlugin', handleLoad); | ||
} | ||
} | ||
document.addEventListener('loadPlugin', handleLoad); | ||
} | ||
}); | ||
} | ||
waitForAllLoaded().then(async function() { | ||
// parse html string | ||
var template = document.createElement('template'); | ||
template.innerHTML = html; | ||
var doc = new DOMParser().parseFromString(html, 'text/html'); | ||
var copyChildren = [...doc.head.children]; | ||
const loadScript = async scripts => { | ||
if (scripts.length === 0) { | ||
// All scripts are loaded | ||
window.allJsLoaded = true; | ||
const loadJS = new Event('loadJS'); | ||
document.dispatchEvent(loadJS); | ||
return; | ||
} | ||
const script = scripts.shift(); | ||
if (script.src) { | ||
// if script is just a link, add it to the head | ||
const scriptTag = document.createElement('script'); | ||
scriptTag.src = script.src; | ||
scriptTag.onload = function() { | ||
// To load the next script only after the current one is loaded | ||
loadScript(scripts); | ||
}; | ||
document.head.appendChild(scriptTag); | ||
} else { | ||
// if the script is a script tag, evaluate it and load the next one | ||
await eval(script.innerHTML); | ||
loadScript(scripts); | ||
} | ||
}; | ||
loadScript(copyChildren); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
<% title _("Download generated report") %> | ||
|
||
<%= react_component('TemplateGenerator', data: { templateName: @template.name }) %> | ||
|
||
<script type="text/javascript"> | ||
tfm.templateInputs.pollReportData('<%= @data_url %>'); | ||
</script> | ||
<% content_for(:javascripts) do %> | ||
<script type="text/javascript"> | ||
tfm.templateInputs.pollReportData('<%= @data_url %>'); | ||
</script> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.