Website: Keep platform filter when navigating to another table page. (#8465)

This commit is contained in:
Eric 2022-11-02 17:33:17 -05:00 committed by GitHub
parent 7fbe394b94
commit b0c8c451a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View file

@ -35,6 +35,18 @@ parasails.registerPage('osquery-table-details', {
},
mounted: async function() {
// Check the URL to see if a platformFilter was provided.
if(window.location.search) {
// https://caniuse.com/mdn-api_urlsearchparams_get
let possibleSearchParamsToFilterBy = new URLSearchParams(window.location.search);
let platformToFilterBy = possibleSearchParamsToFilterBy.get('platformFilter');
// If the provided platform matches a key in the userFriendlyPlatformNames array, we'll set this.selectedPlatform.
if(platformToFilterBy && this.userFriendlyPlatformNames[platformToFilterBy]){
this.selectedPlatform = platformToFilterBy;
}
}
// sort the array of all tables
this.allTables = this.allTables.sort((a, b)=>{
if(a.title < b.title){

View file

@ -41,7 +41,7 @@
</div>
<div class="d-flex d-lg-none pt-3" v-if="showTableNav">
<div purpose="mobile-table-of-contents">
<a class="d-block" :class="[tableToDisplay.title === table.title ? 'active' : '']" :href="table.url" v-for="table in filteredTables">{{table.title}} <span purpose="evented-table-icon" v-if="table.evented"><img alt="evented table" src="/images/icon-evented-12x12@2x.png" ></span></a>
<a class="d-block" :class="[tableToDisplay.title === table.title ? 'active' : '']" :href="table.url+[selectedPlatform !== 'all' ? '?platformFilter='+encodeURIComponent(selectedPlatform) : '' ]" v-for="table in filteredTables">{{table.title}} <span purpose="evented-table-icon" v-if="table.evented"><img alt="evented table" src="/images/icon-evented-12x12@2x.png" ></span></a>
</div>
</div>
</div>
@ -59,7 +59,7 @@
</div>
<div style="position: relative;">
<div purpose="table-of-contents">
<a class="d-block" :class="[tableToDisplay.title === table.title ? 'active' : '']" :href="table.url" v-for="table in filteredTables">{{table.title}} <span purpose="evented-table-icon" v-if="table.evented"><img alt="evented table" src="/images/icon-evented-12x12@2x.png" ></span></a>
<a class="d-block" :class="[tableToDisplay.title === table.title ? 'active' : '']" :href="table.url+[selectedPlatform !== 'all' ? '?platformFilter='+encodeURIComponent(selectedPlatform) : '' ]" v-for="table in filteredTables">{{table.title}} <span purpose="evented-table-icon" v-if="table.evented"><img alt="evented table" src="/images/icon-evented-12x12@2x.png" ></span></a>
</div>
<div purpose="overflow-shadow" class="d-none d-lg-block"></div>
</div>