From 5295f6c6eddfb3be4b0cf67b7430c70e8c563163 Mon Sep 17 00:00:00 2001 From: John Gardner Date: Tue, 19 Mar 2024 14:27:01 -0400 Subject: [PATCH] feat: for APPLAUNCHER-9 added search to grid --- pkg/app-launcher/l10n/en-us.yaml | 1 + pkg/app-launcher/pages/index.vue | 77 ++++++++++++++++++++------------ 2 files changed, 50 insertions(+), 28 deletions(-) diff --git a/pkg/app-launcher/l10n/en-us.yaml b/pkg/app-launcher/l10n/en-us.yaml index 6eb00e4..6882d8a 100644 --- a/pkg/app-launcher/l10n/en-us.yaml +++ b/pkg/app-launcher/l10n/en-us.yaml @@ -11,3 +11,4 @@ appLauncher: loadingServices: Loading services... selectCluster: Select a cluster globalApps: Global Apps + filter: Filter diff --git a/pkg/app-launcher/pages/index.vue b/pkg/app-launcher/pages/index.vue index ff75d35..395721b 100644 --- a/pkg/app-launcher/pages/index.vue +++ b/pkg/app-launcher/pages/index.vue @@ -25,6 +25,7 @@ export default { clusterOptions: [], selectedView: 'grid', favoritedServices: [], + searchQuery: '', tableHeaders: [ { name: 'name', @@ -60,15 +61,9 @@ export default { async mounted() { try { const allClusters = await this.getClusters(); - console.log('allClusters', allClusters); this.servicesByCluster = await this.getServicesByCluster(allClusters); this.ingressesByCluster = await this.getIngressesByCluster(allClusters); - console.log('servicesByCluster', this.servicesByCluster); - console.log('ingressesByCluster', this.ingressesByCluster); - - console.log("ingress path", ingressFullPath(this.ingressesByCluster[1].ingresses[0], this.ingressesByCluster[1].ingresses[0].spec.rules?.[0])); - // Set the first cluster as the selected cluster if (this.servicesByCluster.length > 0) { this.selectedCluster = this.servicesByCluster[0].id; @@ -100,7 +95,6 @@ export default { }, methods: { async getClusters() { - console.log('this.$store', this.$store); return await this.$store.dispatch(`management/findAll`, { type: MANAGEMENT.CLUSTER, }); @@ -277,6 +271,20 @@ export default { } return []; }, + filteredApps() { + if (this.searchQuery.trim() === '') { + return this.sortedApps; + } else { + const searchTerm = this.searchQuery.trim().toLowerCase(); + return this.sortedApps.filter(app => { + return (app.metadata.name.toLowerCase().includes(searchTerm) || + app.metadata.namespace.toLowerCase().includes(searchTerm) || + app.metadata.labels?.['app.kubernetes.io/version']?.toLowerCase().includes(searchTerm) || + app.metadata.labels?.['helm.sh/chart']?.toLowerCase().includes(searchTerm) || + app.metadata.fields.includes(searchTerm)); + }); + } + }, sortedServices() { if (this.selectedClusterData) { return [...this.selectedClusterData.services].sort((a, b) => { @@ -334,27 +342,25 @@ export default {
-
- - - +
+
+ +
+
+ + +