From 63699e02781896b692ec58e81e377f7ba10a376f Mon Sep 17 00:00:00 2001
From: John Gardner
Date: Fri, 12 Apr 2024 08:23:51 -0400
Subject: [PATCH] feat: for APPLAUNCHER-28 various data fixes
---
.../components/AppLauncherCard.vue | 61 ++++++++++----
pkg/app-launcher/pages/index.vue | 83 ++++++++++++-------
2 files changed, 97 insertions(+), 47 deletions(-)
diff --git a/pkg/app-launcher/components/AppLauncherCard.vue b/pkg/app-launcher/components/AppLauncherCard.vue
index 9e19477..93dab38 100644
--- a/pkg/app-launcher/components/AppLauncherCard.vue
+++ b/pkg/app-launcher/components/AppLauncherCard.vue
@@ -14,6 +14,10 @@ export default {
type: String,
required: true,
},
+ clusterName: {
+ type: String,
+ required: false,
+ },
favoritedServices: {
type: Array,
required: true,
@@ -26,29 +30,48 @@ export default {
type: Object,
default: null,
},
+ metadata: {
+ type: Object,
+ default: null,
+ },
},
methods: {
openLink(link) {
window.open(link);
},
toggleFavorite() {
- this.$emit('toggle-favorite', this.service);
+ this.$emit('toggle-favorite', this.app)
},
},
computed: {
app() {
- return this.service || this.ingress;
+ if (this.service) {
+ return {
+ ...this.service,
+ kind: 'Service',
+ clusterId: this.clusterId,
+ clusterName: this.clusterName
+ };
+ } else if (this.ingress) {
+ return {
+ ...this.ingress,
+ kind: 'Ingress',
+ clusterId: this.clusterId,
+ clusterName: this.clusterName
+ };
+ }
+ return null;
},
endpoints() {
return (
this.service?.spec?.ports?.map((port) => {
const endpoint = `${
isMaybeSecure(port.port, port.protocol) ? 'https' : 'http'
- }:${this.service?.metadata?.name}:${port.port}`;
+ }:${this.app.metadata?.name}:${port.port}`;
return {
label: `${endpoint}${port.protocol === 'UDP' ? ' (UDP)' : ''}`,
- value: `/k8s/clusters/${this.clusterId}/api/v1/namespaces/${this.service.metadata.namespace}/services/${endpoint}/proxy`,
+ value: `/k8s/clusters/${this.clusterId}/api/v1/namespaces/${this.service.namespace}/services/${endpoint}/proxy`,
};
}) ?? []
);
@@ -56,30 +79,30 @@ export default {
computedServiceName() {
return (
this.service?.metadata?.labels?.['app.kubernetes.io/component'] ??
- this.service?.metadata?.name
+ this.serice?.metadata?.name
);
},
helmChart() {
- return this.service?.metadata?.labels?.['helm.sh/chart'];
+ return this.app?.metadata?.labels?.['helm.sh/chart'];
},
kubernetesVersion() {
- return this.service?.metadata?.labels?.['app.kubernetes.io/version'];
+ return this.app?.metadata?.labels?.['app.kubernetes.io/version'];
},
name() {
- return this.service?.metadata?.name;
+ return this.app?.metadata?.name;
},
namespace() {
- return this.service?.metadata?.namespace;
+ return this.app?.metadata?.namespace;
},
isFavorited() {
return this.favoritedServices.some(
(favoritedService) =>
- favoritedService?.clusterId === this.clusterId &&
- favoritedService?.service?.id === this.service?.id
+ favoritedService?.app?.id === this.app?.id &&
+ favoritedService?.app?.kind === this.app?.kind
);
},
isGlobalApp() {
- return this.service?.metadata?.annotations?.['extensions.applauncher/global-app'] === 'true';
+ return this.app?.metadata?.annotations?.['extensions.applauncher/global-app'] === 'true';
},
ingressPath() {
return ingressFullPath(this.ingress, this.ingress?.spec?.rules?.[0]);
@@ -98,21 +121,25 @@ export default {
{{ service ? service?.metadata?.name : ingress?.metadata?.name }}
-
+
{{ kubernetesVersion }}
-
+
{{ helmChart }}
-
+
Ingress
- {{ namespace }}/{{ name }}
- {{ ingressPath }}
+
+ {{ isGlobalApp || isFavorited ? `${clusterName}` : '' }}/{{ namespace }}/{{ name }}
+
+
+ {{ isGlobalApp || isFavorited ? `${clusterName}` : '' }}/{{ ingressPath }}
+
-
+
@@ -378,9 +399,11 @@ export default {
v-for="app in clusterData.filteredApps"
:key="app.uniqueId"
:cluster-id="clusterData.id"
- :service="app.type === 'service' ? app : null"
- :ingress="app.type === 'ingress' ? app : null"
- :favorited-services="favoritedServices"
+ :cluster-name="clusterData.name"
+ :metadata="app.metadata"
+ :service="app.kind === 'Service' ? app : null"
+ :ingress="app.kind === 'Ingress' ? app : null"
+ :favorited-services="favoritedApps"
@toggle-favorite="toggleFavorite"
/>
@@ -417,7 +440,7 @@ export default {