Skip to content

Commit

Permalink
Fix Permissions-Policy header when run on GitHub Pages
Browse files Browse the repository at this point in the history
  • Loading branch information
javiertuya committed Feb 13, 2024
1 parent e7c45ec commit c4022ff
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
33 changes: 20 additions & 13 deletions dashgit-web/app/IndexController.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,12 @@ import { configController } from "./ConfigController.js"

/**
* Manages the top level elements visibility and actions (header and tabs).
* Enters one of two modes depending on the token encription configuration
* Enters one of two modes depending on the token encription configuration.
*
* Note: The index.html cannot import this module with src, on chromium causes this error:
* Error with Permissions-Policy header: Origin trial controlled feature not enabled: 'interest-cohort'.
* Solution is to define an inline module in index.html that initializes jquery and imports this controller
*/
$(document).ready(async function () {
config.appVersion = $("#appVersion").text();
console.log(`Loading, version ${config.appVersion}`)
config.load();
if (config.data.encrypted) {
indexController.loginMode();
} else {
indexController.workMode();
indexController.render();
}
$('[data-toggle="tooltip"]').tooltip({ trigger: "hover", delay: 600 });
});

//In login mode, enter and validate password
$(document).on('click', '#inputPasswordButton', function (e) {
Expand Down Expand Up @@ -68,6 +60,21 @@ $(document).on('click', '.accordion-button', function () {
});

const indexController = {

// Initial configuration to be run by jquery on document ready
load: function() {
config.appVersion = $("#appVersion").text();
config.load();
$("#appVersion").text(config.appVersion);
if (config.data.encrypted) {
indexController.loginMode();
} else {
indexController.workMode();
indexController.render();
}
$('[data-toggle="tooltip"]').tooltip({trigger:"hover", delay:600});
},

//Rendering depends on the selected tab, calls the appropriate controller to update the UI
render: function () {
wiView.resetAlerts();
Expand Down
7 changes: 6 additions & 1 deletion dashgit-web/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@
}
}
</script>
<script type="module" src="./indexController.js"></script>
<script type="module">
import { indexController } from "./IndexController.js"
$(document).ready(async function () {
indexController.load();
});
</script>
</head>

<style>
Expand Down
2 changes: 1 addition & 1 deletion dashgit-web/prepare-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ rm -rf ./dist/
cp -rf ./app ./dist
find ./dist/*.js -type f -exec sed -i "s/.js\"/.js\?v=${VERSION}\"/g" {} \;
sed -i "s/IndexController.js/IndexController.js?v=${VERSION}/g" dist/index.html
sed -i "s/\"v0.0.0-local\"/\"${VERSION}\"/g" dist/Config.js
sed -i "s/v0.0.0-local/${VERSION}/g" dist/index.html

0 comments on commit c4022ff

Please sign in to comment.