-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathUpstreamFormPage.vue
63 lines (53 loc) · 1.62 KB
/
UpstreamFormPage.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<template>
<div>
<h2>Konnect API</h2>
<UpstreamsForm
:config="konnectConfig"
:upstream-id="upstreamId"
@error="onError($event)"
@loading="onLoading($event)"
@update="onUpdate($event)"
/>
<h2>Kong Manager API</h2>
<UpstreamsForm
:config="KMConfig"
:upstream-id="upstreamId"
@error="onError($event)"
@loading="onLoading($event)"
@update="onUpdate($event)"
/>
</div>
</template>
<script lang="ts" setup>
import UpstreamsForm from '../../src/components/UpstreamsForm.vue'
import { useRoute, useRouter } from 'vue-router'
import { computed, ref } from 'vue'
import type { KongManagerUpstreamsFormConfig, KonnectUpstreamsFormConfig } from '../../src'
import type { AxiosError } from 'axios'
const route = useRoute()
const router = useRouter()
const upstreamId = computed((): string => route?.params?.id as string || '')
const controlPlaneId = import.meta.env.VITE_KONNECT_CONTROL_PLANE_ID || ''
const konnectConfig = ref<KonnectUpstreamsFormConfig>({
app: 'konnect',
apiBaseUrl: '/us/kong-api',
controlPlaneId,
cancelRoute: { name: 'upstreams-list' },
})
const KMConfig = ref<KongManagerUpstreamsFormConfig>({
app: 'kongManager',
workspace: 'default',
apiBaseUrl: '/kong-manager', // For local dev server proxy
cancelRoute: { name: 'upstreams-list' },
})
const onLoading = (val: boolean): void => {
console.log(`Loading: ${val}`)
}
const onError = (val: AxiosError): void => {
console.log(`Error: ${val}`)
}
const onUpdate = (val: Record<string, any>): void => {
console.log(`Updated: ${val}`)
router.push({ name: 'upstreams-list' })
}
</script>