Skip to content

Commit

Permalink
Allow to disable pages (for Pilot live)
Browse files Browse the repository at this point in the history
  • Loading branch information
Didosa committed Nov 19, 2024
1 parent ffe7e59 commit 35cf0ae
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 38 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -361,3 +361,4 @@ healthchecksdb
/PiLotBackupAPI/config/config.*.json
/PiLotTilesDownloader/Properties/launchSettings.json
/.gitignore
/PiLotWeb/js/Config.pilotLive.js
33 changes: 0 additions & 33 deletions PiLotWeb/js/Config.pilotLive.js

This file was deleted.

13 changes: 9 additions & 4 deletions PiLotWeb/js/View/Common.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,17 +419,18 @@ PiLot.View.Common = (function () {
this.control = PiLot.Utils.Common.createNode(PiLot.Templates.Common.mainMenuContent);
this.container.appendChild(this.control);
let pageKey, pageObject;
const pages = PiLot.Utils.Loader.pages;
this.processLinks(function (pLink, pPageObject) {
this.processLinks(function (pLink, pPageObject, pPageKey) {
pLink.href = PiLot.Utils.Loader.createPageLink(pPageObject);
this.checkLinkPermissions(pLink, pPageObject)
this.hideDisabledPages(pLink, pPageKey);
}.bind(this));
},

/** Sets the visibility links according to the current user's permissions */
checkPermissions: function () {
this.processLinks(function (pLink, pPageObject) {
this.processLinks(function (pLink, pPageObject, pPageKey) {
this.checkLinkPermissions(pLink, pPageObject)
this.hideDisabledPages(pLink, pPageKey);
}.bind(this));
},

Expand All @@ -445,7 +446,7 @@ PiLot.View.Common = (function () {
pageKey = aLink.dataset['page'];
if (pageKey in pages) {
pageObject = pages[pageKey];
pProcessFunction(aLink, pageObject);
pProcessFunction(aLink, pageObject, pageKey);
} else {
console.log(`Invalid page key in MainMenu: ${pageKey}`);
}
Expand All @@ -459,6 +460,10 @@ PiLot.View.Common = (function () {
*/
checkLinkPermissions: function (pLink, pPageObject) {
pLink.hidden = !this.permissionsHelper.checkPermissions(pPageObject);
},

hideDisabledPages: function (pLink, pPageKey) {
pLink.hidden = pLink.hidden || (PiLot.Config.Disable && PiLot.Config.Disable.pages && PiLot.Config.Disable.pages.includes(pPageKey));
}

};
Expand Down
3 changes: 2 additions & 1 deletion PiLotWeb/js/View/Diary.js
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,8 @@ PiLot.View.Diary = (function () {

/** @param {PiLot.Model.Nav.Track} pTrack */
showTrackStatistics: function (pTrack) {
if (pTrack && pTrack.getTrackPointsCount() > 0) {
const disabled = PiLot.Config.Disable && PiLot.Config.Disable.trackSections;
if (!disabled && pTrack && pTrack.getTrackPointsCount() > 0) {
this.trackStatistics.showTrackStatisticsAsync(pTrack);
} else {
this.trackStatistics.hide();
Expand Down

0 comments on commit 35cf0ae

Please sign in to comment.