diff --git a/src/mixins/routerMixin.js b/src/mixins/routerMixin.js new file mode 100644 index 000000000..0363c227b --- /dev/null +++ b/src/mixins/routerMixin.js @@ -0,0 +1,13 @@ +export default { + methods: { + setSearchTextQuery (searchText) { + let queries = JSON.parse(JSON.stringify(this.$route.query)); + if (searchText === '') { + delete queries.searchText; + } else { + queries.searchText = searchText; + } + this.$router.replace({query: queries}); + } + } +} diff --git a/src/views/policy/PolicyList.vue b/src/views/policy/PolicyList.vue index b61b86ce7..2710b31c2 100644 --- a/src/views/policy/PolicyList.vue +++ b/src/views/policy/PolicyList.vue @@ -20,6 +20,7 @@ import xssFilters from "xss-filters"; import CreatePolicyModal from "./CreatePolicyModal"; import permissionsMixin from "../../mixins/permissionsMixin"; + import routerMixin from "../../mixins/routerMixin"; import i18n from "../../i18n"; import ActionableListGroupItem from "../components/ActionableListGroupItem"; import BInputGroupFormInput from "../../forms/BInputGroupFormInput"; @@ -33,7 +34,7 @@ import { Switch as cSwitch } from '@coreui/vue'; export default { - mixins: [permissionsMixin, bootstrapTableMixin], + mixins: [permissionsMixin, bootstrapTableMixin, routerMixin], components: { CreatePolicyModal }, @@ -89,6 +90,7 @@ queryParamsType: 'pageSize', pageList: '[10, 25, 50, 100]', pageSize: (localStorage && localStorage.getItem("PolicyListPageSize") !== null) ? Number(localStorage.getItem("PolicyListPageSize")) : 10, + searchText: (this.$route.query.searchText ? this.$route.query.searchText : ''), icons: { refresh: 'fa-refresh' }, @@ -354,6 +356,9 @@ localStorage.setItem("PolicyListPageSize", size.toString()) } }), + onSearch: ((text) => { + this.setSearchTextQuery(text); + }) } }; } diff --git a/src/views/portfolio/licenses/LicenseList.vue b/src/views/portfolio/licenses/LicenseList.vue index 5c26fa9d2..50cc949a6 100644 --- a/src/views/portfolio/licenses/LicenseList.vue +++ b/src/views/portfolio/licenses/LicenseList.vue @@ -22,11 +22,12 @@ import PortfolioWidgetRow from "../../dashboard/PortfolioWidgetRow"; import xssFilters from "xss-filters"; import permissionsMixin from "../../../mixins/permissionsMixin"; + import routerMixin from "../../../mixins/routerMixin"; import LicenseAddLicenseModal from "@/views/portfolio/licenses/LicenseAddLicenseModal"; import {loadUserPreferencesForBootstrapTable} from "@/shared/utils"; export default { - mixins: [permissionsMixin], + mixins: [permissionsMixin, routerMixin], components: { LicenseAddLicenseModal, PortfolioWidgetRow @@ -107,6 +108,7 @@ pageSize: (localStorage && localStorage.getItem("LicenseListPageSize") !== null) ? Number(localStorage.getItem("LicenseListPageSize")) : 10, sortName: (localStorage && localStorage.getItem("LicenseListSortName") !== null) ? localStorage.getItem("LicenseListSortName") : undefined, sortOrder: (localStorage && localStorage.getItem("LicenseListSortOrder") !== null) ? localStorage.getItem("LicenseListSortOrder") : undefined, + searchText: (this.$route.query.searchText ? this.$route.query.searchText : ''), icons: { refresh: 'fa-refresh' }, @@ -131,6 +133,9 @@ localStorage.setItem("LicenseListSortName", name); localStorage.setItem("LicenseListSortOrder", order); } + }), + onSearch: ((text) => { + this.setSearchTextQuery(text); }) } }; diff --git a/src/views/portfolio/projects/ProjectList.vue b/src/views/portfolio/projects/ProjectList.vue index ee39ac432..da1eccd2d 100644 --- a/src/views/portfolio/projects/ProjectList.vue +++ b/src/views/portfolio/projects/ProjectList.vue @@ -28,6 +28,7 @@ import MurmurHash2 from "imurmurhash"; import Vue from 'vue'; import xssFilters from "xss-filters"; import permissionsMixin from "../../../mixins/permissionsMixin"; +import routerMixin from "../../../mixins/routerMixin"; import common from "../../../shared/common"; import PolicyViolationProgressBar from "../../components/PolicyViolationProgressBar"; import SeverityProgressBar from "../../components/SeverityProgressBar"; @@ -35,7 +36,7 @@ import PortfolioWidgetRow from "../../dashboard/PortfolioWidgetRow"; import ProjectCreateProjectModal from "./ProjectCreateProjectModal"; export default { - mixins: [permissionsMixin], + mixins: [permissionsMixin, routerMixin], components: { cSwitch, ProjectCreateProjectModal, @@ -304,6 +305,7 @@ import ProjectCreateProjectModal from "./ProjectCreateProjectModal"; pageSize: (localStorage && localStorage.getItem("ProjectListPageSize") !== null) ? Number(localStorage.getItem("ProjectListPageSize")) : 10, sortName: (localStorage && localStorage.getItem("ProjectListSortName") !== null) ? localStorage.getItem("ProjectListSortName") : undefined, sortOrder: (localStorage && localStorage.getItem("ProjectListSortOrder") !== null) ? localStorage.getItem("ProjectListSortOrder") : undefined, + searchText: (this.$route.query.searchText ? this.$route.query.searchText : ''), icons: { refresh: 'fa-refresh' }, @@ -342,6 +344,7 @@ import ProjectCreateProjectModal from "./ProjectCreateProjectModal"; this.showFlatView = false; } } + this.setSearchTextQuery(text); }), onPageChange: ((number, size) => { if (localStorage) { diff --git a/src/views/portfolio/vulnerabilities/VulnerabilityList.vue b/src/views/portfolio/vulnerabilities/VulnerabilityList.vue index 1ba7b48aa..debf1e8b2 100644 --- a/src/views/portfolio/vulnerabilities/VulnerabilityList.vue +++ b/src/views/portfolio/vulnerabilities/VulnerabilityList.vue @@ -22,12 +22,13 @@ import $ from "jquery"; import xssFilters from "xss-filters"; import permissionsMixin from "../../../mixins/permissionsMixin"; +import routerMixin from "../../../mixins/routerMixin"; import common from "../../../shared/common"; import PortfolioWidgetRow from "../../dashboard/PortfolioWidgetRow"; import VulnerabilityCreateVulnerabilityModal from "./VulnerabilityCreateVulnerabilityModal"; export default { - mixins: [permissionsMixin], + mixins: [permissionsMixin, routerMixin], components: { VulnerabilityCreateVulnerabilityModal, PortfolioWidgetRow @@ -139,6 +140,7 @@ import VulnerabilityCreateVulnerabilityModal from "./VulnerabilityCreateVulnerab pageSize: (localStorage && localStorage.getItem("VulnerabilityListPageSize") !== null) ? Number(localStorage.getItem("VulnerabilityListPageSize")) : 10, sortName: (localStorage && localStorage.getItem("VulnerabilityListSortName") !== null) ? localStorage.getItem("VulnerabilityListSortName") : undefined, sortOrder: (localStorage && localStorage.getItem("VulnerabilityListSortOrder") !== null) ? localStorage.getItem("VulnerabilityListSortOrder") : undefined, + searchText: (this.$route.query.searchText ? this.$route.query.searchText : ''), icons: { refresh: 'fa-refresh' }, @@ -163,7 +165,10 @@ import VulnerabilityCreateVulnerabilityModal from "./VulnerabilityCreateVulnerab localStorage.setItem("VulnerabilityListSortName", name); localStorage.setItem("VulnerabilityListSortOrder", order); } - }) + }), + onSearch: ((text) => { + this.setSearchTextQuery(text); + }), } }; }