fleet/website/assets/js/pages/scripts.page.js
Eric 048fcd13ed
Website: Add controls library pages (#33143)
Related to: https://github.com/fleetdm/confidential/issues/10737

Changes:
- Added `docs/scripts.yml`, a YAML file that contains a list of scripts
- Added `docs/mdm-commands.yml`, a YAML file that contains Windows and
Apple MDM commands
- Added `/mdm-commands`, a page that contains a list of MDM commands for
Windows and Apple commands
- Added `/scripts`, a page that contains a list of scripts
- Updated the `<docs-nav-and-search>` component to have a link to the
controls library, and reordered the lists.
- Updated the build static content script to add the scripts and mdm
commands from scripts.yml and mdm-commands.yml to the website's
`builtStaticContent` configuration.
- Updated the layout of the os-settings page to match the latest
wireframes
2025-09-19 12:02:55 -05:00

70 lines
2.6 KiB
JavaScript
Vendored

parasails.registerPage('scripts', {
// ╦╔╗╔╦╔╦╗╦╔═╗╦ ╔═╗╔╦╗╔═╗╔╦╗╔═╗
// ║║║║║ ║ ║╠═╣║ ╚═╗ ║ ╠═╣ ║ ║╣
// ╩╝╚╝╩ ╩ ╩╩ ╩╩═╝ ╚═╝ ╩ ╩ ╩ ╩ ╚═╝
data: {
selectedPlatform: 'apple',
modal: undefined,
},
// ╦ ╦╔═╗╔═╗╔═╗╦ ╦╔═╗╦ ╔═╗
// ║ ║╠╣ ║╣ ║ ╚╦╝║ ║ ║╣
// ╩═╝╩╚ ╚═╝╚═╝ ╩ ╚═╝╩═╝╚═╝
beforeMount: function() {
//…
},
mounted: async function() {
if(bowser.windows){
this.selectedPlatform = 'windows';
}
if(window.location.hash) {
if(window.location.hash === '#linux') {
this.selectedPlatform = 'linux';
} else if(window.location.hash === '#apple') {
this.selectedPlatform = 'apple';
} else if(window.location.hash === '#windows') {
this.selectedPlatform = 'windows';
}
window.location.hash = '';
}
this.handleScrollingPlatformFilters();
window.addEventListener('scroll', this.handleScrollingPlatformFilters);
},
// ╦╔╗╔╔╦╗╔═╗╦═╗╔═╗╔═╗╔╦╗╦╔═╗╔╗╔╔═╗
// ║║║║ ║ ║╣ ╠╦╝╠═╣║ ║ ║║ ║║║║╚═╗
// ╩╝╚╝ ╩ ╚═╝╩╚═╩ ╩╚═╝ ╩ ╩╚═╝╝╚╝╚═╝
methods: {
clickSelectPlatform: function(platform) {
this.selectedPlatform = platform;
window.scrollTo({
top: 0,
left: 0,
behavior: 'smooth',
});
},
handleScrollingPlatformFilters: function () {
let platformFilters = document.querySelector('div[purpose="platform-filters"]');
let scrollTop = window.pageYOffset;
let windowHeight = window.innerHeight;
// If the right nav bar exists, add and remove a class based on the current scroll position.
if (platformFilters) {
if (scrollTop > this.scrollDistance && scrollTop > windowHeight * 1.5) {
platformFilters.classList.add('header-hidden');
this.lastScrollTop = scrollTop;
} else if(scrollTop < this.lastScrollTop - 60) {
platformFilters.classList.remove('header-hidden');
this.lastScrollTop = scrollTop;
}
}
this.scrollDistance = scrollTop;
},
clickOpenTableOfContents: function () {
this.modal = 'table-of-contents';
},
closeModal: async function() {
this.modal = '';
await this.forceRender();
}
}
});